pay-sdk-react 1.1.6 → 1.1.8
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 +46 -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 +23 -10
- 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 +42 -12
- 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 +23 -10
- 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 +47 -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 +23 -10
- 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 +43 -13
- 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 +23 -10
- 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 +149 -88
- package/dist/umd/pay-sdk-react.umd.js.map +1 -1
- package/package.json +1 -1
|
@@ -22,27 +22,40 @@ const WechatButton = /*#__PURE__*/(0, _react.forwardRef)((props, ref) => {
|
|
|
22
22
|
modalProps,
|
|
23
23
|
...others
|
|
24
24
|
} = props;
|
|
25
|
-
const wechatButtonRef = (0, _react.useRef)(
|
|
26
|
-
nativeElement: null
|
|
27
|
-
});
|
|
25
|
+
const wechatButtonRef = (0, _react.useRef)(null);
|
|
28
26
|
const wechatModalRef = (0, _react.useRef)(null);
|
|
29
|
-
(0, _react.useImperativeHandle)(ref, () =>
|
|
27
|
+
(0, _react.useImperativeHandle)(ref, () => ({
|
|
28
|
+
get nativeElement() {
|
|
29
|
+
var _wechatButtonRef$curr;
|
|
30
|
+
return ((_wechatButtonRef$curr = wechatButtonRef.current) === null || _wechatButtonRef$curr === void 0 ? void 0 : _wechatButtonRef$curr.nativeElement) || null;
|
|
31
|
+
},
|
|
32
|
+
openModal: options => {
|
|
33
|
+
var _wechatModalRef$curre;
|
|
34
|
+
(_wechatModalRef$curre = wechatModalRef.current) === null || _wechatModalRef$curre === void 0 || _wechatModalRef$curre.open(options);
|
|
35
|
+
},
|
|
36
|
+
closeModal: () => {
|
|
37
|
+
var _wechatModalRef$curre2;
|
|
38
|
+
(_wechatModalRef$curre2 = wechatModalRef.current) === null || _wechatModalRef$curre2 === void 0 || _wechatModalRef$curre2.close();
|
|
39
|
+
},
|
|
40
|
+
current: wechatButtonRef.current
|
|
41
|
+
}));
|
|
30
42
|
const handlePayCreateOrder = (0, _react.useCallback)(async () => {
|
|
31
43
|
if (createOrder) {
|
|
32
|
-
var _wechatModalRef$
|
|
44
|
+
var _wechatModalRef$curre3;
|
|
33
45
|
const options = await createOrder();
|
|
34
|
-
(_wechatModalRef$
|
|
46
|
+
(_wechatModalRef$curre3 = wechatModalRef.current) === null || _wechatModalRef$curre3 === void 0 || _wechatModalRef$curre3.open(options);
|
|
35
47
|
}
|
|
36
48
|
}, [createOrder]);
|
|
37
49
|
const handleClick = (0, _react.useCallback)(e => {
|
|
50
|
+
var _modalProps$wechatPro;
|
|
38
51
|
if (createOrder) {
|
|
39
52
|
handlePayCreateOrder();
|
|
40
|
-
} else {
|
|
41
|
-
var _wechatModalRef$
|
|
42
|
-
wechatModalRef === null || wechatModalRef === void 0 || (_wechatModalRef$
|
|
53
|
+
} else if (modalProps !== null && modalProps !== void 0 && (_modalProps$wechatPro = modalProps.wechatProps) !== null && _modalProps$wechatPro !== void 0 && _modalProps$wechatPro.wechatUrl) {
|
|
54
|
+
var _wechatModalRef$curre4;
|
|
55
|
+
wechatModalRef === null || wechatModalRef === void 0 || (_wechatModalRef$curre4 = wechatModalRef.current) === null || _wechatModalRef$curre4 === void 0 || _wechatModalRef$curre4.open();
|
|
43
56
|
}
|
|
44
57
|
onClick === null || onClick === void 0 || onClick(e);
|
|
45
|
-
}, [onClick, createOrder, handlePayCreateOrder]);
|
|
58
|
+
}, [onClick, createOrder, handlePayCreateOrder, modalProps]);
|
|
46
59
|
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_Button.default, _extends({
|
|
47
60
|
ref: wechatButtonRef,
|
|
48
61
|
className: (0, _classNames.default)((0, _getPrefixCls.getPrefixCls)('wechat-btn'), className),
|
|
@@ -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}
|
|
@@ -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}
|
|
@@ -5524,58 +5524,32 @@
|
|
|
5524
5524
|
Button.displayName = 'Button';
|
|
5525
5525
|
|
|
5526
5526
|
const PaypalButton = React.forwardRef((props, ref) => {
|
|
5527
|
-
const { className, children = (jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [jsxRuntimeExports.jsx(IconPaypalText, {}), " Buy Now"] })), onClick, paypalUrl: propsPaypalUrl, createOrder, maskProps,
|
|
5527
|
+
const { className, children = (jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [jsxRuntimeExports.jsx(IconPaypalText, {}), " Buy Now"] })), onClick, paypalUrl: propsPaypalUrl, createOrder, maskProps, isPayment, closeWindowOnUnmount = true, ...others } = props;
|
|
5528
5528
|
const { onClose: onMaskClose, ...restMaskProps } = maskProps || {};
|
|
5529
|
-
const paypalButtonRef = React.useRef(
|
|
5529
|
+
const paypalButtonRef = React.useRef(null);
|
|
5530
5530
|
const [showMask, setShowMask] = React.useState(false);
|
|
5531
5531
|
const [paypalUrl, setPaypalUrl] = React.useState();
|
|
5532
|
-
|
|
5533
|
-
React.
|
|
5534
|
-
|
|
5535
|
-
|
|
5536
|
-
if (!checkPaymentStatus)
|
|
5537
|
-
return;
|
|
5538
|
-
// 先清除之前的定时器
|
|
5539
|
-
if (pollingTimerRef.current) {
|
|
5540
|
-
clearTimeout(pollingTimerRef.current);
|
|
5541
|
-
pollingTimerRef.current = null;
|
|
5532
|
+
// 监听 isPayment 状态变化,当支付完成时隐藏蒙层
|
|
5533
|
+
React.useEffect(() => {
|
|
5534
|
+
if (createOrder && isPayment) {
|
|
5535
|
+
setShowMask(false);
|
|
5542
5536
|
}
|
|
5543
|
-
|
|
5544
|
-
|
|
5545
|
-
|
|
5546
|
-
|
|
5547
|
-
|
|
5548
|
-
|
|
5549
|
-
|
|
5550
|
-
|
|
5551
|
-
|
|
5552
|
-
}
|
|
5553
|
-
return;
|
|
5554
|
-
}
|
|
5555
|
-
// 继续轮询
|
|
5556
|
-
if (pollingTimerRef.current) {
|
|
5557
|
-
clearTimeout(pollingTimerRef.current);
|
|
5558
|
-
}
|
|
5559
|
-
pollingTimerRef.current = setTimeout(poll, 3000);
|
|
5560
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
5561
|
-
}
|
|
5562
|
-
catch (error) {
|
|
5563
|
-
// 出错时继续轮询
|
|
5564
|
-
if (pollingTimerRef.current) {
|
|
5565
|
-
clearTimeout(pollingTimerRef.current);
|
|
5566
|
-
}
|
|
5567
|
-
pollingTimerRef.current = setTimeout(poll, 3000);
|
|
5537
|
+
}, [createOrder, isPayment]);
|
|
5538
|
+
React.useImperativeHandle(ref, () => ({
|
|
5539
|
+
get nativeElement() {
|
|
5540
|
+
return paypalButtonRef.current?.nativeElement || null;
|
|
5541
|
+
},
|
|
5542
|
+
openPayment: (options) => {
|
|
5543
|
+
if (options) {
|
|
5544
|
+
setPaypalUrl(options.paypalUrl);
|
|
5545
|
+
setShowMask(true);
|
|
5568
5546
|
}
|
|
5569
|
-
}
|
|
5570
|
-
|
|
5571
|
-
|
|
5572
|
-
|
|
5573
|
-
|
|
5574
|
-
|
|
5575
|
-
clearTimeout(pollingTimerRef.current);
|
|
5576
|
-
pollingTimerRef.current = null;
|
|
5577
|
-
}
|
|
5578
|
-
}, []);
|
|
5547
|
+
},
|
|
5548
|
+
closePayment: () => {
|
|
5549
|
+
setShowMask(false);
|
|
5550
|
+
},
|
|
5551
|
+
current: paypalButtonRef.current,
|
|
5552
|
+
}));
|
|
5579
5553
|
const handlePayCreateOrder = React.useCallback(async () => {
|
|
5580
5554
|
if (createOrder) {
|
|
5581
5555
|
// 1. 业务侧创建订单,获取参数
|
|
@@ -5584,13 +5558,9 @@
|
|
|
5584
5558
|
// 2. 唤起蒙层
|
|
5585
5559
|
setShowMask(true);
|
|
5586
5560
|
setPaypalUrl(paypalUrl);
|
|
5587
|
-
// 3. 开始轮询支付状态
|
|
5588
|
-
if (checkPaymentStatus) {
|
|
5589
|
-
startPaymentPolling();
|
|
5590
|
-
}
|
|
5591
5561
|
}
|
|
5592
5562
|
}
|
|
5593
|
-
}, [createOrder
|
|
5563
|
+
}, [createOrder]);
|
|
5594
5564
|
const handleOpen = React.useCallback(() => {
|
|
5595
5565
|
if (propsPaypalUrl) {
|
|
5596
5566
|
setShowMask(true);
|
|
@@ -5606,15 +5576,8 @@
|
|
|
5606
5576
|
}
|
|
5607
5577
|
onClick?.(e);
|
|
5608
5578
|
}, [onClick, createOrder, handlePayCreateOrder, handleOpen]);
|
|
5609
|
-
// 组件卸载时清理轮询
|
|
5610
|
-
React.useEffect(() => {
|
|
5611
|
-
return () => {
|
|
5612
|
-
stopPaymentPolling();
|
|
5613
|
-
};
|
|
5614
|
-
}, [stopPaymentPolling]);
|
|
5615
5579
|
return (jsxRuntimeExports.jsxs(React.Fragment, { children: [jsxRuntimeExports.jsx(Button, { ref: paypalButtonRef, className: cs(getPrefixCls('paypal-btn'), className), onClick: handleClick, ...others, children: children }), showMask && paypalUrl && (jsxRuntimeExports.jsx(PayMask, { visible: showMask, onClose: () => {
|
|
5616
5580
|
setShowMask(false);
|
|
5617
|
-
stopPaymentPolling();
|
|
5618
5581
|
onMaskClose?.();
|
|
5619
5582
|
}, payUrl: paypalUrl, title: jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [jsxRuntimeExports.jsx(IconPaypalWhite, {}), "PayPal"] }), closeWindowOnUnmount: closeWindowOnUnmount, ...restMaskProps }))] }));
|
|
5620
5583
|
});
|
|
@@ -9448,10 +9411,27 @@
|
|
|
9448
9411
|
|
|
9449
9412
|
const StripeButton = React.forwardRef((props, ref) => {
|
|
9450
9413
|
const { children = 'Stripe', onClick, displayType = 'popup', stripePopupProps, stripeModalProps, createOrder, ...others } = props;
|
|
9451
|
-
const stripeButtonRef = React.useRef(
|
|
9414
|
+
const stripeButtonRef = React.useRef(null);
|
|
9452
9415
|
const stripePopupRef = React.useRef(null);
|
|
9453
9416
|
const stripeModalRef = React.useRef(null);
|
|
9454
|
-
React.useImperativeHandle(ref, () =>
|
|
9417
|
+
React.useImperativeHandle(ref, () => ({
|
|
9418
|
+
get nativeElement() {
|
|
9419
|
+
return stripeButtonRef.current?.nativeElement || null;
|
|
9420
|
+
},
|
|
9421
|
+
openPopup: (options) => {
|
|
9422
|
+
stripePopupRef.current?.open(options);
|
|
9423
|
+
},
|
|
9424
|
+
closePopup: () => {
|
|
9425
|
+
stripePopupRef.current?.close();
|
|
9426
|
+
},
|
|
9427
|
+
openModal: (options) => {
|
|
9428
|
+
stripeModalRef.current?.open(options);
|
|
9429
|
+
},
|
|
9430
|
+
closeModal: () => {
|
|
9431
|
+
stripeModalRef.current?.close();
|
|
9432
|
+
},
|
|
9433
|
+
current: stripeButtonRef.current,
|
|
9434
|
+
}));
|
|
9455
9435
|
const handlePayCreateOrder = React.useCallback(async () => {
|
|
9456
9436
|
if (createOrder) {
|
|
9457
9437
|
// 1. 业务侧创建订单,获取参数
|
|
@@ -9473,14 +9453,29 @@
|
|
|
9473
9453
|
}
|
|
9474
9454
|
else {
|
|
9475
9455
|
if (displayType === 'modal') {
|
|
9476
|
-
|
|
9456
|
+
const clientSecret = stripeModalProps?.stripeProps?.clientSecret;
|
|
9457
|
+
const stripeKey = stripeModalProps?.stripeProps?.stripeKey;
|
|
9458
|
+
if (clientSecret && stripeKey) {
|
|
9459
|
+
stripeModalRef?.current?.open();
|
|
9460
|
+
}
|
|
9477
9461
|
}
|
|
9478
9462
|
else {
|
|
9479
|
-
|
|
9463
|
+
const clientSecret = stripePopupProps?.stripeProps?.clientSecret;
|
|
9464
|
+
const stripeKey = stripePopupProps?.stripeProps?.stripeKey;
|
|
9465
|
+
if (clientSecret && stripeKey) {
|
|
9466
|
+
stripePopupRef?.current?.open();
|
|
9467
|
+
}
|
|
9480
9468
|
}
|
|
9481
9469
|
}
|
|
9482
9470
|
onClick?.(e);
|
|
9483
|
-
}, [
|
|
9471
|
+
}, [
|
|
9472
|
+
onClick,
|
|
9473
|
+
createOrder,
|
|
9474
|
+
handlePayCreateOrder,
|
|
9475
|
+
displayType,
|
|
9476
|
+
stripeModalProps,
|
|
9477
|
+
stripePopupProps,
|
|
9478
|
+
]);
|
|
9484
9479
|
return (jsxRuntimeExports.jsxs(React.Fragment, { children: [jsxRuntimeExports.jsx(Button, { ref: stripeButtonRef, onClick: handleClick, ...others, children: children }), displayType === 'popup' && (jsxRuntimeExports.jsx(StripePopup$1, { ref: stripePopupRef, ...stripePopupProps })), displayType === 'modal' && (jsxRuntimeExports.jsx(StripeModal$1, { ref: stripeModalRef, ...stripeModalProps }))] }));
|
|
9485
9480
|
});
|
|
9486
9481
|
StripeButton.displayName = 'StripeButton';
|
|
@@ -9627,14 +9622,38 @@
|
|
|
9627
9622
|
|
|
9628
9623
|
const AirwallexButton = React.forwardRef((props, ref) => {
|
|
9629
9624
|
const { children = 'Airwallex', onClick, createOrder, ...others } = props;
|
|
9630
|
-
const airwallexButtonRef = React.useRef(
|
|
9631
|
-
nativeElement: null,
|
|
9632
|
-
});
|
|
9625
|
+
const airwallexButtonRef = React.useRef(null);
|
|
9633
9626
|
const airwallexPopupRef = React.useRef(null);
|
|
9634
9627
|
const airwallexModalRef = React.useRef(null);
|
|
9635
9628
|
const [showMask, setShowMask] = React.useState(false);
|
|
9636
9629
|
const [airwallexUrl, setAirwallexUrl] = React.useState();
|
|
9637
|
-
React.useImperativeHandle(ref, () =>
|
|
9630
|
+
React.useImperativeHandle(ref, () => ({
|
|
9631
|
+
get nativeElement() {
|
|
9632
|
+
return airwallexButtonRef.current?.nativeElement || null;
|
|
9633
|
+
},
|
|
9634
|
+
openModal: (options) => {
|
|
9635
|
+
airwallexModalRef.current?.open(options);
|
|
9636
|
+
},
|
|
9637
|
+
closeModal: () => {
|
|
9638
|
+
airwallexModalRef.current?.close();
|
|
9639
|
+
},
|
|
9640
|
+
openPopup: (options) => {
|
|
9641
|
+
airwallexPopupRef.current?.open(options);
|
|
9642
|
+
},
|
|
9643
|
+
closePopup: () => {
|
|
9644
|
+
airwallexPopupRef.current?.close();
|
|
9645
|
+
},
|
|
9646
|
+
openPayment: (options) => {
|
|
9647
|
+
if (options) {
|
|
9648
|
+
setAirwallexUrl(options.airwallexUrl);
|
|
9649
|
+
setShowMask(true);
|
|
9650
|
+
}
|
|
9651
|
+
},
|
|
9652
|
+
closePayment: () => {
|
|
9653
|
+
setShowMask(false);
|
|
9654
|
+
},
|
|
9655
|
+
current: airwallexButtonRef.current,
|
|
9656
|
+
}));
|
|
9638
9657
|
const handlePayCreateOrder = React.useCallback(async () => {
|
|
9639
9658
|
if (createOrder) {
|
|
9640
9659
|
// 1. 业务侧创建订单,获取参数
|
|
@@ -9663,10 +9682,14 @@
|
|
|
9663
9682
|
}
|
|
9664
9683
|
if (props?.payMode === 'embedded') {
|
|
9665
9684
|
if (props?.displayType === 'modal') {
|
|
9666
|
-
|
|
9685
|
+
if (props?.modalProps?.airwallexProps?.initOptions) {
|
|
9686
|
+
airwallexModalRef?.current?.open();
|
|
9687
|
+
}
|
|
9667
9688
|
}
|
|
9668
9689
|
else {
|
|
9669
|
-
|
|
9690
|
+
if (props?.popupProps?.airwallexProps?.initOptions) {
|
|
9691
|
+
airwallexPopupRef?.current?.open();
|
|
9692
|
+
}
|
|
9670
9693
|
}
|
|
9671
9694
|
return;
|
|
9672
9695
|
}
|
|
@@ -9699,10 +9722,24 @@
|
|
|
9699
9722
|
const PayssionButton = React.forwardRef((props, ref) => {
|
|
9700
9723
|
const { className, children = (jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [jsxRuntimeExports.jsx(IconPayssionPay, {}), "Payssion"] })), onClick, payssionUrl: propsPayssionUrl, createOrder, maskProps, ...others } = props;
|
|
9701
9724
|
const { onClose, ...restMaskProps } = maskProps || {};
|
|
9702
|
-
const payssionButtonRef = React.useRef(
|
|
9725
|
+
const payssionButtonRef = React.useRef(null);
|
|
9703
9726
|
const [showMask, setShowMask] = React.useState(false);
|
|
9704
9727
|
const [payssionUrl, setPayssionUrl] = React.useState();
|
|
9705
|
-
React.useImperativeHandle(ref, () =>
|
|
9728
|
+
React.useImperativeHandle(ref, () => ({
|
|
9729
|
+
get nativeElement() {
|
|
9730
|
+
return payssionButtonRef.current?.nativeElement || null;
|
|
9731
|
+
},
|
|
9732
|
+
openPayment: (options) => {
|
|
9733
|
+
if (options) {
|
|
9734
|
+
setPayssionUrl(options.payssionUrl);
|
|
9735
|
+
setShowMask(true);
|
|
9736
|
+
}
|
|
9737
|
+
},
|
|
9738
|
+
closePayment: () => {
|
|
9739
|
+
setShowMask(false);
|
|
9740
|
+
},
|
|
9741
|
+
current: payssionButtonRef.current,
|
|
9742
|
+
}));
|
|
9706
9743
|
const handlePayCreateOrder = React.useCallback(async () => {
|
|
9707
9744
|
if (createOrder) {
|
|
9708
9745
|
// 1. 业务侧创建订单,获取参数
|
|
@@ -10058,9 +10095,20 @@
|
|
|
10058
10095
|
|
|
10059
10096
|
const AlipayButton = React.forwardRef((props, ref) => {
|
|
10060
10097
|
const { className, children = (jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [jsxRuntimeExports.jsx(IconAlipay, {}), "\u652F\u4ED8\u5B9D\u652F\u4ED8"] })), onClick, createOrder, modalProps, ...others } = props;
|
|
10061
|
-
const alipayButtonRef = React.useRef(
|
|
10098
|
+
const alipayButtonRef = React.useRef(null);
|
|
10062
10099
|
const alipayModalRef = React.useRef(null);
|
|
10063
|
-
React.useImperativeHandle(ref, () =>
|
|
10100
|
+
React.useImperativeHandle(ref, () => ({
|
|
10101
|
+
get nativeElement() {
|
|
10102
|
+
return alipayButtonRef.current?.nativeElement || null;
|
|
10103
|
+
},
|
|
10104
|
+
openModal: (options) => {
|
|
10105
|
+
alipayModalRef.current?.open(options);
|
|
10106
|
+
},
|
|
10107
|
+
closeModal: () => {
|
|
10108
|
+
alipayModalRef.current?.close();
|
|
10109
|
+
},
|
|
10110
|
+
current: alipayButtonRef.current,
|
|
10111
|
+
}));
|
|
10064
10112
|
const handlePayCreateOrder = React.useCallback(async () => {
|
|
10065
10113
|
if (createOrder) {
|
|
10066
10114
|
const options = await createOrder();
|
|
@@ -10073,11 +10121,11 @@
|
|
|
10073
10121
|
if (createOrder) {
|
|
10074
10122
|
handlePayCreateOrder();
|
|
10075
10123
|
}
|
|
10076
|
-
else {
|
|
10124
|
+
else if (modalProps?.alipayProps?.formHtml) {
|
|
10077
10125
|
alipayModalRef?.current?.open();
|
|
10078
10126
|
}
|
|
10079
10127
|
onClick?.(e);
|
|
10080
|
-
}, [onClick, createOrder, handlePayCreateOrder]);
|
|
10128
|
+
}, [onClick, createOrder, handlePayCreateOrder, modalProps]);
|
|
10081
10129
|
return (jsxRuntimeExports.jsxs(React.Fragment, { children: [jsxRuntimeExports.jsx(Button, { ref: alipayButtonRef, className: cs(getPrefixCls('alipay-btn'), className), onClick: handleClick, ...others, children: children }), jsxRuntimeExports.jsx(AlipayModal$1, { ref: alipayModalRef, ...modalProps })] }));
|
|
10082
10130
|
});
|
|
10083
10131
|
AlipayButton.displayName = 'AlipayButton';
|
|
@@ -16465,9 +16513,20 @@
|
|
|
16465
16513
|
|
|
16466
16514
|
const WechatButton = React.forwardRef((props, ref) => {
|
|
16467
16515
|
const { className, children = (jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [jsxRuntimeExports.jsx(IconWechatPay, {}), "\u5FAE\u4FE1\u652F\u4ED8"] })), onClick, createOrder, modalProps, ...others } = props;
|
|
16468
|
-
const wechatButtonRef = React.useRef(
|
|
16516
|
+
const wechatButtonRef = React.useRef(null);
|
|
16469
16517
|
const wechatModalRef = React.useRef(null);
|
|
16470
|
-
React.useImperativeHandle(ref, () =>
|
|
16518
|
+
React.useImperativeHandle(ref, () => ({
|
|
16519
|
+
get nativeElement() {
|
|
16520
|
+
return wechatButtonRef.current?.nativeElement || null;
|
|
16521
|
+
},
|
|
16522
|
+
openModal: (options) => {
|
|
16523
|
+
wechatModalRef.current?.open(options);
|
|
16524
|
+
},
|
|
16525
|
+
closeModal: () => {
|
|
16526
|
+
wechatModalRef.current?.close();
|
|
16527
|
+
},
|
|
16528
|
+
current: wechatButtonRef.current,
|
|
16529
|
+
}));
|
|
16471
16530
|
const handlePayCreateOrder = React.useCallback(async () => {
|
|
16472
16531
|
if (createOrder) {
|
|
16473
16532
|
const options = await createOrder();
|
|
@@ -16478,11 +16537,11 @@
|
|
|
16478
16537
|
if (createOrder) {
|
|
16479
16538
|
handlePayCreateOrder();
|
|
16480
16539
|
}
|
|
16481
|
-
else {
|
|
16540
|
+
else if (modalProps?.wechatProps?.wechatUrl) {
|
|
16482
16541
|
wechatModalRef?.current?.open();
|
|
16483
16542
|
}
|
|
16484
16543
|
onClick?.(e);
|
|
16485
|
-
}, [onClick, createOrder, handlePayCreateOrder]);
|
|
16544
|
+
}, [onClick, createOrder, handlePayCreateOrder, modalProps]);
|
|
16486
16545
|
return (jsxRuntimeExports.jsxs(React.Fragment, { children: [jsxRuntimeExports.jsx(Button, { ref: wechatButtonRef, className: cs(getPrefixCls('wechat-btn'), className), onClick: handleClick, ...others, children: children }), jsxRuntimeExports.jsx(WechatModal$1, { ref: wechatModalRef, ...modalProps })] }));
|
|
16487
16546
|
});
|
|
16488
16547
|
WechatButton.displayName = 'WechatButton';
|
|
@@ -16493,31 +16552,33 @@
|
|
|
16493
16552
|
WechatComponent.Modal = WechatModal$1;
|
|
16494
16553
|
|
|
16495
16554
|
const PayButton = React.forwardRef((props, ref) => {
|
|
16555
|
+
// 使用类型断言来确保 ref 类型正确
|
|
16556
|
+
const typedRef = ref;
|
|
16496
16557
|
if (props.payMethod === exports.PaymentMethod.PaypalH5 ||
|
|
16497
16558
|
props.payMethod === exports.PaymentMethod.PaypalPc) {
|
|
16498
|
-
return jsxRuntimeExports.jsx(PaypalButton$1, { ref:
|
|
16559
|
+
return (jsxRuntimeExports.jsx(PaypalButton$1, { ref: typedRef, ...props }));
|
|
16499
16560
|
}
|
|
16500
16561
|
if (props.payMethod === exports.PaymentMethod.StripeH5 ||
|
|
16501
16562
|
props.payMethod === exports.PaymentMethod.StripePc) {
|
|
16502
|
-
return jsxRuntimeExports.jsx(StripeComponent.Button, { ref:
|
|
16563
|
+
return (jsxRuntimeExports.jsx(StripeComponent.Button, { ref: typedRef, ...props }));
|
|
16503
16564
|
}
|
|
16504
16565
|
if (props.payMethod === exports.PaymentMethod.Airwallex) {
|
|
16505
|
-
return jsxRuntimeExports.jsx(AirwallexComponent.Button, { ref:
|
|
16566
|
+
return (jsxRuntimeExports.jsx(AirwallexComponent.Button, { ref: typedRef, ...props }));
|
|
16506
16567
|
}
|
|
16507
16568
|
if (props.payMethod === exports.PaymentMethod.Payssion) {
|
|
16508
|
-
return jsxRuntimeExports.jsx(PayssionButton$1, { ref:
|
|
16569
|
+
return (jsxRuntimeExports.jsx(PayssionButton$1, { ref: typedRef, ...props }));
|
|
16509
16570
|
}
|
|
16510
16571
|
if (props.payMethod === exports.PaymentMethod.WechatH5) {
|
|
16511
|
-
return jsxRuntimeExports.jsx(MWechatButton$1, { ref:
|
|
16572
|
+
return (jsxRuntimeExports.jsx(MWechatButton$1, { ref: typedRef, ...props }));
|
|
16512
16573
|
}
|
|
16513
16574
|
if (props.payMethod === exports.PaymentMethod.AlipayH5) {
|
|
16514
|
-
return jsxRuntimeExports.jsx(MAlipayComponent.Button, { ref:
|
|
16575
|
+
return (jsxRuntimeExports.jsx(MAlipayComponent.Button, { ref: typedRef, ...props }));
|
|
16515
16576
|
}
|
|
16516
16577
|
if (props.payMethod === exports.PaymentMethod.AlipayPc) {
|
|
16517
|
-
return jsxRuntimeExports.jsx(AlipayComponent.Button, { ref:
|
|
16578
|
+
return (jsxRuntimeExports.jsx(AlipayComponent.Button, { ref: typedRef, ...props }));
|
|
16518
16579
|
}
|
|
16519
16580
|
if (props.payMethod === exports.PaymentMethod.WechatPc) {
|
|
16520
|
-
return jsxRuntimeExports.jsx(WechatComponent.Button, { ref:
|
|
16581
|
+
return (jsxRuntimeExports.jsx(WechatComponent.Button, { ref: typedRef, ...props }));
|
|
16521
16582
|
}
|
|
16522
16583
|
return null;
|
|
16523
16584
|
});
|