diff --git a/public/js/clients/payments/stripe-bacs.js b/public/js/clients/payments/stripe-bacs.js index 31c8136a7df0..aa816738d10f 100644 --- a/public/js/clients/payments/stripe-bacs.js +++ b/public/js/clients/payments/stripe-bacs.js @@ -1,2 +1,2 @@ /*! For license information please see stripe-bacs.js.LICENSE.txt */ -(()=>{var e,t,n,o,r,i;function a(e,t){for(var n=0;n svg").classList.remove("hidden"),document.querySelector("#authorize-bacs > span").classList.add("hidden"),location.href=document.querySelector("meta[name=stripe-redirect-url").content})):document.getElementById("pay-now").addEventListener("click",(function(e){document.querySelector("input[name=token]").value;var t=document.getElementById("pay-now");o.payNowButton=t,o.payNowButton.disabled=!0,o.payNowButton.querySelector("svg").classList.remove("hidden"),o.payNowButton.querySelector("span").classList.add("hidden"),o.stripe.confirmBacsDebitPayment(document.querySelector("meta[name=pi-client-secret").content)}))})),this.key=t,this.errors=document.getElementById("errors"),this.stripeConnect=n,this.onlyAuthorization=m})),d=null!==(e=null===(t=document.querySelector('meta[name="stripe-publishable-key"]'))||void 0===t?void 0:t.content)&&void 0!==e?e:"",s=null!==(n=null===(o=document.querySelector('meta[name="stripe-account-id"]'))||void 0===o?void 0:o.content)&&void 0!==n?n:"",m=null!==(r=null===(i=document.querySelector('meta[name="only-authorization"]'))||void 0===i?void 0:i.content)&&void 0!==r?r:"";new l(d,s).setupStripe().handle()})(); \ No newline at end of file +(()=>{var e,t,n,o,r,i;function a(e,t){for(var n=0;n svg").classList.remove("hidden"),document.querySelector("#authorize-bacs > span").classList.add("hidden"),location.href=document.querySelector("meta[name=stripe-redirect-url").content})):document.getElementById("pay-now").addEventListener("click",(function(e){var t=document.querySelector("input[name=token]").value,n=document.getElementById("pay-now");o.payNowButton=n,o.payNowButton.disabled=!0,o.payNowButton.querySelector("svg").classList.remove("hidden"),o.payNowButton.querySelector("span").classList.add("hidden"),o.stripe.confirmBacsDebitPayment(document.querySelector("meta[name=pi-client-secret").content,{payment_method:t}).then((function(e){return e.error?o.handleFailure(e.error.message):o.handleSuccess(e)}))}))})),this.key=t,this.errors=document.getElementById("errors"),this.stripeConnect=n,this.onlyAuthorization=s}var t,n,o;return t=e,(n=[{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")}},{key:"handleSuccess",value:function(e){document.querySelector('input[name="gateway_response"]').value=JSON.stringify(e.paymentIntent),document.getElementById("server-response").submit()}}])&&a(t.prototype,n),o&&a(t,o),Object.defineProperty(t,"prototype",{writable:!1}),e}(),d=null!==(e=null===(t=document.querySelector('meta[name="stripe-publishable-key"]'))||void 0===t?void 0:t.content)&&void 0!==e?e:"",l=null!==(n=null===(o=document.querySelector('meta[name="stripe-account-id"]'))||void 0===o?void 0:o.content)&&void 0!==n?n:"",s=null!==(r=null===(i=document.querySelector('meta[name="only-authorization"]'))||void 0===i?void 0:i.content)&&void 0!==r?r:"";new c(d,l).setupStripe().handle()})(); \ No newline at end of file diff --git a/resources/js/clients/payments/stripe-bacs.js b/resources/js/clients/payments/stripe-bacs.js index 9e26aa613033..2b55c8f1fbbd 100644 --- a/resources/js/clients/payments/stripe-bacs.js +++ b/resources/js/clients/payments/stripe-bacs.js @@ -51,11 +51,36 @@ class ProcessBACS { this.payNowButton.querySelector('svg').classList.remove('hidden'); this.payNowButton.querySelector('span').classList.add('hidden'); this.stripe.confirmBacsDebitPayment( - document.querySelector('meta[name=pi-client-secret').content, - ); + document.querySelector('meta[name=pi-client-secret').content, { + payment_method: token}).then((result) => { + if (result.error) { + return this.handleFailure(result.error.message); + } + + return this.handleSuccess(result); + }); }); } }; + + handleFailure(message) { + let errors = document.getElementById('errors'); + + errors.textContent = ''; + errors.textContent = message; + errors.hidden = false; + + document.getElementById('pay-now').disabled = false; + document.querySelector('#pay-now > svg').classList.add('hidden'); + document.querySelector('#pay-now > span').classList.remove('hidden'); + } + handleSuccess(result) { + document.querySelector( + 'input[name="gateway_response"]' + ).value = JSON.stringify(result.paymentIntent); + + document.getElementById('server-response').submit(); + } } const publishableKey = document.querySelector( diff --git a/resources/js/clients/payments/stripe-sepa.js b/resources/js/clients/payments/stripe-sepa.js index 8e9a74536187..cafcf8e7cc9c 100644 --- a/resources/js/clients/payments/stripe-sepa.js +++ b/resources/js/clients/payments/stripe-sepa.js @@ -5,7 +5,7 @@ * * @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com) * - * @license https://www.elastic.co/licensing/elastic-license + * @license https://www.elastic.co/licensing/elastic-license */ class ProcessSEPA { @@ -215,6 +215,22 @@ class ProcessSEPA { document.querySelector('#pay-now > svg').classList.add('hidden'); document.querySelector('#pay-now > span').classList.remove('hidden'); } + handleSuccess(result) { + document.querySelector( + 'input[name="gateway_response"]' + ).value = JSON.stringify(result.paymentIntent); + + let tokenBillingCheckbox = document.querySelector( + 'input[name="token-billing-checkbox"]:checked' + ); + + if (tokenBillingCheckbox) { + document.querySelector('input[name="store_card"]').value = + tokenBillingCheckbox.value; + } + + document.getElementById('server-response').submit(); + } } const publishableKey = diff --git a/resources/views/portal/ninja2020/gateways/stripe/bacs/pay.blade.php b/resources/views/portal/ninja2020/gateways/stripe/bacs/pay.blade.php index b0aa482d5e63..7116a6a183aa 100644 --- a/resources/views/portal/ninja2020/gateways/stripe/bacs/pay.blade.php +++ b/resources/views/portal/ninja2020/gateways/stripe/bacs/pay.blade.php @@ -18,8 +18,6 @@ - -