1import{r as t,c as e,h as s,a as i}from"./p-9add63ef.js";import{l as a,g as o}from"./p-a0974978.js";import"./p-8dccb656.js";import{g as c}from"./p-6fb86bf6.js";import{c as n}from"./p-78468e45.js";import{a as r}from"./p-259c3935.js";import"./p-401e165e.js";import"./p-d3366af3.js";import"./p-22f50d49.js";import"./p-2b28ea49.js";import"./p-dd24e53c.js";import"./p-830ab1a3.js";import"./p-d15c4b50.js";import"./p-3f6362a4.js";import"./p-31faf2b8.js";import"./p-610295e2.js";const d=':host{display:block}.paypal-buttons{position:relative;line-height:0;text-align:center}.paypal-buttons:not(.paypal-buttons--busy):after{content:" ";border-bottom:1px solid var(--sc-input-border-color);width:100%;height:0;top:50%;left:0;right:0;position:absolute}';const l=d;const p=class{constructor(s){t(this,s);this.scSetState=e(this,"scSetState",7);this.scPaid=e(this,"scPaid",7);this.bootstrapId=0;this.clientId=undefined;this.busy=false;this.merchantId=undefined;this.merchantInitiated=undefined;this.mode=undefined;this.order=undefined;this.buttons=["paypal","card"];this.label="paypal";this.color="gold";this.loaded=false}handleOrderChange(t,e){if((t===null||t===void 0?void 0:t.currency)===(e===null||e===void 0?void 0:e.currency)&&Boolean(t===null||t===void 0?void 0:t.reusable_payment_method_required)===Boolean(e===null||e===void 0?void 0:e.reusable_payment_method_required)){return}this.loadScript()}async loadScript(){var t,e,s;if(!this.clientId||!this.merchantId)return;const i=++this.bootstrapId;this.loaded=false;try{const c=await a(o({clientId:this.clientId,merchantId:this.merchantId,merchantInitiated:this.merchantInitiated,reusable:(t=this.order)===null||t===void 0?void 0:t.reusable_payment_method_required,currency:(e=this.order)===null||e===void 0?void 0:e.currency,locale:(s=window.scData)===null||s===void 0?void 0:s.locale}));if(i!==this.bootstrapId)return;if(this.cardContainer){this.cardContainer.innerHTML=""}if(this.paypalContainer){this.paypalContainer.innerHTML=""}this.renderButtons(c)}catch(t){console.error("failed to load the PayPal JS SDK script",t)}}componentDidLoad(){this.loadScript()}renderButtons(t){const e=this.order.reusable_payment_method_required?"createBillingAgreement":"createOrder";const s={onClick:async(t,e)=>{const s=this.el.closest("sc-checkout");const i=await s.validate();return i?e.resolve():e.reject()},onInit:()=>{this.loaded=true},onCancel:()=>{this.scSetState.emit("REJECT")},onApprove:async()=>{var t,e,s,i;try{this.order=await c({id:(t=this.order)===null||t===void 0?void 0:t.id})}catch(t){console.error(t);n({code:"could_not_capture",message:wp.i18n.__("The payment did not process. Please try again.","surecart")});this.scSetState.emit("REJECT")}try{this.scSetState.emit("PAYING");const t=await r({method:"PATCH",path:`surecart/v1/payment_intents/${((s=(e=this.order)===null||e===void 0?void 0:e.payment_intent)===null||s===void 0?void 0:s.id)||((i=this.order)===null||i===void 0?void 0:i.payment_intent)}/capture`});if(["succeeded","processing"].includes(t===null||t===void 0?void 0:t.status)){this.scSetState.emit("PAID");this.scPaid.emit()}else{n({code:"could_not_capture",message:wp.i18n.__("Payment processing failed. Kindly attempt the transaction once more.","surecart")});this.scSetState.emit("REJECT")}}catch(t){console.error(t);n({code:"could_not_capture",message:wp.i18n.__("Payment processing failed. Kindly attempt the transaction once more.","surecart")});this.scSetState.emit("REJECT")}},onError:t=>{console.error(t);n(t);this.scSetState.emit("REJECT")}};s[e]=async()=>new Promise((async(t,e)=>{var s,i;const a=this.el.closest("sc-checkout");const o=await a.submit();if(o instanceof Error){return e(o)}if((o===null||o===void 0?void 0:o.status)!=="finalized"){return e(new Error("Something went wrong. Please try again."))}if((s=o===null||o===void 0?void 0:o.payment_intent)===null||s===void 0?void 0:s.external_intent_id){return t((i=o===null||o===void 0?void 0:o.payment_intent)===null||i===void 0?void 0:i.external_intent_id)}n({code:"missing_payment_intent",message:wp.i18n.__("Something went wrong. Please contact us for payment.","surecart")});return e()}));if(t.FUNDING.PAYPAL&&this.buttons.includes("paypal")){const e=t.Buttons({fundingSource:t.FUNDING.PAYPAL,style:{label:this.label,color:this.color},...s});if(e.isEligible()){e.render(this.paypalContainer).catch((t=>console.error("failed to render the PayPal button",t)))}}if(t.FUNDING.CARD&&this.buttons.includes("card")){const e=t.Buttons({fundingSource:t.FUNDING.CARD,style:{color:"black"},...s});if(e.isEligible()){e.render(this.cardContainer).catch((t=>console.error("failed to render the PayPal card button",t)))}}}render(){return s("div",{key:"f681d1010c35f672f46a4c5f737f759e573d1a4a",part:`base ${this.busy||!this.loaded&&"base--busy"}`,class:{"paypal-buttons":true,"paypal-buttons--busy":this.busy||!this.loaded}},(!this.loaded||this.busy)&&s("sc-skeleton",{key:"a85b9f0aa7defe49024c3c41f2e0c577191df877",style:{height:"55px","--border-radius":"4px",cursor:"wait"}}),s("div",{key:"6306ac9b752f4701d773c73afa586361eb5bbbae",class:"sc-paypal-button-container",hidden:!this.loaded||this.busy},s("div",{key:"69c70f93ce4ff3ca4ae19d6575f436a0913c71f8",part:"paypal-card-button",hidden:!this.buttons.includes("card"),class:"sc-paypal-card-button",ref:t=>this.cardContainer=t}),s("div",{key:"7f8af65055e23fc39316737e619d4ddd77b62aec",part:"paypal-button",hidden:!this.buttons.includes("paypal"),class:"sc-paypal-button",ref:t=>this.paypalContainer=t})))}get el(){return i(this)}static get watchers(){return{order:["handleOrderChange"]}}};p.style=l;const h=":host{display:block;--sc-secure-notice-icon-color:var(--sc-color-gray-300);--sc-secure-notice-font-size:var(--sc-font-size-small);--sc-secure-notice-color:var(--sc-color-gray-500)}.notice{color:var(--sc-secure-notice-color);font-size:var(--sc-secure-notice-font-size);display:flex;align-items:center;gap:5px}.notice__text{flex:1;display:flex;align-items:center;justify-content:space-between;flex-wrap:wrap}.notice__icon{color:var(--sc-secure-notice-icon-color);margin-right:5px}";const f=h;const u=class{constructor(e){t(this,e)}render(){return s("div",{key:"ae73fd89aad081ab32ba575f9e9116226cbcf855",class:"notice",part:"base"},s("svg",{key:"34b1bd815392d7d9b6aae77574f6a2575b4c55ef",class:"notice__icon",part:"icon",xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 512 512",fill:"
1currentColor"},s("path",{key:"7d3085568edf591f6fb6e43aeebd78aa8a82379a",d:"M368,192H352V112a96,96,0,1,0-192,0v80H144a64.07,64.07,0,0,0-64,64V432a64.07,64.07,0,0,0,64,64H368a64.07,64.07,0,0,0,64-64V256A64.07,64.07,0,0,0,368,192Zm-48,0H192V112a64,64,0,1,1,128,0Z"})),s("span",{key:"32127abd73cbd43f720161ee8d789377019969cb",class:"notice__text",part:"text"},s("slot",{key:"e05ebd2f3a873185072cb40577f4bcf4e4e6716f",name:"prefix"}),s("slot",{key:"cf1333caa00bdc4402e1efa96f0cecb8fa905c4a"}),s("slot",{key:"dcbc649f7f642a189afbc54064a8ceb5de914d2e",name:"suffix"})))}};u.style=f;export{p as sc_paypal_buttons,u as sc_secure_notice}; 2//# sourceMappingURL=p-94864a8a.entry.js.map
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.