cppay-sdk 0.0.2-beta.4 → 0.0.2-beta.40
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/cppay-Db8t1Cra.js +216 -0
- package/dist/cppay-DuOJqlpA.cjs +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +172 -7
- package/dist/index.js +1 -100
- package/dist/locales-BU7nq14n.js +118 -0
- package/dist/locales-ChrHW5Qd.cjs +1 -0
- package/dist/react.cjs +1 -1
- package/dist/react.d.ts +240 -1
- package/dist/react.js +757 -3
- package/dist/vue.cjs +1 -1
- package/dist/vue.d.ts +193 -5
- package/dist/vue.js +609 -10
- package/package.json +46 -18
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
var payment_dialog_default = ":root{--cppay-bg:#fff;--cppay-bg-secondary:#fafafa;--cppay-surface:#f7f7f8;--cppay-surface-hover:#efeff0;--cppay-text-main:#18181b;--cppay-text-sub:#71717a;--cppay-text-muted:#a1a1aa;--cppay-accent:#18181b;--cppay-accent-primary:#6366f1;--cppay-accent-primary-light:#eef2ff;--cppay-accent-primary-border:#c7d2fe;--cppay-border:#e4e4e7;--cppay-border-dark:#d4d4d8;--cppay-danger:#ef4444;--cppay-danger-light:#fee2e2;--cppay-danger-border:#fecaca;--cppay-warning:#f97316;--cppay-warning-light:#fef3c7;--cppay-warning-border:#fcd34d;--cppay-success:#16a34a;--cppay-radius-lg:24px;--cppay-radius-md:16px;--cppay-radius-sm:12px;--cppay-radius-xs:8px;--cppay-space-xs:4px;--cppay-space-sm:8px;--cppay-space-md:12px;--cppay-space-lg:16px;--cppay-space-xl:24px;--cppay-space-2xl:32px;--cppay-shadow-sm:0 1px 2px 0 #0000000d;--cppay-shadow-md:0 4px 6px -1px #0000001a;--cppay-shadow-lg:0 10px 15px -3px #0000001a;--cppay-shadow-xl:0 20px 25px -5px #0000001a;--cppay-transition:all .2s cubic-bezier(.4, 0, .2, 1)}._cppay-overlay{-webkit-backdrop-filter:blur(4px);z-index:999;padding:var(--cppay-space-lg);background-color:#00000080;justify-content:center;align-items:center;animation:.3s ease-out _cppay-fadeIn;display:flex;position:fixed;inset:0}._cppay-dialog{background-color:var(--cppay-bg);border-radius:var(--cppay-radius-md);box-shadow:var(--cppay-shadow-xl);flex-direction:column;width:100%;max-width:520px;max-height:90vh;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,sans-serif;animation:.3s cubic-bezier(.4,0,.2,1) _cppay-slideUp;display:flex;overflow:hidden}._cppay-header{padding:var(--cppay-space-xl);border-bottom:1px solid var(--cppay-border);background:var(--cppay-bg);flex-shrink:0;justify-content:space-between;align-items:center;display:flex}._cppay-title{color:var(--cppay-text-main);letter-spacing:-.01em;margin:0;font-size:20px;font-weight:600}._cppay-close-btn{color:var(--cppay-text-muted);cursor:pointer;background:0 0;border:none;border-radius:50%;justify-content:center;align-items:center;padding:.5rem;transition:all .2s;display:flex}._cppay-close-btn:disabled{opacity:.3;cursor:not-allowed}._cppay-close-btn:not(:disabled):hover{background-color:var(--cppay-surface);color:var(--cppay-text-main)}._cppay-close-btn svg{width:1.5rem;height:1.5rem}._cppay-content{flex:1;padding:1rem 2rem 2rem;overflow-y:auto}._cppay-content::-webkit-scrollbar{width:0;height:0}._cppay-section{margin-bottom:1.5rem}._cppay-section:last-child{margin-bottom:0}._cppay-label{color:var(--cppay-text-sub);margin-bottom:.75rem;font-size:.875rem;font-weight:600;display:block}._cppay-grid{grid-template-columns:repeat(2,1fr);gap:.75rem;display:grid}._cppay-select-btn{border-radius:var(--cppay-radius-sm);background:var(--cppay-surface);cursor:pointer;color:var(--cppay-text-main);border:2px solid #0000;justify-content:flex-start;align-items:center;gap:.75rem;padding:.875rem 1rem;font-family:inherit;font-size:.95rem;font-weight:500;transition:all .2s cubic-bezier(.4,0,.2,1);display:flex;position:relative}._cppay-select-btn:hover{background-color:var(--cppay-surface-hover)}._cppay-select-btn._cppay-selected{background-color:var(--cppay-bg);border-color:var(--cppay-accent);box-shadow:0 4px 12px #0000000d}._cppay-select-btn img{object-fit:cover;border-radius:50%;width:1.5rem;height:1.5rem}._cppay-price-box{text-align:center;padding:1.5rem 0;position:relative}._cppay-price-label{color:var(--cppay-text-sub);margin-bottom:.5rem;font-size:.875rem;font-weight:500;display:block}._cppay-price-main{color:var(--cppay-text-main);letter-spacing:-.03em;justify-content:center;align-items:baseline;gap:.5rem;font-size:2.5rem;font-weight:800;line-height:1.1;display:flex}._cppay-price-symbol{color:var(--cppay-text-sub);font-size:1rem;font-weight:600;transform:translateY(-4px)}._cppay-price-sub{color:var(--cppay-text-muted);margin-top:.75rem;font-size:.95rem;font-weight:500}._cppay-btn{border-radius:var(--cppay-radius-md);cursor:pointer;letter-spacing:-.01em;border:none;justify-content:center;align-items:center;gap:.5rem;width:100%;padding:1rem;font-size:1rem;font-weight:600;transition:all .2s;display:flex}._cppay-btn-primary{background:var(--cppay-accent);color:#fff;box-shadow:0 4px 6px -1px #0000001a}._cppay-btn-primary:hover:not(:disabled){background:#222;transform:translateY(-1px);box-shadow:0 10px 15px -3px #0000001a}._cppay-btn-primary:active:not(:disabled){transform:scale(.98)}._cppay-btn-primary:disabled{color:#a3a3a3;cursor:not-allowed;box-shadow:none;background:#e5e5e5}._cppay-btn-secondary{background:var(--cppay-surface);color:var(--cppay-text-main);border:1px solid var(--cppay-border);box-shadow:0 1px 1px #0000000d}._cppay-btn-secondary:hover:not(:disabled){background:var(--cppay-surface-hover);border-color:var(--cppay-accent);color:var(--cppay-accent);transform:translateY(-1px);box-shadow:0 4px 6px -1px #3b82f633}._cppay-btn-secondary:active:not(:disabled){transform:scale(.98)}._cppay-btn-secondary:disabled{color:#a3a3a3;cursor:not-allowed;box-shadow:none;background:#f5f5f5;border-color:#e5e5e5}._cppay-btn-text{color:var(--cppay-text-sub);background:0 0;margin-top:.5rem;font-size:.875rem}._cppay-btn-text:hover:not(:disabled){color:var(--cppay-text-main)}._cppay-btn-text:disabled{opacity:.5;cursor:not-allowed}._cppay-qr-container{justify-content:center;margin:1.5rem 0 2rem;display:flex}._cppay-qr-code{border-radius:var(--cppay-radius-md);border:1px solid var(--cppay-border);background:#fff;padding:.75rem;box-shadow:0 10px 20px #00000008}._cppay-qr-image{border-radius:8px;width:190px;height:190px;display:block}._cppay-info-box{background-color:var(--cppay-surface);border-radius:var(--cppay-radius-sm);border:1px solid #0000;margin-bottom:.75rem;padding:1rem;transition:all .2s}._cppay-info-box:hover{background-color:var(--cppay-surface-hover);border-color:var(--cppay-border)}._cppay-info-header{justify-content:space-between;align-items:center;margin-bottom:.5rem;display:flex}._cppay-info-label{text-transform:uppercase;color:var(--cppay-text-sub);letter-spacing:.05em;font-size:.75rem;font-weight:700}._cppay-info-label-flex{justify-content:space-between;align-items:center;gap:.5rem;display:flex}._cppay-info-value{color:var(--cppay-text-main);word-break:break-all;font-size:.95rem}._cppay-info-value-flex{flex-direction:column;gap:.5rem;margin-top:.5rem;display:flex}._cppay-info-value-flex span:first-child{font-size:1rem;font-weight:600}._cppay-info-value-flex span:last-child{color:var(--cppay-text-muted);font-size:.85rem}._cppay-info-flex-container{flex-direction:column;gap:.75rem;display:flex}._cppay-info-flex-child{flex-direction:column;gap:.5rem;display:flex}._cppay-address-row{justify-content:space-between;align-items:center;gap:.75rem;margin-top:.5rem;display:flex}._cppay-address-row code{border:1px solid var(--cppay-border);color:var(--cppay-text-main);word-break:break-all;overflow-wrap:break-word;background:#fff;border-radius:4px;flex:1;padding:.5rem .75rem;font-family:SF Mono,Monaco,Inconsolata,monospace;font-size:.85rem}._cppay-countdown{color:#d97706;background:#fffbeb;border-radius:4px;padding:2px 6px;font-size:.75rem;font-weight:600}._cppay-address-wrapper{justify-content:space-between;align-items:center;gap:.5rem;display:flex}._cppay-address-text{color:var(--cppay-text-main);text-overflow:ellipsis;white-space:nowrap;font-family:SF Mono,Monaco,monospace;font-size:.9rem;overflow:hidden}._cppay-copy-btn{border:1px solid var(--cppay-border);cursor:pointer;width:32px;height:32px;color:var(--cppay-text-main);background:#fff;border-radius:6px;flex-shrink:0;justify-content:center;align-items:center;padding:0;transition:all .2s;display:flex}._cppay-copy-btn:hover:not(._cppay-copy-success){background:var(--cppay-text-main);border-color:var(--cppay-text-main);color:#fff}._cppay-copy-btn._cppay-copy-success{color:#fff;background:#22c55e;border-color:#22c55e;animation:.3s ease-out _cppay-copyPulse}._cppay-copy-icon{justify-content:center;align-items:center;width:1rem;height:1rem;display:flex}._cppay-subscription-box{background-color:#fef3c7;border-color:#fcd34d}._cppay-subscription-label{color:#92400e;font-size:.85rem;font-weight:600}._cppay-subscription-message{color:#b45309;font-size:.85rem;line-height:1.5}._cppay-state-container{text-align:center;padding:3rem 1rem}._cppay-state-icon{background:var(--cppay-surface);border-radius:50%;justify-content:center;align-items:center;width:80px;height:80px;margin:0 auto 1.5rem;font-size:2.5rem;display:flex}._cppay-wallet-address-btn{color:var(--cppay-text-muted);margin-top:.5rem;cursor:pointer;background:0 0;border-radius:0;justify-content:center;align-items:center;gap:.5rem;margin-inline:auto;padding:.5rem 0;font-size:.85rem;font-weight:400;transition:all .2s;display:inline-flex}._cppay-wallet-address-btn:hover:not(:disabled){border-bottom-color:var(--cppay-text-main);color:var(--cppay-text-main);background:0 0}._cppay-wallet-address-btn:active:not(:disabled){transform:scale(.98)}._cppay-wallet-address-btn:disabled{opacity:.5;cursor:not-allowed}._cppay-wallet-icon{width:1rem;height:1rem;color:inherit;flex-shrink:0}._cppay-wallet-address-text{text-align:center;color:inherit;flex-shrink:0;font-family:SF Mono,Monaco,Inconsolata,monospace;font-size:.8rem}._cppay-wallet-arrow{width:.85rem;height:.85rem;color:inherit;opacity:.7;flex-shrink:0;transition:transform .2s}._cppay-wallet-address-btn:hover:not(:disabled) ._cppay-wallet-arrow{opacity:1;transform:translateY(1px)}._cppay-wallet-status{background:var(--cppay-surface);border-radius:var(--cppay-radius-sm);justify-content:space-between;align-items:center;margin-top:1rem;padding:.75rem 1rem;display:flex}._cppay-wallet-addr{color:var(--cppay-text-sub);font-family:monospace;font-size:.875rem}._cppay-divider{border-color:var(--cppay-border);border-top:0}._cppay-wallet-disconnect{color:var(--cppay-text-muted);cursor:pointer;background:0 0;border:none;font-size:.75rem}._cppay-wallet-disconnect:hover{color:var(--cppay-danger)}._cppay-error-tooltip-wrapper{position:relative}._cppay-error-tooltip{color:#991b1b;cursor:help;background-color:#fef2f2;border:1px solid #fecaca;border-radius:.375rem;align-items:center;gap:.5rem;margin-bottom:.5rem;padding:.5rem .75rem;font-size:.8125rem;line-height:1.25;transition:all .2s;display:flex}._cppay-error-tooltip:hover{background-color:#fee2e2;border-color:#fca5a5}._cppay-error-tooltip svg{flex-shrink:0;width:1rem;height:1rem}._cppay-error-tooltip span{text-overflow:ellipsis;white-space:nowrap;flex:1;min-width:0;overflow:hidden}._cppay-error-tooltip-full{color:#fff;z-index:10;word-wrap:break-word;white-space:normal;background-color:#7f1d1d;border-radius:.5rem;margin-bottom:.25rem;padding:.625rem .875rem;font-size:.8125rem;line-height:1.4;animation:.2s ease-out _cppay-tooltipFadeIn;position:absolute;bottom:100%;left:0;right:0;box-shadow:0 4px 6px -1px #0000001a,0 2px 4px -1px #0000000f}._cppay-error-tooltip-full:after{content:\"\";border:.375rem solid #0000;border-top-color:#7f1d1d;position:absolute;top:100%;left:1rem}@keyframes _cppay-fadeIn{0%{opacity:0}to{opacity:1}}@keyframes _cppay-slideUp{0%{opacity:0;transform:translateY(20px)}to{opacity:1;transform:translateY(0)}}@keyframes _cppay-scaleIn{0%{opacity:0;transform:scale(.5)}to{opacity:1;transform:scale(1)}}@keyframes _cppay-copyPulse{0%{transform:scale(1)}50%{transform:scale(1.1)}to{transform:scale(1)}}@keyframes _cppay-pulse{0%,to{opacity:1}50%{opacity:.7}}@keyframes _cppay-tooltipFadeIn{0%{opacity:0;transform:translateY(-4px)}to{opacity:1;transform:translateY(0)}}._cppay-state-container{padding:var(--cppay-space-2xl) var(--cppay-space-xl);text-align:center;justify-content:center;align-items:center;gap:var(--cppay-space-lg);flex-direction:column;min-height:380px;display:flex}._cppay-state-success-bg{background:linear-gradient(135deg,#d1fae5 0%,#a7f3d0 100%);border-radius:50%;justify-content:center;align-items:center;width:88px;height:88px;animation:.5s cubic-bezier(.34,1.56,.64,1) _cppay-scaleIn;display:flex}._cppay-state-success-icon{color:#16a34a;font-size:44px;font-weight:700;line-height:1}._cppay-state-expired-bg{background:linear-gradient(135deg,#fef3c7 0%,#fde68a 100%);border-radius:50%;justify-content:center;align-items:center;width:88px;height:88px;animation:.5s cubic-bezier(.34,1.56,.64,1) _cppay-scaleIn;display:flex}._cppay-state-expired-icon{font-size:44px;line-height:1;animation:2s infinite _cppay-pulse}._cppay-state-failed-bg{background:linear-gradient(135deg,#fee2e2 0%,#fecaca 100%);border-radius:50%;justify-content:center;align-items:center;width:88px;height:88px;animation:.5s cubic-bezier(.34,1.56,.64,1) _cppay-scaleIn;display:flex}._cppay-state-failed-icon{color:#dc2626;font-size:44px;font-weight:700;line-height:1}._cppay-state-error-bg{background:linear-gradient(135deg,#f3e8e8 0%,#e5d4d4 100%);border-radius:50%;justify-content:center;align-items:center;width:88px;height:88px;animation:.5s cubic-bezier(.34,1.56,.64,1) _cppay-scaleIn;display:flex}._cppay-state-error-icon{color:#7c2d12;justify-content:center;align-items:center;font-size:44px;font-weight:700;line-height:1;display:flex}._cppay-state-title{color:var(--cppay-text-main);letter-spacing:-.01em;margin:0;margin-top:var(--cppay-space-md);font-size:24px;font-weight:700}._cppay-state-title-success{color:#16a34a}._cppay-state-title-expired{color:#f97316}._cppay-state-title-failed{color:#dc2626}._cppay-state-title-error{color:#7c2d12}._cppay-state-message{color:var(--cppay-text-sub);max-width:300px;margin:0;font-size:14px;line-height:1.5}._cppay-state-hash-container{background:var(--cppay-surface);border-radius:var(--cppay-radius-sm);width:100%;padding:var(--cppay-space-md);border:1px solid var(--cppay-border)}._cppay-state-label{color:var(--cppay-text-muted);text-transform:uppercase;letter-spacing:.05em;margin-bottom:var(--cppay-space-md);font-size:12px;font-weight:600}._cppay-hash-row{align-items:center;gap:var(--cppay-space-md);justify-content:center;display:flex}._cppay-state-hash{color:var(--cppay-text-sub);background:var(--cppay-bg);padding:var(--cppay-space-md) var(--cppay-space-lg);border-radius:var(--cppay-radius-xs);border:1px solid var(--cppay-border);word-break:break-all;text-align:center;flex:1;font-family:SF Mono,Monaco,Cascadia Code,Roboto Mono,Consolas,Courier New,monospace;font-size:12px}._cppay-state-copy-btn{background:var(--cppay-bg);border:1px solid var(--cppay-border);border-radius:var(--cppay-radius-xs);cursor:pointer;width:36px;height:36px;color:var(--cppay-text-sub);transition:var(--cppay-transition);flex-shrink:0;justify-content:center;align-items:center;padding:0;display:flex}._cppay-state-copy-btn:hover{background:var(--cppay-accent-primary);color:#fff;border-color:var(--cppay-accent-primary)}._cppay-state-copy-btn svg{width:16px;height:16px}._cppay-state-btn{margin-top:var(--cppay-space-lg);min-width:200px}@media (max-width:640px){._cppay-dialog{max-width:100%;margin:var(--cppay-space-lg);border-radius:var(--cppay-radius-md)}._cppay-header{padding:var(--cppay-space-lg)}._cppay-title{font-size:18px}._cppay-content{padding:var(--cppay-space-lg)}._cppay-grid{gap:var(--cppay-space-sm);grid-template-columns:repeat(auto-fit,minmax(100px,1fr))}._cppay-select-btn{padding:var(--cppay-space-md) var(--cppay-space-sm);font-size:12px}._cppay-select-btn img{width:28px;height:28px}._cppay-price-main{font-size:18px}._cppay-qr-image{width:160px;height:160px}}";
|
|
2
|
+
function injectStyle(e) {
|
|
3
|
+
if (typeof document > "u" || document.getElementById("_cppay-payment-dialog-style")) return;
|
|
4
|
+
let r = document.createElement("style");
|
|
5
|
+
r.id = "_cppay-payment-dialog-style", r.textContent = e, document.head.appendChild(r);
|
|
6
|
+
}
|
|
7
|
+
const locales = {
|
|
8
|
+
"zh-CN": {
|
|
9
|
+
selectPaymentMethod: "选择支付方式",
|
|
10
|
+
completePayment: "完成支付",
|
|
11
|
+
paymentResult: "支付结果",
|
|
12
|
+
paymentExpired: "支付已过期",
|
|
13
|
+
paymentFailed: "支付失败",
|
|
14
|
+
error: "出错",
|
|
15
|
+
authorizationSuccess: "授权成功!",
|
|
16
|
+
paymentSuccess: "支付成功!",
|
|
17
|
+
subscriptionActivated: "订阅已激活",
|
|
18
|
+
transactionCompleted: "交易已完成",
|
|
19
|
+
paymentExpiredMessage: "支付已过期,请重选创建支付订单",
|
|
20
|
+
orderPaymentFailed: "订单支付失败!",
|
|
21
|
+
pleaseInitiatePaymentAgain: "请重新发起支付",
|
|
22
|
+
checkStatusFailed: "检查支付状态失败,请稍后重试",
|
|
23
|
+
transactionHash: "交易哈希",
|
|
24
|
+
returnButton: "返回",
|
|
25
|
+
continuePayment: "继续支付",
|
|
26
|
+
processing: "处理中...",
|
|
27
|
+
connectWallet: "连接钱包",
|
|
28
|
+
connecting: "连接中...",
|
|
29
|
+
walletAuthorize: "钱包授权",
|
|
30
|
+
walletPay: "钱包支付",
|
|
31
|
+
authorizing: "授权中...",
|
|
32
|
+
paying: "支付中...",
|
|
33
|
+
completedPayment: "我已完成支付",
|
|
34
|
+
checking: "检查中...",
|
|
35
|
+
changePaymentMethod: "更改支付方式",
|
|
36
|
+
paymentNetwork: "支付网络",
|
|
37
|
+
paymentToken: "支付代币",
|
|
38
|
+
paymentAmount: "支付金额",
|
|
39
|
+
authorizationAmount: "授权金额",
|
|
40
|
+
paymentAddress: "支付地址",
|
|
41
|
+
authorizationContractAddress: "授权合约地址",
|
|
42
|
+
copyAddress: "复制地址",
|
|
43
|
+
copied: "已复制!",
|
|
44
|
+
subscriptionNotice: "📌 订阅说明",
|
|
45
|
+
subscriptionNoticeMessage: "订阅支付需要授权代币给合约地址,系统将按周期自动扣款。授权后无需每次手动支付。",
|
|
46
|
+
clickToModifyWallet: "点击修改或查看钱包状态",
|
|
47
|
+
expired: "已过期",
|
|
48
|
+
hours: "时",
|
|
49
|
+
minutes: "分",
|
|
50
|
+
seconds: "秒",
|
|
51
|
+
loadPaymentNetworkFailed: "加载支付网络失败",
|
|
52
|
+
createPaymentFailed: "创建支付失败",
|
|
53
|
+
walletConnectionFailed: "钱包连接失败",
|
|
54
|
+
walletPaymentFailed: "钱包支付失败",
|
|
55
|
+
walletAuthorizationFailed: "钱包授权失败",
|
|
56
|
+
pleaseConnectWallet: "请先连接钱包",
|
|
57
|
+
pleaseAddNetwork: "请在钱包中添加该网络",
|
|
58
|
+
subscriptionDoesNotSupportNative: "订阅支付不支持原生代币",
|
|
59
|
+
checkPaymentStatusFailed: "检查支付状态失败"
|
|
60
|
+
},
|
|
61
|
+
"en-US": {
|
|
62
|
+
selectPaymentMethod: "Select Payment Method",
|
|
63
|
+
completePayment: "Complete Payment",
|
|
64
|
+
paymentResult: "Payment Result",
|
|
65
|
+
paymentExpired: "Payment Expired",
|
|
66
|
+
paymentFailed: "Payment Failed",
|
|
67
|
+
error: "Error",
|
|
68
|
+
authorizationSuccess: "Authorization Successful!",
|
|
69
|
+
paymentSuccess: "Payment Successful!",
|
|
70
|
+
subscriptionActivated: "Subscription Activated",
|
|
71
|
+
transactionCompleted: "Transaction Completed",
|
|
72
|
+
paymentExpiredMessage: "Payment has expired, please create a new payment order",
|
|
73
|
+
orderPaymentFailed: "Order payment failed!",
|
|
74
|
+
pleaseInitiatePaymentAgain: "Please initiate payment again",
|
|
75
|
+
checkStatusFailed: "Failed to check payment status, please try again later",
|
|
76
|
+
transactionHash: "Transaction Hash",
|
|
77
|
+
returnButton: "Return",
|
|
78
|
+
continuePayment: "Continue Payment",
|
|
79
|
+
processing: "Processing...",
|
|
80
|
+
connectWallet: "Connect Wallet",
|
|
81
|
+
connecting: "Connecting...",
|
|
82
|
+
walletAuthorize: "Wallet Authorize",
|
|
83
|
+
walletPay: "Wallet Pay",
|
|
84
|
+
authorizing: "Authorizing...",
|
|
85
|
+
paying: "Paying...",
|
|
86
|
+
completedPayment: "I have completed payment",
|
|
87
|
+
checking: "Checking...",
|
|
88
|
+
changePaymentMethod: "Change Payment Method",
|
|
89
|
+
paymentNetwork: "Payment Network",
|
|
90
|
+
paymentToken: "Payment Token",
|
|
91
|
+
paymentAmount: "Payment Amount",
|
|
92
|
+
authorizationAmount: "Authorization Amount",
|
|
93
|
+
paymentAddress: "Payment Address",
|
|
94
|
+
authorizationContractAddress: "Authorization Contract Address",
|
|
95
|
+
copyAddress: "Copy Address",
|
|
96
|
+
copied: "Copied!",
|
|
97
|
+
subscriptionNotice: "📌 Subscription Notice",
|
|
98
|
+
subscriptionNoticeMessage: "Subscription payment requires token authorization to the contract address. The system will automatically deduct payment periodically. No manual payment is needed after authorization.",
|
|
99
|
+
clickToModifyWallet: "Click to modify or view wallet status",
|
|
100
|
+
expired: "Expired",
|
|
101
|
+
hours: "h",
|
|
102
|
+
minutes: "m",
|
|
103
|
+
seconds: "s",
|
|
104
|
+
loadPaymentNetworkFailed: "Failed to load payment network",
|
|
105
|
+
createPaymentFailed: "Failed to create payment",
|
|
106
|
+
walletConnectionFailed: "Wallet connection failed",
|
|
107
|
+
walletPaymentFailed: "Wallet payment failed",
|
|
108
|
+
walletAuthorizationFailed: "Wallet authorization failed",
|
|
109
|
+
pleaseConnectWallet: "Please connect wallet first",
|
|
110
|
+
pleaseAddNetwork: "Please add this network in your wallet",
|
|
111
|
+
subscriptionDoesNotSupportNative: "Subscription payment does not support native tokens",
|
|
112
|
+
checkPaymentStatusFailed: "Failed to check payment status"
|
|
113
|
+
}
|
|
114
|
+
};
|
|
115
|
+
function getLocaleMessages(e = "en-US") {
|
|
116
|
+
return locales[e] || locales["en-US"];
|
|
117
|
+
}
|
|
118
|
+
export { injectStyle as n, payment_dialog_default as r, getLocaleMessages as t };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,a)=>(a=n==null?{}:e(i(n)),o(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n)),c=`:root{--cppay-bg:#fff;--cppay-bg-secondary:#fafafa;--cppay-surface:#f7f7f8;--cppay-surface-hover:#efeff0;--cppay-text-main:#18181b;--cppay-text-sub:#71717a;--cppay-text-muted:#a1a1aa;--cppay-accent:#18181b;--cppay-accent-primary:#6366f1;--cppay-accent-primary-light:#eef2ff;--cppay-accent-primary-border:#c7d2fe;--cppay-border:#e4e4e7;--cppay-border-dark:#d4d4d8;--cppay-danger:#ef4444;--cppay-danger-light:#fee2e2;--cppay-danger-border:#fecaca;--cppay-warning:#f97316;--cppay-warning-light:#fef3c7;--cppay-warning-border:#fcd34d;--cppay-success:#16a34a;--cppay-radius-lg:24px;--cppay-radius-md:16px;--cppay-radius-sm:12px;--cppay-radius-xs:8px;--cppay-space-xs:4px;--cppay-space-sm:8px;--cppay-space-md:12px;--cppay-space-lg:16px;--cppay-space-xl:24px;--cppay-space-2xl:32px;--cppay-shadow-sm:0 1px 2px 0 #0000000d;--cppay-shadow-md:0 4px 6px -1px #0000001a;--cppay-shadow-lg:0 10px 15px -3px #0000001a;--cppay-shadow-xl:0 20px 25px -5px #0000001a;--cppay-transition:all .2s cubic-bezier(.4, 0, .2, 1)}._cppay-overlay{-webkit-backdrop-filter:blur(4px);z-index:999;padding:var(--cppay-space-lg);background-color:#00000080;justify-content:center;align-items:center;animation:.3s ease-out _cppay-fadeIn;display:flex;position:fixed;inset:0}._cppay-dialog{background-color:var(--cppay-bg);border-radius:var(--cppay-radius-md);box-shadow:var(--cppay-shadow-xl);flex-direction:column;width:100%;max-width:520px;max-height:90vh;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,sans-serif;animation:.3s cubic-bezier(.4,0,.2,1) _cppay-slideUp;display:flex;overflow:hidden}._cppay-header{padding:var(--cppay-space-xl);border-bottom:1px solid var(--cppay-border);background:var(--cppay-bg);flex-shrink:0;justify-content:space-between;align-items:center;display:flex}._cppay-title{color:var(--cppay-text-main);letter-spacing:-.01em;margin:0;font-size:20px;font-weight:600}._cppay-close-btn{color:var(--cppay-text-muted);cursor:pointer;background:0 0;border:none;border-radius:50%;justify-content:center;align-items:center;padding:.5rem;transition:all .2s;display:flex}._cppay-close-btn:disabled{opacity:.3;cursor:not-allowed}._cppay-close-btn:not(:disabled):hover{background-color:var(--cppay-surface);color:var(--cppay-text-main)}._cppay-close-btn svg{width:1.5rem;height:1.5rem}._cppay-content{flex:1;padding:1rem 2rem 2rem;overflow-y:auto}._cppay-content::-webkit-scrollbar{width:0;height:0}._cppay-section{margin-bottom:1.5rem}._cppay-section:last-child{margin-bottom:0}._cppay-label{color:var(--cppay-text-sub);margin-bottom:.75rem;font-size:.875rem;font-weight:600;display:block}._cppay-grid{grid-template-columns:repeat(2,1fr);gap:.75rem;display:grid}._cppay-select-btn{border-radius:var(--cppay-radius-sm);background:var(--cppay-surface);cursor:pointer;color:var(--cppay-text-main);border:2px solid #0000;justify-content:flex-start;align-items:center;gap:.75rem;padding:.875rem 1rem;font-family:inherit;font-size:.95rem;font-weight:500;transition:all .2s cubic-bezier(.4,0,.2,1);display:flex;position:relative}._cppay-select-btn:hover{background-color:var(--cppay-surface-hover)}._cppay-select-btn._cppay-selected{background-color:var(--cppay-bg);border-color:var(--cppay-accent);box-shadow:0 4px 12px #0000000d}._cppay-select-btn img{object-fit:cover;border-radius:50%;width:1.5rem;height:1.5rem}._cppay-price-box{text-align:center;padding:1.5rem 0;position:relative}._cppay-price-label{color:var(--cppay-text-sub);margin-bottom:.5rem;font-size:.875rem;font-weight:500;display:block}._cppay-price-main{color:var(--cppay-text-main);letter-spacing:-.03em;justify-content:center;align-items:baseline;gap:.5rem;font-size:2.5rem;font-weight:800;line-height:1.1;display:flex}._cppay-price-symbol{color:var(--cppay-text-sub);font-size:1rem;font-weight:600;transform:translateY(-4px)}._cppay-price-sub{color:var(--cppay-text-muted);margin-top:.75rem;font-size:.95rem;font-weight:500}._cppay-btn{border-radius:var(--cppay-radius-md);cursor:pointer;letter-spacing:-.01em;border:none;justify-content:center;align-items:center;gap:.5rem;width:100%;padding:1rem;font-size:1rem;font-weight:600;transition:all .2s;display:flex}._cppay-btn-primary{background:var(--cppay-accent);color:#fff;box-shadow:0 4px 6px -1px #0000001a}._cppay-btn-primary:hover:not(:disabled){background:#222;transform:translateY(-1px);box-shadow:0 10px 15px -3px #0000001a}._cppay-btn-primary:active:not(:disabled){transform:scale(.98)}._cppay-btn-primary:disabled{color:#a3a3a3;cursor:not-allowed;box-shadow:none;background:#e5e5e5}._cppay-btn-secondary{background:var(--cppay-surface);color:var(--cppay-text-main);border:1px solid var(--cppay-border);box-shadow:0 1px 1px #0000000d}._cppay-btn-secondary:hover:not(:disabled){background:var(--cppay-surface-hover);border-color:var(--cppay-accent);color:var(--cppay-accent);transform:translateY(-1px);box-shadow:0 4px 6px -1px #3b82f633}._cppay-btn-secondary:active:not(:disabled){transform:scale(.98)}._cppay-btn-secondary:disabled{color:#a3a3a3;cursor:not-allowed;box-shadow:none;background:#f5f5f5;border-color:#e5e5e5}._cppay-btn-text{color:var(--cppay-text-sub);background:0 0;margin-top:.5rem;font-size:.875rem}._cppay-btn-text:hover:not(:disabled){color:var(--cppay-text-main)}._cppay-btn-text:disabled{opacity:.5;cursor:not-allowed}._cppay-qr-container{justify-content:center;margin:1.5rem 0 2rem;display:flex}._cppay-qr-code{border-radius:var(--cppay-radius-md);border:1px solid var(--cppay-border);background:#fff;padding:.75rem;box-shadow:0 10px 20px #00000008}._cppay-qr-image{border-radius:8px;width:190px;height:190px;display:block}._cppay-info-box{background-color:var(--cppay-surface);border-radius:var(--cppay-radius-sm);border:1px solid #0000;margin-bottom:.75rem;padding:1rem;transition:all .2s}._cppay-info-box:hover{background-color:var(--cppay-surface-hover);border-color:var(--cppay-border)}._cppay-info-header{justify-content:space-between;align-items:center;margin-bottom:.5rem;display:flex}._cppay-info-label{text-transform:uppercase;color:var(--cppay-text-sub);letter-spacing:.05em;font-size:.75rem;font-weight:700}._cppay-info-label-flex{justify-content:space-between;align-items:center;gap:.5rem;display:flex}._cppay-info-value{color:var(--cppay-text-main);word-break:break-all;font-size:.95rem}._cppay-info-value-flex{flex-direction:column;gap:.5rem;margin-top:.5rem;display:flex}._cppay-info-value-flex span:first-child{font-size:1rem;font-weight:600}._cppay-info-value-flex span:last-child{color:var(--cppay-text-muted);font-size:.85rem}._cppay-info-flex-container{flex-direction:column;gap:.75rem;display:flex}._cppay-info-flex-child{flex-direction:column;gap:.5rem;display:flex}._cppay-address-row{justify-content:space-between;align-items:center;gap:.75rem;margin-top:.5rem;display:flex}._cppay-address-row code{border:1px solid var(--cppay-border);color:var(--cppay-text-main);word-break:break-all;overflow-wrap:break-word;background:#fff;border-radius:4px;flex:1;padding:.5rem .75rem;font-family:SF Mono,Monaco,Inconsolata,monospace;font-size:.85rem}._cppay-countdown{color:#d97706;background:#fffbeb;border-radius:4px;padding:2px 6px;font-size:.75rem;font-weight:600}._cppay-address-wrapper{justify-content:space-between;align-items:center;gap:.5rem;display:flex}._cppay-address-text{color:var(--cppay-text-main);text-overflow:ellipsis;white-space:nowrap;font-family:SF Mono,Monaco,monospace;font-size:.9rem;overflow:hidden}._cppay-copy-btn{border:1px solid var(--cppay-border);cursor:pointer;width:32px;height:32px;color:var(--cppay-text-main);background:#fff;border-radius:6px;flex-shrink:0;justify-content:center;align-items:center;padding:0;transition:all .2s;display:flex}._cppay-copy-btn:hover:not(._cppay-copy-success){background:var(--cppay-text-main);border-color:var(--cppay-text-main);color:#fff}._cppay-copy-btn._cppay-copy-success{color:#fff;background:#22c55e;border-color:#22c55e;animation:.3s ease-out _cppay-copyPulse}._cppay-copy-icon{justify-content:center;align-items:center;width:1rem;height:1rem;display:flex}._cppay-subscription-box{background-color:#fef3c7;border-color:#fcd34d}._cppay-subscription-label{color:#92400e;font-size:.85rem;font-weight:600}._cppay-subscription-message{color:#b45309;font-size:.85rem;line-height:1.5}._cppay-state-container{text-align:center;padding:3rem 1rem}._cppay-state-icon{background:var(--cppay-surface);border-radius:50%;justify-content:center;align-items:center;width:80px;height:80px;margin:0 auto 1.5rem;font-size:2.5rem;display:flex}._cppay-wallet-address-btn{color:var(--cppay-text-muted);margin-top:.5rem;cursor:pointer;background:0 0;border-radius:0;justify-content:center;align-items:center;gap:.5rem;margin-inline:auto;padding:.5rem 0;font-size:.85rem;font-weight:400;transition:all .2s;display:inline-flex}._cppay-wallet-address-btn:hover:not(:disabled){border-bottom-color:var(--cppay-text-main);color:var(--cppay-text-main);background:0 0}._cppay-wallet-address-btn:active:not(:disabled){transform:scale(.98)}._cppay-wallet-address-btn:disabled{opacity:.5;cursor:not-allowed}._cppay-wallet-icon{width:1rem;height:1rem;color:inherit;flex-shrink:0}._cppay-wallet-address-text{text-align:center;color:inherit;flex-shrink:0;font-family:SF Mono,Monaco,Inconsolata,monospace;font-size:.8rem}._cppay-wallet-arrow{width:.85rem;height:.85rem;color:inherit;opacity:.7;flex-shrink:0;transition:transform .2s}._cppay-wallet-address-btn:hover:not(:disabled) ._cppay-wallet-arrow{opacity:1;transform:translateY(1px)}._cppay-wallet-status{background:var(--cppay-surface);border-radius:var(--cppay-radius-sm);justify-content:space-between;align-items:center;margin-top:1rem;padding:.75rem 1rem;display:flex}._cppay-wallet-addr{color:var(--cppay-text-sub);font-family:monospace;font-size:.875rem}._cppay-divider{border-color:var(--cppay-border);border-top:0}._cppay-wallet-disconnect{color:var(--cppay-text-muted);cursor:pointer;background:0 0;border:none;font-size:.75rem}._cppay-wallet-disconnect:hover{color:var(--cppay-danger)}._cppay-error-tooltip-wrapper{position:relative}._cppay-error-tooltip{color:#991b1b;cursor:help;background-color:#fef2f2;border:1px solid #fecaca;border-radius:.375rem;align-items:center;gap:.5rem;margin-bottom:.5rem;padding:.5rem .75rem;font-size:.8125rem;line-height:1.25;transition:all .2s;display:flex}._cppay-error-tooltip:hover{background-color:#fee2e2;border-color:#fca5a5}._cppay-error-tooltip svg{flex-shrink:0;width:1rem;height:1rem}._cppay-error-tooltip span{text-overflow:ellipsis;white-space:nowrap;flex:1;min-width:0;overflow:hidden}._cppay-error-tooltip-full{color:#fff;z-index:10;word-wrap:break-word;white-space:normal;background-color:#7f1d1d;border-radius:.5rem;margin-bottom:.25rem;padding:.625rem .875rem;font-size:.8125rem;line-height:1.4;animation:.2s ease-out _cppay-tooltipFadeIn;position:absolute;bottom:100%;left:0;right:0;box-shadow:0 4px 6px -1px #0000001a,0 2px 4px -1px #0000000f}._cppay-error-tooltip-full:after{content:"";border:.375rem solid #0000;border-top-color:#7f1d1d;position:absolute;top:100%;left:1rem}@keyframes _cppay-fadeIn{0%{opacity:0}to{opacity:1}}@keyframes _cppay-slideUp{0%{opacity:0;transform:translateY(20px)}to{opacity:1;transform:translateY(0)}}@keyframes _cppay-scaleIn{0%{opacity:0;transform:scale(.5)}to{opacity:1;transform:scale(1)}}@keyframes _cppay-copyPulse{0%{transform:scale(1)}50%{transform:scale(1.1)}to{transform:scale(1)}}@keyframes _cppay-pulse{0%,to{opacity:1}50%{opacity:.7}}@keyframes _cppay-tooltipFadeIn{0%{opacity:0;transform:translateY(-4px)}to{opacity:1;transform:translateY(0)}}._cppay-state-container{padding:var(--cppay-space-2xl) var(--cppay-space-xl);text-align:center;justify-content:center;align-items:center;gap:var(--cppay-space-lg);flex-direction:column;min-height:380px;display:flex}._cppay-state-success-bg{background:linear-gradient(135deg,#d1fae5 0%,#a7f3d0 100%);border-radius:50%;justify-content:center;align-items:center;width:88px;height:88px;animation:.5s cubic-bezier(.34,1.56,.64,1) _cppay-scaleIn;display:flex}._cppay-state-success-icon{color:#16a34a;font-size:44px;font-weight:700;line-height:1}._cppay-state-expired-bg{background:linear-gradient(135deg,#fef3c7 0%,#fde68a 100%);border-radius:50%;justify-content:center;align-items:center;width:88px;height:88px;animation:.5s cubic-bezier(.34,1.56,.64,1) _cppay-scaleIn;display:flex}._cppay-state-expired-icon{font-size:44px;line-height:1;animation:2s infinite _cppay-pulse}._cppay-state-failed-bg{background:linear-gradient(135deg,#fee2e2 0%,#fecaca 100%);border-radius:50%;justify-content:center;align-items:center;width:88px;height:88px;animation:.5s cubic-bezier(.34,1.56,.64,1) _cppay-scaleIn;display:flex}._cppay-state-failed-icon{color:#dc2626;font-size:44px;font-weight:700;line-height:1}._cppay-state-error-bg{background:linear-gradient(135deg,#f3e8e8 0%,#e5d4d4 100%);border-radius:50%;justify-content:center;align-items:center;width:88px;height:88px;animation:.5s cubic-bezier(.34,1.56,.64,1) _cppay-scaleIn;display:flex}._cppay-state-error-icon{color:#7c2d12;justify-content:center;align-items:center;font-size:44px;font-weight:700;line-height:1;display:flex}._cppay-state-title{color:var(--cppay-text-main);letter-spacing:-.01em;margin:0;margin-top:var(--cppay-space-md);font-size:24px;font-weight:700}._cppay-state-title-success{color:#16a34a}._cppay-state-title-expired{color:#f97316}._cppay-state-title-failed{color:#dc2626}._cppay-state-title-error{color:#7c2d12}._cppay-state-message{color:var(--cppay-text-sub);max-width:300px;margin:0;font-size:14px;line-height:1.5}._cppay-state-hash-container{background:var(--cppay-surface);border-radius:var(--cppay-radius-sm);width:100%;padding:var(--cppay-space-md);border:1px solid var(--cppay-border)}._cppay-state-label{color:var(--cppay-text-muted);text-transform:uppercase;letter-spacing:.05em;margin-bottom:var(--cppay-space-md);font-size:12px;font-weight:600}._cppay-hash-row{align-items:center;gap:var(--cppay-space-md);justify-content:center;display:flex}._cppay-state-hash{color:var(--cppay-text-sub);background:var(--cppay-bg);padding:var(--cppay-space-md) var(--cppay-space-lg);border-radius:var(--cppay-radius-xs);border:1px solid var(--cppay-border);word-break:break-all;text-align:center;flex:1;font-family:SF Mono,Monaco,Cascadia Code,Roboto Mono,Consolas,Courier New,monospace;font-size:12px}._cppay-state-copy-btn{background:var(--cppay-bg);border:1px solid var(--cppay-border);border-radius:var(--cppay-radius-xs);cursor:pointer;width:36px;height:36px;color:var(--cppay-text-sub);transition:var(--cppay-transition);flex-shrink:0;justify-content:center;align-items:center;padding:0;display:flex}._cppay-state-copy-btn:hover{background:var(--cppay-accent-primary);color:#fff;border-color:var(--cppay-accent-primary)}._cppay-state-copy-btn svg{width:16px;height:16px}._cppay-state-btn{margin-top:var(--cppay-space-lg);min-width:200px}@media (max-width:640px){._cppay-dialog{max-width:100%;margin:var(--cppay-space-lg);border-radius:var(--cppay-radius-md)}._cppay-header{padding:var(--cppay-space-lg)}._cppay-title{font-size:18px}._cppay-content{padding:var(--cppay-space-lg)}._cppay-grid{gap:var(--cppay-space-sm);grid-template-columns:repeat(auto-fit,minmax(100px,1fr))}._cppay-select-btn{padding:var(--cppay-space-md) var(--cppay-space-sm);font-size:12px}._cppay-select-btn img{width:28px;height:28px}._cppay-price-main{font-size:18px}._cppay-qr-image{width:160px;height:160px}}`;function l(e){if(typeof document>`u`||document.getElementById(`_cppay-payment-dialog-style`))return;let t=document.createElement(`style`);t.id=`_cppay-payment-dialog-style`,t.textContent=e,document.head.appendChild(t)}const u={"zh-CN":{selectPaymentMethod:`选择支付方式`,completePayment:`完成支付`,paymentResult:`支付结果`,paymentExpired:`支付已过期`,paymentFailed:`支付失败`,error:`出错`,authorizationSuccess:`授权成功!`,paymentSuccess:`支付成功!`,subscriptionActivated:`订阅已激活`,transactionCompleted:`交易已完成`,paymentExpiredMessage:`支付已过期,请重选创建支付订单`,orderPaymentFailed:`订单支付失败!`,pleaseInitiatePaymentAgain:`请重新发起支付`,checkStatusFailed:`检查支付状态失败,请稍后重试`,transactionHash:`交易哈希`,returnButton:`返回`,continuePayment:`继续支付`,processing:`处理中...`,connectWallet:`连接钱包`,connecting:`连接中...`,walletAuthorize:`钱包授权`,walletPay:`钱包支付`,authorizing:`授权中...`,paying:`支付中...`,completedPayment:`我已完成支付`,checking:`检查中...`,changePaymentMethod:`更改支付方式`,paymentNetwork:`支付网络`,paymentToken:`支付代币`,paymentAmount:`支付金额`,authorizationAmount:`授权金额`,paymentAddress:`支付地址`,authorizationContractAddress:`授权合约地址`,copyAddress:`复制地址`,copied:`已复制!`,subscriptionNotice:`📌 订阅说明`,subscriptionNoticeMessage:`订阅支付需要授权代币给合约地址,系统将按周期自动扣款。授权后无需每次手动支付。`,clickToModifyWallet:`点击修改或查看钱包状态`,expired:`已过期`,hours:`时`,minutes:`分`,seconds:`秒`,loadPaymentNetworkFailed:`加载支付网络失败`,createPaymentFailed:`创建支付失败`,walletConnectionFailed:`钱包连接失败`,walletPaymentFailed:`钱包支付失败`,walletAuthorizationFailed:`钱包授权失败`,pleaseConnectWallet:`请先连接钱包`,pleaseAddNetwork:`请在钱包中添加该网络`,subscriptionDoesNotSupportNative:`订阅支付不支持原生代币`,checkPaymentStatusFailed:`检查支付状态失败`},"en-US":{selectPaymentMethod:`Select Payment Method`,completePayment:`Complete Payment`,paymentResult:`Payment Result`,paymentExpired:`Payment Expired`,paymentFailed:`Payment Failed`,error:`Error`,authorizationSuccess:`Authorization Successful!`,paymentSuccess:`Payment Successful!`,subscriptionActivated:`Subscription Activated`,transactionCompleted:`Transaction Completed`,paymentExpiredMessage:`Payment has expired, please create a new payment order`,orderPaymentFailed:`Order payment failed!`,pleaseInitiatePaymentAgain:`Please initiate payment again`,checkStatusFailed:`Failed to check payment status, please try again later`,transactionHash:`Transaction Hash`,returnButton:`Return`,continuePayment:`Continue Payment`,processing:`Processing...`,connectWallet:`Connect Wallet`,connecting:`Connecting...`,walletAuthorize:`Wallet Authorize`,walletPay:`Wallet Pay`,authorizing:`Authorizing...`,paying:`Paying...`,completedPayment:`I have completed payment`,checking:`Checking...`,changePaymentMethod:`Change Payment Method`,paymentNetwork:`Payment Network`,paymentToken:`Payment Token`,paymentAmount:`Payment Amount`,authorizationAmount:`Authorization Amount`,paymentAddress:`Payment Address`,authorizationContractAddress:`Authorization Contract Address`,copyAddress:`Copy Address`,copied:`Copied!`,subscriptionNotice:`📌 Subscription Notice`,subscriptionNoticeMessage:`Subscription payment requires token authorization to the contract address. The system will automatically deduct payment periodically. No manual payment is needed after authorization.`,clickToModifyWallet:`Click to modify or view wallet status`,expired:`Expired`,hours:`h`,minutes:`m`,seconds:`s`,loadPaymentNetworkFailed:`Failed to load payment network`,createPaymentFailed:`Failed to create payment`,walletConnectionFailed:`Wallet connection failed`,walletPaymentFailed:`Wallet payment failed`,walletAuthorizationFailed:`Wallet authorization failed`,pleaseConnectWallet:`Please connect wallet first`,pleaseAddNetwork:`Please add this network in your wallet`,subscriptionDoesNotSupportNative:`Subscription payment does not support native tokens`,checkPaymentStatusFailed:`Failed to check payment status`}};function d(e=`en-US`){return u[e]||u[`en-US`]}Object.defineProperty(exports,`i`,{enumerable:!0,get:function(){return s}}),Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return l}}),Object.defineProperty(exports,`r`,{enumerable:!0,get:function(){return c}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return d}});
|
package/dist/react.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,a)=>(a=n==null?{}:e(i(n)),o(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));let c=require(`react`);c=s(c);var l=()=>null,u=c.default.memo(l);exports.PaymentDialog=u;
|
|
1
|
+
const e=require(`./locales-ChrHW5Qd.cjs`),t=require(`./cppay-DuOJqlpA.cjs`);let n=require(`qrcode`);n=e.i(n);let r=require(`rxjs`),i=require(`rxjs/operators`),a=require(`viem`),o=require(`viem/chains`),s=require(`@reown/appkit`),c=require(`@reown/appkit-adapter-ethers`),l=require(`react`);l=e.i(l);let u=require(`react/jsx-runtime`);var d=({apikey:d,ott:f,plain:p,orderId:m,amount:h,intervalDays:g,remark:_,locale:v,onSuccess:y,onExpired:b,onFailed:x,onError:S,Slots:C,onPaymentStepChange:ee})=>{let w=(0,l.useMemo)(()=>new t.t(d,f),[d,f]),T=(0,l.useMemo)(()=>e.t(v),[v]),[E,D]=(0,l.useState)(`select`),O=(0,l.useMemo)(()=>E===`checking`,[E]),[k,A]=(0,l.useState)(!1),[j,M]=(0,l.useState)(),[N,te]=(0,l.useState)([]),[P,ne]=(0,l.useState)(),[F,re]=(0,l.useState)(),[ie,ae]=(0,l.useState)(),[I,oe]=(0,l.useState)(),[se,ce]=(0,l.useState)(!1),[L,R]=(0,l.useState)(),[le,ue]=(0,l.useState)(``),[z,B]=(0,l.useState)(!1),[de,V]=(0,l.useState)(!1),[H,U]=(0,l.useState)(``),W=(0,l.useRef)(null),G=(0,l.useRef)(null),K=(0,l.useRef)(null),q=(0,l.useRef)(null),J=(0,l.useRef)(``);(0,l.useEffect)(()=>{typeof window<`u`&&!W.current&&(W.current=(0,s.createAppKit)({debug:!1,enableNetworkSwitch:!1,adapters:[new c.EthersAdapter],projectId:`8d2e1854d3f1782e45aa15fbd8938894`,allowUnsupportedChain:!0,networks:[o.mainnet,o.bsc,o.polygon,o.arbitrum,o.optimism,o.base],metadata:{name:`Cppay`,description:`Cppay Payment Gateway`,url:window.location.origin,icons:[`https://cppay.com/icon.png`]},features:{analytics:!1}}),oe(W.current.getAddress()),R(W.current.getProvider(`eip155`)),W.current.subscribeAccount(e=>{e.isConnected?oe(e.address):(oe(void 0),R(void 0))}),W.current.subscribeProviders(e=>{let t=e?.eip155;R(t)}))},[]),(0,l.useEffect)(()=>{ee?.(E)},[E]);let fe=async()=>{try{ce(!0),M(void 0),W.current&&await W.current.open()}catch(e){console.error(`钱包连接失败:`,e),M(e instanceof Error?e.message:T.walletConnectionFailed),S?.(e)}finally{ce(!1)}},Y=(0,l.useMemo)(()=>N.find(e=>e.chain===P),[N,P]),X=(0,l.useMemo)(()=>Y?.tokens||[],[Y]),Z=(0,l.useMemo)(()=>X.find(e=>e.symbol===F),[X,F]),pe=e=>[`USDT`,`USDC`,`BUSD`,`DAI`,`TUSD`,`USDD`,`FDUSD`].includes(e.toUpperCase())?2:6,me=(e,t)=>{let n=parseFloat(e);return isNaN(n)?`0`:n.toFixed(t).replace(/\.?0+$/,``)},he=e=>{if(e<=0)return T.expired;let t=Math.floor(e/3600),n=Math.floor(e%3600/60),r=e%60;return t>0?`${t}${T.hours}${n}${T.minutes}${r}${T.seconds}`:`${n}${T.minutes}${r}${T.seconds}`},ge=e=>{K.current&&clearInterval(K.current);let t=()=>{if(E===`checking`){_e();return}let t=e-Math.floor(Date.now()/1e3);ue(he(t)),t<=0&&(D(`expired`),_e())};t(),K.current=setInterval(t,1e3)},_e=()=>{K.current&&=(clearInterval(K.current),null)},Q=(0,l.useMemo)(()=>{if(!F||!Z)return`0`;let e=parseFloat(Z.price);if(isNaN(e)||e===0)return`0`;let t=pe(F);return me((parseFloat(h)/e).toFixed(t),t)},[h,F,Z]),ve=async()=>{try{A(!0),M(void 0);let e=await w.getSupportedChains();te(e),e.length>0&&ne(e[0].chain)}catch(e){M(e instanceof Error?e.message:T.loadPaymentNetworkFailed),S?.(e)}finally{A(!1)}},ye=async e=>{if(L)try{await L.request({method:`wallet_switchEthereumChain`,params:[{chainId:`0x${e.toString(16)}`}]})}catch(e){throw e.code===4902?Error(T.pleaseAddNetwork):e}},be=async()=>{if(!(!I||!L||!q.current||!Z||!Y))try{A(!0);let e=q.current;await ye(Y.chainId);let t=(0,a.createWalletClient)({account:I,transport:(0,a.custom)(L)});if(Z.address){let n=await t.writeContract({address:Z.address,abi:[{name:`transfer`,type:`function`,stateMutability:`nonpayable`,inputs:[{name:`to`,type:`address`},{name:`amount`,type:`uint256`}],outputs:[{type:`bool`}]}],functionName:`transfer`,args:[e.receiveAddress,(0,a.parseUnits)(e.paymentAmount,Z.decimals)],chain:null});console.log(`转账交易哈希:`,n),U(n),J.current=n}else{let n=await t.sendTransaction({to:e.receiveAddress,value:(0,a.parseUnits)(e.paymentAmount,Z.decimals),chain:null});console.log(`转账交易哈希:`,n),U(n),J.current=n}A(!1),D(`checking`)}catch(e){console.error(`钱包支付失败:`,e),M(e instanceof Error?e.message:T.walletPaymentFailed),S?.(e),A(!1)}},xe=async()=>{if(!(!I||!L||!q.current||!Z||!Y))try{A(!0);let e=q.current;await ye(Y.chainId);let t=(0,a.createWalletClient)({account:I,transport:(0,a.custom)(L)});if(!Z.address)throw Error(T.subscriptionDoesNotSupportNative);let n=await t.writeContract({address:Z.address,abi:[{name:`approve`,type:`function`,stateMutability:`nonpayable`,inputs:[{name:`spender`,type:`address`},{name:`amount`,type:`uint256`}],outputs:[{type:`bool`}]}],functionName:`approve`,args:[e.spenderAddress,(0,a.parseUnits)(e.approveAmount,Z.decimals)],chain:null});console.log(`授权交易哈希:`,n),U(n),J.current=n,A(!1),D(`checking`)}catch(e){console.error(`钱包授权失败:`,e),M(e instanceof Error?e.message:T.walletPaymentFailed),S?.(e),A(!1)}},Se=async()=>{if(!I){let e=T.pleaseConnectWallet;M(e),S?.(Error(e));return}p===`instant`?await be():p===`subscription`&&await xe()},Ce=async()=>{if(!(!P||!F))try{A(!0),M(void 0);let e=``;if(p===`instant`)q.current=await w.createOnetimePayment({paymentChain:P,paymentToken:F,orderId:m,amount:Q,remark:_}),e=`${P.toLowerCase()}:${q.current.receiveAddress}?amount=${q.current.paymentAmount}`,ge(q.current.expireAt),$({paymentId:q.current.paymentId});else if(p===`subscription`){if(!g)throw Error(`Invalid Renewal Days: ${g??``}`);q.current=await w.createSubscriptionPayment({paymentChain:P,paymentToken:F,orderId:m,amountOfUsd:Q,intervalDays:g}),e=`${P.toLowerCase()}:${q.current.spenderAddress}?amount=${q.current.approveAmount}`,ge(q.current.expireAt),$({subscriptionId:q.current.subscriptionId})}D(`payment`),ae(await n.toDataURL(e,{width:200,margin:2,errorCorrectionLevel:`H`}))}catch(e){M(e instanceof Error?e.message:T.createPaymentFailed),S?.(e)}finally{A(!1)}},we=()=>{q.current&&(D(`checking`),M(void 0))},$=e=>{G.current?.unsubscribe();let t=()=>(0,r.defer)(()=>p===`subscription`?w.checkSubscriptionPaymentStatus(e):w.checkOnetimePaymentStatus(e)).pipe((0,i.timeout)(15e3),(0,i.retry)({delay:2e3}));G.current=t().pipe((0,i.expand)(e=>e.status===`pending`?(0,r.timer)(2e3).pipe((0,i.switchMap)(()=>t())):r.EMPTY),(0,i.tap)(e=>{(e.status===`paid`||e.status===`approved`)&&(D(`success`),y?.(e)),e.status===`expired`&&(D(`expired`),b?.(e)),e.status===`failed`&&(D(`failed`),x?.(e))})).subscribe({error:e=>{if(q.current){let t=e instanceof Error?e.message:T.checkPaymentStatusFailed;D(`error`),M(t),S?.(e)}},complete:()=>{G.current?.unsubscribe()}})};return(0,l.useEffect)(()=>{N.length===0&&ve()},[]),(0,l.useEffect)(()=>{X.length>0&&re(X[0].symbol)},[X]),(0,l.useEffect)(()=>(m&&$({orderId:m}),()=>{G.current?.unsubscribe(),_e()}),[m]),(0,u.jsx)(`div`,{className:`_cppay-content`,children:E===`success`?C?.Success?(0,u.jsx)(C.Success,{paymentInfo:q.current}):(0,u.jsxs)(`div`,{className:`_cppay-state-container`,children:[(0,u.jsx)(`div`,{className:`_cppay-state-success-bg`,children:(0,u.jsx)(`div`,{className:`_cppay-state-success-icon`,children:`✓`})}),(0,u.jsx)(`h3`,{className:`_cppay-state-title _cppay-state-title-success`,children:p===`subscription`?T.authorizationSuccess:T.paymentSuccess}),(0,u.jsx)(`p`,{className:`_cppay-state-message`,children:p===`subscription`?T.subscriptionActivated:T.transactionCompleted}),H&&(0,u.jsxs)(`div`,{className:`_cppay-state-hash-container`,children:[(0,u.jsx)(`div`,{className:`_cppay-state-label`,children:T.transactionHash}),(0,u.jsxs)(`div`,{className:`_cppay-hash-row`,children:[(0,u.jsxs)(`code`,{className:`_cppay-state-hash`,children:[H.slice(0,20),`...`,H.slice(-20)]}),(0,u.jsx)(`button`,{onClick:async()=>{if(H)try{await navigator.clipboard.writeText(H),B(!0),setTimeout(()=>{B(!1)},2e3)}catch(e){console.error(`复制失败:`,e)}},className:`_cppay-state-copy-btn`,title:T.copyAddress,children:(0,u.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,children:[(0,u.jsx)(`path`,{d:`M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2`}),(0,u.jsx)(`rect`,{x:`8`,y:`2`,width:`8`,height:`4`,rx:`1`,ry:`1`})]})})]})]}),(0,u.jsx)(`button`,{onClick:()=>D(`select`),className:`_cppay-btn _cppay-btn-primary _cppay-state-btn`,children:T.returnButton})]}):E===`expired`?C?.Expired?(0,u.jsx)(C.Expired,{paymentInfo:q.current}):(0,u.jsxs)(`div`,{className:`_cppay-state-container`,children:[(0,u.jsx)(`div`,{className:`_cppay-state-expired-bg`,children:(0,u.jsx)(`div`,{className:`_cppay-state-expired-icon`,children:`⏰`})}),(0,u.jsx)(`h3`,{className:`_cppay-state-title _cppay-state-title-expired`,children:T.paymentExpired}),(0,u.jsx)(`p`,{className:`_cppay-state-message`,children:T.pleaseInitiatePaymentAgain}),(0,u.jsx)(`button`,{onClick:()=>D(`select`),disabled:k||O,className:`_cppay-btn _cppay-btn-primary _cppay-state-btn`,children:T.returnButton})]}):E===`error`?C?.Error?(0,u.jsx)(C.Error,{paymentInfo:q.current}):(0,u.jsxs)(`div`,{className:`_cppay-state-container`,children:[(0,u.jsx)(`div`,{className:`_cppay-state-error-bg`,children:(0,u.jsx)(`div`,{className:`_cppay-state-error-icon`,children:`!`})}),(0,u.jsx)(`h3`,{className:`_cppay-state-title _cppay-state-title-error`,children:j||T.error}),(0,u.jsx)(`p`,{className:`_cppay-state-message`,children:T.checkStatusFailed}),(0,u.jsx)(`button`,{onClick:()=>D(`select`),disabled:k||O,className:`_cppay-btn _cppay-btn-primary _cppay-state-btn`,children:T.returnButton})]}):E===`failed`?C?.Failed?(0,u.jsx)(C.Failed,{paymentInfo:q.current}):(0,u.jsxs)(`div`,{className:`_cppay-state-container`,children:[(0,u.jsx)(`div`,{className:`_cppay-state-failed-bg`,children:(0,u.jsx)(`div`,{className:`_cppay-state-failed-icon`,children:`✕`})}),(0,u.jsx)(`h3`,{className:`_cppay-state-title _cppay-state-title-failed`,children:T.paymentFailed}),(0,u.jsx)(`p`,{className:`_cppay-state-message`,children:T.pleaseInitiatePaymentAgain}),(0,u.jsx)(`button`,{onClick:()=>D(`select`),disabled:k||O,className:`_cppay-btn _cppay-btn-primary _cppay-state-btn`,children:T.returnButton})]}):E===`select`?(0,u.jsxs)(`div`,{children:[C?.ChooseTop,(0,u.jsxs)(`div`,{className:`_cppay-section`,children:[(0,u.jsx)(`label`,{className:`_cppay-label`,children:T.paymentNetwork}),(0,u.jsx)(`div`,{className:`_cppay-grid`,children:N.map(e=>(0,u.jsxs)(`button`,{onClick:()=>ne(e.chain),className:`_cppay-select-btn ${P===e.chain?`_cppay-selected`:``}`,children:[e.icon&&(0,u.jsx)(`img`,{src:e.icon,alt:e.chain}),(0,u.jsx)(`span`,{children:e.chain})]},e.chain))})]}),(0,u.jsxs)(`div`,{className:`_cppay-section`,children:[(0,u.jsx)(`label`,{className:`_cppay-label`,children:T.paymentToken}),(0,u.jsx)(`div`,{className:`_cppay-grid`,children:X.map(e=>(0,u.jsxs)(`button`,{onClick:()=>re(e.symbol),className:`_cppay-select-btn ${F===e.symbol?`_cppay-selected`:``}`,children:[e.icon&&(0,u.jsx)(`img`,{src:e.icon,alt:e.symbol}),(0,u.jsx)(`span`,{children:e.symbol})]},e.symbol))})]}),C?.ChooseBottom,(0,u.jsx)(`div`,{className:`_cppay-section`,children:(0,u.jsx)(`div`,{className:`_cppay-price-box`,children:(0,u.jsxs)(`div`,{className:`_cppay-price-row`,children:[(0,u.jsx)(`span`,{className:`_cppay-price-label`,children:T.paymentAmount}),(0,u.jsxs)(`div`,{className:`_cppay-price-amount`,children:[(0,u.jsxs)(`div`,{className:`_cppay-price-main`,children:[Q??`-`,` `,F??``]}),(0,u.jsxs)(`div`,{className:`_cppay-price-sub`,children:[`≈ $`,h]})]})]})})}),(0,u.jsxs)(`div`,{className:`_cppay-section`,children:[j&&(0,u.jsxs)(`div`,{className:`_cppay-error-tooltip-wrapper`,onMouseEnter:()=>V(!0),onMouseLeave:()=>V(!1),children:[(0,u.jsxs)(`div`,{className:`_cppay-error-tooltip`,children:[(0,u.jsx)(`svg`,{viewBox:`0 0 20 20`,fill:`currentColor`,children:(0,u.jsx)(`path`,{fillRule:`evenodd`,d:`M10 18a8 8 0 100-16 8 8 0 000 16zM8.707 7.293a1 1 0 00-1.414 1.414L8.586 10l-1.293 1.293a1 1 0 101.414 1.414L10 11.414l1.293 1.293a1 1 0 001.414-1.414L11.414 10l1.293-1.293a1 1 0 00-1.414-1.414L10 8.586 8.707 7.293z`,clipRule:`evenodd`})}),(0,u.jsx)(`span`,{children:j})]}),de&&(0,u.jsx)(`div`,{className:`_cppay-error-tooltip-full`,children:j})]}),(0,u.jsx)(`button`,{onClick:Ce,disabled:!P||!F||k,className:`_cppay-btn _cppay-btn-primary`,children:k?T.processing:T.continuePayment})]})]}):(0,u.jsxs)(`div`,{children:[(0,u.jsx)(`div`,{className:`_cppay-qr-container`,children:(0,u.jsx)(`div`,{className:`_cppay-qr-code`,children:ie&&(0,u.jsx)(`img`,{src:ie,alt:`Payment QR Code`,className:`_cppay-qr-image`})})}),(0,u.jsxs)(`div`,{className:`_cppay-section`,children:[Z&&(0,u.jsx)(`div`,{className:`_cppay-info-box`,children:(0,u.jsx)(`div`,{className:`_cppay-info-flex-container`,children:(0,u.jsxs)(`div`,{className:`_cppay-info-flex-child`,children:[(0,u.jsx)(`div`,{className:`_cppay-info-label`,children:p===`subscription`?T.authorizationAmount:T.paymentAmount}),(0,u.jsxs)(`div`,{className:`_cppay-info-value _cppay-info-value-flex`,children:[(0,u.jsx)(`span`,{children:p===`subscription`?`${me(q.current.approveAmount,pe(Z.symbol))} ${Z.symbol}`:`${me(q.current.paymentAmount,pe(Z.symbol))} ${Z.symbol}`}),(0,u.jsxs)(`span`,{children:[`≈ $`,h]})]})]})})}),(0,u.jsx)(`div`,{className:`_cppay-info-box`,children:(0,u.jsxs)(`div`,{className:`_cppay-info-flex-child`,children:[(0,u.jsxs)(`div`,{className:`_cppay-info-label _cppay-info-label-flex`,children:[(0,u.jsx)(`span`,{children:p===`subscription`?T.authorizationContractAddress:T.paymentAddress}),le&&(0,u.jsxs)(`span`,{className:`_cppay-countdown`,children:[`⏰ `,le]})]}),(0,u.jsxs)(`div`,{className:`_cppay-address-row`,children:[(0,u.jsx)(`code`,{children:p===`subscription`?q.current.spenderAddress:q.current.receiveAddress}),(0,u.jsx)(`button`,{onClick:async()=>{if(!q.current)return;let e=p===`subscription`?q.current.spenderAddress:q.current.receiveAddress;if(e)try{await navigator.clipboard.writeText(e),B(!0),setTimeout(()=>{B(!1)},2e3)}catch(e){console.error(`复制失败:`,e)}},className:`_cppay-copy-btn ${z?`_cppay-copy-success`:``}`,title:z?T.copied:T.copyAddress,children:z?(0,u.jsx)(`svg`,{className:`_cppay-copy-icon`,viewBox:`0 0 24 24`,fill:`currentColor`,children:(0,u.jsx)(`path`,{d:`M9 16.17L4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41z`})}):(0,u.jsxs)(`svg`,{className:`_cppay-copy-icon`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,children:[(0,u.jsx)(`path`,{d:`M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2`}),(0,u.jsx)(`rect`,{x:`8`,y:`2`,width:`8`,height:`4`,rx:`1`,ry:`1`})]})})]})]})}),p===`subscription`&&(0,u.jsxs)(`div`,{className:`_cppay-info-box _cppay-subscription-box`,children:[(0,u.jsx)(`div`,{className:`_cppay-info-label _cppay-subscription-label`,children:T.subscriptionNotice}),(0,u.jsx)(`div`,{className:`_cppay-info-value _cppay-subscription-message`,children:T.subscriptionNoticeMessage})]})]}),j&&(0,u.jsxs)(`div`,{className:`_cppay-error-tooltip-wrapper`,onMouseEnter:()=>V(!0),onMouseLeave:()=>V(!1),children:[(0,u.jsxs)(`div`,{className:`_cppay-error-tooltip`,children:[(0,u.jsx)(`svg`,{viewBox:`0 0 20 20`,fill:`currentColor`,children:(0,u.jsx)(`path`,{fillRule:`evenodd`,d:`M10 18a8 8 0 100-16 8 8 0 000 16zM8.707 7.293a1 1 0 00-1.414 1.414L8.586 10l-1.293 1.293a1 1 0 101.414 1.414L10 11.414l1.293 1.293a1 1 0 001.414-1.414L11.414 10l1.293-1.293a1 1 0 00-1.414-1.414L10 8.586 8.707 7.293z`,clipRule:`evenodd`})}),(0,u.jsx)(`span`,{children:j})]}),de&&(0,u.jsx)(`div`,{className:`_cppay-error-tooltip-full`,children:j})]}),!O&&(0,u.jsx)(`div`,{className:`_cppay-section`,children:I?(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(`button`,{onClick:Se,disabled:k,className:`_cppay-btn _cppay-btn-primary`,children:k?p===`subscription`?T.authorizing:T.processing:p===`subscription`?`💳 ${T.connectWallet}`:`💳 ${T.walletPay}`}),(0,u.jsxs)(`button`,{onClick:fe,disabled:k,className:`_cppay-btn _cppay-wallet-address-btn`,title:T.clickToModifyWallet,children:[(0,u.jsxs)(`span`,{className:`_cppay-wallet-address-text`,children:[I.slice(0,10),`...`,I.slice(-4)]}),(0,u.jsx)(`svg`,{className:`_cppay-wallet-arrow`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,children:(0,u.jsx)(`polyline`,{points:`6 9 12 15 18 9`})})]})]}):(0,u.jsx)(`button`,{onClick:fe,disabled:se,className:`_cppay-btn _cppay-btn-secondary _cppay-connect-wallet-btn`,children:(0,u.jsx)(`span`,{children:se?T.processing:`💳 ${T.connectWallet}`})})}),(0,u.jsx)(`div`,{className:`_cppay-section`,children:(0,u.jsx)(`button`,{onClick:we,disabled:O,className:`_cppay-btn _cppay-btn-primary`,children:O?T.checking:T.completedPayment})}),(0,u.jsx)(`hr`,{className:`_cppay-divider`}),(0,u.jsx)(`div`,{className:`_cppay-section`,children:(0,u.jsx)(`button`,{onClick:()=>D(`select`),disabled:k||O,className:`_cppay-btn _cppay-btn-text`,children:T.changePaymentMethod})})]})})},f=d,p=({open:t,onClose:n,ott:r,apikey:i,plain:a,orderId:o,amount:s,intervalDays:c,remark:d,locale:p,onExpired:m,onSuccess:h,onFailed:g,onError:_,Slots:v})=>{let[y,b]=(0,l.useState)(`select`),x=(0,l.useMemo)(()=>y!==`checking`,[y]);(0,l.useEffect)(()=>{t||b(`select`)},[t]),(0,l.useEffect)(()=>{if(!t)return;let e=e=>{e.key===`Escape`&&x&&S()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[t,x]);let S=()=>{x&&n()},C=(0,l.useMemo)(()=>e.t(p),[p]);return t?(0,u.jsx)(`div`,{className:`_cppay-overlay`,onClick:e=>e.target===e.currentTarget&&S(),children:(0,u.jsxs)(`div`,{className:`_cppay-dialog`,children:[(0,u.jsxs)(`div`,{className:`_cppay-header`,children:[(0,u.jsx)(`h2`,{className:`_cppay-title`,children:(()=>{switch(y){case`success`:return C.paymentResult;case`expired`:return C.paymentExpired;case`failed`:return C.paymentFailed;case`error`:return C.error;case`payment`:case`checking`:return C.completePayment;default:return C.selectPaymentMethod}})()}),(0,u.jsx)(`button`,{onClick:S,disabled:!x,className:`_cppay-close-btn`,children:(0,u.jsx)(`svg`,{fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`,children:(0,u.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,d:`M6 18L18 6M6 6l12 12`})})})]}),(0,u.jsx)(f,{apikey:i,ott:r,plain:a,orderId:o,amount:s,intervalDays:c,remark:d,locale:p,onSuccess:h,onExpired:m,onFailed:g,onError:_,Slots:v,onPaymentStepChange:b})]})}):null},m=p,h=(0,l.createContext)(null);const g=({children:e})=>{let[t,n]=(0,l.useState)(!1),[r,i]=(0,l.useState)(null),a=(0,l.useCallback)(e=>{i(e),n(!0)},[]),o=(0,l.useCallback)(()=>{n(!1)},[]),s=(0,l.useCallback)(()=>{n(!1)},[]),c=(0,l.useCallback)(e=>{r?.onSuccess?.(e)},[r]),d=(0,l.useCallback)(e=>{r?.onExpired?.(e)},[r]),f=(0,l.useCallback)(e=>{r?.onFailed?.(e)},[r]),p=(0,l.useCallback)(e=>{r?.onError?.(e)},[r]);return(0,u.jsxs)(h.Provider,{value:{showPayment:a,closePayment:o},children:[e,r&&(0,u.jsx)(m,{open:t,onClose:s,...r,onSuccess:c,onExpired:d,onFailed:f,onError:p})]})},_=()=>{let e=(0,l.useContext)(h);if(!e)throw Error(`useCppayPayment must be used within CppayProvider`);return e};e.n(e.r),exports.CppayProvider=g,exports.PaymentContent=f,exports.PaymentDialog=m,exports.useCppayPayment=_;
|
package/dist/react.d.ts
CHANGED
|
@@ -1,5 +1,244 @@
|
|
|
1
1
|
import { default as default_2 } from 'react';
|
|
2
|
+
import { ReactNode } from 'react';
|
|
2
3
|
|
|
3
|
-
|
|
4
|
+
declare type Address = `0x${string}`;
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* CPPay 上下文值
|
|
8
|
+
*/
|
|
9
|
+
declare interface CppayContextValue {
|
|
10
|
+
/** 显示支付对话框 */
|
|
11
|
+
showPayment: (options: PaymentOptions_2) => void;
|
|
12
|
+
/** 关闭支付对话框 */
|
|
13
|
+
closePayment: () => void;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* CPPay Provider 组件
|
|
18
|
+
* 提供支付功能的上下文提供者
|
|
19
|
+
*/
|
|
20
|
+
export declare const CppayProvider: default_2.FC<CppayProviderProps>;
|
|
21
|
+
|
|
22
|
+
declare interface CppayProviderProps {
|
|
23
|
+
/** API Key */
|
|
24
|
+
children: ReactNode;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export declare type Locale = "zh-CN" | "en-US";
|
|
28
|
+
|
|
29
|
+
declare type Numberic = `${number}.${number}` | `${number}`;
|
|
30
|
+
|
|
31
|
+
declare interface OnetimePaymentInfo {
|
|
32
|
+
orderId: string;
|
|
33
|
+
paymentId: string;
|
|
34
|
+
paymentAmount: Numberic;
|
|
35
|
+
paymentChain: string;
|
|
36
|
+
paymentToken: string;
|
|
37
|
+
receiveAddress: Address;
|
|
38
|
+
expireAt: number;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
declare interface OnetimePaymentOrderStatus {
|
|
42
|
+
orderId: string;
|
|
43
|
+
paymentId: string;
|
|
44
|
+
chain: string;
|
|
45
|
+
token: string;
|
|
46
|
+
baseAmount: Numberic;
|
|
47
|
+
payAmount: Numberic;
|
|
48
|
+
receiveAddress: Address;
|
|
49
|
+
expireAt: number;
|
|
50
|
+
status: PaymentStatus;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* PaymentContent - 支付内容组件(纯页面样式和逻辑)
|
|
55
|
+
*
|
|
56
|
+
* 这是一个独立的内容组件,包含所有支付相关的UI和业务逻辑。
|
|
57
|
+
* 可以单独使用,也可以被PaymentDialog弹框包装。
|
|
58
|
+
*
|
|
59
|
+
* @example
|
|
60
|
+
* ```tsx
|
|
61
|
+
* <PaymentContent
|
|
62
|
+
* apikey="your-api-key"
|
|
63
|
+
* plain="instant"
|
|
64
|
+
* orderId="order-123"
|
|
65
|
+
* amount="100"
|
|
66
|
+
* onSuccess={(order) => console.log('支付成功', order)}
|
|
67
|
+
* />
|
|
68
|
+
* ```
|
|
69
|
+
*/
|
|
70
|
+
export declare const PaymentContent: default_2.FC<PaymentContentProps>;
|
|
71
|
+
|
|
72
|
+
declare interface PaymentContentProps {
|
|
73
|
+
/** API Key */
|
|
74
|
+
apikey?: string;
|
|
75
|
+
/** One-Time Token */
|
|
76
|
+
ott?: string;
|
|
77
|
+
/** 支付类型 */
|
|
78
|
+
plain: PaymentPlain;
|
|
79
|
+
/** 订单 ID */
|
|
80
|
+
orderId: string;
|
|
81
|
+
/** 支付金额(USD) */
|
|
82
|
+
amount: string;
|
|
83
|
+
/** 订阅间隔天数 */
|
|
84
|
+
intervalDays?: number;
|
|
85
|
+
/** 备注信息 */
|
|
86
|
+
remark?: string;
|
|
87
|
+
/** 语言设置 */
|
|
88
|
+
locale?: Locale;
|
|
89
|
+
/** 支付成功回调 */
|
|
90
|
+
onSuccess?: (order: SubscriptionPaymentOrderStatus | OnetimePaymentOrderStatus) => void;
|
|
91
|
+
/** 支付过期回调 */
|
|
92
|
+
onExpired?: (order: SubscriptionPaymentOrderStatus | OnetimePaymentOrderStatus) => void;
|
|
93
|
+
/** 支付失败回调 */
|
|
94
|
+
onFailed?: (order: SubscriptionPaymentOrderStatus | OnetimePaymentOrderStatus) => void;
|
|
95
|
+
/** 支付错误回调 */
|
|
96
|
+
onError?: (error: Error) => void;
|
|
97
|
+
/** 插槽,定义自己想要展示的内容 */
|
|
98
|
+
Slots?: Partial<{
|
|
99
|
+
ChooseTop: default_2.ReactNode;
|
|
100
|
+
ChooseBottom: default_2.ReactNode;
|
|
101
|
+
Success: default_2.FC<{
|
|
102
|
+
paymentInfo: OnetimePaymentInfo | SubscriptionPaymentInfo;
|
|
103
|
+
}>;
|
|
104
|
+
Expired: default_2.FC<{
|
|
105
|
+
paymentInfo: OnetimePaymentInfo | SubscriptionPaymentInfo;
|
|
106
|
+
}>;
|
|
107
|
+
Failed: default_2.FC<{
|
|
108
|
+
paymentInfo: OnetimePaymentInfo | SubscriptionPaymentInfo;
|
|
109
|
+
}>;
|
|
110
|
+
Error: default_2.FC<{
|
|
111
|
+
paymentInfo: OnetimePaymentInfo | SubscriptionPaymentInfo;
|
|
112
|
+
}>;
|
|
113
|
+
}>;
|
|
114
|
+
/** 支付步骤状态变化回调 */
|
|
115
|
+
onPaymentStepChange?: (step: PaymentStep) => void;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* PaymentDialog - 支付弹框组件
|
|
120
|
+
*
|
|
121
|
+
* 这是一个纯弹框包装器,负责:
|
|
122
|
+
* - 管理弹框的打开/关闭状态和动画
|
|
123
|
+
* - 处理弹框的UI包装(背景遮罩、标题栏、关闭按钮)
|
|
124
|
+
* - 将 PaymentContent 内容组件嵌入弹框中
|
|
125
|
+
*
|
|
126
|
+
* 弹框关闭的自动重置逻辑:
|
|
127
|
+
* - 支付完成后 1000ms 自动关闭
|
|
128
|
+
* - 关闭后重置内部状态(支付步骤、错误等)
|
|
129
|
+
*
|
|
130
|
+
* @example
|
|
131
|
+
* ```tsx
|
|
132
|
+
* <PaymentDialog
|
|
133
|
+
* open={isOpen}
|
|
134
|
+
* onClose={() => setIsOpen(false)}
|
|
135
|
+
* apikey="your-api-key"
|
|
136
|
+
* plain="instant"
|
|
137
|
+
* orderId="order-123"
|
|
138
|
+
* amount="100"
|
|
139
|
+
* onSuccess={(order) => console.log('支付成功', order)}
|
|
140
|
+
* />
|
|
141
|
+
* ```
|
|
142
|
+
*/
|
|
143
|
+
export declare const PaymentDialog: default_2.FC<PaymentDialogProps>;
|
|
144
|
+
|
|
145
|
+
declare interface PaymentDialogProps {
|
|
146
|
+
/** 是否打开支付对话框 */
|
|
147
|
+
open: boolean;
|
|
148
|
+
/** 关闭对话框回调 */
|
|
149
|
+
onClose: () => void;
|
|
150
|
+
/** API Key */
|
|
151
|
+
apikey?: string;
|
|
152
|
+
/** One-Time Token */
|
|
153
|
+
ott?: string;
|
|
154
|
+
/** 支付类型 */
|
|
155
|
+
plain: PaymentPlain;
|
|
156
|
+
/** 订单 ID */
|
|
157
|
+
orderId: string;
|
|
158
|
+
/** 支付金额(USD) */
|
|
159
|
+
amount: string;
|
|
160
|
+
/** 订阅间隔天数 */
|
|
161
|
+
intervalDays?: number;
|
|
162
|
+
/** 备注信息 */
|
|
163
|
+
remark?: string;
|
|
164
|
+
/** 语言设置 */
|
|
165
|
+
locale?: Locale;
|
|
166
|
+
/** 支付成功回调 */
|
|
167
|
+
onSuccess?: (order: SubscriptionPaymentOrderStatus | OnetimePaymentOrderStatus) => void;
|
|
168
|
+
/** 支付过期回调 */
|
|
169
|
+
onExpired?: (order: SubscriptionPaymentOrderStatus | OnetimePaymentOrderStatus) => void;
|
|
170
|
+
/** 支付失败回调 */
|
|
171
|
+
onFailed?: (order: SubscriptionPaymentOrderStatus | OnetimePaymentOrderStatus) => void;
|
|
172
|
+
/** 支付错误回调 */
|
|
173
|
+
onError?: (error: Error) => void;
|
|
174
|
+
/** 插槽,定义自己想要展示的内容 */
|
|
175
|
+
Slots?: Partial<{
|
|
176
|
+
ChooseTop: default_2.ReactNode;
|
|
177
|
+
ChooseBottom: default_2.ReactNode;
|
|
178
|
+
Success: default_2.FC<{
|
|
179
|
+
paymentInfo: OnetimePaymentInfo | SubscriptionPaymentInfo;
|
|
180
|
+
}>;
|
|
181
|
+
Expired: default_2.FC<{
|
|
182
|
+
paymentInfo: OnetimePaymentInfo | SubscriptionPaymentInfo;
|
|
183
|
+
}>;
|
|
184
|
+
Failed: default_2.FC<{
|
|
185
|
+
paymentInfo: OnetimePaymentInfo | SubscriptionPaymentInfo;
|
|
186
|
+
}>;
|
|
187
|
+
Error: default_2.FC<{
|
|
188
|
+
paymentInfo: OnetimePaymentInfo | SubscriptionPaymentInfo;
|
|
189
|
+
}>;
|
|
190
|
+
}>;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
declare type PaymentOptions_2 = Omit<PaymentDialogProps, "open" | "onClose">;
|
|
194
|
+
|
|
195
|
+
declare type PaymentPlain = "instant" | "subscription" | "x402";
|
|
196
|
+
|
|
197
|
+
declare type PaymentStatus = "pending" | "paid" | "expired" | "failed";
|
|
198
|
+
|
|
199
|
+
declare type PaymentStep = "select" | "payment" | "checking" | "success" | "failed" | "expired" | "error";
|
|
200
|
+
|
|
201
|
+
declare interface SubscriptionPaymentInfo {
|
|
202
|
+
subscriptionId: string;
|
|
203
|
+
approveAmount: Numberic;
|
|
204
|
+
spenderAddress: Address;
|
|
205
|
+
expireAt: number;
|
|
206
|
+
paymentChain: string;
|
|
207
|
+
paymentToken: string;
|
|
208
|
+
orderId: string;
|
|
209
|
+
amountOfUsd: Numberic;
|
|
210
|
+
intervalDays: number;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
declare interface SubscriptionPaymentOrderStatus {
|
|
214
|
+
orderId: string;
|
|
215
|
+
subscriptionId: string;
|
|
216
|
+
chain: string;
|
|
217
|
+
token: string;
|
|
218
|
+
approvedAddress: string;
|
|
219
|
+
txHash: string;
|
|
220
|
+
approveAmount: string;
|
|
221
|
+
amountOfUsd: string;
|
|
222
|
+
expireAt: number;
|
|
223
|
+
status: SubscriptionPaymentStatus;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
declare type SubscriptionPaymentStatus = "pending" | "approved" | "expired" | "failed";
|
|
227
|
+
|
|
228
|
+
/**
|
|
229
|
+
* 使用 CPPay 支付钩子
|
|
230
|
+
* @throws {Error} 如果在 CppayProvider 外使用会抛出错误
|
|
231
|
+
*/
|
|
232
|
+
export declare const useCppayPayment: () => CppayContextValue;
|
|
4
233
|
|
|
5
234
|
export { }
|
|
235
|
+
|
|
236
|
+
|
|
237
|
+
declare module "@vue/runtime-core" {
|
|
238
|
+
interface ComponentCustomProperties {
|
|
239
|
+
/** 显示支付对话框的全局方法 */
|
|
240
|
+
$showPayment: typeof showPayment;
|
|
241
|
+
/** 关闭支付对话框的全局方法 */
|
|
242
|
+
$closePayment: typeof closePayment;
|
|
243
|
+
}
|
|
244
|
+
}
|