mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Handle when stripe ACH dialog is closed
This commit is contained in:
parent
f28a26d3f9
commit
39a7d94b21
104
public/js/clients/payments/stripe-klarna.js
vendored
104
public/js/clients/payments/stripe-klarna.js
vendored
@ -1,2 +1,102 @@
|
||||
/*! For license information please see stripe-klarna.js.LICENSE.txt */
|
||||
(()=>{var e,t,n,r;function o(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function a(e,t,n){return t&&o(e.prototype,t),n&&o(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function c(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var i=a((function e(t,n){var r=this;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),c(this,"setupStripe",(function(){return r.stripeConnect?r.stripe=Stripe(r.key,{stripeAccount:r.stripeConnect}):r.stripe=Stripe(r.key),r})),c(this,"handleError",(function(e){document.getElementById("pay-now").disabled=!1,document.querySelector("#pay-now > svg").classList.add("hidden"),document.querySelector("#pay-now > span").classList.remove("hidden"),r.errors.textContent="",r.errors.textContent=e,r.errors.hidden=!1})),c(this,"handle",(function(){document.getElementById("pay-now").addEventListener("click",(function(e){var t=document.getElementById("errors"),n=document.getElementById("klarna-name").value;/^[A-Za-z\s]*$/.test(n)?(document.getElementById("pay-now").disabled=!0,document.querySelector("#pay-now > svg").classList.remove("hidden"),document.querySelector("#pay-now > span").classList.add("hidden"),r.stripe.confirmKlarnaPayment(document.querySelector("meta[name=pi-client-secret").content,{payment_method:{billing_details:{name:n,email:document.querySelector("meta[name=email]").content,address:{line1:document.querySelector("meta[name=address-1]").content,line2:document.querySelector("meta[name=address-2]").content,city:document.querySelector("meta[name=city]").content,postal_code:document.querySelector("meta[name=postal_code]").content,state:document.querySelector("meta[name=state]").content,country:document.querySelector("meta[name=country]").content}}},return_url:document.querySelector('meta[name="return-url"]').content}).then((function(e){if(e.hasOwnProperty("error"))return r.handleError(e.error.message)}))):(document.getElementById("klarna-name-correction").hidden=!1,document.getElementById("klarna-name").textContent=n.replace(/^[A-Za-z\s]*$/,""),document.getElementById("klarna-name").focus(),t.textContent=document.querySelector("meta[name=translation-name-without-special-characters]").content,t.hidden=!1)}))})),this.key=t,this.errors=document.getElementById("errors"),this.stripeConnect=n}));new i(null!==(e=null===(t=document.querySelector('meta[name="stripe-publishable-key"]'))||void 0===t?void 0:t.content)&&void 0!==e?e:"",null!==(n=null===(r=document.querySelector('meta[name="stripe-account-id"]'))||void 0===r?void 0:r.content)&&void 0!==n?n:"").setupStripe().handle()})();
|
||||
/******/ (() => { // webpackBootstrap
|
||||
var __webpack_exports__ = {};
|
||||
/*!********************************************************!*\
|
||||
!*** ./resources/js/clients/payments/stripe-klarna.js ***!
|
||||
\********************************************************/
|
||||
var _document$querySelect, _document$querySelect2, _document$querySelect3, _document$querySelect4;
|
||||
|
||||
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
||||
|
||||
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
||||
|
||||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
||||
|
||||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
||||
|
||||
/**
|
||||
* Invoice Ninja (https://invoiceninja.com)
|
||||
*
|
||||
* @link https://github.com/invoiceninja/invoiceninja source repository
|
||||
*
|
||||
* @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com)
|
||||
*
|
||||
* @license https://www.elastic.co/licensing/elastic-license
|
||||
*/
|
||||
var ProcessKlarna = /*#__PURE__*/_createClass(function ProcessKlarna(key, stripeConnect) {
|
||||
var _this = this;
|
||||
|
||||
_classCallCheck(this, ProcessKlarna);
|
||||
|
||||
_defineProperty(this, "setupStripe", function () {
|
||||
if (_this.stripeConnect) {
|
||||
// this.stripe.stripeAccount = this.stripeConnect;
|
||||
_this.stripe = Stripe(_this.key, {
|
||||
stripeAccount: _this.stripeConnect
|
||||
});
|
||||
} else {
|
||||
_this.stripe = Stripe(_this.key);
|
||||
}
|
||||
|
||||
return _this;
|
||||
});
|
||||
|
||||
_defineProperty(this, "handleError", function (message) {
|
||||
document.getElementById('pay-now').disabled = false;
|
||||
document.querySelector('#pay-now > svg').classList.add('hidden');
|
||||
document.querySelector('#pay-now > span').classList.remove('hidden');
|
||||
_this.errors.textContent = '';
|
||||
_this.errors.textContent = message;
|
||||
_this.errors.hidden = false;
|
||||
});
|
||||
|
||||
_defineProperty(this, "handle", function () {
|
||||
document.getElementById('pay-now').addEventListener('click', function (e) {
|
||||
var errors = document.getElementById('errors');
|
||||
var name = document.getElementById("klarna-name").value;
|
||||
|
||||
if (!/^[A-Za-z\s]*$/.test(name)) {
|
||||
document.getElementById('klarna-name-correction').hidden = false;
|
||||
document.getElementById('klarna-name').textContent = name.replace(/^[A-Za-z\s]*$/, "");
|
||||
document.getElementById('klarna-name').focus();
|
||||
errors.textContent = document.querySelector('meta[name=translation-name-without-special-characters]').content;
|
||||
errors.hidden = false;
|
||||
} else {
|
||||
document.getElementById('pay-now').disabled = true;
|
||||
document.querySelector('#pay-now > svg').classList.remove('hidden');
|
||||
document.querySelector('#pay-now > span').classList.add('hidden');
|
||||
|
||||
_this.stripe.confirmKlarnaPayment(document.querySelector('meta[name=pi-client-secret').content, {
|
||||
payment_method: {
|
||||
billing_details: {
|
||||
name: name,
|
||||
email: document.querySelector('meta[name=email]').content,
|
||||
address: {
|
||||
line1: document.querySelector('meta[name=address-1]').content,
|
||||
line2: document.querySelector('meta[name=address-2]').content,
|
||||
city: document.querySelector('meta[name=city]').content,
|
||||
postal_code: document.querySelector('meta[name=postal_code]').content,
|
||||
state: document.querySelector('meta[name=state]').content,
|
||||
country: document.querySelector('meta[name=country]').content
|
||||
}
|
||||
}
|
||||
},
|
||||
return_url: document.querySelector('meta[name="return-url"]').content
|
||||
}).then(function (result) {
|
||||
if (result.hasOwnProperty('error')) {
|
||||
return _this.handleError(result.error.message);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
this.key = key;
|
||||
this.errors = document.getElementById('errors');
|
||||
this.stripeConnect = stripeConnect;
|
||||
});
|
||||
|
||||
var publishableKey = (_document$querySelect = (_document$querySelect2 = document.querySelector('meta[name="stripe-publishable-key"]')) === null || _document$querySelect2 === void 0 ? void 0 : _document$querySelect2.content) !== null && _document$querySelect !== void 0 ? _document$querySelect : '';
|
||||
var stripeConnect = (_document$querySelect3 = (_document$querySelect4 = document.querySelector('meta[name="stripe-account-id"]')) === null || _document$querySelect4 === void 0 ? void 0 : _document$querySelect4.content) !== null && _document$querySelect3 !== void 0 ? _document$querySelect3 : '';
|
||||
new ProcessKlarna(publishableKey, stripeConnect).setupStripe().handle();
|
||||
/******/ })()
|
||||
;
|
@ -5,7 +5,7 @@
|
||||
"/js/clients/payments/forte-credit-card-payment.js": "/js/clients/payments/forte-credit-card-payment.js?id=f42dd0caddb3603e71db061924c4b172",
|
||||
"/js/clients/payments/forte-ach-payment.js": "/js/clients/payments/forte-ach-payment.js?id=b8173c7c0dee76bf9ae6312a963ae0e4",
|
||||
"/js/clients/payments/stripe-ach.js": "/js/clients/payments/stripe-ach.js?id=207f218c44553470287f35f33a7eb154",
|
||||
"/js/clients/payments/stripe-klarna.js": "/js/clients/payments/stripe-klarna.js?id=1c248bc1f4f45310cd585a95a5055375",
|
||||
"/js/clients/payments/stripe-klarna.js": "/js/clients/payments/stripe-klarna.js?id=7268f9282c6bb3b04d19d11a7b0c1681",
|
||||
"/js/clients/invoices/action-selectors.js": "/js/clients/invoices/action-selectors.js?id=404b7ee18e420de0e73f5402b7e39122",
|
||||
"/js/clients/purchase_orders/action-selectors.js": "/js/clients/purchase_orders/action-selectors.js?id=2f0c4e3bab30a98e33ac768255113174",
|
||||
"/js/clients/purchase_orders/accept.js": "/js/clients/purchase_orders/accept.js?id=9bb483a89a887f753e49c0b635d6276a",
|
||||
|
@ -180,9 +180,11 @@
|
||||
let bank_account_response = document.getElementById('bank_account_response');
|
||||
bank_account_response.value = JSON.stringify(paymentIntent);
|
||||
|
||||
confirmPayment(stripe, clientSecret);
|
||||
confirmPayment(stripe, clientSecret);
|
||||
}
|
||||
|
||||
resetButtons();
|
||||
return;
|
||||
});
|
||||
});
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user