pay-sdk-react 1.1.5 → 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/PayMask/interface.d.ts +6 -0
- package/dist/es/PayMask/pay-mask.js +5 -2
- package/dist/es/Paypal/interface.d.ts +23 -1
- package/dist/es/Paypal/paypal-button.d.ts +2 -2
- package/dist/es/Paypal/paypal-button.js +31 -7
- 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/Wechat/wechat.js +1 -1
- package/dist/es/confirm-modal/style/index.css +3 -1
- package/dist/es/confirm-modal/style/index.min.css +1 -1
- package/dist/es/hooks/usePayWindowOpen.d.ts +6 -0
- package/dist/es/hooks/usePayWindowOpen.js +9 -4
- 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/PayMask/pay-mask.js +2 -0
- package/dist/lib/Paypal/paypal-button.js +28 -5
- 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/Wechat/wechat.js +1 -1
- package/dist/lib/confirm-modal/style/index.css +3 -1
- package/dist/lib/confirm-modal/style/index.min.css +1 -1
- package/dist/lib/hooks/usePayWindowOpen.js +8 -4
- 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 +131 -28
- package/dist/umd/pay-sdk-react.umd.js.map +1 -1
- package/package.json +1 -1
|
@@ -22,8 +22,30 @@ export interface PaypalButtonProps extends ButtonProps {
|
|
|
22
22
|
* @en Function to create order, returns Paypal required params
|
|
23
23
|
*/
|
|
24
24
|
createOrder?: CreateOrderPaypalFn;
|
|
25
|
+
/**
|
|
26
|
+
* @zh 支付状态,true 表示支付完成,false 表示支付未完成,仅在 createOrder 调用且 openMode 为 "window"时支付完成后关闭蒙层使用
|
|
27
|
+
* @en Payment status, true means payment completed, false means payment not completed, only used to close the mask when payment is completed and openMode is "window"
|
|
28
|
+
*/
|
|
29
|
+
isPayment?: boolean;
|
|
30
|
+
/**
|
|
31
|
+
* @zh 组件卸载时是否关闭第三方支付页面,仅在 createOrder 调用且 openMode 为 "window"时支付完成后关闭蒙层使用
|
|
32
|
+
* @en Whether to close the third-party payment page when component unmounts, only effective when "isPayment" is set and openMode is "window"
|
|
33
|
+
* @default true
|
|
34
|
+
*/
|
|
35
|
+
closeWindowOnUnmount?: boolean;
|
|
36
|
+
}
|
|
37
|
+
export interface PaypalButtonRef extends ButtonRef {
|
|
38
|
+
/**
|
|
39
|
+
* @zh 打开支付页面
|
|
40
|
+
* @en Open payment page
|
|
41
|
+
*/
|
|
42
|
+
openPayment: (options?: PaypalSecretMap) => void;
|
|
43
|
+
/**
|
|
44
|
+
* @zh 关闭支付页面
|
|
45
|
+
* @en Close payment page
|
|
46
|
+
*/
|
|
47
|
+
closePayment: () => void;
|
|
25
48
|
}
|
|
26
|
-
export type PaypalButtonRef = ButtonRef;
|
|
27
49
|
/**
|
|
28
50
|
* @zh Paypal 所需参数
|
|
29
51
|
* @en Paypal required params
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { PaypalButtonProps } from './interface';
|
|
2
|
+
import { PaypalButtonProps, PaypalButtonRef } from './interface';
|
|
3
3
|
declare const _default: React.MemoExoticComponent<React.ForwardRefExoticComponent<PaypalButtonProps & {
|
|
4
4
|
children?: React.ReactNode;
|
|
5
|
-
} & React.RefAttributes<
|
|
5
|
+
} & React.RefAttributes<PaypalButtonRef>>>;
|
|
6
6
|
export default _default;
|
|
@@ -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 }; })(); }
|
|
@@ -13,7 +13,7 @@ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" !=
|
|
|
13
13
|
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
|
|
14
14
|
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; }
|
|
15
15
|
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; }
|
|
16
|
-
import React, { forwardRef, memo, useCallback, useImperativeHandle, useRef, useState } from 'react';
|
|
16
|
+
import React, { forwardRef, memo, useCallback, useImperativeHandle, useRef, useState, useEffect } from 'react';
|
|
17
17
|
import { IconPaypalText, IconPaypalWhite } from '../icons';
|
|
18
18
|
import cs from '../utils/classNames';
|
|
19
19
|
import PayMask from '../PayMask';
|
|
@@ -27,13 +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
|
+
isPayment = props.isPayment,
|
|
31
|
+
_props$closeWindowOnU = props.closeWindowOnUnmount,
|
|
32
|
+
closeWindowOnUnmount = _props$closeWindowOnU === void 0 ? true : _props$closeWindowOnU,
|
|
30
33
|
others = _objectWithoutProperties(props, _excluded);
|
|
31
34
|
var _ref = maskProps || {},
|
|
32
35
|
onMaskClose = _ref.onClose,
|
|
33
36
|
restMaskProps = _objectWithoutProperties(_ref, _excluded2);
|
|
34
|
-
var paypalButtonRef = useRef(
|
|
35
|
-
nativeElement: null
|
|
36
|
-
});
|
|
37
|
+
var paypalButtonRef = useRef(null);
|
|
37
38
|
var _useState = useState(false),
|
|
38
39
|
_useState2 = _slicedToArray(_useState, 2),
|
|
39
40
|
showMask = _useState2[0],
|
|
@@ -42,8 +43,30 @@ var PaypalButton = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
42
43
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
43
44
|
paypalUrl = _useState4[0],
|
|
44
45
|
setPaypalUrl = _useState4[1];
|
|
46
|
+
|
|
47
|
+
// 监听 isPayment 状态变化,当支付完成时隐藏蒙层
|
|
48
|
+
useEffect(function () {
|
|
49
|
+
if (createOrder && isPayment) {
|
|
50
|
+
setShowMask(false);
|
|
51
|
+
}
|
|
52
|
+
}, [createOrder, isPayment]);
|
|
45
53
|
useImperativeHandle(ref, function () {
|
|
46
|
-
return
|
|
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
|
+
};
|
|
47
70
|
});
|
|
48
71
|
var handlePayCreateOrder = useCallback(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee() {
|
|
49
72
|
var _yield$createOrder, _paypalUrl;
|
|
@@ -94,7 +117,8 @@ var PaypalButton = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
94
117
|
onMaskClose === null || onMaskClose === void 0 || onMaskClose();
|
|
95
118
|
},
|
|
96
119
|
payUrl: paypalUrl,
|
|
97
|
-
title: /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(IconPaypalWhite, null), "PayPal")
|
|
120
|
+
title: /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(IconPaypalWhite, null), "PayPal"),
|
|
121
|
+
closeWindowOnUnmount: closeWindowOnUnmount
|
|
98
122
|
}, restMaskProps)));
|
|
99
123
|
});
|
|
100
124
|
PaypalButton.displayName = 'PaypalButton';
|
|
@@ -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]);
|
package/dist/es/Wechat/wechat.js
CHANGED
|
@@ -8,7 +8,7 @@ import React, { memo, useEffect, useState } from 'react';
|
|
|
8
8
|
import cs from '../utils/classNames';
|
|
9
9
|
import makeQrcode from '../utils/qrcode';
|
|
10
10
|
import { getPrefixCls } from '../utils/getPrefixCls';
|
|
11
|
-
var classPrefix = getPrefixCls('wechat');
|
|
11
|
+
var classPrefix = getPrefixCls('wechat-qrcode');
|
|
12
12
|
var WechatQrCode = function WechatQrCode(_ref) {
|
|
13
13
|
var _ref$wechatType = _ref.wechatType,
|
|
14
14
|
wechatType = _ref$wechatType === void 0 ? 'qrcode' : _ref$wechatType,
|
|
@@ -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}
|
|
@@ -5,6 +5,12 @@ interface BaseUsePayWindowOpenOptions {
|
|
|
5
5
|
onClose?: () => void;
|
|
6
6
|
onSuccess?: () => void;
|
|
7
7
|
autoOpen?: boolean;
|
|
8
|
+
/**
|
|
9
|
+
* @zh 组件卸载时是否关闭支付窗口
|
|
10
|
+
* @en Whether to close payment window when component unmounts
|
|
11
|
+
* @default true
|
|
12
|
+
*/
|
|
13
|
+
closeWindowOnUnmount?: boolean;
|
|
8
14
|
}
|
|
9
15
|
interface WindowModeOptions extends BaseUsePayWindowOpenOptions {
|
|
10
16
|
openMode?: OpenPayUrlMode.Window;
|
|
@@ -19,7 +19,8 @@ function getScreenWidth() {
|
|
|
19
19
|
}
|
|
20
20
|
var defaultProps = {
|
|
21
21
|
payUrl: '',
|
|
22
|
-
openMode: OpenPayUrlMode.Window
|
|
22
|
+
openMode: OpenPayUrlMode.Window,
|
|
23
|
+
closeWindowOnUnmount: true
|
|
23
24
|
};
|
|
24
25
|
export function usePayWindowOpen(p) {
|
|
25
26
|
var props = mergeProps(defaultProps, p);
|
|
@@ -27,7 +28,9 @@ export function usePayWindowOpen(p) {
|
|
|
27
28
|
onClose = props.onClose,
|
|
28
29
|
onSuccess = props.onSuccess,
|
|
29
30
|
_props$autoOpen = props.autoOpen,
|
|
30
|
-
autoOpen = _props$autoOpen === void 0 ? true : _props$autoOpen
|
|
31
|
+
autoOpen = _props$autoOpen === void 0 ? true : _props$autoOpen,
|
|
32
|
+
_props$closeWindowOnU = props.closeWindowOnUnmount,
|
|
33
|
+
closeWindowOnUnmount = _props$closeWindowOnU === void 0 ? true : _props$closeWindowOnU;
|
|
31
34
|
var payWindowRef = useRef(null);
|
|
32
35
|
var pollTimerRef = useRef(null);
|
|
33
36
|
var _useState = useState(false),
|
|
@@ -122,10 +125,12 @@ export function usePayWindowOpen(p) {
|
|
|
122
125
|
}
|
|
123
126
|
window.addEventListener('message', handleMessage);
|
|
124
127
|
return function () {
|
|
125
|
-
var _payWindowRef$current3;
|
|
126
128
|
clearInterval(pollTimerRef.current);
|
|
127
129
|
window.removeEventListener('message', handleMessage);
|
|
128
|
-
(
|
|
130
|
+
if (closeWindowOnUnmount) {
|
|
131
|
+
var _payWindowRef$current3;
|
|
132
|
+
(_payWindowRef$current3 = payWindowRef.current) === null || _payWindowRef$current3 === void 0 || _payWindowRef$current3.close();
|
|
133
|
+
}
|
|
129
134
|
};
|
|
130
135
|
}, [isWindowMonitoring, props, onClose, onSuccess]);
|
|
131
136
|
return {
|
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
|
}
|