pay-sdk-react 1.1.13 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +465 -84
- package/README.zh-CN.md +466 -85
- package/dist/css/index.css +86 -6
- package/dist/css/index.min.css +1 -1
- package/dist/es/Airwallex/airwallex-button.js +48 -16
- package/dist/es/Airwallex/airwallex-checkout-button.d.ts +4 -0
- package/dist/es/Airwallex/airwallex-checkout-button.js +73 -0
- package/dist/es/Airwallex/airwallex-managed.d.ts +4 -0
- package/dist/es/Airwallex/airwallex-managed.js +87 -0
- package/dist/es/Airwallex/airwallex-modal.js +7 -3
- package/dist/es/Airwallex/airwallex-popup.js +7 -3
- package/dist/es/Airwallex/airwallex.d.ts +1 -3
- package/dist/es/Airwallex/airwallex.js +10 -1
- package/dist/es/Airwallex/hooks/useAirwallexCheckout.d.ts +7 -0
- package/dist/es/Airwallex/hooks/useAirwallexCheckout.js +155 -0
- package/dist/es/Airwallex/index.d.ts +4 -0
- package/dist/es/Airwallex/index.js +5 -1
- package/dist/es/Airwallex/interface.d.ts +146 -0
- package/dist/es/Airwallex/style/index.css +2 -2
- package/dist/es/Airwallex/style/index.min.css +1 -1
- package/dist/es/Alipay/alipay-button.js +26 -7
- package/dist/es/Alipay/alipay.js +39 -12
- package/dist/es/Alipay/interface.d.ts +26 -1
- package/dist/es/Alipay/style/index.css +2 -2
- package/dist/es/Alipay/style/index.min.css +1 -1
- package/dist/es/MAlipay/style/index.css +2 -2
- package/dist/es/MAlipay/style/index.min.css +1 -1
- package/dist/es/MPix/index.d.ts +2 -0
- package/dist/es/MPix/index.js +2 -0
- package/dist/es/MPix/interface.d.ts +44 -0
- package/dist/es/MPix/interface.js +1 -0
- package/dist/es/MPix/m-pix-button.d.ts +6 -0
- package/dist/es/MPix/m-pix-button.js +159 -0
- package/dist/es/MPix/style/index.css +256 -0
- package/dist/es/MPix/style/index.d.ts +1 -0
- package/dist/es/MPix/style/index.js +1 -0
- package/dist/es/MPix/style/index.min.css +1 -0
- package/dist/es/MWeChat/style/index.css +2 -2
- package/dist/es/MWeChat/style/index.min.css +1 -1
- package/dist/es/PayButton/index.js +12 -0
- package/dist/es/PayButton/interface.d.ts +28 -2
- package/dist/es/Paypal/index.d.ts +2 -0
- package/dist/es/Paypal/index.js +3 -1
- package/dist/es/Paypal/interface.d.ts +40 -0
- package/dist/es/Paypal/paypal-button.js +24 -3
- package/dist/es/Paypal/paypal-smart-button.d.ts +4 -0
- package/dist/es/Paypal/paypal-smart-button.js +48 -0
- package/dist/es/Payssion/interface.d.ts +7 -0
- package/dist/es/Payssion/payssion-button.js +25 -4
- package/dist/es/Pix/index.d.ts +11 -0
- package/dist/es/Pix/index.js +10 -0
- package/dist/es/Pix/interface.d.ts +147 -0
- package/dist/es/Pix/interface.js +1 -0
- package/dist/es/Pix/pix-button.d.ts +6 -0
- package/dist/es/Pix/pix-button.js +99 -0
- package/dist/es/Pix/pix-enhanced.d.ts +4 -0
- package/dist/es/Pix/pix-enhanced.js +182 -0
- package/dist/es/Pix/pix-modal.d.ts +6 -0
- package/dist/es/Pix/pix-modal.js +57 -0
- package/dist/es/Pix/pix.d.ts +4 -0
- package/dist/es/Pix/pix.js +125 -0
- package/dist/es/Pix/style/index.css +80 -0
- package/dist/es/Pix/style/index.d.ts +1 -0
- package/dist/es/Pix/style/index.js +1 -0
- package/dist/es/Pix/style/index.min.css +1 -0
- package/dist/es/Stripe/hooks/useStripeCheckout.d.ts +7 -0
- package/dist/es/Stripe/hooks/useStripeCheckout.js +86 -0
- package/dist/es/Stripe/index.d.ts +4 -0
- package/dist/es/Stripe/index.js +5 -1
- package/dist/es/Stripe/interface.d.ts +120 -0
- package/dist/es/Stripe/stripe-button.js +32 -10
- package/dist/es/Stripe/stripe-checkout-button.d.ts +4 -0
- package/dist/es/Stripe/stripe-checkout-button.js +70 -0
- package/dist/es/Stripe/stripe-modal.js +19 -2
- package/dist/es/Stripe/stripe-popup.js +13 -2
- package/dist/es/Stripe/stripe.js +38 -4
- package/dist/es/Stripe/style/index.css +2 -2
- package/dist/es/Stripe/style/index.min.css +1 -1
- package/dist/es/Wechat/interface.d.ts +13 -0
- package/dist/es/Wechat/style/index.css +2 -2
- package/dist/es/Wechat/style/index.min.css +1 -1
- package/dist/es/Wechat/wechat-button.js +26 -7
- package/dist/es/Wechat/wechat-content.d.ts +4 -0
- package/dist/es/Wechat/wechat-content.js +61 -0
- package/dist/es/Wechat/wechat.d.ts +1 -1
- package/dist/es/Wechat/wechat.js +5 -1
- package/dist/es/confirm-modal/style/index.css +2 -2
- package/dist/es/confirm-modal/style/index.min.css +1 -1
- package/dist/es/hooks/useLatestCallback.d.ts +1 -0
- package/dist/es/hooks/useLatestCallback.js +8 -0
- package/dist/es/hooks/useManagedOrder.d.ts +8 -0
- package/dist/es/hooks/useManagedOrder.js +67 -0
- package/dist/es/hooks/usePaymentExecution.d.ts +13 -0
- package/dist/es/hooks/usePaymentExecution.js +176 -0
- package/dist/es/hooks/usePaymentQr.d.ts +6 -0
- package/dist/es/hooks/usePaymentQr.js +52 -0
- package/dist/es/hooks/usePaymentRedirect.d.ts +5 -0
- package/dist/es/hooks/usePaymentRedirect.js +83 -0
- package/dist/es/icons/IconCheck/index.d.ts +4 -0
- package/dist/es/icons/IconCheck/index.js +22 -0
- package/dist/es/icons/IconCopy/index.d.ts +4 -0
- package/dist/es/icons/IconCopy/index.js +27 -0
- package/dist/es/icons/IconPix/index.d.ts +4 -0
- package/dist/es/icons/IconPix/index.js +33 -0
- package/dist/es/icons/index.d.ts +3 -0
- package/dist/es/icons/index.js +4 -1
- package/dist/es/index.d.ts +50 -6
- package/dist/es/index.js +28 -1
- package/dist/es/pay-modal/interface.d.ts +22 -2
- package/dist/es/pay-modal/pay-modal.js +36 -16
- package/dist/es/pay-modal/style/index.css +2 -2
- package/dist/es/pay-modal/style/index.min.css +1 -1
- package/dist/es/shared/entitys/payment.d.ts +227 -0
- package/dist/es/shared/entitys/payment.js +75 -0
- package/dist/es/shared/enums/index.d.ts +1 -78
- package/dist/es/shared/enums/index.js +1 -81
- package/dist/es/shared/enums/payment.d.ts +162 -0
- package/dist/es/shared/enums/payment.js +168 -0
- package/dist/es/shared/index.d.ts +2 -0
- package/dist/es/shared/index.js +2 -1
- package/dist/lib/Airwallex/airwallex-button.js +31 -10
- package/dist/lib/Airwallex/airwallex-checkout-button.js +52 -0
- package/dist/lib/Airwallex/airwallex-managed.js +86 -0
- package/dist/lib/Airwallex/airwallex-modal.js +4 -2
- package/dist/lib/Airwallex/airwallex-popup.js +4 -2
- package/dist/lib/Airwallex/airwallex.js +9 -1
- package/dist/lib/Airwallex/hooks/useAirwallexCheckout.js +83 -0
- package/dist/lib/Airwallex/index.js +18 -1
- package/dist/lib/Airwallex/style/index.css +2 -2
- package/dist/lib/Airwallex/style/index.min.css +1 -1
- package/dist/lib/Alipay/alipay-button.js +21 -6
- package/dist/lib/Alipay/alipay.js +36 -9
- package/dist/lib/Alipay/style/index.css +2 -2
- package/dist/lib/Alipay/style/index.min.css +1 -1
- package/dist/lib/MAlipay/style/index.css +2 -2
- package/dist/lib/MAlipay/style/index.min.css +1 -1
- package/dist/lib/MPix/index.js +28 -0
- package/dist/lib/MPix/interface.js +5 -0
- package/dist/lib/MPix/m-pix-button.js +127 -0
- package/dist/lib/MPix/style/index.css +256 -0
- package/dist/lib/MPix/style/index.js +3 -0
- package/dist/lib/MPix/style/index.min.css +1 -0
- package/dist/lib/MWeChat/style/index.css +2 -2
- package/dist/lib/MWeChat/style/index.min.css +1 -1
- package/dist/lib/PayButton/index.js +12 -0
- package/dist/lib/Paypal/index.js +17 -1
- package/dist/lib/Paypal/paypal-button.js +19 -2
- package/dist/lib/Paypal/paypal-smart-button.js +45 -0
- package/dist/lib/Payssion/payssion-button.js +20 -3
- package/dist/lib/Pix/index.js +43 -0
- package/dist/lib/Pix/interface.js +5 -0
- package/dist/lib/Pix/pix-button.js +83 -0
- package/dist/lib/Pix/pix-enhanced.js +143 -0
- package/dist/lib/Pix/pix-modal.js +50 -0
- package/dist/lib/Pix/pix.js +97 -0
- package/dist/lib/Pix/style/index.css +80 -0
- package/dist/lib/Pix/style/index.js +3 -0
- package/dist/lib/Pix/style/index.min.css +1 -0
- package/dist/lib/Stripe/hooks/useStripeCheckout.js +41 -0
- package/dist/lib/Stripe/index.js +18 -1
- package/dist/lib/Stripe/stripe-button.js +28 -10
- package/dist/lib/Stripe/stripe-checkout-button.js +50 -0
- package/dist/lib/Stripe/stripe-modal.js +12 -1
- package/dist/lib/Stripe/stripe-popup.js +12 -1
- package/dist/lib/Stripe/stripe.js +30 -1
- package/dist/lib/Stripe/style/index.css +2 -2
- package/dist/lib/Stripe/style/index.min.css +1 -1
- package/dist/lib/Wechat/style/index.css +2 -2
- package/dist/lib/Wechat/style/index.min.css +1 -1
- package/dist/lib/Wechat/wechat-button.js +21 -6
- package/dist/lib/Wechat/wechat-content.js +65 -0
- package/dist/lib/Wechat/wechat.js +3 -1
- package/dist/lib/confirm-modal/style/index.css +2 -2
- package/dist/lib/confirm-modal/style/index.min.css +1 -1
- package/dist/lib/hooks/useLatestCallback.js +13 -0
- package/dist/lib/hooks/useManagedOrder.js +29 -0
- package/dist/lib/hooks/usePaymentExecution.js +113 -0
- package/dist/lib/hooks/usePaymentQr.js +51 -0
- package/dist/lib/hooks/usePaymentRedirect.js +87 -0
- package/dist/lib/icons/IconCheck/index.js +27 -0
- package/dist/lib/icons/IconCopy/index.js +32 -0
- package/dist/lib/icons/IconPix/index.js +38 -0
- package/dist/lib/icons/index.js +25 -1
- package/dist/lib/index.js +86 -1
- package/dist/lib/pay-modal/pay-modal.js +33 -16
- package/dist/lib/pay-modal/style/index.css +2 -2
- package/dist/lib/pay-modal/style/index.min.css +1 -1
- package/dist/lib/shared/entitys/payment.js +61 -0
- package/dist/lib/shared/enums/index.js +11 -81
- package/dist/lib/shared/enums/payment.js +172 -0
- package/dist/lib/shared/index.js +12 -1
- package/dist/umd/pay-sdk-react.umd.js +10455 -11463
- package/dist/umd/pay-sdk-react.umd.js.map +1 -1
- package/package.json +44 -25
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
8
|
+
var _classNames = _interopRequireDefault(require("../utils/classNames"));
|
|
9
|
+
var _pixEnhanced = _interopRequireDefault(require("./pix-enhanced"));
|
|
10
|
+
var _qrcode = _interopRequireDefault(require("../utils/qrcode"));
|
|
11
|
+
var _icons = require("../icons");
|
|
12
|
+
var _getPrefixCls = require("../utils/getPrefixCls");
|
|
13
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
14
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
15
|
+
const classPrefix = (0, _getPrefixCls.getPrefixCls)('pix-qrcode');
|
|
16
|
+
const PixQrCode = ({
|
|
17
|
+
pixCode,
|
|
18
|
+
tipText = '请使用银行App扫码支付',
|
|
19
|
+
showCopyButton = true,
|
|
20
|
+
className,
|
|
21
|
+
style
|
|
22
|
+
}) => {
|
|
23
|
+
const [imageUrl, setImageUrl] = (0, _react.useState)('');
|
|
24
|
+
const [copied, setCopied] = (0, _react.useState)(false);
|
|
25
|
+
const timerRef = (0, _react.useRef)();
|
|
26
|
+
(0, _react.useEffect)(() => {
|
|
27
|
+
if (pixCode) {
|
|
28
|
+
(0, _qrcode.default)(pixCode).then(url => {
|
|
29
|
+
setImageUrl(url);
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
}, [pixCode]);
|
|
33
|
+
(0, _react.useEffect)(() => {
|
|
34
|
+
return () => {
|
|
35
|
+
if (timerRef.current) {
|
|
36
|
+
clearTimeout(timerRef.current);
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
}, []);
|
|
40
|
+
const handleCopy = (0, _react.useCallback)(async () => {
|
|
41
|
+
try {
|
|
42
|
+
await navigator.clipboard.writeText(pixCode);
|
|
43
|
+
setCopied(true);
|
|
44
|
+
if (timerRef.current) {
|
|
45
|
+
clearTimeout(timerRef.current);
|
|
46
|
+
}
|
|
47
|
+
timerRef.current = setTimeout(() => setCopied(false), 2000);
|
|
48
|
+
} catch {
|
|
49
|
+
// Fallback: use textarea for older browsers
|
|
50
|
+
const textarea = document.createElement('textarea');
|
|
51
|
+
textarea.value = pixCode;
|
|
52
|
+
textarea.style.position = 'fixed';
|
|
53
|
+
textarea.style.opacity = '0';
|
|
54
|
+
document.body.appendChild(textarea);
|
|
55
|
+
textarea.select();
|
|
56
|
+
document.execCommand('copy');
|
|
57
|
+
document.body.removeChild(textarea);
|
|
58
|
+
setCopied(true);
|
|
59
|
+
if (timerRef.current) {
|
|
60
|
+
clearTimeout(timerRef.current);
|
|
61
|
+
}
|
|
62
|
+
timerRef.current = setTimeout(() => setCopied(false), 2000);
|
|
63
|
+
}
|
|
64
|
+
}, [pixCode]);
|
|
65
|
+
if (!imageUrl) {
|
|
66
|
+
return null;
|
|
67
|
+
}
|
|
68
|
+
return /*#__PURE__*/_react.default.createElement("div", {
|
|
69
|
+
className: (0, _classNames.default)(classPrefix, className),
|
|
70
|
+
style: style
|
|
71
|
+
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
72
|
+
className: `${classPrefix}__container`
|
|
73
|
+
}, /*#__PURE__*/_react.default.createElement("img", {
|
|
74
|
+
className: `${classPrefix}__image`,
|
|
75
|
+
src: imageUrl,
|
|
76
|
+
alt: 'PIX支付二维码'
|
|
77
|
+
})), tipText && /*#__PURE__*/_react.default.createElement("span", {
|
|
78
|
+
className: `${classPrefix}__tip`
|
|
79
|
+
}, tipText), showCopyButton && /*#__PURE__*/_react.default.createElement("div", {
|
|
80
|
+
className: `${classPrefix}__code-section`
|
|
81
|
+
}, /*#__PURE__*/_react.default.createElement("button", {
|
|
82
|
+
type: "button",
|
|
83
|
+
className: (0, _classNames.default)(`${classPrefix}__copy-btn`, {
|
|
84
|
+
[`${classPrefix}__copy-btn--copied`]: copied
|
|
85
|
+
}),
|
|
86
|
+
onClick: handleCopy
|
|
87
|
+
}, copied ? /*#__PURE__*/_react.default.createElement(_icons.IconCheck, {
|
|
88
|
+
className: `${classPrefix}__copy-icon`
|
|
89
|
+
}) : /*#__PURE__*/_react.default.createElement(_icons.IconCopy, {
|
|
90
|
+
className: `${classPrefix}__copy-icon`
|
|
91
|
+
}), /*#__PURE__*/_react.default.createElement("span", null, copied ? '已复制' : '复制 PIX Code'))));
|
|
92
|
+
};
|
|
93
|
+
const PixEntry = props => {
|
|
94
|
+
const enhanced = props.qrProps !== undefined || props.showCode !== undefined || props.copyText !== undefined || props.copiedText !== undefined || props.confirmText !== undefined || props.onConfirm !== undefined || props.onCopy !== undefined || props.onCopyError !== undefined || props.actionClassNames !== undefined || props.actionStyles !== undefined;
|
|
95
|
+
return enhanced ? /*#__PURE__*/_react.default.createElement(_pixEnhanced.default, props) : /*#__PURE__*/_react.default.createElement(PixQrCode, props);
|
|
96
|
+
};
|
|
97
|
+
var _default = exports.default = /*#__PURE__*/(0, _react.memo)(PixEntry);
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
.pay-pix-qrcode {
|
|
2
|
+
display: flex;
|
|
3
|
+
flex-direction: column;
|
|
4
|
+
align-items: center;
|
|
5
|
+
}
|
|
6
|
+
.pay-pix-qrcode__container {
|
|
7
|
+
background-color: #fff;
|
|
8
|
+
border-radius: 8px;
|
|
9
|
+
display: flex;
|
|
10
|
+
justify-content: center;
|
|
11
|
+
align-items: center;
|
|
12
|
+
width: 180px;
|
|
13
|
+
height: 180px;
|
|
14
|
+
}
|
|
15
|
+
.pay-pix-qrcode__image {
|
|
16
|
+
width: 100%;
|
|
17
|
+
height: 100%;
|
|
18
|
+
object-fit: cover;
|
|
19
|
+
}
|
|
20
|
+
.pay-pix-qrcode__tip {
|
|
21
|
+
text-align: center;
|
|
22
|
+
color: #333;
|
|
23
|
+
font-size: 14px;
|
|
24
|
+
line-height: 20px;
|
|
25
|
+
margin-top: 12px;
|
|
26
|
+
}
|
|
27
|
+
.pay-pix-qrcode__code-section {
|
|
28
|
+
width: 100%;
|
|
29
|
+
max-width: 320px;
|
|
30
|
+
margin-top: 16px;
|
|
31
|
+
}
|
|
32
|
+
.pay-pix-qrcode__copy-btn {
|
|
33
|
+
width: 100%;
|
|
34
|
+
padding: 10px 16px;
|
|
35
|
+
border: 1px solid #32bcad;
|
|
36
|
+
background-color: #fff;
|
|
37
|
+
color: #32bcad;
|
|
38
|
+
border-radius: 8px;
|
|
39
|
+
font-size: 13px;
|
|
40
|
+
font-weight: 600;
|
|
41
|
+
cursor: pointer;
|
|
42
|
+
transition: all 0.2s ease;
|
|
43
|
+
display: flex;
|
|
44
|
+
align-items: center;
|
|
45
|
+
justify-content: center;
|
|
46
|
+
gap: 6px;
|
|
47
|
+
}
|
|
48
|
+
.pay-pix-qrcode__copy-btn:hover {
|
|
49
|
+
background-color: rgba(50, 188, 173, 0.06);
|
|
50
|
+
}
|
|
51
|
+
.pay-pix-qrcode__copy-btn:active {
|
|
52
|
+
background-color: rgba(50, 188, 173, 0.12);
|
|
53
|
+
}
|
|
54
|
+
.pay-pix-qrcode__copy-btn--copied {
|
|
55
|
+
color: #2ecc71;
|
|
56
|
+
border-color: #2ecc71;
|
|
57
|
+
background-color: rgba(46, 204, 113, 0.04);
|
|
58
|
+
}
|
|
59
|
+
.pay-pix-qrcode__copy-btn--copied:hover {
|
|
60
|
+
background-color: rgba(46, 204, 113, 0.08);
|
|
61
|
+
}
|
|
62
|
+
.pay-pix-qrcode__copy-btn--copied:active {
|
|
63
|
+
background-color: rgba(46, 204, 113, 0.14);
|
|
64
|
+
}
|
|
65
|
+
.pay-pix-qrcode__copy-icon {
|
|
66
|
+
width: 16px;
|
|
67
|
+
height: 16px;
|
|
68
|
+
flex-shrink: 0;
|
|
69
|
+
}
|
|
70
|
+
.pay-pix-qrcode__code {
|
|
71
|
+
display: block;
|
|
72
|
+
max-width: 100%;
|
|
73
|
+
overflow-wrap: anywhere;
|
|
74
|
+
padding: 8px;
|
|
75
|
+
}
|
|
76
|
+
.pay-pix-qrcode__confirm-btn {
|
|
77
|
+
cursor: pointer;
|
|
78
|
+
margin-top: 12px;
|
|
79
|
+
padding: 8px 16px;
|
|
80
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.pay-pix-qrcode{display:flex;flex-direction:column;align-items:center}.pay-pix-qrcode__container{background-color:#fff;border-radius:8px;display:flex;justify-content:center;align-items:center;width:180px;height:180px}.pay-pix-qrcode__image{width:100%;height:100%;object-fit:cover}.pay-pix-qrcode__tip{text-align:center;color:#333;font-size:14px;line-height:20px;margin-top:12px}.pay-pix-qrcode__code-section{width:100%;max-width:320px;margin-top:16px}.pay-pix-qrcode__copy-btn{width:100%;padding:10px 16px;border:1px solid #32bcad;background-color:#fff;color:#32bcad;border-radius:8px;font-size:13px;font-weight:600;cursor:pointer;transition:.2s;display:flex;align-items:center;justify-content:center;gap:6px}.pay-pix-qrcode__copy-btn:hover{background-color:rgba(50,188,173,.06)}.pay-pix-qrcode__copy-btn:active{background-color:rgba(50,188,173,.12)}.pay-pix-qrcode__copy-btn--copied{color:#2ecc71;border-color:#2ecc71;background-color:rgba(46,204,113,.04)}.pay-pix-qrcode__copy-btn--copied:hover{background-color:rgba(46,204,113,.08)}.pay-pix-qrcode__copy-btn--copied:active{background-color:rgba(46,204,113,.14)}.pay-pix-qrcode__copy-icon{width:16px;height:16px;flex-shrink:0}.pay-pix-qrcode__code{display:block;max-width:100%;overflow-wrap:anywhere;padding:8px}.pay-pix-qrcode__confirm-btn{cursor:pointer;margin-top:12px;padding:8px 16px}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
'use client';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.useStripeCheckout = void 0;
|
|
8
|
+
var _usePaymentExecution = require("../../hooks/usePaymentExecution");
|
|
9
|
+
var _usePaymentRedirect = require("../../hooks/usePaymentRedirect");
|
|
10
|
+
var _useLatestCallback = require("../../hooks/useLatestCallback");
|
|
11
|
+
var _enums = require("../../shared/enums");
|
|
12
|
+
var _payment = require("../../shared/entitys/payment");
|
|
13
|
+
/**
|
|
14
|
+
* @zh 打开 Stripe 托管支付页面,不自动下单。
|
|
15
|
+
* @en Open hosted Stripe checkout; no automatic order creation.
|
|
16
|
+
* @since 1.2.0
|
|
17
|
+
*/
|
|
18
|
+
const useStripeCheckout = (options = {}) => {
|
|
19
|
+
const execution = (0, _usePaymentExecution.usePaymentExecution)(options);
|
|
20
|
+
const redirect = (0, _usePaymentRedirect.usePaymentRedirect)(options.redirectOptions);
|
|
21
|
+
const openCheckout = (0, _useLatestCallback.useLatestCallback)(source => execution.run(async context => {
|
|
22
|
+
const target = typeof source === 'function' ? await source(context.signal) : source;
|
|
23
|
+
if (!context.isCurrent()) return;
|
|
24
|
+
if (target === null) {
|
|
25
|
+
execution.cancel();
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
if (!target || typeof target.url !== 'string') throw new _payment.PaymentExecutionError(_enums.PaymentErrorCode.InvalidParameters, 'A payment URL is required.');
|
|
29
|
+
redirect.open(target.url);
|
|
30
|
+
}));
|
|
31
|
+
const closeCheckout = (0, _useLatestCallback.useLatestCallback)(() => {
|
|
32
|
+
execution.cancel();
|
|
33
|
+
redirect.close();
|
|
34
|
+
});
|
|
35
|
+
return {
|
|
36
|
+
...execution,
|
|
37
|
+
openCheckout,
|
|
38
|
+
closeCheckout
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
exports.useStripeCheckout = useStripeCheckout;
|
package/dist/lib/Stripe/index.js
CHANGED
|
@@ -4,9 +4,11 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
var _exportNames = {
|
|
7
|
+
StripeCheckoutButton: true,
|
|
7
8
|
StripePopup: true,
|
|
8
9
|
StripeButton: true,
|
|
9
|
-
StripeModal: true
|
|
10
|
+
StripeModal: true,
|
|
11
|
+
useStripeCheckout: true
|
|
10
12
|
};
|
|
11
13
|
Object.defineProperty(exports, "StripeButton", {
|
|
12
14
|
enumerable: true,
|
|
@@ -14,6 +16,12 @@ Object.defineProperty(exports, "StripeButton", {
|
|
|
14
16
|
return _stripeButton.default;
|
|
15
17
|
}
|
|
16
18
|
});
|
|
19
|
+
Object.defineProperty(exports, "StripeCheckoutButton", {
|
|
20
|
+
enumerable: true,
|
|
21
|
+
get: function () {
|
|
22
|
+
return _stripeCheckoutButton.default;
|
|
23
|
+
}
|
|
24
|
+
});
|
|
17
25
|
Object.defineProperty(exports, "StripeModal", {
|
|
18
26
|
enumerable: true,
|
|
19
27
|
get: function () {
|
|
@@ -27,6 +35,13 @@ Object.defineProperty(exports, "StripePopup", {
|
|
|
27
35
|
}
|
|
28
36
|
});
|
|
29
37
|
exports.default = void 0;
|
|
38
|
+
Object.defineProperty(exports, "useStripeCheckout", {
|
|
39
|
+
enumerable: true,
|
|
40
|
+
get: function () {
|
|
41
|
+
return _useStripeCheckout.useStripeCheckout;
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
var _stripeCheckoutButton = _interopRequireDefault(require("./stripe-checkout-button"));
|
|
30
45
|
var _stripe = _interopRequireDefault(require("./stripe"));
|
|
31
46
|
var _stripePopup = _interopRequireDefault(require("./stripe-popup"));
|
|
32
47
|
var _stripeButton = _interopRequireDefault(require("./stripe-button"));
|
|
@@ -43,8 +58,10 @@ Object.keys(_interface).forEach(function (key) {
|
|
|
43
58
|
}
|
|
44
59
|
});
|
|
45
60
|
});
|
|
61
|
+
var _useStripeCheckout = require("./hooks/useStripeCheckout");
|
|
46
62
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
47
63
|
const StripeComponent = Object.assign({}, _stripe.default, {
|
|
64
|
+
CheckoutButton: _stripeCheckoutButton.default,
|
|
48
65
|
Button: _stripeButton.default,
|
|
49
66
|
Popup: _stripePopup.default,
|
|
50
67
|
Modal: _stripeModal.default
|
|
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
+
var _useManagedOrder = require("../hooks/useManagedOrder");
|
|
7
8
|
var _react = _interopRequireWildcard(require("react"));
|
|
8
9
|
var _stripePopup = _interopRequireDefault(require("./stripe-popup"));
|
|
9
10
|
var _stripeModal = _interopRequireDefault(require("./stripe-modal"));
|
|
@@ -19,6 +20,7 @@ const StripeButton = /*#__PURE__*/(0, _react.forwardRef)((props, ref) => {
|
|
|
19
20
|
stripePopupProps,
|
|
20
21
|
stripeModalProps,
|
|
21
22
|
createOrder,
|
|
23
|
+
executionOptions,
|
|
22
24
|
...others
|
|
23
25
|
} = props;
|
|
24
26
|
const stripeButtonRef = (0, _react.useRef)(null);
|
|
@@ -35,6 +37,7 @@ const StripeButton = /*#__PURE__*/(0, _react.forwardRef)((props, ref) => {
|
|
|
35
37
|
},
|
|
36
38
|
closePopup: () => {
|
|
37
39
|
var _stripePopupRef$curre2;
|
|
40
|
+
if (executionOptions) managed.cancel();
|
|
38
41
|
(_stripePopupRef$curre2 = stripePopupRef.current) === null || _stripePopupRef$curre2 === void 0 || _stripePopupRef$curre2.close();
|
|
39
42
|
},
|
|
40
43
|
openModal: options => {
|
|
@@ -43,10 +46,18 @@ const StripeButton = /*#__PURE__*/(0, _react.forwardRef)((props, ref) => {
|
|
|
43
46
|
},
|
|
44
47
|
closeModal: () => {
|
|
45
48
|
var _stripeModalRef$curre2;
|
|
49
|
+
if (executionOptions) managed.cancel();
|
|
46
50
|
(_stripeModalRef$curre2 = stripeModalRef.current) === null || _stripeModalRef$curre2 === void 0 || _stripeModalRef$curre2.close();
|
|
47
51
|
},
|
|
48
52
|
current: stripeButtonRef.current
|
|
49
53
|
}));
|
|
54
|
+
const managed = (0, _useManagedOrder.useManagedOrder)(createOrder, target => {
|
|
55
|
+
if (target.clientSecret && target.stripeKey) {
|
|
56
|
+
var _stripeModalRef$curre3, _stripePopupRef$curre3;
|
|
57
|
+
if (displayType === 'modal') (_stripeModalRef$curre3 = stripeModalRef.current) === null || _stripeModalRef$curre3 === void 0 || _stripeModalRef$curre3.open(target);else (_stripePopupRef$curre3 = stripePopupRef.current) === null || _stripePopupRef$curre3 === void 0 || _stripePopupRef$curre3.open(target);
|
|
58
|
+
}
|
|
59
|
+
}, executionOptions, target => typeof target.clientSecret === 'string' && Boolean(target.clientSecret.trim()) && typeof target.stripeKey === 'string' && Boolean(target.stripeKey.trim()));
|
|
60
|
+
const managedRun = managed.run;
|
|
50
61
|
const handlePayCreateOrder = (0, _react.useCallback)(async () => {
|
|
51
62
|
if (createOrder) {
|
|
52
63
|
// 1. 业务侧创建订单,获取参数
|
|
@@ -54,17 +65,22 @@ const StripeButton = /*#__PURE__*/(0, _react.forwardRef)((props, ref) => {
|
|
|
54
65
|
if (options !== null && options !== void 0 && options.clientSecret && options !== null && options !== void 0 && options.stripeKey) {
|
|
55
66
|
// 2. 唤起弹窗
|
|
56
67
|
if (displayType === 'modal') {
|
|
57
|
-
var _stripeModalRef$
|
|
58
|
-
(_stripeModalRef$
|
|
68
|
+
var _stripeModalRef$curre4;
|
|
69
|
+
(_stripeModalRef$curre4 = stripeModalRef.current) === null || _stripeModalRef$curre4 === void 0 || _stripeModalRef$curre4.open(options);
|
|
59
70
|
} else {
|
|
60
|
-
var _stripePopupRef$
|
|
61
|
-
(_stripePopupRef$
|
|
71
|
+
var _stripePopupRef$curre4;
|
|
72
|
+
(_stripePopupRef$curre4 = stripePopupRef.current) === null || _stripePopupRef$curre4 === void 0 || _stripePopupRef$curre4.open(options);
|
|
62
73
|
}
|
|
63
74
|
}
|
|
64
75
|
}
|
|
65
76
|
}, [createOrder, displayType]);
|
|
66
77
|
const handleClick = (0, _react.useCallback)(e => {
|
|
67
78
|
if (createOrder) {
|
|
79
|
+
if (executionOptions) {
|
|
80
|
+
onClick === null || onClick === void 0 || onClick(e);
|
|
81
|
+
if (e.defaultPrevented) return;
|
|
82
|
+
return managedRun().then(() => undefined);
|
|
83
|
+
}
|
|
68
84
|
handlePayCreateOrder();
|
|
69
85
|
} else {
|
|
70
86
|
if (displayType === 'modal') {
|
|
@@ -72,25 +88,27 @@ const StripeButton = /*#__PURE__*/(0, _react.forwardRef)((props, ref) => {
|
|
|
72
88
|
const clientSecret = stripeModalProps === null || stripeModalProps === void 0 || (_stripeModalProps$str = stripeModalProps.stripeProps) === null || _stripeModalProps$str === void 0 ? void 0 : _stripeModalProps$str.clientSecret;
|
|
73
89
|
const stripeKey = stripeModalProps === null || stripeModalProps === void 0 || (_stripeModalProps$str2 = stripeModalProps.stripeProps) === null || _stripeModalProps$str2 === void 0 ? void 0 : _stripeModalProps$str2.stripeKey;
|
|
74
90
|
if (clientSecret && stripeKey) {
|
|
75
|
-
var _stripeModalRef$
|
|
76
|
-
stripeModalRef === null || stripeModalRef === void 0 || (_stripeModalRef$
|
|
91
|
+
var _stripeModalRef$curre5;
|
|
92
|
+
stripeModalRef === null || stripeModalRef === void 0 || (_stripeModalRef$curre5 = stripeModalRef.current) === null || _stripeModalRef$curre5 === void 0 || _stripeModalRef$curre5.open();
|
|
77
93
|
}
|
|
78
94
|
} else {
|
|
79
95
|
var _stripePopupProps$str, _stripePopupProps$str2;
|
|
80
96
|
const clientSecret = stripePopupProps === null || stripePopupProps === void 0 || (_stripePopupProps$str = stripePopupProps.stripeProps) === null || _stripePopupProps$str === void 0 ? void 0 : _stripePopupProps$str.clientSecret;
|
|
81
97
|
const stripeKey = stripePopupProps === null || stripePopupProps === void 0 || (_stripePopupProps$str2 = stripePopupProps.stripeProps) === null || _stripePopupProps$str2 === void 0 ? void 0 : _stripePopupProps$str2.stripeKey;
|
|
82
98
|
if (clientSecret && stripeKey) {
|
|
83
|
-
var _stripePopupRef$
|
|
84
|
-
stripePopupRef === null || stripePopupRef === void 0 || (_stripePopupRef$
|
|
99
|
+
var _stripePopupRef$curre5;
|
|
100
|
+
stripePopupRef === null || stripePopupRef === void 0 || (_stripePopupRef$curre5 = stripePopupRef.current) === null || _stripePopupRef$curre5 === void 0 || _stripePopupRef$curre5.open();
|
|
85
101
|
}
|
|
86
102
|
}
|
|
87
103
|
}
|
|
88
104
|
onClick === null || onClick === void 0 || onClick(e);
|
|
89
|
-
}, [onClick, createOrder, handlePayCreateOrder, displayType, stripeModalProps, stripePopupProps]);
|
|
105
|
+
}, [executionOptions, managedRun, onClick, createOrder, handlePayCreateOrder, displayType, stripeModalProps, stripePopupProps]);
|
|
90
106
|
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_Button.default, _extends({
|
|
91
107
|
ref: stripeButtonRef,
|
|
92
108
|
onClick: handleClick
|
|
93
|
-
}, others
|
|
109
|
+
}, others, {
|
|
110
|
+
loading: executionOptions ? managed.loading || others.loading : others.loading
|
|
111
|
+
}), children), displayType === 'popup' && /*#__PURE__*/_react.default.createElement(_stripePopup.default, _extends({
|
|
94
112
|
ref: stripePopupRef
|
|
95
113
|
}, stripePopupProps)), displayType === 'modal' && /*#__PURE__*/_react.default.createElement(_stripeModal.default, _extends({
|
|
96
114
|
ref: stripeModalRef
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
'use client';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.default = void 0;
|
|
8
|
+
var _react = _interopRequireDefault(require("react"));
|
|
9
|
+
var _Button = _interopRequireDefault(require("../Button"));
|
|
10
|
+
var _useStripeCheckout = require("./hooks/useStripeCheckout");
|
|
11
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
12
|
+
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); }
|
|
13
|
+
/**
|
|
14
|
+
* @zh Stripe 托管支付按钮,复用 useStripeCheckout。
|
|
15
|
+
* @en Hosted Stripe button sharing useStripeCheckout.
|
|
16
|
+
* @since 1.2.0
|
|
17
|
+
*/
|
|
18
|
+
const StripeCheckoutButton = props => {
|
|
19
|
+
const {
|
|
20
|
+
url,
|
|
21
|
+
createOrder,
|
|
22
|
+
redirectOptions,
|
|
23
|
+
beforePay,
|
|
24
|
+
onLoadingChange,
|
|
25
|
+
onPaymentError,
|
|
26
|
+
onCancel,
|
|
27
|
+
children = 'Stripe',
|
|
28
|
+
onClick,
|
|
29
|
+
loading,
|
|
30
|
+
...buttonProps
|
|
31
|
+
} = props;
|
|
32
|
+
const checkout = (0, _useStripeCheckout.useStripeCheckout)({
|
|
33
|
+
redirectOptions,
|
|
34
|
+
beforePay,
|
|
35
|
+
onLoadingChange,
|
|
36
|
+
onPaymentError,
|
|
37
|
+
onCancel
|
|
38
|
+
});
|
|
39
|
+
return /*#__PURE__*/_react.default.createElement(_Button.default, _extends({}, buttonProps, {
|
|
40
|
+
loading: checkout.loading || loading,
|
|
41
|
+
onClick: async event => {
|
|
42
|
+
event.persist();
|
|
43
|
+
await (onClick === null || onClick === void 0 ? void 0 : onClick(event));
|
|
44
|
+
if (!event.defaultPrevented) await checkout.openCheckout(createOrder ?? {
|
|
45
|
+
url: url ?? ''
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
}), children);
|
|
49
|
+
};
|
|
50
|
+
var _default = exports.default = /*#__PURE__*/_react.default.memo(StripeCheckoutButton);
|
|
@@ -17,6 +17,7 @@ const StripeModal = /*#__PURE__*/_react.default.forwardRef((props, ref) => {
|
|
|
17
17
|
stripeProps: propsStripeProps,
|
|
18
18
|
visible,
|
|
19
19
|
onClose,
|
|
20
|
+
closeOnComplete = false,
|
|
20
21
|
className,
|
|
21
22
|
...rest
|
|
22
23
|
} = props;
|
|
@@ -49,7 +50,17 @@ const StripeModal = /*#__PURE__*/_react.default.forwardRef((props, ref) => {
|
|
|
49
50
|
onClose === null || onClose === void 0 || onClose();
|
|
50
51
|
},
|
|
51
52
|
footer: null
|
|
52
|
-
}, rest), _stripeProps && /*#__PURE__*/_react.default.createElement(_stripe.default, _stripeProps
|
|
53
|
+
}, rest), _stripeProps && /*#__PURE__*/_react.default.createElement(_stripe.default, _extends({}, _stripeProps, {
|
|
54
|
+
checkoutEvents: closeOnComplete ? {
|
|
55
|
+
..._stripeProps.checkoutEvents,
|
|
56
|
+
onComplete: () => {
|
|
57
|
+
var _stripeProps$checkout, _stripeProps$checkout2;
|
|
58
|
+
(_stripeProps$checkout = _stripeProps.checkoutEvents) === null || _stripeProps$checkout === void 0 || (_stripeProps$checkout2 = _stripeProps$checkout.onComplete) === null || _stripeProps$checkout2 === void 0 || _stripeProps$checkout2.call(_stripeProps$checkout);
|
|
59
|
+
if (!isControlled) setUncontrolledVisible(false);
|
|
60
|
+
onClose === null || onClose === void 0 || onClose();
|
|
61
|
+
}
|
|
62
|
+
} : _stripeProps.checkoutEvents
|
|
63
|
+
})));
|
|
53
64
|
});
|
|
54
65
|
StripeModal.displayName = 'StripeModal';
|
|
55
66
|
var _default = exports.default = /*#__PURE__*/(0, _react.memo)(StripeModal);
|
|
@@ -16,6 +16,7 @@ const StripePopup = /*#__PURE__*/_react.default.forwardRef((props, ref) => {
|
|
|
16
16
|
const {
|
|
17
17
|
visible: controlledVisible,
|
|
18
18
|
onClose,
|
|
19
|
+
closeOnComplete = false,
|
|
19
20
|
closeOnMaskClick = true,
|
|
20
21
|
className,
|
|
21
22
|
bodyStyle,
|
|
@@ -56,7 +57,17 @@ const StripePopup = /*#__PURE__*/_react.default.forwardRef((props, ref) => {
|
|
|
56
57
|
overflowY: 'scroll',
|
|
57
58
|
...bodyStyle
|
|
58
59
|
}
|
|
59
|
-
}, others), _stripeProps && /*#__PURE__*/_react.default.createElement(_stripe.default, _stripeProps
|
|
60
|
+
}, others), _stripeProps && /*#__PURE__*/_react.default.createElement(_stripe.default, _extends({}, _stripeProps, {
|
|
61
|
+
checkoutEvents: closeOnComplete ? {
|
|
62
|
+
..._stripeProps.checkoutEvents,
|
|
63
|
+
onComplete: () => {
|
|
64
|
+
var _stripeProps$checkout, _stripeProps$checkout2;
|
|
65
|
+
(_stripeProps$checkout = _stripeProps.checkoutEvents) === null || _stripeProps$checkout === void 0 || (_stripeProps$checkout2 = _stripeProps$checkout.onComplete) === null || _stripeProps$checkout2 === void 0 || _stripeProps$checkout2.call(_stripeProps$checkout);
|
|
66
|
+
if (!isControlled) setUncontrolledVisible(false);
|
|
67
|
+
onClose === null || onClose === void 0 || onClose();
|
|
68
|
+
}
|
|
69
|
+
} : _stripeProps.checkoutEvents
|
|
70
|
+
})));
|
|
60
71
|
});
|
|
61
72
|
StripePopup.displayName = 'StripePopup';
|
|
62
73
|
var _default = exports.default = /*#__PURE__*/(0, _react.memo)(StripePopup);
|
|
@@ -7,6 +7,7 @@ exports.default = void 0;
|
|
|
7
7
|
var _react = _interopRequireWildcard(require("react"));
|
|
8
8
|
var _reactStripeJs = require("@stripe/react-stripe-js");
|
|
9
9
|
var _stripeJs = require("@stripe/stripe-js");
|
|
10
|
+
var _useLatestCallback = require("../hooks/useLatestCallback");
|
|
10
11
|
var _classNames = _interopRequireDefault(require("../utils/classNames"));
|
|
11
12
|
var _getPrefixCls = require("../utils/getPrefixCls");
|
|
12
13
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
@@ -16,9 +17,17 @@ const Stripe = /*#__PURE__*/_react.default.forwardRef((props, ref) => {
|
|
|
16
17
|
const {
|
|
17
18
|
stripeKey,
|
|
18
19
|
clientSecret,
|
|
20
|
+
checkoutEvents,
|
|
21
|
+
instanceKey,
|
|
19
22
|
className = '',
|
|
20
23
|
...others
|
|
21
24
|
} = props;
|
|
25
|
+
const events = (0, _react.useRef)(checkoutEvents);
|
|
26
|
+
events.current = checkoutEvents;
|
|
27
|
+
const onComplete = (0, _useLatestCallback.useLatestCallback)(() => {
|
|
28
|
+
var _events$current, _events$current$onCom;
|
|
29
|
+
return (_events$current = events.current) === null || _events$current === void 0 || (_events$current$onCom = _events$current.onComplete) === null || _events$current$onCom === void 0 ? void 0 : _events$current$onCom.call(_events$current);
|
|
30
|
+
});
|
|
22
31
|
const stripeRef = (0, _react.useRef)(null);
|
|
23
32
|
(0, _react.useImperativeHandle)(ref, () => stripeRef.current);
|
|
24
33
|
const stripePromise = (0, _react.useMemo)(() => {
|
|
@@ -27,15 +36,35 @@ const Stripe = /*#__PURE__*/_react.default.forwardRef((props, ref) => {
|
|
|
27
36
|
}
|
|
28
37
|
return _stripeJs.loadStripe === null || _stripeJs.loadStripe === void 0 ? void 0 : (0, _stripeJs.loadStripe)(stripeKey);
|
|
29
38
|
}, [stripeKey]);
|
|
39
|
+
const observeCheckout = Boolean(checkoutEvents);
|
|
40
|
+
(0, _react.useEffect)(() => {
|
|
41
|
+
if (!observeCheckout || !stripePromise) return;
|
|
42
|
+
let active = true;
|
|
43
|
+
Promise.resolve(stripePromise).then(instance => {
|
|
44
|
+
var _events$current2, _events$current2$onIn, _events$current3, _events$current3$onIn;
|
|
45
|
+
if (!active) return;
|
|
46
|
+
if (instance) (_events$current2 = events.current) === null || _events$current2 === void 0 || (_events$current2$onIn = _events$current2.onInitialized) === null || _events$current2$onIn === void 0 || _events$current2$onIn.call(_events$current2);else (_events$current3 = events.current) === null || _events$current3 === void 0 || (_events$current3$onIn = _events$current3.onInitializationError) === null || _events$current3$onIn === void 0 || _events$current3$onIn.call(_events$current3);
|
|
47
|
+
}).catch(() => {
|
|
48
|
+
var _events$current4, _events$current4$onIn;
|
|
49
|
+
if (active) (_events$current4 = events.current) === null || _events$current4 === void 0 || (_events$current4$onIn = _events$current4.onInitializationError) === null || _events$current4$onIn === void 0 || _events$current4$onIn.call(_events$current4);
|
|
50
|
+
});
|
|
51
|
+
return () => {
|
|
52
|
+
active = false;
|
|
53
|
+
};
|
|
54
|
+
}, [stripePromise, observeCheckout]);
|
|
30
55
|
const classNames = (0, _classNames.default)((0, _getPrefixCls.getPrefixCls)('pay-stripe'), className);
|
|
31
56
|
return /*#__PURE__*/_react.default.createElement("div", _extends({
|
|
32
57
|
ref: stripeRef
|
|
33
58
|
}, others, {
|
|
34
59
|
className: classNames
|
|
35
60
|
}), clientSecret && stripePromise && /*#__PURE__*/_react.default.createElement(_reactStripeJs.EmbeddedCheckoutProvider, {
|
|
61
|
+
key: instanceKey,
|
|
36
62
|
stripe: stripePromise,
|
|
37
63
|
options: {
|
|
38
|
-
clientSecret
|
|
64
|
+
clientSecret,
|
|
65
|
+
...(observeCheckout ? {
|
|
66
|
+
onComplete
|
|
67
|
+
} : {})
|
|
39
68
|
}
|
|
40
69
|
}, /*#__PURE__*/_react.default.createElement(_reactStripeJs.EmbeddedCheckout, null)));
|
|
41
70
|
});
|
|
@@ -123,7 +123,7 @@
|
|
|
123
123
|
max-width: 80vw;
|
|
124
124
|
box-shadow: 0 4px 24px #0001;
|
|
125
125
|
text-align: center;
|
|
126
|
-
max-height:
|
|
126
|
+
max-height: 80vh;
|
|
127
127
|
display: flex;
|
|
128
128
|
flex-direction: column;
|
|
129
129
|
}
|
|
@@ -163,7 +163,7 @@
|
|
|
163
163
|
z-index: 1;
|
|
164
164
|
text-align: center;
|
|
165
165
|
overflow-y: auto;
|
|
166
|
-
flex: 1;
|
|
166
|
+
flex: 0 1 auto;
|
|
167
167
|
min-height: 0;
|
|
168
168
|
}
|
|
169
169
|
.pay-modal__actions {
|
|
@@ -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:
|
|
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:80vh;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{display:flex;justify-content:center;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:0 1 auto;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%}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
.pay-wechat-qrcode{display:flex;flex-direction:column;align-items:center}.pay-wechat-qrcode__container{background-color:#fff;border-radius:8px;display:flex;justify-content:center;align-items:center;width:
|
|
1
|
+
.pay-wechat-qrcode{display:flex;flex-direction:column;align-items:center}.pay-wechat-qrcode__container{background-color:#fff;border-radius:8px;display:flex;justify-content:center;align-items:center;width:180px;height:180px}.pay-wechat-qrcode__image{width:100%;height:100%;object-fit:cover}.pay-wechat-qrcode__tip{text-align:center;color:#333;font-size:14px;line-height:20px}
|