(()=>{functione(e,t){for(varn=0;n<t.length;n++){varr=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"inr&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}(new(function(){functiont(){vare;!function(e,t){if(!(einstanceoft))thrownewTypeError("Cannot call a class as a function")}(this,t),this.clientSecret=null===(e=document.querySelector("meta[name=stripe-pi-client-secret]"))||void0===e?void0:e.content}varn,r,o;returnn=t,(r=[{key:"init",value:function(){vare,t,n={};returndocument.querySelector("meta[name=stripe-account-id]")&&(n.apiVersion="2020-08-27",n.stripeAccount=null===(t=document.querySelector("meta[name=stripe-account-id]"))||void0===t?void0:t.content),this.stripe=Stripe(null===(e=document.querySelector("meta[name=stripe-publishable-key]"))||void0===e?void0:e.content,n),this.elements=this.stripe.elements(),this}},{key:"createPaymentRequest",value:function(){returnthis.paymentRequest=this.stripe.paymentRequest(JSON.parse(document.querySelector("meta[name=payment-request-data").content)),this}},{key:"createPaymentRequestButton",value:function(){this.paymentRequestButton=this.elements.create("paymentRequestButton",{paymentRequest:this.paymentRequest})}},{key:"handlePaymentRequestEvents",value:function(e,t){document.querySelector("#errors").hidden=!0,this.paymentRequest.on("paymentmethod",(function(n){e.confirmCardPayment(t,{payment_method:n.paymentMethod.id},{handleActions:!1}).then((function(r){r.error?(console.log(r),console.log(r.error),n.complete("fail"),document.querySelector("#errors").innerText=r.error.message,document.querySelector("#errors").hidden=!1):(n.complete("success"),"requires_action"===r.paymentIntent.status?e.confirmCardPayment(t).then((function(e){e.error?(n.complete("fail"),document.querySelector("#errors").innerText=e.error.message,document.querySelector("#errors").hidden=!1):(document.querySelector('input[name="gateway_response"]').value=JSON.stringify(e.paymentIntent),document.getElementById("server-response").submit())})):(document.querySelector('input[name="gateway_response"]').value=JSON.stringify(r.paymentIntent),document.getElementById("server-response").submit()))}))}))}},{key:"handle",value:function(){vare=this;this.init().createPaymentRequest().createPaymentRequestButton(),this.paymentRequest.canMakePayment().then((function(t){varn;if(t)returne.paymentRequestButton.mount("#payment-request-button");document.querySelector("#errors").innerHTML=JSON.parse(null===(n=document.querySelector("meta[name=no-available-methods]"))||void0===n?void0:n.content),document.querySelector("#errors").hidden=!1})),this.handlePaymentRequestEvents(this.stripe,this.clientSecret)}}])&&e(n.prototype,r),o&&e(n,o),t}())).handle()})();