pay-sdk-react 1.1.6 → 1.1.7
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/dist/css/index.css +3 -1
- package/dist/css/index.min.css +1 -1
- package/dist/es/Airwallex/airwallex-button.d.ts +2 -2
- package/dist/es/Airwallex/airwallex-button.js +40 -11
- package/dist/es/Airwallex/interface.d.ts +32 -1
- package/dist/es/Airwallex/style/index.css +3 -1
- package/dist/es/Airwallex/style/index.min.css +1 -1
- package/dist/es/Alipay/alipay-button.d.ts +2 -2
- package/dist/es/Alipay/alipay-button.js +20 -8
- package/dist/es/Alipay/interface.d.ts +13 -2
- package/dist/es/MAlipay/style/index.css +3 -1
- package/dist/es/MAlipay/style/index.min.css +1 -1
- package/dist/es/MWeChat/style/index.css +3 -1
- package/dist/es/MWeChat/style/index.min.css +1 -1
- package/dist/es/PayButton/index.d.ts +2 -2
- package/dist/es/PayButton/index.js +10 -8
- package/dist/es/PayButton/interface.d.ts +5 -19
- package/dist/es/PayButton/interface.js +1 -93
- package/dist/es/Paypal/interface.d.ts +17 -11
- package/dist/es/Paypal/paypal-button.d.ts +2 -2
- package/dist/es/Paypal/paypal-button.js +35 -97
- package/dist/es/Payssion/interface.d.ts +12 -1
- package/dist/es/Payssion/payssion-button.d.ts +2 -2
- package/dist/es/Payssion/payssion-button.js +17 -4
- package/dist/es/Stripe/interface.d.ts +22 -1
- package/dist/es/Stripe/stripe-button.d.ts +2 -2
- package/dist/es/Stripe/stripe-button.js +31 -11
- package/dist/es/Stripe/style/index.css +3 -1
- package/dist/es/Stripe/style/index.min.css +1 -1
- package/dist/es/Wechat/interface.d.ts +13 -2
- package/dist/es/Wechat/wechat-button.d.ts +2 -2
- package/dist/es/Wechat/wechat-button.js +20 -8
- package/dist/es/confirm-modal/style/index.css +3 -1
- package/dist/es/confirm-modal/style/index.min.css +1 -1
- package/dist/es/index.d.ts +1 -1
- package/dist/es/pay-modal/style/index.css +3 -1
- package/dist/es/pay-modal/style/index.min.css +1 -1
- package/dist/lib/Airwallex/airwallex-button.js +41 -12
- package/dist/lib/Airwallex/style/index.css +3 -1
- package/dist/lib/Airwallex/style/index.min.css +1 -1
- package/dist/lib/Alipay/alipay-button.js +20 -8
- package/dist/lib/MAlipay/style/index.css +3 -1
- package/dist/lib/MAlipay/style/index.min.css +1 -1
- package/dist/lib/MWeChat/style/index.css +3 -1
- package/dist/lib/MWeChat/style/index.min.css +1 -1
- package/dist/lib/PayButton/index.js +10 -8
- package/dist/lib/PayButton/interface.js +3 -1
- package/dist/lib/Paypal/paypal-button.js +23 -63
- package/dist/lib/Payssion/payssion-button.js +17 -4
- package/dist/lib/Stripe/stripe-button.js +32 -12
- package/dist/lib/Stripe/style/index.css +3 -1
- package/dist/lib/Stripe/style/index.min.css +1 -1
- package/dist/lib/Wechat/wechat-button.js +20 -8
- package/dist/lib/confirm-modal/style/index.css +3 -1
- package/dist/lib/confirm-modal/style/index.min.css +1 -1
- package/dist/lib/pay-modal/style/index.css +3 -1
- package/dist/lib/pay-modal/style/index.min.css +1 -1
- package/dist/umd/pay-sdk-react.umd.js +121 -79
- package/dist/umd/pay-sdk-react.umd.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var _excluded = ["className", "children", "onClick", "paypalUrl", "createOrder", "maskProps", "
|
|
1
|
+
var _excluded = ["className", "children", "onClick", "paypalUrl", "createOrder", "maskProps", "isPayment", "closeWindowOnUnmount"],
|
|
2
2
|
_excluded2 = ["onClose"];
|
|
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 _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 }; })(); }
|
|
@@ -27,17 +27,14 @@ var PaypalButton = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
27
27
|
propsPaypalUrl = props.paypalUrl,
|
|
28
28
|
createOrder = props.createOrder,
|
|
29
29
|
maskProps = props.maskProps,
|
|
30
|
-
|
|
31
|
-
onPaymentSuccess = props.onPaymentSuccess,
|
|
30
|
+
isPayment = props.isPayment,
|
|
32
31
|
_props$closeWindowOnU = props.closeWindowOnUnmount,
|
|
33
32
|
closeWindowOnUnmount = _props$closeWindowOnU === void 0 ? true : _props$closeWindowOnU,
|
|
34
33
|
others = _objectWithoutProperties(props, _excluded);
|
|
35
34
|
var _ref = maskProps || {},
|
|
36
35
|
onMaskClose = _ref.onClose,
|
|
37
36
|
restMaskProps = _objectWithoutProperties(_ref, _excluded2);
|
|
38
|
-
var paypalButtonRef = useRef(
|
|
39
|
-
nativeElement: null
|
|
40
|
-
});
|
|
37
|
+
var paypalButtonRef = useRef(null);
|
|
41
38
|
var _useState = useState(false),
|
|
42
39
|
_useState2 = _slicedToArray(_useState, 2),
|
|
43
40
|
showMask = _useState2[0],
|
|
@@ -46,106 +43,55 @@ var PaypalButton = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
46
43
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
47
44
|
paypalUrl = _useState4[0],
|
|
48
45
|
setPaypalUrl = _useState4[1];
|
|
49
|
-
var pollingTimerRef = useRef(null);
|
|
50
|
-
useImperativeHandle(ref, function () {
|
|
51
|
-
return paypalButtonRef.current;
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
// 支付状态轮询
|
|
55
|
-
var startPaymentPolling = useCallback(function () {
|
|
56
|
-
if (!checkPaymentStatus) return;
|
|
57
46
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
}
|
|
63
|
-
var _poll = /*#__PURE__*/function () {
|
|
64
|
-
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee() {
|
|
65
|
-
var isSuccess, _t;
|
|
66
|
-
return _regenerator().w(function (_context) {
|
|
67
|
-
while (1) switch (_context.n) {
|
|
68
|
-
case 0:
|
|
69
|
-
_context.p = 0;
|
|
70
|
-
_context.n = 1;
|
|
71
|
-
return checkPaymentStatus();
|
|
72
|
-
case 1:
|
|
73
|
-
isSuccess = _context.v;
|
|
74
|
-
if (!isSuccess) {
|
|
75
|
-
_context.n = 2;
|
|
76
|
-
break;
|
|
77
|
-
}
|
|
78
|
-
setShowMask(false);
|
|
79
|
-
onPaymentSuccess === null || onPaymentSuccess === void 0 || onPaymentSuccess();
|
|
80
|
-
if (pollingTimerRef.current) {
|
|
81
|
-
clearTimeout(pollingTimerRef.current);
|
|
82
|
-
pollingTimerRef.current = null;
|
|
83
|
-
}
|
|
84
|
-
return _context.a(2);
|
|
85
|
-
case 2:
|
|
86
|
-
// 继续轮询
|
|
87
|
-
if (pollingTimerRef.current) {
|
|
88
|
-
clearTimeout(pollingTimerRef.current);
|
|
89
|
-
}
|
|
90
|
-
pollingTimerRef.current = setTimeout(_poll, 3000);
|
|
91
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
92
|
-
_context.n = 4;
|
|
93
|
-
break;
|
|
94
|
-
case 3:
|
|
95
|
-
_context.p = 3;
|
|
96
|
-
_t = _context.v;
|
|
97
|
-
// 出错时继续轮询
|
|
98
|
-
if (pollingTimerRef.current) {
|
|
99
|
-
clearTimeout(pollingTimerRef.current);
|
|
100
|
-
}
|
|
101
|
-
pollingTimerRef.current = setTimeout(_poll, 3000);
|
|
102
|
-
case 4:
|
|
103
|
-
return _context.a(2);
|
|
104
|
-
}
|
|
105
|
-
}, _callee, null, [[0, 3]]);
|
|
106
|
-
}));
|
|
107
|
-
return function poll() {
|
|
108
|
-
return _ref2.apply(this, arguments);
|
|
109
|
-
};
|
|
110
|
-
}();
|
|
111
|
-
_poll();
|
|
112
|
-
}, [checkPaymentStatus, onPaymentSuccess]);
|
|
113
|
-
|
|
114
|
-
// 停止轮询
|
|
115
|
-
var stopPaymentPolling = useCallback(function () {
|
|
116
|
-
if (pollingTimerRef.current) {
|
|
117
|
-
clearTimeout(pollingTimerRef.current);
|
|
118
|
-
pollingTimerRef.current = null;
|
|
47
|
+
// 监听 isPayment 状态变化,当支付完成时隐藏蒙层
|
|
48
|
+
useEffect(function () {
|
|
49
|
+
if (createOrder && isPayment) {
|
|
50
|
+
setShowMask(false);
|
|
119
51
|
}
|
|
120
|
-
}, []);
|
|
121
|
-
|
|
52
|
+
}, [createOrder, isPayment]);
|
|
53
|
+
useImperativeHandle(ref, function () {
|
|
54
|
+
return {
|
|
55
|
+
get nativeElement() {
|
|
56
|
+
var _paypalButtonRef$curr;
|
|
57
|
+
return ((_paypalButtonRef$curr = paypalButtonRef.current) === null || _paypalButtonRef$curr === void 0 ? void 0 : _paypalButtonRef$curr.nativeElement) || null;
|
|
58
|
+
},
|
|
59
|
+
openPayment: function openPayment(options) {
|
|
60
|
+
if (options) {
|
|
61
|
+
setPaypalUrl(options.paypalUrl);
|
|
62
|
+
}
|
|
63
|
+
setShowMask(true);
|
|
64
|
+
},
|
|
65
|
+
closePayment: function closePayment() {
|
|
66
|
+
setShowMask(false);
|
|
67
|
+
},
|
|
68
|
+
current: paypalButtonRef.current
|
|
69
|
+
};
|
|
70
|
+
});
|
|
71
|
+
var handlePayCreateOrder = useCallback(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee() {
|
|
122
72
|
var _yield$createOrder, _paypalUrl;
|
|
123
|
-
return _regenerator().w(function (
|
|
124
|
-
while (1) switch (
|
|
73
|
+
return _regenerator().w(function (_context) {
|
|
74
|
+
while (1) switch (_context.n) {
|
|
125
75
|
case 0:
|
|
126
76
|
if (!createOrder) {
|
|
127
|
-
|
|
77
|
+
_context.n = 2;
|
|
128
78
|
break;
|
|
129
79
|
}
|
|
130
|
-
|
|
80
|
+
_context.n = 1;
|
|
131
81
|
return createOrder();
|
|
132
82
|
case 1:
|
|
133
|
-
_yield$createOrder =
|
|
83
|
+
_yield$createOrder = _context.v;
|
|
134
84
|
_paypalUrl = _yield$createOrder.paypalUrl;
|
|
135
85
|
if (_paypalUrl) {
|
|
136
86
|
// 2. 唤起蒙层
|
|
137
87
|
setShowMask(true);
|
|
138
88
|
setPaypalUrl(_paypalUrl);
|
|
139
|
-
// 3. 开始轮询支付状态
|
|
140
|
-
if (checkPaymentStatus) {
|
|
141
|
-
startPaymentPolling();
|
|
142
|
-
}
|
|
143
89
|
}
|
|
144
90
|
case 2:
|
|
145
|
-
return
|
|
91
|
+
return _context.a(2);
|
|
146
92
|
}
|
|
147
|
-
},
|
|
148
|
-
})), [createOrder
|
|
93
|
+
}, _callee);
|
|
94
|
+
})), [createOrder]);
|
|
149
95
|
var handleOpen = useCallback(function () {
|
|
150
96
|
if (propsPaypalUrl) {
|
|
151
97
|
setShowMask(true);
|
|
@@ -160,13 +106,6 @@ var PaypalButton = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
160
106
|
}
|
|
161
107
|
onClick === null || onClick === void 0 || onClick(e);
|
|
162
108
|
}, [onClick, createOrder, handlePayCreateOrder, handleOpen]);
|
|
163
|
-
|
|
164
|
-
// 组件卸载时清理轮询
|
|
165
|
-
useEffect(function () {
|
|
166
|
-
return function () {
|
|
167
|
-
stopPaymentPolling();
|
|
168
|
-
};
|
|
169
|
-
}, [stopPaymentPolling]);
|
|
170
109
|
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Button, _extends({
|
|
171
110
|
ref: paypalButtonRef,
|
|
172
111
|
className: cs(getPrefixCls('paypal-btn'), className),
|
|
@@ -175,7 +114,6 @@ var PaypalButton = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
175
114
|
visible: showMask,
|
|
176
115
|
onClose: function onClose() {
|
|
177
116
|
setShowMask(false);
|
|
178
|
-
stopPaymentPolling();
|
|
179
117
|
onMaskClose === null || onMaskClose === void 0 || onMaskClose();
|
|
180
118
|
},
|
|
181
119
|
payUrl: paypalUrl,
|
|
@@ -23,7 +23,18 @@ export interface PayssionButtonProps extends ButtonProps {
|
|
|
23
23
|
*/
|
|
24
24
|
createOrder?: CreateOrderPayssionFn;
|
|
25
25
|
}
|
|
26
|
-
export
|
|
26
|
+
export interface PayssionButtonRef extends ButtonRef {
|
|
27
|
+
/**
|
|
28
|
+
* @zh 打开支付页面
|
|
29
|
+
* @en Open payment page
|
|
30
|
+
*/
|
|
31
|
+
openPayment: (options?: PayssionSecretMap) => void;
|
|
32
|
+
/**
|
|
33
|
+
* @zh 关闭支付页面
|
|
34
|
+
* @en Close payment page
|
|
35
|
+
*/
|
|
36
|
+
closePayment: () => void;
|
|
37
|
+
}
|
|
27
38
|
export interface PayssionSecretMap {
|
|
28
39
|
/**
|
|
29
40
|
* @zh Payssion 支付页面链接
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { PayssionButtonProps } from './interface';
|
|
2
|
+
import { PayssionButtonProps, PayssionButtonRef } from './interface';
|
|
3
3
|
declare const _default: React.MemoExoticComponent<React.ForwardRefExoticComponent<PayssionButtonProps & {
|
|
4
4
|
children?: React.ReactNode;
|
|
5
|
-
} & React.RefAttributes<
|
|
5
|
+
} & React.RefAttributes<PayssionButtonRef>>>;
|
|
6
6
|
export default _default;
|
|
@@ -31,9 +31,7 @@ var PayssionButton = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
31
31
|
var _ref = maskProps || {},
|
|
32
32
|
_onClose = _ref.onClose,
|
|
33
33
|
restMaskProps = _objectWithoutProperties(_ref, _excluded2);
|
|
34
|
-
var payssionButtonRef = useRef(
|
|
35
|
-
nativeElement: null
|
|
36
|
-
});
|
|
34
|
+
var payssionButtonRef = useRef(null);
|
|
37
35
|
var _useState = useState(false),
|
|
38
36
|
_useState2 = _slicedToArray(_useState, 2),
|
|
39
37
|
showMask = _useState2[0],
|
|
@@ -43,7 +41,22 @@ var PayssionButton = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
43
41
|
payssionUrl = _useState4[0],
|
|
44
42
|
setPayssionUrl = _useState4[1];
|
|
45
43
|
useImperativeHandle(ref, function () {
|
|
46
|
-
return
|
|
44
|
+
return {
|
|
45
|
+
get nativeElement() {
|
|
46
|
+
var _payssionButtonRef$cu;
|
|
47
|
+
return ((_payssionButtonRef$cu = payssionButtonRef.current) === null || _payssionButtonRef$cu === void 0 ? void 0 : _payssionButtonRef$cu.nativeElement) || null;
|
|
48
|
+
},
|
|
49
|
+
openPayment: function openPayment(options) {
|
|
50
|
+
if (options) {
|
|
51
|
+
setPayssionUrl(options.payssionUrl);
|
|
52
|
+
}
|
|
53
|
+
setShowMask(true);
|
|
54
|
+
},
|
|
55
|
+
closePayment: function closePayment() {
|
|
56
|
+
setShowMask(false);
|
|
57
|
+
},
|
|
58
|
+
current: payssionButtonRef.current
|
|
59
|
+
};
|
|
47
60
|
});
|
|
48
61
|
var handlePayCreateOrder = useCallback(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee() {
|
|
49
62
|
var _yield$createOrder, _payssionUrl;
|
|
@@ -80,7 +80,28 @@ export interface StripeButtonProps extends ButtonProps {
|
|
|
80
80
|
*/
|
|
81
81
|
createOrder?: CreateOrderStripeFn;
|
|
82
82
|
}
|
|
83
|
-
export
|
|
83
|
+
export interface StripeButtonRef extends ButtonRef {
|
|
84
|
+
/**
|
|
85
|
+
* @zh 打开弹窗
|
|
86
|
+
* @en Open the popup
|
|
87
|
+
*/
|
|
88
|
+
openModal: (options?: BasesStripeProps) => void;
|
|
89
|
+
/**
|
|
90
|
+
* @zh 关闭弹窗
|
|
91
|
+
* @en Close the popup
|
|
92
|
+
*/
|
|
93
|
+
closeModal: () => void;
|
|
94
|
+
/**
|
|
95
|
+
* @zh 打开弹窗
|
|
96
|
+
* @en Open the popup
|
|
97
|
+
*/
|
|
98
|
+
openPopup: (options?: BasesStripeProps) => void;
|
|
99
|
+
/**
|
|
100
|
+
* @zh 关闭弹窗
|
|
101
|
+
* @en Close the popup
|
|
102
|
+
*/
|
|
103
|
+
closePopup: () => void;
|
|
104
|
+
}
|
|
84
105
|
export interface StripeModalProps extends PayModalProps {
|
|
85
106
|
/**
|
|
86
107
|
* @zh Stripe 属性
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { StripeButtonProps } from './interface';
|
|
2
|
+
import { StripeButtonProps, StripeButtonRef } from './interface';
|
|
3
3
|
declare const _default: React.MemoExoticComponent<React.ForwardRefExoticComponent<StripeButtonProps & {
|
|
4
4
|
children?: React.ReactNode;
|
|
5
|
-
} & React.RefAttributes<
|
|
5
|
+
} & React.RefAttributes<StripeButtonRef>>>;
|
|
6
6
|
export default _default;
|
|
@@ -20,16 +20,36 @@ var StripeButton = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
20
20
|
stripeModalProps = props.stripeModalProps,
|
|
21
21
|
createOrder = props.createOrder,
|
|
22
22
|
others = _objectWithoutProperties(props, _excluded);
|
|
23
|
-
var stripeButtonRef = useRef(
|
|
24
|
-
nativeElement: null
|
|
25
|
-
});
|
|
23
|
+
var stripeButtonRef = useRef(null);
|
|
26
24
|
var stripePopupRef = useRef(null);
|
|
27
25
|
var stripeModalRef = useRef(null);
|
|
28
26
|
useImperativeHandle(ref, function () {
|
|
29
|
-
return
|
|
27
|
+
return {
|
|
28
|
+
get nativeElement() {
|
|
29
|
+
var _stripeButtonRef$curr;
|
|
30
|
+
return ((_stripeButtonRef$curr = stripeButtonRef.current) === null || _stripeButtonRef$curr === void 0 ? void 0 : _stripeButtonRef$curr.nativeElement) || null;
|
|
31
|
+
},
|
|
32
|
+
openPopup: function openPopup(options) {
|
|
33
|
+
var _stripePopupRef$curre;
|
|
34
|
+
(_stripePopupRef$curre = stripePopupRef.current) === null || _stripePopupRef$curre === void 0 || _stripePopupRef$curre.open(options);
|
|
35
|
+
},
|
|
36
|
+
closePopup: function closePopup() {
|
|
37
|
+
var _stripePopupRef$curre2;
|
|
38
|
+
(_stripePopupRef$curre2 = stripePopupRef.current) === null || _stripePopupRef$curre2 === void 0 || _stripePopupRef$curre2.close();
|
|
39
|
+
},
|
|
40
|
+
openModal: function openModal(options) {
|
|
41
|
+
var _stripeModalRef$curre;
|
|
42
|
+
(_stripeModalRef$curre = stripeModalRef.current) === null || _stripeModalRef$curre === void 0 || _stripeModalRef$curre.open(options);
|
|
43
|
+
},
|
|
44
|
+
closeModal: function closeModal() {
|
|
45
|
+
var _stripeModalRef$curre2;
|
|
46
|
+
(_stripeModalRef$curre2 = stripeModalRef.current) === null || _stripeModalRef$curre2 === void 0 || _stripeModalRef$curre2.close();
|
|
47
|
+
},
|
|
48
|
+
current: stripeButtonRef.current
|
|
49
|
+
};
|
|
30
50
|
});
|
|
31
51
|
var handlePayCreateOrder = useCallback(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee() {
|
|
32
|
-
var options, _stripeModalRef$
|
|
52
|
+
var options, _stripeModalRef$curre3, _stripePopupRef$curre3;
|
|
33
53
|
return _regenerator().w(function (_context) {
|
|
34
54
|
while (1) switch (_context.n) {
|
|
35
55
|
case 0:
|
|
@@ -44,9 +64,9 @@ var StripeButton = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
44
64
|
if (options !== null && options !== void 0 && options.clientSecret && options !== null && options !== void 0 && options.stripeKey) {
|
|
45
65
|
// 2. 唤起弹窗
|
|
46
66
|
if (displayType === 'modal') {
|
|
47
|
-
(_stripeModalRef$
|
|
67
|
+
(_stripeModalRef$curre3 = stripeModalRef.current) === null || _stripeModalRef$curre3 === void 0 || _stripeModalRef$curre3.open(options);
|
|
48
68
|
} else {
|
|
49
|
-
(_stripePopupRef$
|
|
69
|
+
(_stripePopupRef$curre3 = stripePopupRef.current) === null || _stripePopupRef$curre3 === void 0 || _stripePopupRef$curre3.open(options);
|
|
50
70
|
}
|
|
51
71
|
}
|
|
52
72
|
case 2:
|
|
@@ -59,11 +79,11 @@ var StripeButton = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
59
79
|
handlePayCreateOrder();
|
|
60
80
|
} else {
|
|
61
81
|
if (displayType === 'modal') {
|
|
62
|
-
var _stripeModalRef$
|
|
63
|
-
stripeModalRef === null || stripeModalRef === void 0 || (_stripeModalRef$
|
|
82
|
+
var _stripeModalRef$curre4;
|
|
83
|
+
stripeModalRef === null || stripeModalRef === void 0 || (_stripeModalRef$curre4 = stripeModalRef.current) === null || _stripeModalRef$curre4 === void 0 || _stripeModalRef$curre4.open();
|
|
64
84
|
} else {
|
|
65
|
-
var _stripePopupRef$
|
|
66
|
-
stripePopupRef === null || stripePopupRef === void 0 || (_stripePopupRef$
|
|
85
|
+
var _stripePopupRef$curre4;
|
|
86
|
+
stripePopupRef === null || stripePopupRef === void 0 || (_stripePopupRef$curre4 = stripePopupRef.current) === null || _stripePopupRef$curre4 === void 0 || _stripePopupRef$curre4.open();
|
|
67
87
|
}
|
|
68
88
|
}
|
|
69
89
|
onClick === null || onClick === void 0 || onClick(e);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
.pay-dot-loading{display:inline-block}.pay-button{display:inline-block;padding:7px 12px;font-size:16px;border-radius:4px;border:1px solid #eee;background:#fff;color:#333;cursor:pointer;transition:.2s;user-select:none;position:relative;text-align:center}.pay-button-content{display:flex;align-items:center;justify-content:center;gap:6px}.pay-button-block{display:block;width:100%}.pay-button-disabled{opacity:.4;cursor:not-allowed}.pay-button-loading{cursor:wait}.pay-button-loading-wrapper{display:flex;align-items:center;justify-content:center;gap:6px}.pay-button-primary{background:#1677ff;border-color:#1677ff;color:#fff}.pay-button-primary:hover{background:#409eff}.pay-button-success{background:#00b578;border-color:#00b578;color:#fff}.pay-button-danger{background:#ff3141;border-color:#ff3141;color:#fff}.pay-button-warning{background:#ff8f1f;border-color:#ff8f1f;color:#fff}.pay-button-default{background:#fff;border-color:#eee;color:#333}.pay-button-fill-outline{background:0 0;color:inherit}.pay-button-fill-none{background:0 0;border:none;color:inherit}.pay-button-mini{font-size:12px;padding:2px 8px}.pay-button-small{font-size:14px;padding:4px 10px}.pay-button-large{font-size:18px;padding:10px 18px}.pay-button-shape-rounded{border-radius:1000px}.pay-button-shape-rectangular{border-radius:0}.pay-modal{position:fixed;z-index:9999;left:0;top:0;right:0;bottom:0;display:flex;align-items:center;justify-content:center}.pay-modal__mask{position:absolute;left:0;top:0;right:0;bottom:0;background:rgba(0,0,0,.55);z-index:0}.pay-modal__content{position:relative;z-index:1;background:#fff;border-radius:16px;padding:42px 20px 20px;min-width:280px;max-width:80vw;box-shadow:0 4px 24px #0001;text-align:center;max-height:60vh;display:flex;flex-direction:column}.pay-modal__close{position:absolute;right:12px;top:12px;background:0 0;border:none;font-size:
|
|
1
|
+
.pay-dot-loading{display:inline-block}.pay-button{display:inline-block;padding:7px 12px;font-size:16px;border-radius:4px;border:1px solid #eee;background:#fff;color:#333;cursor:pointer;transition:.2s;user-select:none;position:relative;text-align:center}.pay-button-content{display:flex;align-items:center;justify-content:center;gap:6px}.pay-button-block{display:block;width:100%}.pay-button-disabled{opacity:.4;cursor:not-allowed}.pay-button-loading{cursor:wait}.pay-button-loading-wrapper{display:flex;align-items:center;justify-content:center;gap:6px}.pay-button-primary{background:#1677ff;border-color:#1677ff;color:#fff}.pay-button-primary:hover{background:#409eff}.pay-button-success{background:#00b578;border-color:#00b578;color:#fff}.pay-button-danger{background:#ff3141;border-color:#ff3141;color:#fff}.pay-button-warning{background:#ff8f1f;border-color:#ff8f1f;color:#fff}.pay-button-default{background:#fff;border-color:#eee;color:#333}.pay-button-fill-outline{background:0 0;color:inherit}.pay-button-fill-none{background:0 0;border:none;color:inherit}.pay-button-mini{font-size:12px;padding:2px 8px}.pay-button-small{font-size:14px;padding:4px 10px}.pay-button-large{font-size:18px;padding:10px 18px}.pay-button-shape-rounded{border-radius:1000px}.pay-button-shape-rectangular{border-radius:0}.pay-modal{position:fixed;z-index:9999;left:0;top:0;right:0;bottom:0;display:flex;align-items:center;justify-content:center}.pay-modal__mask{position:absolute;left:0;top:0;right:0;bottom:0;background:rgba(0,0,0,.55);z-index:0}.pay-modal__content{position:relative;z-index:1;background:#fff;border-radius:16px;padding:42px 20px 20px;min-width:280px;max-width:80vw;box-shadow:0 4px 24px #0001;text-align:center;max-height:60vh;display:flex;flex-direction:column}.pay-modal__close{position:absolute;right:12px;top:12px;background:0 0;border:none;font-size:32px;font-weight:500;line-height:32px;cursor:pointer;text-align:left}.pay-modal__icon{margin-bottom:8px;font-size:40px}.pay-modal__title{font-size:20px;font-weight:700;color:#222;margin-bottom:12px}.pay-modal__desc{color:#222;font-size:15px;margin-bottom:24px;line-height:1.7;text-align:left}.pay-modal__content-wrapper{position:relative;z-index:1;text-align:center;overflow-y:auto;flex:1;min-height:0}.pay-modal__actions{display:flex;justify-content:center;gap:16px;margin-top:16px}.pay-modal__btn{min-width:96px;padding:8px 0;border-radius:24px;border:none;font-size:15px;font-weight:600;cursor:pointer;transition:background .2s}.pay-modal__btn--retry{background:#fff;color:#f25a5a;border:1.5px solid #f25a5a}.pay-modal__btn--finish{background:#f25a5a;color:#fff;border:none}.pay-mask{position:fixed;z-index:1000;left:0;top:0;right:0;bottom:0;display:flex;align-items:center;justify-content:center}.pay-icon{display:inline-block;color:inherit;width:16px;vertical-align:-2px;stroke:currentColor}.pay-icon[fill=currentColor]{fill:currentColor;stroke:none}.pay-icon[stroke=currentColor]{stroke:currentColor;fill:none}.pay-icon[fill=currentColor][stroke=currentColor]{fill:currentColor;stroke:currentColor}.pay-icon-paypal-text{width:64px;height:26px;max-width:72px;max-height:32px}.pay-icon-close{width:18px;height:18px}.pay-icon-stripe-text{width:24px;height:24px}.pay-icon-alipay{width:20px;height:20px}.pay-icon-wechat-pay{width:20px;height:20px}.pay-icon-payssion-pay{width:36px;height:20px}.pay-popup{position:fixed;z-index:1001}.pay-popup-body{position:fixed;display:flex;flex-direction:column;background-color:#fff;z-index:1010;box-sizing:border-box}.pay-popup-body.pay-popup-body-position-bottom{width:100%;left:0;bottom:0}.pay-popup-body.pay-popup-body-position-top{width:100%;left:0;top:0}.pay-popup-body.pay-popup-body-position-left{height:100%;width:80vw;left:0;top:0}.pay-popup-body.pay-popup-body-position-right{height:100%;width:80vw;right:0;top:0}.pay-popup-body.pay-popup-body-round.pay-popup-body-position-bottom{border-radius:16px 16px 0 0}.pay-popup-body.pay-popup-body-round.pay-popup-body-position-top{border-radius:0 0 16px 16px}.pay-popup-body.pay-popup-body-round.pay-popup-body-position-left{border-radius:0 16px 16px 0}.pay-popup-body.pay-popup-body-round.pay-popup-body-position-right{border-radius:16px 0 0 16px}.pay-popup-close-icon{position:absolute;z-index:1;cursor:pointer;padding:4px;font-size:18px;line-height:1;color:#999}.pay-popup-body.pay-popup-body-position-bottom .pay-popup-close-icon,.pay-popup-body.pay-popup-body-position-left .pay-popup-close-icon{top:8px;right:8px}.pay-popup-body.pay-popup-body-position-top .pay-popup-close-icon{bottom:8px;right:8px}.pay-popup-body.pay-popup-body-position-right .pay-popup-close-icon{top:8px;left:8px}.pay-popup-content{flex:1;overflow-y:auto;-webkit-overflow-scrolling:touch}.pay-popup-body.pay-popup-body-with-close.pay-popup-body-position-bottom .pay-popup-content,.pay-popup-body.pay-popup-body-with-close.pay-popup-body-position-left .pay-popup-content{padding-top:40px}.pay-popup-body.pay-popup-body-with-close.pay-popup-body-position-right .pay-popup-content{padding-top:40px}.pay-popup-body.pay-popup-body-with-close.pay-popup-body-position-top .pay-popup-content{padding-bottom:40px}@media (min-width:576px){.pay-stripe-modal.pay-modal .pay-modal__content{width:72%}}@media (min-width:768px){.pay-stripe-modal.pay-modal .pay-modal__content{width:50%}}@media (min-width:992px){.pay-stripe-modal.pay-modal .pay-modal__content{width:40%}}@media (min-width:1200px){.pay-stripe-modal.pay-modal .pay-modal__content{width:27%}}@media (min-width:1600px){.pay-stripe-modal.pay-modal .pay-modal__content{width:26%}}@media (min-width:2000px){.pay-stripe-modal.pay-modal .pay-modal__content{width:20%}}
|
|
@@ -40,9 +40,20 @@ export interface WechatButtonProps extends ButtonProps {
|
|
|
40
40
|
* @zh 弹窗属性
|
|
41
41
|
* @en Modal props
|
|
42
42
|
*/
|
|
43
|
-
modalProps?:
|
|
43
|
+
modalProps?: WechatModalProps;
|
|
44
|
+
}
|
|
45
|
+
export interface WechatButtonRef extends ButtonRef {
|
|
46
|
+
/**
|
|
47
|
+
* @zh 打开弹窗
|
|
48
|
+
* @en Open the popup
|
|
49
|
+
*/
|
|
50
|
+
openModal: (options?: WechatProps) => void;
|
|
51
|
+
/**
|
|
52
|
+
* @zh 关闭弹窗
|
|
53
|
+
* @en Close the popup
|
|
54
|
+
*/
|
|
55
|
+
closeModal: () => void;
|
|
44
56
|
}
|
|
45
|
-
export type WechatButtonRef = ButtonRef;
|
|
46
57
|
/**
|
|
47
58
|
* @zh 创建订单函数,返回 Paypal 所需参数
|
|
48
59
|
* @en Function to create order, returns Paypal required params
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { WechatButtonProps } from './interface';
|
|
2
|
+
import { WechatButtonProps, WechatButtonRef } from './interface';
|
|
3
3
|
declare const _default: React.MemoExoticComponent<React.ForwardRefExoticComponent<WechatButtonProps & {
|
|
4
4
|
children?: React.ReactNode;
|
|
5
|
-
} & React.RefAttributes<
|
|
5
|
+
} & React.RefAttributes<WechatButtonRef>>>;
|
|
6
6
|
export default _default;
|
|
@@ -20,15 +20,27 @@ var WechatButton = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
20
20
|
createOrder = props.createOrder,
|
|
21
21
|
modalProps = props.modalProps,
|
|
22
22
|
others = _objectWithoutProperties(props, _excluded);
|
|
23
|
-
var wechatButtonRef = useRef(
|
|
24
|
-
nativeElement: null
|
|
25
|
-
});
|
|
23
|
+
var wechatButtonRef = useRef(null);
|
|
26
24
|
var wechatModalRef = useRef(null);
|
|
27
25
|
useImperativeHandle(ref, function () {
|
|
28
|
-
return
|
|
26
|
+
return {
|
|
27
|
+
get nativeElement() {
|
|
28
|
+
var _wechatButtonRef$curr;
|
|
29
|
+
return ((_wechatButtonRef$curr = wechatButtonRef.current) === null || _wechatButtonRef$curr === void 0 ? void 0 : _wechatButtonRef$curr.nativeElement) || null;
|
|
30
|
+
},
|
|
31
|
+
openModal: function openModal(options) {
|
|
32
|
+
var _wechatModalRef$curre;
|
|
33
|
+
(_wechatModalRef$curre = wechatModalRef.current) === null || _wechatModalRef$curre === void 0 || _wechatModalRef$curre.open(options);
|
|
34
|
+
},
|
|
35
|
+
closeModal: function closeModal() {
|
|
36
|
+
var _wechatModalRef$curre2;
|
|
37
|
+
(_wechatModalRef$curre2 = wechatModalRef.current) === null || _wechatModalRef$curre2 === void 0 || _wechatModalRef$curre2.close();
|
|
38
|
+
},
|
|
39
|
+
current: wechatButtonRef.current
|
|
40
|
+
};
|
|
29
41
|
});
|
|
30
42
|
var handlePayCreateOrder = useCallback(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee() {
|
|
31
|
-
var _wechatModalRef$
|
|
43
|
+
var _wechatModalRef$curre3, options;
|
|
32
44
|
return _regenerator().w(function (_context) {
|
|
33
45
|
while (1) switch (_context.n) {
|
|
34
46
|
case 0:
|
|
@@ -40,7 +52,7 @@ var WechatButton = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
40
52
|
return createOrder();
|
|
41
53
|
case 1:
|
|
42
54
|
options = _context.v;
|
|
43
|
-
(_wechatModalRef$
|
|
55
|
+
(_wechatModalRef$curre3 = wechatModalRef.current) === null || _wechatModalRef$curre3 === void 0 || _wechatModalRef$curre3.open(options);
|
|
44
56
|
case 2:
|
|
45
57
|
return _context.a(2);
|
|
46
58
|
}
|
|
@@ -50,8 +62,8 @@ var WechatButton = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
50
62
|
if (createOrder) {
|
|
51
63
|
handlePayCreateOrder();
|
|
52
64
|
} else {
|
|
53
|
-
var _wechatModalRef$
|
|
54
|
-
wechatModalRef === null || wechatModalRef === void 0 || (_wechatModalRef$
|
|
65
|
+
var _wechatModalRef$curre4;
|
|
66
|
+
wechatModalRef === null || wechatModalRef === void 0 || (_wechatModalRef$curre4 = wechatModalRef.current) === null || _wechatModalRef$curre4 === void 0 || _wechatModalRef$curre4.open();
|
|
55
67
|
}
|
|
56
68
|
onClick === null || onClick === void 0 || onClick(e);
|
|
57
69
|
}, [onClick, createOrder, handlePayCreateOrder]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
.pay-modal{position:fixed;z-index:9999;left:0;top:0;right:0;bottom:0;display:flex;align-items:center;justify-content:center}.pay-modal__mask{position:absolute;left:0;top:0;right:0;bottom:0;background:rgba(0,0,0,.55);z-index:0}.pay-modal__content{position:relative;z-index:1;background:#fff;border-radius:16px;padding:42px 20px 20px;min-width:280px;max-width:80vw;box-shadow:0 4px 24px #0001;text-align:center;max-height:60vh;display:flex;flex-direction:column}.pay-modal__close{position:absolute;right:12px;top:12px;background:0 0;border:none;font-size:
|
|
1
|
+
.pay-modal{position:fixed;z-index:9999;left:0;top:0;right:0;bottom:0;display:flex;align-items:center;justify-content:center}.pay-modal__mask{position:absolute;left:0;top:0;right:0;bottom:0;background:rgba(0,0,0,.55);z-index:0}.pay-modal__content{position:relative;z-index:1;background:#fff;border-radius:16px;padding:42px 20px 20px;min-width:280px;max-width:80vw;box-shadow:0 4px 24px #0001;text-align:center;max-height:60vh;display:flex;flex-direction:column}.pay-modal__close{position:absolute;right:12px;top:12px;background:0 0;border:none;font-size:32px;font-weight:500;line-height:32px;cursor:pointer;text-align:left}.pay-modal__icon{margin-bottom:8px;font-size:40px}.pay-modal__title{font-size:20px;font-weight:700;color:#222;margin-bottom:12px}.pay-modal__desc{color:#222;font-size:15px;margin-bottom:24px;line-height:1.7;text-align:left}.pay-modal__content-wrapper{position:relative;z-index:1;text-align:center;overflow-y:auto;flex:1;min-height:0}.pay-modal__actions{display:flex;justify-content:center;gap:16px;margin-top:16px}.pay-modal__btn{min-width:96px;padding:8px 0;border-radius:24px;border:none;font-size:15px;font-weight:600;cursor:pointer;transition:background .2s}.pay-modal__btn--retry{background:#fff;color:#f25a5a;border:1.5px solid #f25a5a}.pay-modal__btn--finish{background:#f25a5a;color:#fff;border:none}
|
package/dist/es/index.d.ts
CHANGED
|
@@ -14,6 +14,6 @@ export type { AlipayProps, AlipayModalProps, AlipayButtonProps, AlipayButtonRef,
|
|
|
14
14
|
export { default as Alipay } from './Alipay';
|
|
15
15
|
export type { WechatProps, WechatModalProps, WechatButtonProps, WechatButtonRef, WechatModalRef, } from './Wechat/interface';
|
|
16
16
|
export { default as Wechat } from './Wechat';
|
|
17
|
-
export type { PayButtonProps,
|
|
17
|
+
export type { PayButtonProps, GenericPayButtonRef, } from './PayButton/interface';
|
|
18
18
|
export { default as PayButton } from './PayButton';
|
|
19
19
|
export * from './shared';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
.pay-modal{position:fixed;z-index:9999;left:0;top:0;right:0;bottom:0;display:flex;align-items:center;justify-content:center}.pay-modal__mask{position:absolute;left:0;top:0;right:0;bottom:0;background:rgba(0,0,0,.55);z-index:0}.pay-modal__content{position:relative;z-index:1;background:#fff;border-radius:16px;padding:42px 20px 20px;min-width:280px;max-width:80vw;box-shadow:0 4px 24px #0001;text-align:center;max-height:60vh;display:flex;flex-direction:column}.pay-modal__close{position:absolute;right:12px;top:12px;background:0 0;border:none;font-size:
|
|
1
|
+
.pay-modal{position:fixed;z-index:9999;left:0;top:0;right:0;bottom:0;display:flex;align-items:center;justify-content:center}.pay-modal__mask{position:absolute;left:0;top:0;right:0;bottom:0;background:rgba(0,0,0,.55);z-index:0}.pay-modal__content{position:relative;z-index:1;background:#fff;border-radius:16px;padding:42px 20px 20px;min-width:280px;max-width:80vw;box-shadow:0 4px 24px #0001;text-align:center;max-height:60vh;display:flex;flex-direction:column}.pay-modal__close{position:absolute;right:12px;top:12px;background:0 0;border:none;font-size:32px;font-weight:500;line-height:32px;cursor:pointer;text-align:left}.pay-modal__icon{margin-bottom:8px;font-size:40px}.pay-modal__title{font-size:20px;font-weight:700;color:#222;margin-bottom:12px}.pay-modal__desc{color:#222;font-size:15px;margin-bottom:24px;line-height:1.7;text-align:left}.pay-modal__content-wrapper{position:relative;z-index:1;text-align:center;overflow-y:auto;flex:1;min-height:0}.pay-modal__actions{display:flex;justify-content:center;gap:16px;margin-top:16px}.pay-modal__btn{min-width:96px;padding:8px 0;border-radius:24px;border:none;font-size:15px;font-weight:600;cursor:pointer;transition:background .2s}.pay-modal__btn--retry{background:#fff;color:#f25a5a;border:1.5px solid #f25a5a}.pay-modal__btn--finish{background:#f25a5a;color:#fff;border:none}
|
|
@@ -20,14 +20,43 @@ const AirwallexButton = /*#__PURE__*/(0, _react.forwardRef)((props, ref) => {
|
|
|
20
20
|
createOrder,
|
|
21
21
|
...others
|
|
22
22
|
} = props;
|
|
23
|
-
const airwallexButtonRef = (0, _react.useRef)(
|
|
24
|
-
nativeElement: null
|
|
25
|
-
});
|
|
23
|
+
const airwallexButtonRef = (0, _react.useRef)(null);
|
|
26
24
|
const airwallexPopupRef = (0, _react.useRef)(null);
|
|
27
25
|
const airwallexModalRef = (0, _react.useRef)(null);
|
|
28
26
|
const [showMask, setShowMask] = (0, _react.useState)(false);
|
|
29
27
|
const [airwallexUrl, setAirwallexUrl] = (0, _react.useState)();
|
|
30
|
-
(0, _react.useImperativeHandle)(ref, () =>
|
|
28
|
+
(0, _react.useImperativeHandle)(ref, () => ({
|
|
29
|
+
get nativeElement() {
|
|
30
|
+
var _airwallexButtonRef$c;
|
|
31
|
+
return ((_airwallexButtonRef$c = airwallexButtonRef.current) === null || _airwallexButtonRef$c === void 0 ? void 0 : _airwallexButtonRef$c.nativeElement) || null;
|
|
32
|
+
},
|
|
33
|
+
openModal: options => {
|
|
34
|
+
var _airwallexModalRef$cu;
|
|
35
|
+
(_airwallexModalRef$cu = airwallexModalRef.current) === null || _airwallexModalRef$cu === void 0 || _airwallexModalRef$cu.open(options);
|
|
36
|
+
},
|
|
37
|
+
closeModal: () => {
|
|
38
|
+
var _airwallexModalRef$cu2;
|
|
39
|
+
(_airwallexModalRef$cu2 = airwallexModalRef.current) === null || _airwallexModalRef$cu2 === void 0 || _airwallexModalRef$cu2.close();
|
|
40
|
+
},
|
|
41
|
+
openPopup: options => {
|
|
42
|
+
var _airwallexPopupRef$cu;
|
|
43
|
+
(_airwallexPopupRef$cu = airwallexPopupRef.current) === null || _airwallexPopupRef$cu === void 0 || _airwallexPopupRef$cu.open(options);
|
|
44
|
+
},
|
|
45
|
+
closePopup: () => {
|
|
46
|
+
var _airwallexPopupRef$cu2;
|
|
47
|
+
(_airwallexPopupRef$cu2 = airwallexPopupRef.current) === null || _airwallexPopupRef$cu2 === void 0 || _airwallexPopupRef$cu2.close();
|
|
48
|
+
},
|
|
49
|
+
openPayment: options => {
|
|
50
|
+
if (options) {
|
|
51
|
+
setAirwallexUrl(options.airwallexUrl);
|
|
52
|
+
}
|
|
53
|
+
setShowMask(true);
|
|
54
|
+
},
|
|
55
|
+
closePayment: () => {
|
|
56
|
+
setShowMask(false);
|
|
57
|
+
},
|
|
58
|
+
current: airwallexButtonRef.current
|
|
59
|
+
}));
|
|
31
60
|
const handlePayCreateOrder = (0, _react.useCallback)(async () => {
|
|
32
61
|
if (createOrder) {
|
|
33
62
|
// 1. 业务侧创建订单,获取参数
|
|
@@ -35,11 +64,11 @@ const AirwallexButton = /*#__PURE__*/(0, _react.forwardRef)((props, ref) => {
|
|
|
35
64
|
if (options) {
|
|
36
65
|
if ((props === null || props === void 0 ? void 0 : props.payMode) === 'embedded') {
|
|
37
66
|
if ((props === null || props === void 0 ? void 0 : props.displayType) === 'modal') {
|
|
38
|
-
var _airwallexModalRef$
|
|
39
|
-
airwallexModalRef === null || airwallexModalRef === void 0 || (_airwallexModalRef$
|
|
67
|
+
var _airwallexModalRef$cu3;
|
|
68
|
+
airwallexModalRef === null || airwallexModalRef === void 0 || (_airwallexModalRef$cu3 = airwallexModalRef.current) === null || _airwallexModalRef$cu3 === void 0 || _airwallexModalRef$cu3.open(options);
|
|
40
69
|
} else {
|
|
41
|
-
var _airwallexPopupRef$
|
|
42
|
-
(_airwallexPopupRef$
|
|
70
|
+
var _airwallexPopupRef$cu3;
|
|
71
|
+
(_airwallexPopupRef$cu3 = airwallexPopupRef.current) === null || _airwallexPopupRef$cu3 === void 0 || _airwallexPopupRef$cu3.open(options);
|
|
43
72
|
}
|
|
44
73
|
} else {
|
|
45
74
|
setShowMask(true);
|
|
@@ -56,11 +85,11 @@ const AirwallexButton = /*#__PURE__*/(0, _react.forwardRef)((props, ref) => {
|
|
|
56
85
|
}
|
|
57
86
|
if ((props === null || props === void 0 ? void 0 : props.payMode) === 'embedded') {
|
|
58
87
|
if ((props === null || props === void 0 ? void 0 : props.displayType) === 'modal') {
|
|
59
|
-
var _airwallexModalRef$
|
|
60
|
-
airwallexModalRef === null || airwallexModalRef === void 0 || (_airwallexModalRef$
|
|
88
|
+
var _airwallexModalRef$cu4;
|
|
89
|
+
airwallexModalRef === null || airwallexModalRef === void 0 || (_airwallexModalRef$cu4 = airwallexModalRef.current) === null || _airwallexModalRef$cu4 === void 0 || _airwallexModalRef$cu4.open();
|
|
61
90
|
} else {
|
|
62
|
-
var _airwallexPopupRef$
|
|
63
|
-
airwallexPopupRef === null || airwallexPopupRef === void 0 || (_airwallexPopupRef$
|
|
91
|
+
var _airwallexPopupRef$cu4;
|
|
92
|
+
airwallexPopupRef === null || airwallexPopupRef === void 0 || (_airwallexPopupRef$cu4 = airwallexPopupRef.current) === null || _airwallexPopupRef$cu4 === void 0 || _airwallexPopupRef$cu4.open();
|
|
64
93
|
}
|
|
65
94
|
return;
|
|
66
95
|
}
|