pay-sdk-react 1.1.14 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +241 -78
- package/README.zh-CN.md +243 -79
- package/dist/css/index.css +11 -0
- package/dist/css/index.min.css +1 -1
- package/dist/es/Airwallex/airwallex-button.js +48 -16
- package/dist/es/Airwallex/airwallex-checkout-button.d.ts +4 -0
- package/dist/es/Airwallex/airwallex-checkout-button.js +73 -0
- package/dist/es/Airwallex/airwallex-managed.d.ts +4 -0
- package/dist/es/Airwallex/airwallex-managed.js +87 -0
- package/dist/es/Airwallex/airwallex-modal.js +7 -3
- package/dist/es/Airwallex/airwallex-popup.js +7 -3
- package/dist/es/Airwallex/airwallex.d.ts +1 -3
- package/dist/es/Airwallex/airwallex.js +10 -1
- package/dist/es/Airwallex/hooks/useAirwallexCheckout.d.ts +7 -0
- package/dist/es/Airwallex/hooks/useAirwallexCheckout.js +155 -0
- package/dist/es/Airwallex/index.d.ts +4 -0
- package/dist/es/Airwallex/index.js +5 -1
- package/dist/es/Airwallex/interface.d.ts +146 -0
- package/dist/es/Alipay/alipay-button.js +26 -7
- package/dist/es/Alipay/alipay.js +39 -12
- package/dist/es/Alipay/interface.d.ts +26 -1
- package/dist/es/Paypal/index.d.ts +2 -0
- package/dist/es/Paypal/index.js +3 -1
- package/dist/es/Paypal/interface.d.ts +40 -0
- package/dist/es/Paypal/paypal-button.js +24 -3
- package/dist/es/Paypal/paypal-smart-button.d.ts +4 -0
- package/dist/es/Paypal/paypal-smart-button.js +48 -0
- package/dist/es/Payssion/interface.d.ts +7 -0
- package/dist/es/Payssion/payssion-button.js +25 -4
- package/dist/es/Pix/interface.d.ts +67 -0
- package/dist/es/Pix/pix-button.js +26 -7
- package/dist/es/Pix/pix-enhanced.d.ts +4 -0
- package/dist/es/Pix/pix-enhanced.js +182 -0
- package/dist/es/Pix/pix.d.ts +1 -1
- package/dist/es/Pix/pix.js +6 -1
- package/dist/es/Pix/style/index.css +11 -0
- package/dist/es/Pix/style/index.min.css +1 -1
- package/dist/es/Stripe/hooks/useStripeCheckout.d.ts +7 -0
- package/dist/es/Stripe/hooks/useStripeCheckout.js +86 -0
- package/dist/es/Stripe/index.d.ts +4 -0
- package/dist/es/Stripe/index.js +5 -1
- package/dist/es/Stripe/interface.d.ts +120 -0
- package/dist/es/Stripe/stripe-button.js +32 -10
- package/dist/es/Stripe/stripe-checkout-button.d.ts +4 -0
- package/dist/es/Stripe/stripe-checkout-button.js +70 -0
- package/dist/es/Stripe/stripe-modal.js +19 -2
- package/dist/es/Stripe/stripe-popup.js +13 -2
- package/dist/es/Stripe/stripe.js +38 -4
- package/dist/es/Wechat/interface.d.ts +13 -0
- package/dist/es/Wechat/wechat-button.js +26 -7
- package/dist/es/Wechat/wechat-content.d.ts +4 -0
- package/dist/es/Wechat/wechat-content.js +61 -0
- package/dist/es/Wechat/wechat.d.ts +1 -1
- package/dist/es/Wechat/wechat.js +5 -1
- package/dist/es/hooks/useLatestCallback.d.ts +1 -0
- package/dist/es/hooks/useLatestCallback.js +8 -0
- package/dist/es/hooks/useManagedOrder.d.ts +8 -0
- package/dist/es/hooks/useManagedOrder.js +67 -0
- package/dist/es/hooks/usePaymentExecution.d.ts +13 -0
- package/dist/es/hooks/usePaymentExecution.js +176 -0
- package/dist/es/hooks/usePaymentQr.d.ts +6 -0
- package/dist/es/hooks/usePaymentQr.js +52 -0
- package/dist/es/hooks/usePaymentRedirect.d.ts +5 -0
- package/dist/es/hooks/usePaymentRedirect.js +83 -0
- package/dist/es/index.d.ts +33 -6
- package/dist/es/index.js +19 -1
- package/dist/es/pay-modal/interface.d.ts +22 -2
- package/dist/es/pay-modal/pay-modal.js +36 -16
- package/dist/es/shared/entitys/payment.d.ts +227 -0
- package/dist/es/shared/entitys/payment.js +75 -0
- package/dist/es/shared/enums/index.d.ts +1 -88
- package/dist/es/shared/enums/index.js +1 -91
- package/dist/es/shared/enums/payment.d.ts +162 -0
- package/dist/es/shared/enums/payment.js +168 -0
- package/dist/es/shared/index.d.ts +2 -0
- package/dist/es/shared/index.js +2 -1
- package/dist/lib/Airwallex/airwallex-button.js +31 -10
- package/dist/lib/Airwallex/airwallex-checkout-button.js +52 -0
- package/dist/lib/Airwallex/airwallex-managed.js +86 -0
- package/dist/lib/Airwallex/airwallex-modal.js +4 -2
- package/dist/lib/Airwallex/airwallex-popup.js +4 -2
- package/dist/lib/Airwallex/airwallex.js +9 -1
- package/dist/lib/Airwallex/hooks/useAirwallexCheckout.js +83 -0
- package/dist/lib/Airwallex/index.js +18 -1
- package/dist/lib/Alipay/alipay-button.js +21 -6
- package/dist/lib/Alipay/alipay.js +36 -9
- package/dist/lib/Paypal/index.js +17 -1
- package/dist/lib/Paypal/paypal-button.js +19 -2
- package/dist/lib/Paypal/paypal-smart-button.js +45 -0
- package/dist/lib/Payssion/payssion-button.js +20 -3
- package/dist/lib/Pix/pix-button.js +21 -6
- package/dist/lib/Pix/pix-enhanced.js +143 -0
- package/dist/lib/Pix/pix.js +6 -1
- package/dist/lib/Pix/style/index.css +11 -0
- package/dist/lib/Pix/style/index.min.css +1 -1
- package/dist/lib/Stripe/hooks/useStripeCheckout.js +41 -0
- package/dist/lib/Stripe/index.js +18 -1
- package/dist/lib/Stripe/stripe-button.js +28 -10
- package/dist/lib/Stripe/stripe-checkout-button.js +50 -0
- package/dist/lib/Stripe/stripe-modal.js +12 -1
- package/dist/lib/Stripe/stripe-popup.js +12 -1
- package/dist/lib/Stripe/stripe.js +30 -1
- package/dist/lib/Wechat/wechat-button.js +21 -6
- package/dist/lib/Wechat/wechat-content.js +65 -0
- package/dist/lib/Wechat/wechat.js +3 -1
- package/dist/lib/hooks/useLatestCallback.js +13 -0
- package/dist/lib/hooks/useManagedOrder.js +29 -0
- package/dist/lib/hooks/usePaymentExecution.js +113 -0
- package/dist/lib/hooks/usePaymentQr.js +51 -0
- package/dist/lib/hooks/usePaymentRedirect.js +87 -0
- package/dist/lib/index.js +57 -1
- package/dist/lib/pay-modal/pay-modal.js +33 -16
- package/dist/lib/shared/entitys/payment.js +61 -0
- package/dist/lib/shared/enums/index.js +11 -91
- package/dist/lib/shared/enums/payment.js +172 -0
- package/dist/lib/shared/index.js +12 -1
- package/dist/umd/pay-sdk-react.umd.js +6488 -7731
- package/dist/umd/pay-sdk-react.umd.js.map +1 -1
- package/package.json +17 -3
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
var _excluded = ["target", "createOrder", "redirectOptions", "initOptions", "beforePay", "onLoadingChange", "onPaymentError", "onCancel", "children", "onClick", "loading"];
|
|
4
|
+
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
5
|
+
function _regenerator() { /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */ var e, t, r = "function" == typeof Symbol ? Symbol : {}, n = r.iterator || "@@iterator", o = r.toStringTag || "@@toStringTag"; function i(r, n, o, i) { var c = n && n.prototype instanceof Generator ? n : Generator, u = Object.create(c.prototype); return _regeneratorDefine2(u, "_invoke", function (r, n, o) { var i, c, u, f = 0, p = o || [], y = !1, G = { p: 0, n: 0, v: e, a: d, f: d.bind(e, 4), d: function d(t, r) { return i = t, c = 0, u = e, G.n = r, a; } }; function d(r, n) { for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) { var o, i = p[t], d = G.p, l = i[2]; r > 3 ? (o = l === n) && (u = i[(c = i[4]) ? 5 : (c = 3, 3)], i[4] = i[5] = e) : i[0] <= d && ((o = r < 2 && d < i[1]) ? (c = 0, G.v = n, G.n = i[1]) : d < l && (o = r < 3 || i[0] > n || n > l) && (i[4] = r, i[5] = n, G.n = l, c = 0)); } if (o || r > 1) return a; throw y = !0, n; } return function (o, p, l) { if (f > 1) throw TypeError("Generator is already running"); for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) { i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u); try { if (f = 2, i) { if (c || (o = "next"), t = i[o]) { if (!(t = t.call(i, u))) throw TypeError("iterator result is not an object"); if (!t.done) return t; u = t.value, c < 2 && (c = 0); } else 1 === c && (t = i.return) && t.call(i), c < 2 && (u = TypeError("The iterator does not provide a '" + o + "' method"), c = 1); i = e; } else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break; } catch (t) { i = e, c = 1, u = t; } finally { f = 1; } } return { value: t, done: y }; }; }(r, o, i), !0), u; } var a = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} t = Object.getPrototypeOf; var c = [][n] ? t(t([][n]())) : (_regeneratorDefine2(t = {}, n, function () { return this; }), t), u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c); function f(e) { return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, _regeneratorDefine2(e, o, "GeneratorFunction")), e.prototype = Object.create(u), e; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, _regeneratorDefine2(u, "constructor", GeneratorFunctionPrototype), _regeneratorDefine2(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = "GeneratorFunction", _regeneratorDefine2(GeneratorFunctionPrototype, o, "GeneratorFunction"), _regeneratorDefine2(u), _regeneratorDefine2(u, o, "Generator"), _regeneratorDefine2(u, n, function () { return this; }), _regeneratorDefine2(u, "toString", function () { return "[object Generator]"; }), (_regenerator = function _regenerator() { return { w: i, m: f }; })(); }
|
|
6
|
+
function _regeneratorDefine2(e, r, n, t) { var i = Object.defineProperty; try { i({}, "", {}); } catch (e) { i = 0; } _regeneratorDefine2 = function _regeneratorDefine(e, r, n, t) { if (r) i ? i(e, r, { value: n, enumerable: !t, configurable: !t, writable: !t }) : e[r] = n;else { var o = function o(r, n) { _regeneratorDefine2(e, r, function (e) { return this._invoke(r, n, e); }); }; o("next", 0), o("throw", 1), o("return", 2); } }, _regeneratorDefine2(e, r, n, t); }
|
|
7
|
+
function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }
|
|
8
|
+
function _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; }
|
|
9
|
+
function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
|
|
10
|
+
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
|
|
11
|
+
import React from 'react';
|
|
12
|
+
import Button from '../Button';
|
|
13
|
+
import { useAirwallexCheckout } from './hooks/useAirwallexCheckout';
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* @zh Airwallex 托管支付按钮,复用 useAirwallexCheckout。
|
|
17
|
+
* @en Hosted Airwallex button sharing useAirwallexCheckout.
|
|
18
|
+
* @since 1.2.0
|
|
19
|
+
*/
|
|
20
|
+
var AirwallexCheckoutButton = function AirwallexCheckoutButton(props) {
|
|
21
|
+
var target = props.target,
|
|
22
|
+
createOrder = props.createOrder,
|
|
23
|
+
redirectOptions = props.redirectOptions,
|
|
24
|
+
initOptions = props.initOptions,
|
|
25
|
+
beforePay = props.beforePay,
|
|
26
|
+
onLoadingChange = props.onLoadingChange,
|
|
27
|
+
onPaymentError = props.onPaymentError,
|
|
28
|
+
onCancel = props.onCancel,
|
|
29
|
+
_props$children = props.children,
|
|
30
|
+
children = _props$children === void 0 ? 'Airwallex' : _props$children,
|
|
31
|
+
onClick = props.onClick,
|
|
32
|
+
loading = props.loading,
|
|
33
|
+
buttonProps = _objectWithoutProperties(props, _excluded);
|
|
34
|
+
var checkout = useAirwallexCheckout({
|
|
35
|
+
redirectOptions: redirectOptions,
|
|
36
|
+
initOptions: initOptions,
|
|
37
|
+
beforePay: beforePay,
|
|
38
|
+
onLoadingChange: onLoadingChange,
|
|
39
|
+
onPaymentError: onPaymentError,
|
|
40
|
+
onCancel: onCancel
|
|
41
|
+
});
|
|
42
|
+
return /*#__PURE__*/React.createElement(Button, _extends({}, buttonProps, {
|
|
43
|
+
loading: checkout.loading || loading,
|
|
44
|
+
onClick: (/*#__PURE__*/function () {
|
|
45
|
+
var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(event) {
|
|
46
|
+
var _ref2;
|
|
47
|
+
return _regenerator().w(function (_context) {
|
|
48
|
+
while (1) switch (_context.n) {
|
|
49
|
+
case 0:
|
|
50
|
+
event.persist();
|
|
51
|
+
_context.n = 1;
|
|
52
|
+
return onClick === null || onClick === void 0 ? void 0 : onClick(event);
|
|
53
|
+
case 1:
|
|
54
|
+
if (event.defaultPrevented) {
|
|
55
|
+
_context.n = 2;
|
|
56
|
+
break;
|
|
57
|
+
}
|
|
58
|
+
_context.n = 2;
|
|
59
|
+
return checkout.openCheckout((_ref2 = createOrder !== null && createOrder !== void 0 ? createOrder : target) !== null && _ref2 !== void 0 ? _ref2 : {
|
|
60
|
+
url: ''
|
|
61
|
+
});
|
|
62
|
+
case 2:
|
|
63
|
+
return _context.a(2);
|
|
64
|
+
}
|
|
65
|
+
}, _callee);
|
|
66
|
+
}));
|
|
67
|
+
return function (_x) {
|
|
68
|
+
return _ref.apply(this, arguments);
|
|
69
|
+
};
|
|
70
|
+
}())
|
|
71
|
+
}), children);
|
|
72
|
+
};
|
|
73
|
+
export default /*#__PURE__*/React.memo(AirwallexCheckoutButton);
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
4
|
+
var _excluded = ["type", "options", "initOptions", "instanceOptions", "onReady", "onSuccess", "onError", "style"];
|
|
5
|
+
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
6
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
7
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
8
|
+
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
9
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
10
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
11
|
+
function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
|
|
12
|
+
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
|
|
13
|
+
import React, { useEffect, useImperativeHandle, useRef } from 'react';
|
|
14
|
+
import { loadAirwallex } from 'airwallex-payment-elements';
|
|
15
|
+
var AirwallexManaged = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
16
|
+
var type = props.type,
|
|
17
|
+
options = props.options,
|
|
18
|
+
initOptions = props.initOptions,
|
|
19
|
+
instanceOptions = props.instanceOptions,
|
|
20
|
+
onReady = props.onReady,
|
|
21
|
+
onSuccess = props.onSuccess,
|
|
22
|
+
onError = props.onError,
|
|
23
|
+
style = props.style,
|
|
24
|
+
others = _objectWithoutProperties(props, _excluded);
|
|
25
|
+
var container = useRef(null);
|
|
26
|
+
var latest = useRef(props);
|
|
27
|
+
latest.current = props;
|
|
28
|
+
var configuration = JSON.stringify([type, options, initOptions]);
|
|
29
|
+
useImperativeHandle(ref, function () {
|
|
30
|
+
return container.current;
|
|
31
|
+
});
|
|
32
|
+
useEffect(function () {
|
|
33
|
+
var active = true;
|
|
34
|
+
var element = null;
|
|
35
|
+
var node = container.current;
|
|
36
|
+
if (!node) return;
|
|
37
|
+
var ready = function ready(event) {
|
|
38
|
+
var _latest$current$onRea, _latest$current;
|
|
39
|
+
return (_latest$current$onRea = (_latest$current = latest.current).onReady) === null || _latest$current$onRea === void 0 ? void 0 : _latest$current$onRea.call(_latest$current, event);
|
|
40
|
+
};
|
|
41
|
+
var success = function success(event) {
|
|
42
|
+
var _latest$current$onSuc, _latest$current2;
|
|
43
|
+
return (_latest$current$onSuc = (_latest$current2 = latest.current).onSuccess) === null || _latest$current$onSuc === void 0 ? void 0 : _latest$current$onSuc.call(_latest$current2, event);
|
|
44
|
+
};
|
|
45
|
+
var error = function error(event) {
|
|
46
|
+
var _latest$current$onErr, _latest$current3;
|
|
47
|
+
return (_latest$current$onErr = (_latest$current3 = latest.current).onError) === null || _latest$current$onErr === void 0 ? void 0 : _latest$current$onErr.call(_latest$current3, event);
|
|
48
|
+
};
|
|
49
|
+
node.addEventListener('onReady', ready);
|
|
50
|
+
node.addEventListener('onSuccess', success);
|
|
51
|
+
node.addEventListener('onError', error);
|
|
52
|
+
var snapshot = latest.current;
|
|
53
|
+
loadAirwallex(_objectSpread({
|
|
54
|
+
env: 'demo'
|
|
55
|
+
}, snapshot.initOptions)).then(function (sdk) {
|
|
56
|
+
if (!active || !sdk) return;
|
|
57
|
+
var created = sdk.createElement(snapshot.type, snapshot.options);
|
|
58
|
+
if (!created) throw new Error('Payment element unavailable.');
|
|
59
|
+
element = created;
|
|
60
|
+
created.mount(node);
|
|
61
|
+
}).catch(function () {
|
|
62
|
+
var _latest$current$onErr2, _latest$current4;
|
|
63
|
+
if (active) (_latest$current$onErr2 = (_latest$current4 = latest.current).onError) === null || _latest$current$onErr2 === void 0 || _latest$current$onErr2.call(_latest$current4, new Error('Unable to initialize Airwallex element.'));
|
|
64
|
+
});
|
|
65
|
+
return function () {
|
|
66
|
+
var _element;
|
|
67
|
+
active = false;
|
|
68
|
+
node.removeEventListener('onReady', ready);
|
|
69
|
+
node.removeEventListener('onSuccess', success);
|
|
70
|
+
node.removeEventListener('onError', error);
|
|
71
|
+
(_element = element) === null || _element === void 0 || _element.unmount();
|
|
72
|
+
};
|
|
73
|
+
}, [configuration]);
|
|
74
|
+
// callbacks are read through latest; keep them out of the DOM.
|
|
75
|
+
void onReady;
|
|
76
|
+
void onSuccess;
|
|
77
|
+
void onError;
|
|
78
|
+
return /*#__PURE__*/React.createElement("div", _extends({}, others, {
|
|
79
|
+
ref: container,
|
|
80
|
+
id: instanceOptions === null || instanceOptions === void 0 ? void 0 : instanceOptions.containerId,
|
|
81
|
+
style: _objectSpread({
|
|
82
|
+
width: '100%'
|
|
83
|
+
}, style)
|
|
84
|
+
}));
|
|
85
|
+
});
|
|
86
|
+
AirwallexManaged.displayName = 'AirwallexManaged';
|
|
87
|
+
export default AirwallexManaged;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var _excluded = ["airwallexProps", "visible", "onClose", "footer"];
|
|
1
|
+
var _excluded = ["airwallexProps", "visible", "onClose", "closeOnSuccess", "closeOnError", "footer"];
|
|
2
2
|
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
3
3
|
function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
|
|
4
4
|
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
@@ -16,6 +16,10 @@ var AirwallexModal = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
16
16
|
var propsAirwallexProps = props.airwallexProps,
|
|
17
17
|
visible = props.visible,
|
|
18
18
|
_onClose = props.onClose,
|
|
19
|
+
_props$closeOnSuccess = props.closeOnSuccess,
|
|
20
|
+
closeOnSuccess = _props$closeOnSuccess === void 0 ? true : _props$closeOnSuccess,
|
|
21
|
+
_props$closeOnError = props.closeOnError,
|
|
22
|
+
closeOnError = _props$closeOnError === void 0 ? true : _props$closeOnError,
|
|
19
23
|
_props$footer = props.footer,
|
|
20
24
|
footer = _props$footer === void 0 ? null : _props$footer,
|
|
21
25
|
rest = _objectWithoutProperties(props, _excluded);
|
|
@@ -58,14 +62,14 @@ var AirwallexModal = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
58
62
|
}, rest), _airwallexProps && /*#__PURE__*/React.createElement(Airwallex, _extends({
|
|
59
63
|
onSuccess: function onSuccess(event) {
|
|
60
64
|
var _airwallexProps$onSuc;
|
|
61
|
-
if (!isControlled) {
|
|
65
|
+
if (closeOnSuccess && !isControlled) {
|
|
62
66
|
setUncontrolledVisible(false);
|
|
63
67
|
}
|
|
64
68
|
_airwallexProps === null || _airwallexProps === void 0 || (_airwallexProps$onSuc = _airwallexProps.onSuccess) === null || _airwallexProps$onSuc === void 0 || _airwallexProps$onSuc.call(_airwallexProps, event);
|
|
65
69
|
},
|
|
66
70
|
onError: function onError(event) {
|
|
67
71
|
var _airwallexProps$onErr;
|
|
68
|
-
if (!isControlled) {
|
|
72
|
+
if (closeOnError && !isControlled) {
|
|
69
73
|
setUncontrolledVisible(false);
|
|
70
74
|
}
|
|
71
75
|
_airwallexProps === null || _airwallexProps === void 0 || (_airwallexProps$onErr = _airwallexProps.onError) === null || _airwallexProps$onErr === void 0 || _airwallexProps$onErr.call(_airwallexProps, event);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
-
var _excluded = ["visible", "onClose", "closeOnMaskClick", "bodyStyle", "airwallexProps"];
|
|
2
|
+
var _excluded = ["visible", "onClose", "closeOnSuccess", "closeOnError", "closeOnMaskClick", "bodyStyle", "airwallexProps"];
|
|
3
3
|
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
4
4
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
5
5
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
@@ -21,6 +21,10 @@ import omit from '../utils/omit';
|
|
|
21
21
|
var AirwallexPopup = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
22
22
|
var controlledVisible = props.visible,
|
|
23
23
|
_onClose = props.onClose,
|
|
24
|
+
_props$closeOnSuccess = props.closeOnSuccess,
|
|
25
|
+
closeOnSuccess = _props$closeOnSuccess === void 0 ? true : _props$closeOnSuccess,
|
|
26
|
+
_props$closeOnError = props.closeOnError,
|
|
27
|
+
closeOnError = _props$closeOnError === void 0 ? true : _props$closeOnError,
|
|
24
28
|
_props$closeOnMaskCli = props.closeOnMaskClick,
|
|
25
29
|
closeOnMaskClick = _props$closeOnMaskCli === void 0 ? true : _props$closeOnMaskCli,
|
|
26
30
|
bodyStyle = props.bodyStyle,
|
|
@@ -70,14 +74,14 @@ var AirwallexPopup = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
70
74
|
}, others), _airwallexProps && /*#__PURE__*/React.createElement(Airwallex, _extends({
|
|
71
75
|
onSuccess: function onSuccess(event) {
|
|
72
76
|
var _airwallexProps$onSuc;
|
|
73
|
-
if (!isControlled) {
|
|
77
|
+
if (closeOnSuccess && !isControlled) {
|
|
74
78
|
setUncontrolledVisible(false);
|
|
75
79
|
}
|
|
76
80
|
_airwallexProps === null || _airwallexProps === void 0 || (_airwallexProps$onSuc = _airwallexProps.onSuccess) === null || _airwallexProps$onSuc === void 0 || _airwallexProps$onSuc.call(_airwallexProps, event);
|
|
77
81
|
},
|
|
78
82
|
onError: function onError(event) {
|
|
79
83
|
var _airwallexProps$onErr;
|
|
80
|
-
if (!isControlled) {
|
|
84
|
+
if (closeOnError && !isControlled) {
|
|
81
85
|
setUncontrolledVisible(false);
|
|
82
86
|
}
|
|
83
87
|
_airwallexProps === null || _airwallexProps === void 0 || (_airwallexProps$onErr = _airwallexProps.onError) === null || _airwallexProps$onErr === void 0 || _airwallexProps$onErr.call(_airwallexProps, event);
|
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { AirwallexProps } from './interface';
|
|
3
|
-
declare const _default: React.MemoExoticComponent<React.ForwardRefExoticComponent<AirwallexProps &
|
|
4
|
-
children?: React.ReactNode;
|
|
5
|
-
} & React.RefAttributes<HTMLElement>>>;
|
|
3
|
+
declare const _default: React.MemoExoticComponent<React.ForwardRefExoticComponent<AirwallexProps & React.RefAttributes<HTMLElement>>>;
|
|
6
4
|
export default _default;
|
|
@@ -9,6 +9,7 @@ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e
|
|
|
9
9
|
function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
|
|
10
10
|
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
|
|
11
11
|
import React, { forwardRef, useEffect, useImperativeHandle, useRef } from 'react';
|
|
12
|
+
import AirwallexManaged from './airwallex-managed';
|
|
12
13
|
import { loadAirwallex } from 'airwallex-payment-elements';
|
|
13
14
|
import { clientDocument, off, on } from '../utils/dom';
|
|
14
15
|
var Airwallex = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
@@ -70,4 +71,12 @@ var Airwallex = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
70
71
|
}, others));
|
|
71
72
|
});
|
|
72
73
|
Airwallex.displayName = 'Airwallex';
|
|
73
|
-
|
|
74
|
+
var AirwallexEntry = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
75
|
+
return props.instanceOptions ? /*#__PURE__*/React.createElement(AirwallexManaged, _extends({}, props, {
|
|
76
|
+
ref: ref
|
|
77
|
+
})) : /*#__PURE__*/React.createElement(Airwallex, _extends({}, props, {
|
|
78
|
+
ref: ref
|
|
79
|
+
}));
|
|
80
|
+
});
|
|
81
|
+
AirwallexEntry.displayName = 'AirwallexEntry';
|
|
82
|
+
export default /*#__PURE__*/React.memo(AirwallexEntry);
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { UseAirwallexCheckoutOptions, UseAirwallexCheckoutReturn } from '../interface';
|
|
2
|
+
/**
|
|
3
|
+
* @zh URL 跳转或官方托管 Checkout;不在挂载时执行。
|
|
4
|
+
* @en URL or official hosted checkout; no mount-time execution.
|
|
5
|
+
* @since 1.2.0
|
|
6
|
+
*/
|
|
7
|
+
export declare const useAirwallexCheckout: (options?: UseAirwallexCheckoutOptions) => UseAirwallexCheckoutReturn;
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
4
|
+
function _regenerator() { /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */ var e, t, r = "function" == typeof Symbol ? Symbol : {}, n = r.iterator || "@@iterator", o = r.toStringTag || "@@toStringTag"; function i(r, n, o, i) { var c = n && n.prototype instanceof Generator ? n : Generator, u = Object.create(c.prototype); return _regeneratorDefine2(u, "_invoke", function (r, n, o) { var i, c, u, f = 0, p = o || [], y = !1, G = { p: 0, n: 0, v: e, a: d, f: d.bind(e, 4), d: function d(t, r) { return i = t, c = 0, u = e, G.n = r, a; } }; function d(r, n) { for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) { var o, i = p[t], d = G.p, l = i[2]; r > 3 ? (o = l === n) && (u = i[(c = i[4]) ? 5 : (c = 3, 3)], i[4] = i[5] = e) : i[0] <= d && ((o = r < 2 && d < i[1]) ? (c = 0, G.v = n, G.n = i[1]) : d < l && (o = r < 3 || i[0] > n || n > l) && (i[4] = r, i[5] = n, G.n = l, c = 0)); } if (o || r > 1) return a; throw y = !0, n; } return function (o, p, l) { if (f > 1) throw TypeError("Generator is already running"); for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) { i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u); try { if (f = 2, i) { if (c || (o = "next"), t = i[o]) { if (!(t = t.call(i, u))) throw TypeError("iterator result is not an object"); if (!t.done) return t; u = t.value, c < 2 && (c = 0); } else 1 === c && (t = i.return) && t.call(i), c < 2 && (u = TypeError("The iterator does not provide a '" + o + "' method"), c = 1); i = e; } else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break; } catch (t) { i = e, c = 1, u = t; } finally { f = 1; } } return { value: t, done: y }; }; }(r, o, i), !0), u; } var a = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} t = Object.getPrototypeOf; var c = [][n] ? t(t([][n]())) : (_regeneratorDefine2(t = {}, n, function () { return this; }), t), u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c); function f(e) { return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, _regeneratorDefine2(e, o, "GeneratorFunction")), e.prototype = Object.create(u), e; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, _regeneratorDefine2(u, "constructor", GeneratorFunctionPrototype), _regeneratorDefine2(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = "GeneratorFunction", _regeneratorDefine2(GeneratorFunctionPrototype, o, "GeneratorFunction"), _regeneratorDefine2(u), _regeneratorDefine2(u, o, "Generator"), _regeneratorDefine2(u, n, function () { return this; }), _regeneratorDefine2(u, "toString", function () { return "[object Generator]"; }), (_regenerator = function _regenerator() { return { w: i, m: f }; })(); }
|
|
5
|
+
function _regeneratorDefine2(e, r, n, t) { var i = Object.defineProperty; try { i({}, "", {}); } catch (e) { i = 0; } _regeneratorDefine2 = function _regeneratorDefine(e, r, n, t) { if (r) i ? i(e, r, { value: n, enumerable: !t, configurable: !t, writable: !t }) : e[r] = n;else { var o = function o(r, n) { _regeneratorDefine2(e, r, function (e) { return this._invoke(r, n, e); }); }; o("next", 0), o("throw", 1), o("return", 2); } }, _regeneratorDefine2(e, r, n, t); }
|
|
6
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
7
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
8
|
+
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
9
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
10
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
11
|
+
function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }
|
|
12
|
+
function _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; }
|
|
13
|
+
import { useRef } from 'react';
|
|
14
|
+
import { usePaymentExecution } from '../../hooks/usePaymentExecution';
|
|
15
|
+
import { usePaymentRedirect } from '../../hooks/usePaymentRedirect';
|
|
16
|
+
import { useLatestCallback } from '../../hooks/useLatestCallback';
|
|
17
|
+
import { OpenPayUrlMode, PaymentErrorCode } from '../../shared/enums';
|
|
18
|
+
import { PaymentExecutionError } from '../../shared/entitys/payment';
|
|
19
|
+
/**
|
|
20
|
+
* @zh URL 跳转或官方托管 Checkout;不在挂载时执行。
|
|
21
|
+
* @en URL or official hosted checkout; no mount-time execution.
|
|
22
|
+
* @since 1.2.0
|
|
23
|
+
*/
|
|
24
|
+
export var useAirwallexCheckout = function useAirwallexCheckout() {
|
|
25
|
+
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
26
|
+
var latest = useRef(options);
|
|
27
|
+
latest.current = options;
|
|
28
|
+
var initialized = useRef();
|
|
29
|
+
var execution = usePaymentExecution(options);
|
|
30
|
+
var redirect = usePaymentRedirect(options.redirectOptions);
|
|
31
|
+
var openCheckout = useLatestCallback(function (source) {
|
|
32
|
+
return execution.run(/*#__PURE__*/function () {
|
|
33
|
+
var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(context) {
|
|
34
|
+
var _latest$current$redir;
|
|
35
|
+
var target, params, mode, initOptions, key, value, instance, _t, _t2;
|
|
36
|
+
return _regenerator().w(function (_context) {
|
|
37
|
+
while (1) switch (_context.n) {
|
|
38
|
+
case 0:
|
|
39
|
+
if (!(typeof source === 'function')) {
|
|
40
|
+
_context.n = 2;
|
|
41
|
+
break;
|
|
42
|
+
}
|
|
43
|
+
_context.n = 1;
|
|
44
|
+
return source(context.signal);
|
|
45
|
+
case 1:
|
|
46
|
+
_t = _context.v;
|
|
47
|
+
_context.n = 3;
|
|
48
|
+
break;
|
|
49
|
+
case 2:
|
|
50
|
+
_t = source;
|
|
51
|
+
case 3:
|
|
52
|
+
target = _t;
|
|
53
|
+
if (context.isCurrent()) {
|
|
54
|
+
_context.n = 4;
|
|
55
|
+
break;
|
|
56
|
+
}
|
|
57
|
+
return _context.a(2);
|
|
58
|
+
case 4:
|
|
59
|
+
if (!(target === null)) {
|
|
60
|
+
_context.n = 5;
|
|
61
|
+
break;
|
|
62
|
+
}
|
|
63
|
+
execution.cancel();
|
|
64
|
+
return _context.a(2);
|
|
65
|
+
case 5:
|
|
66
|
+
if (!(target && typeof target.url === 'string')) {
|
|
67
|
+
_context.n = 6;
|
|
68
|
+
break;
|
|
69
|
+
}
|
|
70
|
+
redirect.open(target.url);
|
|
71
|
+
return _context.a(2);
|
|
72
|
+
case 6:
|
|
73
|
+
params = target === null || target === void 0 ? void 0 : target.checkout;
|
|
74
|
+
if (!(!(params !== null && params !== void 0 && params.client_secret) || !params.currency || (params.mode === 'recurring' ? !params.customer_id : !params.intent_id))) {
|
|
75
|
+
_context.n = 7;
|
|
76
|
+
break;
|
|
77
|
+
}
|
|
78
|
+
throw new PaymentExecutionError(PaymentErrorCode.InvalidParameters, 'Required hosted checkout parameters are missing.');
|
|
79
|
+
case 7:
|
|
80
|
+
mode = (_latest$current$redir = latest.current.redirectOptions) === null || _latest$current$redir === void 0 ? void 0 : _latest$current$redir.openMode;
|
|
81
|
+
if (!(mode && mode !== OpenPayUrlMode.Href)) {
|
|
82
|
+
_context.n = 8;
|
|
83
|
+
break;
|
|
84
|
+
}
|
|
85
|
+
throw new PaymentExecutionError(PaymentErrorCode.InvalidParameters, 'Official hosted checkout navigates the current page.');
|
|
86
|
+
case 8:
|
|
87
|
+
if (!(typeof window === 'undefined')) {
|
|
88
|
+
_context.n = 9;
|
|
89
|
+
break;
|
|
90
|
+
}
|
|
91
|
+
throw new PaymentExecutionError(PaymentErrorCode.BrowserUnavailable, 'A browser is required.');
|
|
92
|
+
case 9:
|
|
93
|
+
initOptions = _objectSpread(_objectSpread({}, latest.current.initOptions), {}, {
|
|
94
|
+
enabledElements: ['payments']
|
|
95
|
+
});
|
|
96
|
+
key = JSON.stringify(initOptions);
|
|
97
|
+
if (!initialized.current || initialized.current.key !== key) {
|
|
98
|
+
value = import('@airwallex/components-sdk').then(function (_ref2) {
|
|
99
|
+
var init = _ref2.init;
|
|
100
|
+
return init(initOptions);
|
|
101
|
+
});
|
|
102
|
+
initialized.current = {
|
|
103
|
+
key: key,
|
|
104
|
+
value: value
|
|
105
|
+
};
|
|
106
|
+
value.catch(function () {
|
|
107
|
+
var _initialized$current;
|
|
108
|
+
if (((_initialized$current = initialized.current) === null || _initialized$current === void 0 ? void 0 : _initialized$current.value) === value) initialized.current = undefined;
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
_context.p = 10;
|
|
112
|
+
_context.n = 11;
|
|
113
|
+
return initialized.current.value;
|
|
114
|
+
case 11:
|
|
115
|
+
instance = _context.v;
|
|
116
|
+
_context.n = 13;
|
|
117
|
+
break;
|
|
118
|
+
case 12:
|
|
119
|
+
_context.p = 12;
|
|
120
|
+
_t2 = _context.v;
|
|
121
|
+
throw new PaymentExecutionError(PaymentErrorCode.InitializationFailed, 'Unable to initialize Airwallex.');
|
|
122
|
+
case 13:
|
|
123
|
+
if (context.isCurrent()) {
|
|
124
|
+
_context.n = 14;
|
|
125
|
+
break;
|
|
126
|
+
}
|
|
127
|
+
return _context.a(2);
|
|
128
|
+
case 14:
|
|
129
|
+
if (instance.payments) {
|
|
130
|
+
_context.n = 15;
|
|
131
|
+
break;
|
|
132
|
+
}
|
|
133
|
+
throw new PaymentExecutionError(PaymentErrorCode.InitializationFailed, 'Airwallex payments are unavailable.');
|
|
134
|
+
case 15:
|
|
135
|
+
_context.n = 16;
|
|
136
|
+
return instance.payments.redirectToCheckout(params);
|
|
137
|
+
case 16:
|
|
138
|
+
return _context.a(2);
|
|
139
|
+
}
|
|
140
|
+
}, _callee, null, [[10, 12]]);
|
|
141
|
+
}));
|
|
142
|
+
return function (_x) {
|
|
143
|
+
return _ref.apply(this, arguments);
|
|
144
|
+
};
|
|
145
|
+
}());
|
|
146
|
+
});
|
|
147
|
+
var closeCheckout = useLatestCallback(function () {
|
|
148
|
+
execution.cancel();
|
|
149
|
+
redirect.close();
|
|
150
|
+
});
|
|
151
|
+
return _objectSpread(_objectSpread({}, execution), {}, {
|
|
152
|
+
openCheckout: openCheckout,
|
|
153
|
+
closeCheckout: closeCheckout
|
|
154
|
+
});
|
|
155
|
+
};
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
+
import AirwallexCheckoutButton from './airwallex-checkout-button';
|
|
1
2
|
import Airwallex from './airwallex';
|
|
2
3
|
import AirwallexPopup from './airwallex-popup';
|
|
3
4
|
import AirwallexButton from './airwallex-button';
|
|
4
5
|
import AirwallexModal from './airwallex-modal';
|
|
5
6
|
export * from './interface';
|
|
6
7
|
type AirwallexComponentType = typeof Airwallex & {
|
|
8
|
+
CheckoutButton: typeof AirwallexCheckoutButton;
|
|
7
9
|
Button: typeof AirwallexButton;
|
|
8
10
|
Popup: typeof AirwallexPopup;
|
|
9
11
|
Modal: typeof AirwallexModal;
|
|
@@ -11,3 +13,5 @@ type AirwallexComponentType = typeof Airwallex & {
|
|
|
11
13
|
declare const AirwallexComponent: AirwallexComponentType;
|
|
12
14
|
export default AirwallexComponent;
|
|
13
15
|
export { AirwallexButton, AirwallexPopup, AirwallexModal };
|
|
16
|
+
export { AirwallexCheckoutButton };
|
|
17
|
+
export { useAirwallexCheckout } from './hooks/useAirwallexCheckout';
|
|
@@ -1,12 +1,16 @@
|
|
|
1
|
+
import AirwallexCheckoutButton from './airwallex-checkout-button';
|
|
1
2
|
import Airwallex from './airwallex';
|
|
2
3
|
import AirwallexPopup from './airwallex-popup';
|
|
3
4
|
import AirwallexButton from './airwallex-button';
|
|
4
5
|
import AirwallexModal from './airwallex-modal';
|
|
5
6
|
export * from './interface';
|
|
6
7
|
var AirwallexComponent = Object.assign({}, Airwallex, {
|
|
8
|
+
CheckoutButton: AirwallexCheckoutButton,
|
|
7
9
|
Button: AirwallexButton,
|
|
8
10
|
Popup: AirwallexPopup,
|
|
9
11
|
Modal: AirwallexModal
|
|
10
12
|
});
|
|
11
13
|
export default AirwallexComponent;
|
|
12
|
-
export { AirwallexButton, AirwallexPopup, AirwallexModal };
|
|
14
|
+
export { AirwallexButton, AirwallexPopup, AirwallexModal };
|
|
15
|
+
export { AirwallexCheckoutButton };
|
|
16
|
+
export { useAirwallexCheckout } from './hooks/useAirwallexCheckout';
|