1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-11 13:42:49 +01:00
invoiceninja/public/js/clients/payments/stripe-becs.js
2021-10-20 16:39:07 +02:00

2 lines
3.8 KiB
JavaScript
Vendored

!function(n){var o={};function r(e){if(o[e])return o[e].exports;var t=o[e]={i:e,l:!1,exports:{}};return n[e].call(t.exports,t,t.exports,r),t.l=!0,t.exports}r.m=n,r.c=o,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var o in t)r.d(n,o,function(e){return t[e]}.bind(null,o));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="/",r(r.s=28)}({28:function(e,t,n){e.exports=n("guV3")},guV3:function(e,t){var n;function o(e,t){for(var n=0;n<t.length;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}function r(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var a=(o(u.prototype,[{key:"handleSuccess",value:function(e){document.querySelector('input[name="gateway_response"]').value=JSON.stringify(e.paymentIntent),document.getElementById("server-response").submit()}},{key:"handleFailure",value:function(e){var t=document.getElementById("errors");t.textContent="",t.textContent=e,t.hidden=!1,document.getElementById("pay-now").disabled=!1,document.querySelector("#pay-now > svg").classList.add("hidden"),document.querySelector("#pay-now > span").classList.remove("hidden")}}]),u),c=null!==(n=null===(c=document.querySelector('meta[name="stripe-publishable-key"]'))||void 0===c?void 0:c.content)&&void 0!==n?n:"",i=null!==(n=null===(n=document.querySelector('meta[name="stripe-account-id"]'))||void 0===n?void 0:n.content)&&void 0!==n?n:"";function u(e,t){var n=this;!function(e){if(!(e instanceof u))throw new TypeError("Cannot call a class as a function")}(this),r(this,"setupStripe",function(){n.stripe=Stripe(n.key),n.stripeConnect&&(n.stripe.stripeAccount=i);const e=n.stripe.elements();var t={style:{base:{color:"#32325d",fontSize:"16px","::placeholder":{color:"#aab7c4"},":-webkit-autofill":{color:"#32325d"}},invalid:{color:"#fa755a",iconColor:"#fa755a",":-webkit-autofill":{color:"#fa755a"}}},disabled:!1,hideIcon:!1,iconStyle:"default"};return n.auBankAccount=e.create("auBankAccount",t),n.auBankAccount.mount("#becs-iban"),n}),r(this,"handle",function(){document.getElementById("pay-now").addEventListener("click",e=>{let t=document.getElementById("errors");return""===document.getElementById("becs-name").value?(document.getElementById("becs-name").focus(),t.textContent="Name required.",void(t.hidden=!1)):""===document.getElementById("becs-email-address").value?(document.getElementById("becs-email-address").focus(),t.textContent="Email required.",void(t.hidden=!1)):document.getElementById("becs-mandate-acceptance").checked?(document.getElementById("pay-now").disabled=!0,document.querySelector("#pay-now > svg").classList.remove("hidden"),document.querySelector("#pay-now > span").classList.add("hidden"),void this.stripe.confirmAuBecsDebitPayment(document.querySelector("meta[name=pi-client-secret").content,{payment_method:{au_becs_debit:this.auBankAccount,billing_details:{name:document.getElementById("becs-name").value,email:document.getElementById("becs-email-address").value}}}).then(e=>e.error?this.handleFailure(e.error.message):this.handleSuccess(e))):(document.getElementById("becs-mandate-acceptance").focus(),t.textContent="Accept Terms",t.hidden=!1,void console.log("Terms"))})}),this.key=e,this.errors=document.getElementById("errors"),this.stripeConnect=t}new a(c,i).setupStripe().handle()}});