import{p as i}from"./Dq2bRmo2.js";import{u as c}from"./Bxmfm8sn.js";import{K as m,a as d,b as p,m as u,j as l,k as y,v as h}from"./BCLrUOBx.js";const f={setup(){const t=d(),{getUserToken:r}=t,e=p(),{setToastMessage:o,setToastError:s,postRequest:a}=e;return{getUserToken:r,setToastMessage:o,setToastError:s,postRequest:a}},name:"RazorpayPayment",data(){return{}},watch:{},props:{orderId:{type:Number,default:""},razorpayPaymentToken:{type:String,default:""},razorpayKey:{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:{},computed:{},mixins:[c,i],methods:{makePayment(){const t=this;var r=new Razorpay({key:this.razorpayKey,amount:parseInt(this.amount*100),name:this.siteName,currency:this.currency,description:this.$t("payment.bestDeal"),handler:async e=>{e.razorpay_order_id===t.razorpayPaymentToken&&await this.paymentDoneFn(this.orderId,e.razorpay_order_id,this.orderMethods.RAZORPAY)},modal:{ondismiss:function(){t.$emit("closed")}},prefill:{name:this.userName,email:this.userEmail},notes:{address:""},theme:{color:"#6F55D5"},order_id:this.razorpayPaymentToken,redirect:!1});r.on("payment.failed",function(e){console.log(e.error.description),console.log(e.error.source),console.log(e.error.step),console.log(e.error.reason),this.$emit("error",e.error.description)}),r.open()}},created(){},async mounted(){let t=document.createElement("script");t.setAttribute("src","https://checkout.razorpay.com/v1/checkout.js"),document.head.appendChild(t),t.addEventListener("load",r=>{this.$refs.payBtn.click()})}},k={class:""},_=["value"];function g(t,r,e,o,s,a){return l(),u("div",k,[y("input",{ref:"payBtn",type:"hidden",onClick:r[0]||(r[0]=h((...n)=>a.makePayment&&a.makePayment(...n),["prevent"])),class:"btn btn-success",value:t.$t("ajaxButton.submit")},null,8,_)])}const P=m(f,[["render",g]]);export{P as default};
