import l from"./Bvs3L9q-.js";import m from"./CWalxxGV.js";import{u as f}from"./Bxmfm8sn.js";import{p as _}from"./Dq2bRmo2.js";import{K as g,u as h,s as y,a as S,b,m as o,j as a,l as c,A as u,t as x}from"./BCLrUOBx.js";const k={setup(){const r=h(),{langCode:n}=y(r),e=S(),{getUserToken:i}=e,t=b(),{postRequest:s}=t;return{postRequest:s,getUserToken:i,langCode:n}},name:"FlutterwavePayBtn",data(){return{errorText:"",submitting:!1,placingOrder:!1}},props:{order:{type:Object,default(){return null}},loading:{type:Boolean,default:!1},currency:{type:String,default:"USD"},amount:{type:Number,default:0},name:{type:String,default:""},userId:{type:String,default:""},email:{type:String,default:""},publicKey:{type:String,default:""},siteName:{type:String,default:""},headerLogo:{type:String,default:""},btnText:{type:String,default:""}},components:{AjaxButton:l,Spinner:m},mixins:[f,_],methods:{confirmOrder(){this.placingOrder=!0,this.$emit("clicked")},makePayment(){this.placingOrder=!1;const r=this,n=FlutterwaveCheckout({public_key:this.publicKey,tx_ref:"ref_"+this.order.order,amount:this.amount,currency:this.currency,payment_options:"card, banktransfer, ussd",meta:{consumer_id:this.userId},customer:{email:this.email,user_id:this.userId,name:this.name},callback:async e=>{this.submitting=!0,await this.paymentDoneFn(this.order.id,e.transaction_id,this.orderMethods.FLUTTERWAVE),n.close()},onclose:function(){r.$emit("closed",r.order.id)},customizations:{title:this.siteName,description:"",logo:this.headerLogo}})}}},T={key:0,class:"error"},O={key:1,class:"spinner-wrapper flex layer-white"};function w(r,n,e,i,t,s){const d=l,p=m;return a(),o("div",null,[c(d,{class:"primary-btn plr-30 plr-sm-15",type:"button","fetching-data":t.placingOrder,text:e.btnText,onClicked:s.confirmOrder},null,8,["fetching-data","text","onClicked"]),t.errorText?(a(),o("p",T,x(t.errorText),1)):u("",!0),e.loading||t.submitting?(a(),o("span",O,[c(p,{radius:50})])):u("",!0)])}const L=g(k,[["render",w]]);export{L as default};
