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
|
@@ -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
|
-
pollingTimerRef.current = null;
|
|
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);
|
|
5568
5545
|
}
|
|
5569
|
-
|
|
5570
|
-
|
|
5571
|
-
|
|
5572
|
-
|
|
5573
|
-
|
|
5574
|
-
|
|
5575
|
-
|
|
5576
|
-
pollingTimerRef.current = null;
|
|
5577
|
-
}
|
|
5578
|
-
}, []);
|
|
5546
|
+
setShowMask(true);
|
|
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. 业务侧创建订单,获取参数
|
|
@@ -9627,14 +9607,38 @@
|
|
|
9627
9607
|
|
|
9628
9608
|
const AirwallexButton = React.forwardRef((props, ref) => {
|
|
9629
9609
|
const { children = 'Airwallex', onClick, createOrder, ...others } = props;
|
|
9630
|
-
const airwallexButtonRef = React.useRef(
|
|
9631
|
-
nativeElement: null,
|
|
9632
|
-
});
|
|
9610
|
+
const airwallexButtonRef = React.useRef(null);
|
|
9633
9611
|
const airwallexPopupRef = React.useRef(null);
|
|
9634
9612
|
const airwallexModalRef = React.useRef(null);
|
|
9635
9613
|
const [showMask, setShowMask] = React.useState(false);
|
|
9636
9614
|
const [airwallexUrl, setAirwallexUrl] = React.useState();
|
|
9637
|
-
React.useImperativeHandle(ref, () =>
|
|
9615
|
+
React.useImperativeHandle(ref, () => ({
|
|
9616
|
+
get nativeElement() {
|
|
9617
|
+
return airwallexButtonRef.current?.nativeElement || null;
|
|
9618
|
+
},
|
|
9619
|
+
openModal: (options) => {
|
|
9620
|
+
airwallexModalRef.current?.open(options);
|
|
9621
|
+
},
|
|
9622
|
+
closeModal: () => {
|
|
9623
|
+
airwallexModalRef.current?.close();
|
|
9624
|
+
},
|
|
9625
|
+
openPopup: (options) => {
|
|
9626
|
+
airwallexPopupRef.current?.open(options);
|
|
9627
|
+
},
|
|
9628
|
+
closePopup: () => {
|
|
9629
|
+
airwallexPopupRef.current?.close();
|
|
9630
|
+
},
|
|
9631
|
+
openPayment: (options) => {
|
|
9632
|
+
if (options) {
|
|
9633
|
+
setAirwallexUrl(options.airwallexUrl);
|
|
9634
|
+
}
|
|
9635
|
+
setShowMask(true);
|
|
9636
|
+
},
|
|
9637
|
+
closePayment: () => {
|
|
9638
|
+
setShowMask(false);
|
|
9639
|
+
},
|
|
9640
|
+
current: airwallexButtonRef.current,
|
|
9641
|
+
}));
|
|
9638
9642
|
const handlePayCreateOrder = React.useCallback(async () => {
|
|
9639
9643
|
if (createOrder) {
|
|
9640
9644
|
// 1. 业务侧创建订单,获取参数
|
|
@@ -9699,10 +9703,24 @@
|
|
|
9699
9703
|
const PayssionButton = React.forwardRef((props, ref) => {
|
|
9700
9704
|
const { className, children = (jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [jsxRuntimeExports.jsx(IconPayssionPay, {}), "Payssion"] })), onClick, payssionUrl: propsPayssionUrl, createOrder, maskProps, ...others } = props;
|
|
9701
9705
|
const { onClose, ...restMaskProps } = maskProps || {};
|
|
9702
|
-
const payssionButtonRef = React.useRef(
|
|
9706
|
+
const payssionButtonRef = React.useRef(null);
|
|
9703
9707
|
const [showMask, setShowMask] = React.useState(false);
|
|
9704
9708
|
const [payssionUrl, setPayssionUrl] = React.useState();
|
|
9705
|
-
React.useImperativeHandle(ref, () =>
|
|
9709
|
+
React.useImperativeHandle(ref, () => ({
|
|
9710
|
+
get nativeElement() {
|
|
9711
|
+
return payssionButtonRef.current?.nativeElement || null;
|
|
9712
|
+
},
|
|
9713
|
+
openPayment: (options) => {
|
|
9714
|
+
if (options) {
|
|
9715
|
+
setPayssionUrl(options.payssionUrl);
|
|
9716
|
+
}
|
|
9717
|
+
setShowMask(true);
|
|
9718
|
+
},
|
|
9719
|
+
closePayment: () => {
|
|
9720
|
+
setShowMask(false);
|
|
9721
|
+
},
|
|
9722
|
+
current: payssionButtonRef.current,
|
|
9723
|
+
}));
|
|
9706
9724
|
const handlePayCreateOrder = React.useCallback(async () => {
|
|
9707
9725
|
if (createOrder) {
|
|
9708
9726
|
// 1. 业务侧创建订单,获取参数
|
|
@@ -10058,9 +10076,20 @@
|
|
|
10058
10076
|
|
|
10059
10077
|
const AlipayButton = React.forwardRef((props, ref) => {
|
|
10060
10078
|
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(
|
|
10079
|
+
const alipayButtonRef = React.useRef(null);
|
|
10062
10080
|
const alipayModalRef = React.useRef(null);
|
|
10063
|
-
React.useImperativeHandle(ref, () =>
|
|
10081
|
+
React.useImperativeHandle(ref, () => ({
|
|
10082
|
+
get nativeElement() {
|
|
10083
|
+
return alipayButtonRef.current?.nativeElement || null;
|
|
10084
|
+
},
|
|
10085
|
+
openModal: (options) => {
|
|
10086
|
+
alipayModalRef.current?.open(options);
|
|
10087
|
+
},
|
|
10088
|
+
closeModal: () => {
|
|
10089
|
+
alipayModalRef.current?.close();
|
|
10090
|
+
},
|
|
10091
|
+
current: alipayButtonRef.current,
|
|
10092
|
+
}));
|
|
10064
10093
|
const handlePayCreateOrder = React.useCallback(async () => {
|
|
10065
10094
|
if (createOrder) {
|
|
10066
10095
|
const options = await createOrder();
|
|
@@ -16465,9 +16494,20 @@
|
|
|
16465
16494
|
|
|
16466
16495
|
const WechatButton = React.forwardRef((props, ref) => {
|
|
16467
16496
|
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(
|
|
16497
|
+
const wechatButtonRef = React.useRef(null);
|
|
16469
16498
|
const wechatModalRef = React.useRef(null);
|
|
16470
|
-
React.useImperativeHandle(ref, () =>
|
|
16499
|
+
React.useImperativeHandle(ref, () => ({
|
|
16500
|
+
get nativeElement() {
|
|
16501
|
+
return wechatButtonRef.current?.nativeElement || null;
|
|
16502
|
+
},
|
|
16503
|
+
openModal: (options) => {
|
|
16504
|
+
wechatModalRef.current?.open(options);
|
|
16505
|
+
},
|
|
16506
|
+
closeModal: () => {
|
|
16507
|
+
wechatModalRef.current?.close();
|
|
16508
|
+
},
|
|
16509
|
+
current: wechatButtonRef.current,
|
|
16510
|
+
}));
|
|
16471
16511
|
const handlePayCreateOrder = React.useCallback(async () => {
|
|
16472
16512
|
if (createOrder) {
|
|
16473
16513
|
const options = await createOrder();
|
|
@@ -16493,31 +16533,33 @@
|
|
|
16493
16533
|
WechatComponent.Modal = WechatModal$1;
|
|
16494
16534
|
|
|
16495
16535
|
const PayButton = React.forwardRef((props, ref) => {
|
|
16536
|
+
// 使用类型断言来确保 ref 类型正确
|
|
16537
|
+
const typedRef = ref;
|
|
16496
16538
|
if (props.payMethod === exports.PaymentMethod.PaypalH5 ||
|
|
16497
16539
|
props.payMethod === exports.PaymentMethod.PaypalPc) {
|
|
16498
|
-
return jsxRuntimeExports.jsx(PaypalButton$1, { ref:
|
|
16540
|
+
return (jsxRuntimeExports.jsx(PaypalButton$1, { ref: typedRef, ...props }));
|
|
16499
16541
|
}
|
|
16500
16542
|
if (props.payMethod === exports.PaymentMethod.StripeH5 ||
|
|
16501
16543
|
props.payMethod === exports.PaymentMethod.StripePc) {
|
|
16502
|
-
return jsxRuntimeExports.jsx(StripeComponent.Button, { ref:
|
|
16544
|
+
return (jsxRuntimeExports.jsx(StripeComponent.Button, { ref: typedRef, ...props }));
|
|
16503
16545
|
}
|
|
16504
16546
|
if (props.payMethod === exports.PaymentMethod.Airwallex) {
|
|
16505
|
-
return jsxRuntimeExports.jsx(AirwallexComponent.Button, { ref:
|
|
16547
|
+
return (jsxRuntimeExports.jsx(AirwallexComponent.Button, { ref: typedRef, ...props }));
|
|
16506
16548
|
}
|
|
16507
16549
|
if (props.payMethod === exports.PaymentMethod.Payssion) {
|
|
16508
|
-
return jsxRuntimeExports.jsx(PayssionButton$1, { ref:
|
|
16550
|
+
return (jsxRuntimeExports.jsx(PayssionButton$1, { ref: typedRef, ...props }));
|
|
16509
16551
|
}
|
|
16510
16552
|
if (props.payMethod === exports.PaymentMethod.WechatH5) {
|
|
16511
|
-
return jsxRuntimeExports.jsx(MWechatButton$1, { ref:
|
|
16553
|
+
return (jsxRuntimeExports.jsx(MWechatButton$1, { ref: typedRef, ...props }));
|
|
16512
16554
|
}
|
|
16513
16555
|
if (props.payMethod === exports.PaymentMethod.AlipayH5) {
|
|
16514
|
-
return jsxRuntimeExports.jsx(MAlipayComponent.Button, { ref:
|
|
16556
|
+
return (jsxRuntimeExports.jsx(MAlipayComponent.Button, { ref: typedRef, ...props }));
|
|
16515
16557
|
}
|
|
16516
16558
|
if (props.payMethod === exports.PaymentMethod.AlipayPc) {
|
|
16517
|
-
return jsxRuntimeExports.jsx(AlipayComponent.Button, { ref:
|
|
16559
|
+
return (jsxRuntimeExports.jsx(AlipayComponent.Button, { ref: typedRef, ...props }));
|
|
16518
16560
|
}
|
|
16519
16561
|
if (props.payMethod === exports.PaymentMethod.WechatPc) {
|
|
16520
|
-
return jsxRuntimeExports.jsx(WechatComponent.Button, { ref:
|
|
16562
|
+
return (jsxRuntimeExports.jsx(WechatComponent.Button, { ref: typedRef, ...props }));
|
|
16521
16563
|
}
|
|
16522
16564
|
return null;
|
|
16523
16565
|
});
|