2023-03-01 07:57:52 +01:00
|
|
|
/******/ (() => { // webpackBootstrap
|
|
|
|
var __webpack_exports__ = {};
|
|
|
|
/*!********************************************************!*\
|
|
|
|
!*** ./resources/js/clients/payments/stripe-alipay.js ***!
|
|
|
|
\********************************************************/
|
|
|
|
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
|
|
|
|
|
|
var _document$querySelect, _document$querySelect2, _document$querySelect3, _document$querySelect4;
|
|
|
|
|
|
|
|
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return generator._invoke = function (innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; }(innerFn, self, context), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; this._invoke = function (method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resol
|
|
|
|
|
|
|
|
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
|
|
|
|
|
|
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
|
|
|
|
|
|
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; }
|
|
|
|
|
|
|
|
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 ProcessAlipay = /*#__PURE__*/function () {
|
|
|
|
function ProcessAlipay(key, stripeConnect) {
|
|
|
|
var _this = this;
|
|
|
|
|
|
|
|
_classCallCheck(this, ProcessAlipay);
|
|
|
|
|
|
|
|
_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;
|
|
|
|
});
|
|
|
|
|
|
|
|
this.key = key;
|
|
|
|
this.stripeConnect = stripeConnect;
|
|
|
|
this.errors = document.getElementById('errors');
|
|
|
|
}
|
|
|
|
|
|
|
|
_createClass(ProcessAlipay, [{
|
|
|
|
key: "handle",
|
|
|
|
value: function () {
|
|
|
|
var _handle = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
|
|
var _this2 = this;
|
|
|
|
|
|
|
|
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
|
|
while (1) {
|
|
|
|
switch (_context2.prev = _context2.next) {
|
|
|
|
case 0:
|
|
|
|
document.getElementById('pay-now').addEventListener('click', /*#__PURE__*/function () {
|
|
|
|
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(e) {
|
|
|
|
var _yield$_this2$stripe$, error;
|
|
|
|
|
|
|
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
|
|
while (1) {
|
|
|
|
switch (_context.prev = _context.next) {
|
|
|
|
case 0:
|
|
|
|
document.getElementById('pay-now').disabled = true;
|
|
|
|
document.querySelector('#pay-now > svg').classList.add('hidden');
|
|
|
|
document.querySelector('#pay-now > span').classList.remove('hidden');
|
|
|
|
_context.next = 5;
|
|
|
|
return _this2.stripe.confirmAlipayPayment(document.querySelector('meta[name=ci_intent]').content, {
|
|
|
|
// Return URL where the customer should be redirected after the authorization
|
|
|
|
return_url: "".concat(document.querySelector('meta[name=return_url]').content)
|
|
|
|
});
|
|
|
|
|
|
|
|
case 5:
|
|
|
|
_yield$_this2$stripe$ = _context.sent;
|
|
|
|
error = _yield$_this2$stripe$.error;
|
|
|
|
document.getElementById('pay-now').disabled = false;
|
|
|
|
document.querySelector('#pay-now > svg').classList.remove('hidden');
|
|
|
|
document.querySelector('#pay-now > span').classList.add('hidden');
|
|
|
|
|
|
|
|
if (error) {
|
|
|
|
_this2.errors.textContent = '';
|
|
|
|
_this2.errors.textContent = result.error.message;
|
|
|
|
_this2.errors.hidden = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
case 11:
|
|
|
|
case "end":
|
|
|
|
return _context.stop();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}, _callee);
|
|
|
|
}));
|
|
|
|
|
|
|
|
return function (_x) {
|
|
|
|
return _ref.apply(this, arguments);
|
|
|
|
};
|
|
|
|
}());
|
|
|
|
|
|
|
|
case 1:
|
|
|
|
case "end":
|
|
|
|
return _context2.stop();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}, _callee2);
|
|
|
|
}));
|
|
|
|
|
|
|
|
function handle() {
|
|
|
|
return _handle.apply(this, arguments);
|
|
|
|
}
|
|
|
|
|
|
|
|
return handle;
|
|
|
|
}()
|
|
|
|
}]);
|
|
|
|
|
|
|
|
return ProcessAlipay;
|
|
|
|
}();
|
|
|
|
|
|
|
|
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 ProcessAlipay(publishableKey, stripeConnect).setupStripe().handle();
|
|
|
|
/******/ })()
|
|
|
|
;
|