import y from"./a5umXhxZ.js";import f from"./Bvs3L9q-.js";import _ from"./YMgwR3Gi.js";import{p as P}from"./Dq2bRmo2.js";import{u as x}from"./Bxmfm8sn.js";import{K as S,u as C,s as m,b as T,a as k,f as w,m as E,j as h,l as u,w as l,i as N,A as B,k as r,C as D,t as i,T as I}from"./BCLrUOBx.js";import"./CWalxxGV.js";const $={setup(){const e=C(),{langCode:t}=m(e),o=T(),{currencyIcon:a,setting:s}=m(o),{setToastMessage:n,setToastError:p,postRequest:d}=o,c=k(),{getUserToken:g}=c,{profile:v}=m(c),b=w(()=>s.value.currency_position);return{getUserToken:g,currencyPosition:b,langCode:t,profile:v,postRequest:d,currencyIcon:a,setting:s,setToastMessage:n,setToastError:p}},name:"StripePayment",data(){return{stripe:null,card:null,showPopup:!0,loader:!0,submitting:!1,errorText:""}},mixins:[x,P],watch:{},props:{orderId:{type:Number,default:""},stripeKey:{type:String,default:""},currency:{type:String,default:"USD"},amount:{type:Number,default:0},userName:{type:String,default:""},siteName:{type:String,default:""},userEmail:{type:String,default:""}},components:{PopOver:_,AjaxButton:f,PriceFormat:y},computed:{payBtnText(){return this.$t("stripePayment.pay",{amount:this.formattedPrice})},formattedPrice(){return this.priceFormat(this.currencyPosition,this.currencyIcon,this.amount,this.setting)}},methods:{closePopOver(){this.$emit("closed"),this.showPopup=!1,this.$destroy(),this.$el.parentNode.removeChild(this.$el)},initPayment(){this.stripe=Stripe(this.stripeKey);var e=this.stripe.elements(),t={base:{iconColor:"#666EE8",color:"#31325F",lineHeight:"40px","::placeholder":{color:"#CFD7E0"}}};this.card=e.create("cardNumber",{style:t,showIcon:!0});const o=e.create("cardExpiry",{style:t}),a=e.create("cardCvc",{style:t});this.card.mount("#card-number"),o.mount("#card-expiry"),a.mount("#card-cvc"),this.loader=!1},createStripeToken(){var e;this.errorText="",this.submitting=!0,this.stripe.createToken(this.card,{name:(e=this.profile)==null?void 0:e.name}).then(async t=>{t.error?(this.submitting=!1,this.errorText=t.error.message):await this.paymentDoneFn(this.orderId,t.token.id,this.orderMethods.STRIPE)})}},created(){},async mounted(){let e=document.createElement("script");e.setAttribute("src","https://js.stripe.com/v3/"),document.head.appendChild(e),e.onload=()=>{this.initPayment()}}},F={class:"color-inherit semi-bold"},j={class:"color-inherit opacity-8 mb-5"},A={class:"color-inherit"},K={class:"input-wrap"},O={class:"flex"},R={class:"input-wrap"},U={class:"input-wrap"},V={class:"error"};function H(e,t,o,a,s,n){const p=y,d=f,c=_;return h(),E("div",null,[u(I,{name:"fade",mode:"out-in"},{default:l(()=>[s.showPopup?(h(),N(c,{key:0,onClose:n.closePopOver,"elem-id":"card-pop-over",class:"card-popup popup-top-auto",layer:!0,"outside-click-on":!1},{heading:l(()=>[r("div",null,[r("h3",F,i(o.siteName),1),r("h6",j,i(e.$t("stripePayment.bestDeal")),1),r("h3",A,[u(p,{price:o.amount},null,8,["price"])])])]),content:l(()=>[r("form",{action:"",method:"post",id:"payment-form",class:D(["stripe-form",{"opacity-0":s.loader}])},[r("div",K,[r("label",null,i(e.$t("stripePayment.creditDebit")),1),t[0]||(t[0]=r("div",{id:"card-number"},null,-1))]),r("div",O,[r("div",R,[r("label",null,i(e.$t("stripePayment.creditExpiry")),1),t[1]||(t[1]=r("div",{id:"card-expiry"},null,-1))]),r("div",U,[r("label",null,i(e.$t("stripePayment.creditCvc")),1),t[2]||(t[2]=r("div",{id:"card-cvc"},null,-1))])]),t[3]||(t[3]=r("div",{id:"card-errors",role:"alert"},null,-1)),r("p",V,i(s.errorText),1)],2)]),"pop-footer":l(()=>[u(d,{class:"primary-btn w-100",type:"button","fetching-data":s.submitting,onClicked:n.createStripeToken,"loading-text":e.$t("stripePayment.placing"),text:n.payBtnText},null,8,["fetching-data","onClicked","loading-text","text"])]),_:1},8,["onClose"])):B("",!0)]),_:1})])}const W=S($,[["render",H]]);export{W as default};
