D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
home
/
diafdxji
/
shihty.com
/
wp-content
/
plugins
/
surecart
/
dist
/
components
/
surecart
/
Filename :
p-042864c5.entry.js
back
Copy
import{r as e,h as t}from"./p-e97fde0a.js";import{p as i}from"./p-9ef0f73f.js";import{a as d}from"./p-dd3464cd.js";import{a as s}from"./p-401e165e.js";import"./p-d3366af3.js";const a="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=a;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,d,s,a,o,n,r,c,l,f,h,u,p,m,b,v,y;if(!((d=(t=(e=this.paymentIntent)===null||e===void 0?void 0:e.processor_data)===null||t===void 0?void 0:t.stripe)===null||d===void 0?void 0:d.publishable_key)||!((o=(a=(s=this.paymentIntent)===null||s===void 0?void 0:s.processor_data)===null||a===void 0?void 0:a.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:(h=(f=(l=this.paymentIntent)===null||l===void 0?void 0:l.processor_data)===null||f===void 0?void 0:f.stripe)===null||h===void 0?void 0:h.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 d({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:s(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:"b4d8a7e9376048b09bc97f85f5f6031082dc00e5",onScFormSubmit:e=>this.handleSubmit(e)},this.error&&t("sc-alert",{key:"0a3813acb53fdbf22b50d7c899655b4f5ba41be7",open:!!this.error,type:"danger"},t("span",{key:"b8e400a024474000df46be0a8fa18359213c4027",slot:"title"},wp.i18n.__("Error","surecart")),this.error),t("div",{key:"951da24c218b48f4a6b396e1ece529ec239cd260",class:"loader",hidden:this.loaded},t("div",{key:"f2d9139a78a0a7c247b812ed17f5b4dc85f653fe",class:"loader__row"},t("div",{key:"20a99848776cc0895224f587120b6a44521e62e0",style:{width:"50%"}},t("sc-skeleton",{key:"ce735a09c1f57c9029bff493e73e1585869bbe30",style:{width:"50%",marginBottom:"0.5em"}}),t("sc-skeleton",{key:"1caab747399f6718269c49ce1f1fcbd812374286"})),t("div",{key:"d819dce5561299b2ca77a5ff20615148135f544d",style:{flex:"1"}},t("sc-skeleton",{key:"a50e82adbf945e9296e6be3f9c790e20db8dc958",style:{width:"50%",marginBottom:"0.5em"}}),t("sc-skeleton",{key:"846a777869be81a8cc7178eead938d3d57a69a63"})),t("div",{key:"7be7ded8e80a8bc2d65f0a1aeff087eb5fcd14b1",style:{flex:"1"}},t("sc-skeleton",{key:"2f22794800f21093c1c7cc749069d31da2a86601",style:{width:"50%",marginBottom:"0.5em"}}),t("sc-skeleton",{key:"128522f2bbfe179a67043bc0c982d662178da6e9"}))),t("div",{key:"4cf34dd9e9d04b00fe17effa9fc49825f94aad3b",class:"loader__details"},t("sc-skeleton",{key:"dce373bb3b6272b70230f00eb50e5b0783842f7c",style:{height:"1rem"}}),t("sc-skeleton",{key:"f0070cd168300d37b94835f3b1782f4e39db09bd",style:{height:"1rem",width:"30%"}}))),t("div",{key:"2ac0ef02b3662eba8121cf4476c4041dfd43d026",hidden:!this.loaded,class:"sc-payment-element-container",ref:e=>this.container=e}),t("sc-button",{key:"ed8ec2ee3d3f1f40bfd90a53304cc6fcd569c368",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-042864c5.entry.js.map