1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-09-22 17:31:35 +02:00
invoiceninja/public/js/clients/payment_methods/wepay-bank-account.js

77 lines
3.2 KiB
JavaScript
Raw Normal View History

/******/ (() => { // webpackBootstrap
var __webpack_exports__ = {};
/*!********************************************************************!*\
!*** ./resources/js/clients/payment_methods/wepay-bank-account.js ***!
\********************************************************************/
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
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; }
/**
* 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 WePayBank = /*#__PURE__*/function () {
function WePayBank() {
_classCallCheck(this, WePayBank);
}
_createClass(WePayBank, [{
key: "initializeWePay",
value: function initializeWePay() {
var _document$querySelect;
var environment = (_document$querySelect = document.querySelector('meta[name="wepay-environment"]')) === null || _document$querySelect === void 0 ? void 0 : _document$querySelect.content;
WePay.set_endpoint(environment === 'staging' ? 'stage' : 'production');
return this;
}
}, {
key: "showBankPopup",
value: function showBankPopup() {
var _document$querySelect2, _document$querySelect3;
WePay.bank_account.create({
client_id: (_document$querySelect2 = document.querySelector('meta[name=wepay-client-id]')) === null || _document$querySelect2 === void 0 ? void 0 : _document$querySelect2.content,
email: (_document$querySelect3 = document.querySelector('meta[name=contact-email]')) === null || _document$querySelect3 === void 0 ? void 0 : _document$querySelect3.content,
options: {
avoidMicrodeposits: true
}
}, function (data) {
if (data.error) {
errors.textContent = '';
errors.textContent = data.error_description;
errors.hidden = false;
} else {
document.querySelector('input[name="bank_account_id"]').value = data.bank_account_id;
document.getElementById('server_response').submit();
}
}, function (data) {
if (data.error) {
errors.textContent = '';
errors.textContent = data.error_description;
errors.hidden = false;
}
});
}
}, {
key: "handle",
value: function handle() {
this.initializeWePay().showBankPopup();
}
}]);
return WePayBank;
}();
document.addEventListener('DOMContentLoaded', function () {
new WePayBank().handle();
});
/******/ })()
;