FileMaster
Search
Toggle Dark Mode
Home
/
.
/
wp-content
/
plugins
/
surecart
/
dist
/
components
/
surecart
Edit File: p-d3cf341a.entry.js
import{r as e,h as t}from"./p-e97fde0a.js";import{p as i}from"./p-9ef0f73f.js";import{a}from"./p-dd3464cd.js";import{a as d}from"./p-401e165e.js";import"./p-d3366af3.js";const s="sc-stripe-add-method{display:block}sc-stripe-add-method [hidden]{display:none}.loader{display:grid;height:128px;gap:2em}.loader__row{display:flex;align-items:flex-start;justify-content:space-between;gap:1em}.loader__details{display:grid;gap:0.5em}";const o=s;const n=class{constructor(t){e(this,t);this.liveMode=true;this.customerId=undefined;this.successUrl=undefined;this.loading=undefined;this.loaded=undefined;this.error=undefined;this.paymentIntent=undefined}componentWillLoad(){this.createPaymentIntent()}async handlePaymentIntentCreate(){var e,t,a,d,s,o,n,r,c,l,h,f,u,p,m,b,v,y;if(!((a=(t=(e=this.paymentIntent)===null||e===void 0?void 0:e.processor_data)===null||t===void 0?void 0:t.stripe)===null||a===void 0?void 0:a.publishable_key)||!((o=(s=(d=this.paymentIntent)===null||d===void 0?void 0:d.processor_data)===null||s===void 0?void 0:s.stripe)===null||o===void 0?void 0:o.account_id))return;if(!this.stripe){try{this.stripe=await i.loadStripe((c=(r=(n=this.paymentIntent)===null||n===void 0?void 0:n.processor_data)===null||r===void 0?void 0:r.stripe)===null||c===void 0?void 0:c.publishable_key,{stripeAccount:(f=(h=(l=this.paymentIntent)===null||l===void 0?void 0:l.processor_data)===null||h===void 0?void 0:h.stripe)===null||f===void 0?void 0:f.account_id})}catch(e){this.error=(e===null||e===void 0?void 0:e.message)||wp.i18n.__("Stripe could not be loaded","surecart");return}}if(!((m=(p=(u=this.paymentIntent)===null||u===void 0?void 0:u.processor_data)===null||p===void 0?void 0:p.stripe)===null||m===void 0?void 0:m.client_secret)||!this.container){console.warn("do not have client secret or container");return}const k=getComputedStyle(document.body);this.elements=this.stripe.elements({clientSecret:(y=(v=(b=this.paymentIntent)===null||b===void 0?void 0:b.processor_data)===null||v===void 0?void 0:v.stripe)===null||y===void 0?void 0:y.client_secret,appearance:{variables:{colorPrimary:k.getPropertyValue("--sc-color-primary-500"),colorText:k.getPropertyValue("--sc-input-label-color"),borderRadius:k.getPropertyValue("--sc-input-border-radius-medium"),colorBackground:k.getPropertyValue("--sc-input-background-color"),fontSizeBase:k.getPropertyValue("--sc-input-font-size-medium")},rules:{".Input":{border:k.getPropertyValue("--sc-input-border")},".Input::placeholder":{color:k.getPropertyValue("--sc-input-placeholder-color")}}}});this.elements.create("payment",{wallets:{applePay:"never",googlePay:"never"}}).mount(".sc-payment-element-container");this.element=this.elements.getElement("payment");this.element.on("ready",(()=>this.loaded=true))}async createPaymentIntent(){try{this.loading=true;this.error="";this.paymentIntent=await a({method:"POST",path:"surecart/v1/payment_intents",data:{processor_type:"stripe",live_mode:this.liveMode,customer_id:this.customerId,refresh_status:true}})}catch(e){this.error=(e===null||e===void 0?void 0:e.message)||wp.i18n.__("Something went wrong","surecart")}finally{this.loading=false}}async handleSubmit(e){var t;e.preventDefault();this.loading=true;try{const e=await this.stripe.confirmSetup({elements:this.elements,confirmParams:{return_url:d(this.successUrl,{payment_intent:(t=this.paymentIntent)===null||t===void 0?void 0:t.id})},redirect:"always"});if(e===null||e===void 0?void 0:e.error){this.error=e.error.message;throw e.error}}catch(e){console.error(e);this.error=(e===null||e===void 0?void 0:e.message)||wp.i18n.__("Something went wrong","surecart");this.loading=false}}render(){return t("sc-form",{key:"6ada94b2bc880992857c16c5691030c5a9f4e926",onScFormSubmit:e=>this.handleSubmit(e)},this.error&&t("sc-alert",{key:"ab82bd7c6127a5882601d9ecaf151491c823bd53",open:!!this.error,type:"danger"},t("span",{key:"076ce56c24da8c0bd72bc8c208fc0373befc4f07",slot:"title"},wp.i18n.__("Error","surecart")),this.error),t("div",{key:"e6b0c78786042eec6bfc6d87930d15ac3d71b219",class:"loader",hidden:this.loaded},t("div",{key:"7bebb1f8bfb30ba9dcf17fbbec2e50d0ae2a51f3",class:"loader__row"},t("div",{key:"13fc8b7ece68f8fa084859da178207ac69295a12",style:{width:"50%"}},t("sc-skeleton",{key:"a3a54e710901fa3f5b5011cc3c147fba2f571e73",style:{width:"50%",marginBottom:"0.5em"}}),t("sc-skeleton",{key:"36c46a0240be37c16235f359755569b3848c7985"})),t("div",{key:"c1a6e9374979437d36dfabd1940dca23e6c5a4d9",style:{flex:"1"}},t("sc-skeleton",{key:"22f9124aabd5fef20303e5d0ba7292123a513057",style:{width:"50%",marginBottom:"0.5em"}}),t("sc-skeleton",{key:"ae905323f8c8f1b8da46be407025f3da5e8e9924"})),t("div",{key:"e785fdb48266338319252e9300b81d48f94a8d71",style:{flex:"1"}},t("sc-skeleton",{key:"53b946b89ba26da09fa565a53ff1ea6ac473ff2f",style:{width:"50%",marginBottom:"0.5em"}}),t("sc-skeleton",{key:"fe84a5af888827d493279df807fb1eb0b6aa08dc"}))),t("div",{key:"b711b5dc9c554d4210e7aef1b5a4287282403e44",class:"loader__details"},t("sc-skeleton",{key:"34cbb4a2f1404257519954eb5d05f7758ecda7e8",style:{height:"1rem"}}),t("sc-skeleton",{key:"cd2a28cc457fa3a7f7e5e79c54ea20c9ae83ad3a",style:{height:"1rem",width:"30%"}}))),t("div",{key:"a1e632b8957a2a7071ef7b2a4316535c42d70d44",hidden:!this.loaded,class:"sc-payment-element-container",ref:e=>this.container=e}),t("sc-button",{key:"30181a8fc1a72deb247926291e296fc80bd731b6",type:"primary",submit:true,full:true,loading:this.loading},wp.i18n.__("Save Payment Method","surecart")))}static get watchers(){return{paymentIntent:["handlePaymentIntentCreate"]}}};n.style=o;export{n as sc_stripe_add_method}; //# sourceMappingURL=p-d3cf341a.entry.js.map
Save
Back