cppay-sdk 0.0.4 → 0.0.5
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 → cppay-CLtfZy7N.js} +6 -0
- package/dist/{cppay-DuOJqlpA.cjs → cppay-DwIEebOq.cjs} +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +12 -0
- package/dist/index.js +1 -1
- package/dist/react.cjs +1 -1
- package/dist/react.d.ts +6 -0
- package/dist/react.js +302 -328
- package/dist/vue.cjs +1 -1
- package/dist/vue.d.ts +6 -0
- package/dist/vue.js +250 -272
- package/package.json +1 -1
package/dist/react.js
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import { t as cppay_default } from "./cppay-
|
|
1
|
+
import { t as cppay_default } from "./cppay-CLtfZy7N.js";
|
|
2
2
|
import { n as injectStyle, r as payment_dialog_default, t as getLocaleMessages } from "./locales-lB47Gtma.js";
|
|
3
3
|
import * as QRCode from "qrcode";
|
|
4
4
|
import { EMPTY, defer, timer } from "rxjs";
|
|
5
5
|
import { expand, retry, switchMap, tap, timeout } from "rxjs/operators";
|
|
6
|
-
import { createWalletClient, custom, parseUnits } from "viem";
|
|
6
|
+
import { createWalletClient, custom, erc20Abi, parseUnits } from "viem";
|
|
7
7
|
import { arbitrum, base, bsc, mainnet, optimism, polygon } from "viem/chains";
|
|
8
8
|
import { createAppKit } from "@reown/appkit";
|
|
9
9
|
import { EthersAdapter } from "@reown/appkit-adapter-ethers";
|
|
10
10
|
import { createContext, useCallback, useContext, useEffect, useMemo, useRef, useState } from "react";
|
|
11
11
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
12
|
-
var PaymentContent_default = ({ apikey: t, ott: n, plain:
|
|
13
|
-
let
|
|
12
|
+
var PaymentContent_default = ({ apikey: t, ott: n, plain: p, orderId: ye, amount: m, intervalDays: h, remark: be, locale: xe, onSuccess: Se, onExpired: Ce, onFailed: we, onError: g, Slots: _, onPaymentStepChange: Te }) => {
|
|
13
|
+
let v = useMemo(() => new cppay_default(t, n), [t, n]), y = useMemo(() => getLocaleMessages(xe), [xe]), [b, x] = useState("select"), S = useMemo(() => b === "checking", [b]), [C, w] = useState(!1), [T, E] = useState(), [D, Ee] = useState([]), [O, k] = useState(), [A, j] = useState(), [De, M] = useState(), [N, Oe] = useState(), [ke, Ae] = useState(!1), [P, F] = useState(), [je, Me] = useState(""), [I, L] = useState(!1), [Ne, R] = useState(!1), [z, B] = useState(""), V = useRef(null), H = useRef(null), U = useRef(null), W = useRef(null), G = useRef("");
|
|
14
14
|
useEffect(() => {
|
|
15
|
-
typeof window < "u" && !
|
|
15
|
+
typeof window < "u" && !V.current && (V.current = createAppKit({
|
|
16
16
|
debug: !1,
|
|
17
17
|
enableNetworkSwitch: !1,
|
|
18
18
|
adapters: [new EthersAdapter()],
|
|
@@ -33,24 +33,24 @@ var PaymentContent_default = ({ apikey: t, ott: n, plain: u, orderId: xe, amount
|
|
|
33
33
|
icons: ["https://cppay.com/icon.png"]
|
|
34
34
|
},
|
|
35
35
|
features: { analytics: !1 }
|
|
36
|
-
}),
|
|
37
|
-
e.isConnected ?
|
|
38
|
-
}),
|
|
36
|
+
}), Oe(V.current.getAddress()), F(V.current.getProvider("eip155")), V.current.subscribeAccount((e) => {
|
|
37
|
+
e.isConnected ? Oe(e.address) : (Oe(void 0), F(void 0));
|
|
38
|
+
}), V.current.subscribeProviders((e) => {
|
|
39
39
|
let t = e?.eip155;
|
|
40
|
-
|
|
40
|
+
F(t);
|
|
41
41
|
}));
|
|
42
42
|
}, []), useEffect(() => {
|
|
43
|
-
|
|
44
|
-
}, [
|
|
45
|
-
let
|
|
43
|
+
Te?.(b);
|
|
44
|
+
}, [b]);
|
|
45
|
+
let Pe = async () => {
|
|
46
46
|
try {
|
|
47
|
-
|
|
47
|
+
Ae(!0), E(void 0), V.current && await V.current.open();
|
|
48
48
|
} catch (e) {
|
|
49
|
-
console.error("钱包连接失败:", e),
|
|
49
|
+
console.error("钱包连接失败:", e), E(e instanceof Error ? e.message : y.walletConnectionFailed), g?.(e);
|
|
50
50
|
} finally {
|
|
51
|
-
|
|
51
|
+
Ae(!1);
|
|
52
52
|
}
|
|
53
|
-
},
|
|
53
|
+
}, K = useMemo(() => D.find((e) => e.chain === O), [D, O]), q = useMemo(() => K?.tokens || [], [K]), J = useMemo(() => q.find((e) => e.symbol === A), [q, A]), Y = (e) => [
|
|
54
54
|
"USDT",
|
|
55
55
|
"USDC",
|
|
56
56
|
"BUSD",
|
|
@@ -58,177 +58,161 @@ var PaymentContent_default = ({ apikey: t, ott: n, plain: u, orderId: xe, amount
|
|
|
58
58
|
"TUSD",
|
|
59
59
|
"USDD",
|
|
60
60
|
"FDUSD"
|
|
61
|
-
].includes(e.toUpperCase()) ? 2 : 6,
|
|
61
|
+
].includes(e.toUpperCase()) ? 2 : 6, X = (e, t) => {
|
|
62
62
|
let n = parseFloat(e);
|
|
63
63
|
return isNaN(n) ? "0" : n.toFixed(t).replace(/\.?0+$/, "");
|
|
64
|
-
},
|
|
65
|
-
if (e <= 0) return
|
|
64
|
+
}, Fe = (e) => {
|
|
65
|
+
if (e <= 0) return y.expired;
|
|
66
66
|
let t = Math.floor(e / 3600), n = Math.floor(e % 3600 / 60), r = e % 60, i = (e) => e.toString().padStart(2, "0");
|
|
67
67
|
return t > 0 ? `${t}:${i(n)}:${i(r)}` : `${n}:${i(r)}`;
|
|
68
|
-
},
|
|
69
|
-
|
|
68
|
+
}, Z = (e) => {
|
|
69
|
+
U.current && clearInterval(U.current);
|
|
70
70
|
let t = () => {
|
|
71
|
-
if (
|
|
72
|
-
|
|
71
|
+
if (b === "checking") {
|
|
72
|
+
Ie();
|
|
73
73
|
return;
|
|
74
74
|
}
|
|
75
75
|
let t = e - Math.floor(Date.now() / 1e3);
|
|
76
|
-
|
|
76
|
+
Me(Fe(t)), t <= 0 && Ie();
|
|
77
77
|
};
|
|
78
|
-
t(),
|
|
79
|
-
},
|
|
80
|
-
|
|
81
|
-
},
|
|
82
|
-
if (!
|
|
83
|
-
let e = parseFloat(
|
|
78
|
+
t(), U.current = setInterval(t, 1e3);
|
|
79
|
+
}, Ie = () => {
|
|
80
|
+
U.current &&= (clearInterval(U.current), null);
|
|
81
|
+
}, Le = useMemo(() => {
|
|
82
|
+
if (!A || !J) return "0";
|
|
83
|
+
let e = parseFloat(J.price);
|
|
84
84
|
if (isNaN(e) || e === 0) return "0";
|
|
85
|
-
let t =
|
|
86
|
-
return
|
|
85
|
+
let t = Y(A);
|
|
86
|
+
return X((parseFloat(m) / e).toFixed(t), t);
|
|
87
87
|
}, [
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
]),
|
|
88
|
+
m,
|
|
89
|
+
A,
|
|
90
|
+
J
|
|
91
|
+
]), Re = async () => {
|
|
92
92
|
try {
|
|
93
|
-
|
|
94
|
-
let e = await
|
|
95
|
-
|
|
93
|
+
w(!0), E(void 0);
|
|
94
|
+
let e = await v.getSupportedChains();
|
|
95
|
+
Ee(e), e.length > 0 && k(e[0].chain);
|
|
96
96
|
} catch (e) {
|
|
97
|
-
|
|
97
|
+
E(e instanceof Error ? e.message : y.loadPaymentNetworkFailed), g?.(e);
|
|
98
98
|
} finally {
|
|
99
|
-
|
|
99
|
+
w(!1);
|
|
100
100
|
}
|
|
101
|
-
},
|
|
102
|
-
if (
|
|
103
|
-
await
|
|
101
|
+
}, ze = async (e) => {
|
|
102
|
+
if (P) try {
|
|
103
|
+
await P.request({
|
|
104
104
|
method: "wallet_switchEthereumChain",
|
|
105
105
|
params: [{ chainId: `0x${e.toString(16)}` }]
|
|
106
106
|
});
|
|
107
107
|
} catch (e) {
|
|
108
|
-
throw e.code === 4902 ? Error(
|
|
108
|
+
throw e.code === 4902 ? Error(y.pleaseAddNetwork) : e;
|
|
109
109
|
}
|
|
110
|
-
},
|
|
111
|
-
if (!(!
|
|
112
|
-
|
|
113
|
-
let e =
|
|
114
|
-
await
|
|
110
|
+
}, Be = async () => {
|
|
111
|
+
if (!(!N || !P || !W.current || !J || !K)) try {
|
|
112
|
+
w(!0);
|
|
113
|
+
let e = W.current;
|
|
114
|
+
await ze(K.chainId);
|
|
115
115
|
let t = createWalletClient({
|
|
116
|
-
account:
|
|
117
|
-
transport: custom(
|
|
116
|
+
account: N,
|
|
117
|
+
transport: custom(P)
|
|
118
118
|
});
|
|
119
|
-
if (
|
|
119
|
+
if (J.address) {
|
|
120
120
|
let n = await t.writeContract({
|
|
121
|
-
address:
|
|
122
|
-
abi:
|
|
123
|
-
name: "transfer",
|
|
124
|
-
type: "function",
|
|
125
|
-
stateMutability: "nonpayable",
|
|
126
|
-
inputs: [{
|
|
127
|
-
name: "to",
|
|
128
|
-
type: "address"
|
|
129
|
-
}, {
|
|
130
|
-
name: "amount",
|
|
131
|
-
type: "uint256"
|
|
132
|
-
}],
|
|
133
|
-
outputs: [{ type: "bool" }]
|
|
134
|
-
}],
|
|
121
|
+
address: J.address,
|
|
122
|
+
abi: erc20Abi,
|
|
135
123
|
functionName: "transfer",
|
|
136
|
-
args: [e.receiveAddress, parseUnits(e.paymentAmount,
|
|
124
|
+
args: [e.receiveAddress, parseUnits(e.paymentAmount, J.decimals)],
|
|
137
125
|
chain: null
|
|
138
126
|
});
|
|
139
|
-
console.log("转账交易哈希:", n),
|
|
127
|
+
console.log("转账交易哈希:", n), B(n), G.current = n;
|
|
140
128
|
} else {
|
|
141
129
|
let n = await t.sendTransaction({
|
|
142
130
|
to: e.receiveAddress,
|
|
143
|
-
value: parseUnits(e.paymentAmount,
|
|
131
|
+
value: parseUnits(e.paymentAmount, J.decimals),
|
|
144
132
|
chain: null
|
|
145
133
|
});
|
|
146
|
-
console.log("转账交易哈希:", n),
|
|
134
|
+
console.log("转账交易哈希:", n), B(n), G.current = n;
|
|
147
135
|
}
|
|
148
|
-
|
|
136
|
+
w(!1), x("checking"), Q({ paymentId: e.paymentId });
|
|
149
137
|
} catch (e) {
|
|
150
|
-
console.error("钱包支付失败:", e),
|
|
138
|
+
console.error("钱包支付失败:", e), E(e instanceof Error ? e.message : y.walletPaymentFailed), g?.(e), w(!1);
|
|
151
139
|
}
|
|
152
|
-
},
|
|
153
|
-
if (!(!
|
|
154
|
-
|
|
155
|
-
let e =
|
|
156
|
-
await
|
|
140
|
+
}, Ve = async () => {
|
|
141
|
+
if (!(!N || !P || !W.current || !J || !K)) try {
|
|
142
|
+
w(!0);
|
|
143
|
+
let e = W.current;
|
|
144
|
+
await ze(K.chainId);
|
|
157
145
|
let t = createWalletClient({
|
|
158
|
-
account:
|
|
159
|
-
transport: custom(
|
|
146
|
+
account: N,
|
|
147
|
+
transport: custom(P)
|
|
160
148
|
});
|
|
161
|
-
if (!
|
|
149
|
+
if (!J.address) throw Error(y.subscriptionDoesNotSupportNative);
|
|
162
150
|
let n = await t.writeContract({
|
|
163
|
-
address:
|
|
164
|
-
abi:
|
|
165
|
-
name: "approve",
|
|
166
|
-
type: "function",
|
|
167
|
-
stateMutability: "nonpayable",
|
|
168
|
-
inputs: [{
|
|
169
|
-
name: "spender",
|
|
170
|
-
type: "address"
|
|
171
|
-
}, {
|
|
172
|
-
name: "amount",
|
|
173
|
-
type: "uint256"
|
|
174
|
-
}],
|
|
175
|
-
outputs: [{ type: "bool" }]
|
|
176
|
-
}],
|
|
151
|
+
address: J.address,
|
|
152
|
+
abi: erc20Abi,
|
|
177
153
|
functionName: "approve",
|
|
178
|
-
args: [e.spenderAddress, parseUnits(e.approveAmount,
|
|
154
|
+
args: [e.spenderAddress, parseUnits(e.approveAmount, J.decimals)],
|
|
179
155
|
chain: null
|
|
180
156
|
});
|
|
181
|
-
console.log("授权交易哈希:", n),
|
|
157
|
+
console.log("授权交易哈希:", n), B(n), G.current = n, w(!1), x("checking"), Q({ subscriptionId: e.subscriptionId });
|
|
182
158
|
} catch (e) {
|
|
183
|
-
console.error("钱包授权失败:", e),
|
|
159
|
+
console.error("钱包授权失败:", e), E(e instanceof Error ? e.message : y.walletPaymentFailed), g?.(e), w(!1);
|
|
184
160
|
}
|
|
185
|
-
},
|
|
186
|
-
if (!
|
|
187
|
-
let e =
|
|
188
|
-
|
|
161
|
+
}, He = async () => {
|
|
162
|
+
if (!N) {
|
|
163
|
+
let e = y.pleaseConnectWallet;
|
|
164
|
+
E(e), g?.(Error(e));
|
|
189
165
|
return;
|
|
190
166
|
}
|
|
191
|
-
|
|
192
|
-
},
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
167
|
+
p === "instant" ? await Be() : p === "subscription" && await Ve();
|
|
168
|
+
}, Ue = (e) => {
|
|
169
|
+
switch (e.toLowerCase()) {
|
|
170
|
+
case "ethereum":
|
|
171
|
+
case "bsc":
|
|
172
|
+
case "bsc-testnet": return "ethereum";
|
|
173
|
+
}
|
|
174
|
+
return "ethereum";
|
|
175
|
+
}, We = async () => {
|
|
176
|
+
if (!(!K || !J)) try {
|
|
177
|
+
if (w(!0), E(void 0), p === "instant") {
|
|
178
|
+
W.current = await v.createOnetimePayment({
|
|
179
|
+
paymentChain: K.chain,
|
|
180
|
+
paymentToken: J.symbol,
|
|
181
|
+
orderId: ye,
|
|
182
|
+
amount: Le,
|
|
183
|
+
remark: be
|
|
184
|
+
}), Z(W.current.expireAt), Je(W.current.paymentId, "instant");
|
|
185
|
+
let e = !J.address, t = Ue(K.chain.toLowerCase()), n = W.current.receiveAddress, r = parseUnits(W.current.paymentAmount, J.decimals), a = e ? `${t}:${n}@${K.chainId}?value=${r}` : `${t}:${J.address}@${K.chainId}/transfer?address=${n}&uint256=${r}`;
|
|
186
|
+
M(await QRCode.toDataURL(a, {
|
|
187
|
+
width: 200,
|
|
188
|
+
margin: 2,
|
|
189
|
+
errorCorrectionLevel: "H"
|
|
190
|
+
}));
|
|
191
|
+
} else if (p === "subscription") {
|
|
192
|
+
if (!h) throw Error(`Invalid Renewal Days: ${h ?? ""}`);
|
|
193
|
+
W.current = await v.createSubscriptionPayment({
|
|
194
|
+
paymentChain: K.chain,
|
|
195
|
+
paymentToken: J.symbol,
|
|
196
|
+
orderId: ye,
|
|
197
|
+
amountOfUsd: Le,
|
|
198
|
+
intervalDays: h
|
|
199
|
+
}), Z(W.current.expireAt), Je(W.current.subscriptionId, "subscription"), M(void 0);
|
|
212
200
|
}
|
|
213
|
-
|
|
214
|
-
width: 200,
|
|
215
|
-
margin: 2,
|
|
216
|
-
errorCorrectionLevel: "H"
|
|
217
|
-
}));
|
|
201
|
+
x("payment");
|
|
218
202
|
} catch (e) {
|
|
219
|
-
|
|
203
|
+
E(e instanceof Error ? e.message : y.createPaymentFailed), g?.(e);
|
|
220
204
|
} finally {
|
|
221
|
-
|
|
205
|
+
w(!1);
|
|
222
206
|
}
|
|
223
|
-
},
|
|
224
|
-
|
|
207
|
+
}, Ge = () => {
|
|
208
|
+
W.current && (x("checking"), E(void 0), p === "instant" ? Q({ paymentId: W.current.paymentId }) : p === "subscription" && Q({ subscriptionId: W.current.subscriptionId }));
|
|
225
209
|
}, Q = (e) => {
|
|
226
|
-
|
|
227
|
-
let t = () => defer(() =>
|
|
228
|
-
|
|
229
|
-
if (!
|
|
210
|
+
H.current?.unsubscribe();
|
|
211
|
+
let t = () => defer(() => p === "subscription" ? v.checkSubscriptionPaymentStatus(e) : v.checkOnetimePaymentStatus(e)).pipe(timeout(15e3), retry({ delay: 2e3 }));
|
|
212
|
+
H.current = t().pipe(expand((e) => e.status === "pending" ? timer(2e3).pipe(switchMap(() => t())) : EMPTY), tap((e) => {
|
|
213
|
+
if (!W.current && p === "instant") {
|
|
230
214
|
let t = e;
|
|
231
|
-
|
|
215
|
+
W.current = {
|
|
232
216
|
paymentId: t.paymentId,
|
|
233
217
|
orderId: t.orderId,
|
|
234
218
|
paymentChain: t.chain,
|
|
@@ -236,21 +220,21 @@ var PaymentContent_default = ({ apikey: t, ott: n, plain: u, orderId: xe, amount
|
|
|
236
220
|
paymentAmount: t.payAmount,
|
|
237
221
|
receiveAddress: t.receiveAddress,
|
|
238
222
|
expireAt: t.expireAt
|
|
239
|
-
},
|
|
240
|
-
let n =
|
|
241
|
-
QRCode.toDataURL(
|
|
223
|
+
}, k(t.chain), j(t.token), Z(t.expireAt);
|
|
224
|
+
let n = !t.tokenAddress, r = Ue(t.chain.toLowerCase()), a = t.receiveAddress, o = parseUnits(t.payAmount, t.tokenDecimals), s = n ? `${r}:${a}@${t.chainId}?value=${o}` : `${r}:${t.tokenAddress}@${t.chainId}/transfer?address=${a}&uint256=${o}`;
|
|
225
|
+
QRCode.toDataURL(s, {
|
|
242
226
|
width: 200,
|
|
243
227
|
margin: 2,
|
|
244
228
|
errorCorrectionLevel: "H"
|
|
245
229
|
}).then((e) => {
|
|
246
|
-
|
|
230
|
+
M(e), x("payment");
|
|
247
231
|
}).catch((e) => {
|
|
248
|
-
console.error("生成二维码失败:", e),
|
|
232
|
+
console.error("生成二维码失败:", e), x("payment");
|
|
249
233
|
});
|
|
250
234
|
}
|
|
251
|
-
if (!
|
|
235
|
+
if (!W.current && p === "subscription") {
|
|
252
236
|
let t = e;
|
|
253
|
-
|
|
237
|
+
W.current = {
|
|
254
238
|
subscriptionId: t.subscriptionId,
|
|
255
239
|
orderId: t.orderId,
|
|
256
240
|
paymentChain: t.chain,
|
|
@@ -260,49 +244,39 @@ var PaymentContent_default = ({ apikey: t, ott: n, plain: u, orderId: xe, amount
|
|
|
260
244
|
expireAt: t.expireAt,
|
|
261
245
|
intervalDays: 0,
|
|
262
246
|
amountOfUsd: t.amountOfUsd
|
|
263
|
-
},
|
|
264
|
-
let n = `${t.chain.toLowerCase()}:${t.approvedAddress}?amount=${t.approveAmount}`;
|
|
265
|
-
QRCode.toDataURL(n, {
|
|
266
|
-
width: 200,
|
|
267
|
-
margin: 2,
|
|
268
|
-
errorCorrectionLevel: "H"
|
|
269
|
-
}).then((e) => {
|
|
270
|
-
k(e), v("payment");
|
|
271
|
-
}).catch((e) => {
|
|
272
|
-
console.error("生成二维码失败:", e), v("payment");
|
|
273
|
-
});
|
|
247
|
+
}, k(t.chain), j(t.token), Z(t.expireAt), M(void 0);
|
|
274
248
|
}
|
|
275
|
-
(e.status === "paid" || e.status === "approved") && (
|
|
249
|
+
(e.status === "paid" || e.status === "approved") && (x("success"), $(), Se?.(e)), e.status === "expired" && (x("expired"), $(), Ce?.(e)), e.status === "failed" && (x("failed"), $(), we?.(e));
|
|
276
250
|
})).subscribe({
|
|
277
251
|
error: (e) => {
|
|
278
|
-
if (
|
|
279
|
-
let t = e instanceof Error ? e.message :
|
|
280
|
-
|
|
252
|
+
if (W.current) {
|
|
253
|
+
let t = e instanceof Error ? e.message : y.checkPaymentStatusFailed;
|
|
254
|
+
x("error"), E(t), g?.(e);
|
|
281
255
|
}
|
|
282
256
|
},
|
|
283
257
|
complete: () => {
|
|
284
|
-
|
|
258
|
+
H.current?.unsubscribe();
|
|
285
259
|
}
|
|
286
260
|
});
|
|
287
|
-
},
|
|
288
|
-
if (!
|
|
289
|
-
let e =
|
|
261
|
+
}, Ke = async () => {
|
|
262
|
+
if (!W.current) return;
|
|
263
|
+
let e = p === "subscription" ? W.current.spenderAddress : W.current.receiveAddress;
|
|
290
264
|
if (e) try {
|
|
291
|
-
await navigator.clipboard.writeText(e),
|
|
292
|
-
|
|
265
|
+
await navigator.clipboard.writeText(e), L(!0), setTimeout(() => {
|
|
266
|
+
L(!1);
|
|
293
267
|
}, 2e3);
|
|
294
268
|
} catch (e) {
|
|
295
269
|
console.error("复制失败:", e);
|
|
296
270
|
}
|
|
297
|
-
},
|
|
298
|
-
if (
|
|
299
|
-
await navigator.clipboard.writeText(
|
|
300
|
-
|
|
271
|
+
}, qe = async () => {
|
|
272
|
+
if (z) try {
|
|
273
|
+
await navigator.clipboard.writeText(z), L(!0), setTimeout(() => {
|
|
274
|
+
L(!1);
|
|
301
275
|
}, 2e3);
|
|
302
276
|
} catch (e) {
|
|
303
277
|
console.error("复制失败:", e);
|
|
304
278
|
}
|
|
305
|
-
},
|
|
279
|
+
}, Je = (e, t) => {
|
|
306
280
|
if (!n || typeof window > "u") return;
|
|
307
281
|
let r = new URL(window.location.href), i = t === "subscription" ? "subscriptionId" : "paymentId";
|
|
308
282
|
r.searchParams.set(i, e), window.history.replaceState({}, "", r.toString());
|
|
@@ -312,25 +286,25 @@ var PaymentContent_default = ({ apikey: t, ott: n, plain: u, orderId: xe, amount
|
|
|
312
286
|
e.searchParams.delete("paymentId"), e.searchParams.delete("subscriptionId"), window.history.replaceState({}, "", e.toString());
|
|
313
287
|
};
|
|
314
288
|
return useEffect(() => {
|
|
315
|
-
|
|
289
|
+
D.length === 0 && Re();
|
|
316
290
|
}, []), useEffect(() => {
|
|
317
|
-
|
|
318
|
-
}, [
|
|
291
|
+
q.length > 0 && j(q[0].symbol);
|
|
292
|
+
}, [q]), useEffect(() => {
|
|
319
293
|
if (typeof window > "u") return;
|
|
320
294
|
let e = new URL(window.location.href);
|
|
321
|
-
if (
|
|
295
|
+
if (p === "instant") {
|
|
322
296
|
let t = e.searchParams.get("paymentId");
|
|
323
|
-
t && (
|
|
297
|
+
t && (x("payment"), Q({ paymentId: t }));
|
|
324
298
|
}
|
|
325
|
-
if (
|
|
299
|
+
if (p === "subscription") {
|
|
326
300
|
let t = e.searchParams.get("subscriptionId");
|
|
327
|
-
t && (
|
|
301
|
+
t && (x("payment"), Q({ subscriptionId: t }));
|
|
328
302
|
}
|
|
329
303
|
}, []), useEffect(() => () => {
|
|
330
|
-
|
|
304
|
+
H.current?.unsubscribe(), Ie();
|
|
331
305
|
}, []), /* @__PURE__ */ jsx("div", {
|
|
332
306
|
className: "_cppay-content",
|
|
333
|
-
children:
|
|
307
|
+
children: b === "success" ? _?.Success ? /* @__PURE__ */ jsx(_.Success, { paymentInfo: W.current }) : /* @__PURE__ */ jsxs("div", {
|
|
334
308
|
className: "_cppay-state-container",
|
|
335
309
|
children: [
|
|
336
310
|
/* @__PURE__ */ jsx("div", {
|
|
@@ -342,22 +316,22 @@ var PaymentContent_default = ({ apikey: t, ott: n, plain: u, orderId: xe, amount
|
|
|
342
316
|
}),
|
|
343
317
|
/* @__PURE__ */ jsx("h3", {
|
|
344
318
|
className: "_cppay-state-title _cppay-state-title-success",
|
|
345
|
-
children:
|
|
319
|
+
children: p === "subscription" ? y.authorizationSuccess : y.paymentSuccess
|
|
346
320
|
}),
|
|
347
|
-
|
|
321
|
+
z && /* @__PURE__ */ jsxs("div", {
|
|
348
322
|
className: "_cppay-state-hash-container",
|
|
349
323
|
children: [/* @__PURE__ */ jsx("div", {
|
|
350
324
|
className: "_cppay-state-label",
|
|
351
|
-
children:
|
|
325
|
+
children: y.transactionHash
|
|
352
326
|
}), /* @__PURE__ */ jsxs("div", {
|
|
353
327
|
className: "_cppay-hash-row",
|
|
354
328
|
children: [/* @__PURE__ */ jsx("code", {
|
|
355
329
|
className: "_cppay-state-hash",
|
|
356
|
-
children:
|
|
330
|
+
children: z
|
|
357
331
|
}), /* @__PURE__ */ jsx("button", {
|
|
358
|
-
onClick:
|
|
332
|
+
onClick: qe,
|
|
359
333
|
className: "_cppay-state-copy-btn",
|
|
360
|
-
title:
|
|
334
|
+
title: y.copyAddress,
|
|
361
335
|
children: /* @__PURE__ */ jsxs("svg", {
|
|
362
336
|
viewBox: "0 0 24 24",
|
|
363
337
|
fill: "none",
|
|
@@ -375,60 +349,60 @@ var PaymentContent_default = ({ apikey: t, ott: n, plain: u, orderId: xe, amount
|
|
|
375
349
|
})]
|
|
376
350
|
})]
|
|
377
351
|
}),
|
|
378
|
-
|
|
352
|
+
W.current && /* @__PURE__ */ jsxs("div", {
|
|
379
353
|
className: "_cppay-success-details",
|
|
380
354
|
children: [
|
|
381
355
|
/* @__PURE__ */ jsxs("div", {
|
|
382
356
|
className: "_cppay-detail-item",
|
|
383
357
|
children: [/* @__PURE__ */ jsx("span", {
|
|
384
358
|
className: "_cppay-detail-label",
|
|
385
|
-
children:
|
|
359
|
+
children: y.orderId
|
|
386
360
|
}), /* @__PURE__ */ jsx("span", {
|
|
387
361
|
className: "_cppay-detail-value",
|
|
388
|
-
children:
|
|
362
|
+
children: W.current.orderId
|
|
389
363
|
})]
|
|
390
364
|
}),
|
|
391
365
|
/* @__PURE__ */ jsxs("div", {
|
|
392
366
|
className: "_cppay-detail-item",
|
|
393
367
|
children: [/* @__PURE__ */ jsx("span", {
|
|
394
368
|
className: "_cppay-detail-label",
|
|
395
|
-
children:
|
|
369
|
+
children: p === "subscription" ? y.authorizationAmount : y.paymentAmount
|
|
396
370
|
}), /* @__PURE__ */ jsx("span", {
|
|
397
371
|
className: "_cppay-detail-value",
|
|
398
|
-
children:
|
|
372
|
+
children: p === "subscription" ? `${X(W.current.approveAmount, Y(A))} ${A}` : `${X(W.current.paymentAmount, Y(A))} ${A}`
|
|
399
373
|
})]
|
|
400
374
|
}),
|
|
401
375
|
/* @__PURE__ */ jsxs("div", {
|
|
402
376
|
className: "_cppay-detail-item",
|
|
403
377
|
children: [/* @__PURE__ */ jsx("span", {
|
|
404
378
|
className: "_cppay-detail-label",
|
|
405
|
-
children:
|
|
379
|
+
children: y.paymentNetwork
|
|
406
380
|
}), /* @__PURE__ */ jsx("span", {
|
|
407
381
|
className: "_cppay-detail-value",
|
|
408
|
-
children:
|
|
382
|
+
children: W.current.paymentChain
|
|
409
383
|
})]
|
|
410
384
|
}),
|
|
411
385
|
/* @__PURE__ */ jsxs("div", {
|
|
412
386
|
className: "_cppay-detail-item",
|
|
413
387
|
children: [/* @__PURE__ */ jsx("span", {
|
|
414
388
|
className: "_cppay-detail-label",
|
|
415
|
-
children:
|
|
389
|
+
children: y.paymentToken
|
|
416
390
|
}), /* @__PURE__ */ jsx("span", {
|
|
417
391
|
className: "_cppay-detail-value",
|
|
418
|
-
children:
|
|
392
|
+
children: W.current.paymentToken
|
|
419
393
|
})]
|
|
420
394
|
}),
|
|
421
|
-
|
|
395
|
+
p === "subscription" && /* @__PURE__ */ jsxs("div", {
|
|
422
396
|
className: "_cppay-detail-item",
|
|
423
397
|
children: [/* @__PURE__ */ jsx("span", {
|
|
424
398
|
className: "_cppay-detail-label",
|
|
425
|
-
children:
|
|
399
|
+
children: y.renewalInterval
|
|
426
400
|
}), /* @__PURE__ */ jsxs("span", {
|
|
427
401
|
className: "_cppay-detail-value",
|
|
428
402
|
children: [
|
|
429
|
-
|
|
403
|
+
W.current.intervalDays,
|
|
430
404
|
" ",
|
|
431
|
-
|
|
405
|
+
y.days
|
|
432
406
|
]
|
|
433
407
|
})]
|
|
434
408
|
}),
|
|
@@ -436,16 +410,16 @@ var PaymentContent_default = ({ apikey: t, ott: n, plain: u, orderId: xe, amount
|
|
|
436
410
|
className: "_cppay-detail-item",
|
|
437
411
|
children: [/* @__PURE__ */ jsx("span", {
|
|
438
412
|
className: "_cppay-detail-label",
|
|
439
|
-
children:
|
|
413
|
+
children: p === "subscription" ? y.subscriptionId : y.paymentId
|
|
440
414
|
}), /* @__PURE__ */ jsx("span", {
|
|
441
415
|
className: "_cppay-detail-value _cppay-detail-id",
|
|
442
|
-
children:
|
|
416
|
+
children: p === "subscription" ? W.current.subscriptionId : W.current.paymentId
|
|
443
417
|
})]
|
|
444
418
|
})
|
|
445
419
|
]
|
|
446
420
|
})
|
|
447
421
|
]
|
|
448
|
-
}) :
|
|
422
|
+
}) : b === "expired" ? _?.Expired ? /* @__PURE__ */ jsx(_.Expired, { paymentInfo: W.current }) : /* @__PURE__ */ jsxs("div", {
|
|
449
423
|
className: "_cppay-state-container",
|
|
450
424
|
children: [
|
|
451
425
|
/* @__PURE__ */ jsx("div", {
|
|
@@ -457,22 +431,22 @@ var PaymentContent_default = ({ apikey: t, ott: n, plain: u, orderId: xe, amount
|
|
|
457
431
|
}),
|
|
458
432
|
/* @__PURE__ */ jsx("h3", {
|
|
459
433
|
className: "_cppay-state-title _cppay-state-title-expired",
|
|
460
|
-
children:
|
|
434
|
+
children: y.paymentExpired
|
|
461
435
|
}),
|
|
462
436
|
/* @__PURE__ */ jsx("p", {
|
|
463
437
|
className: "_cppay-state-message",
|
|
464
|
-
children:
|
|
438
|
+
children: y.pleaseInitiatePaymentAgain
|
|
465
439
|
}),
|
|
466
440
|
/* @__PURE__ */ jsx("button", {
|
|
467
441
|
onClick: () => {
|
|
468
|
-
|
|
442
|
+
x("select"), $();
|
|
469
443
|
},
|
|
470
|
-
disabled:
|
|
444
|
+
disabled: C || S,
|
|
471
445
|
className: "_cppay-btn _cppay-btn-primary _cppay-state-btn",
|
|
472
|
-
children:
|
|
446
|
+
children: y.returnButton
|
|
473
447
|
})
|
|
474
448
|
]
|
|
475
|
-
}) :
|
|
449
|
+
}) : b === "error" ? _?.Error ? /* @__PURE__ */ jsx(_.Error, { paymentInfo: W.current }) : /* @__PURE__ */ jsxs("div", {
|
|
476
450
|
className: "_cppay-state-container",
|
|
477
451
|
children: [
|
|
478
452
|
/* @__PURE__ */ jsx("div", {
|
|
@@ -484,22 +458,22 @@ var PaymentContent_default = ({ apikey: t, ott: n, plain: u, orderId: xe, amount
|
|
|
484
458
|
}),
|
|
485
459
|
/* @__PURE__ */ jsx("h3", {
|
|
486
460
|
className: "_cppay-state-title _cppay-state-title-error",
|
|
487
|
-
children:
|
|
461
|
+
children: T || y.error
|
|
488
462
|
}),
|
|
489
463
|
/* @__PURE__ */ jsx("p", {
|
|
490
464
|
className: "_cppay-state-message",
|
|
491
|
-
children:
|
|
465
|
+
children: y.checkStatusFailed
|
|
492
466
|
}),
|
|
493
467
|
/* @__PURE__ */ jsx("button", {
|
|
494
468
|
onClick: () => {
|
|
495
|
-
|
|
469
|
+
x("select"), $();
|
|
496
470
|
},
|
|
497
|
-
disabled:
|
|
471
|
+
disabled: C || S,
|
|
498
472
|
className: "_cppay-btn _cppay-btn-primary _cppay-state-btn",
|
|
499
|
-
children:
|
|
473
|
+
children: y.returnButton
|
|
500
474
|
})
|
|
501
475
|
]
|
|
502
|
-
}) :
|
|
476
|
+
}) : b === "failed" ? _?.Failed ? /* @__PURE__ */ jsx(_.Failed, { paymentInfo: W.current }) : /* @__PURE__ */ jsxs("div", {
|
|
503
477
|
className: "_cppay-state-container",
|
|
504
478
|
children: [
|
|
505
479
|
/* @__PURE__ */ jsx("div", {
|
|
@@ -511,33 +485,33 @@ var PaymentContent_default = ({ apikey: t, ott: n, plain: u, orderId: xe, amount
|
|
|
511
485
|
}),
|
|
512
486
|
/* @__PURE__ */ jsx("h3", {
|
|
513
487
|
className: "_cppay-state-title _cppay-state-title-failed",
|
|
514
|
-
children:
|
|
488
|
+
children: y.paymentFailed
|
|
515
489
|
}),
|
|
516
490
|
/* @__PURE__ */ jsx("p", {
|
|
517
491
|
className: "_cppay-state-message",
|
|
518
|
-
children:
|
|
492
|
+
children: y.pleaseInitiatePaymentAgain
|
|
519
493
|
}),
|
|
520
494
|
/* @__PURE__ */ jsx("button", {
|
|
521
495
|
onClick: () => {
|
|
522
|
-
|
|
496
|
+
x("select"), $();
|
|
523
497
|
},
|
|
524
|
-
disabled:
|
|
498
|
+
disabled: C || S,
|
|
525
499
|
className: "_cppay-btn _cppay-btn-primary _cppay-state-btn",
|
|
526
|
-
children:
|
|
500
|
+
children: y.returnButton
|
|
527
501
|
})
|
|
528
502
|
]
|
|
529
|
-
}) :
|
|
530
|
-
|
|
503
|
+
}) : b === "select" ? /* @__PURE__ */ jsxs("div", { children: [
|
|
504
|
+
_?.ChooseTop,
|
|
531
505
|
/* @__PURE__ */ jsxs("div", {
|
|
532
506
|
className: "_cppay-section",
|
|
533
507
|
children: [/* @__PURE__ */ jsx("label", {
|
|
534
508
|
className: "_cppay-label",
|
|
535
|
-
children:
|
|
509
|
+
children: y.paymentNetwork
|
|
536
510
|
}), /* @__PURE__ */ jsx("div", {
|
|
537
511
|
className: "_cppay-grid",
|
|
538
|
-
children:
|
|
539
|
-
onClick: () =>
|
|
540
|
-
className: `_cppay-select-btn ${
|
|
512
|
+
children: D.map((e) => /* @__PURE__ */ jsxs("button", {
|
|
513
|
+
onClick: () => k(e.chain),
|
|
514
|
+
className: `_cppay-select-btn ${O === e.chain ? "_cppay-selected" : ""}`,
|
|
541
515
|
children: [e.icon && /* @__PURE__ */ jsx("img", {
|
|
542
516
|
src: e.icon,
|
|
543
517
|
alt: e.chain
|
|
@@ -549,12 +523,12 @@ var PaymentContent_default = ({ apikey: t, ott: n, plain: u, orderId: xe, amount
|
|
|
549
523
|
className: "_cppay-section",
|
|
550
524
|
children: [/* @__PURE__ */ jsx("label", {
|
|
551
525
|
className: "_cppay-label",
|
|
552
|
-
children:
|
|
526
|
+
children: y.paymentToken
|
|
553
527
|
}), /* @__PURE__ */ jsx("div", {
|
|
554
528
|
className: "_cppay-grid",
|
|
555
|
-
children:
|
|
556
|
-
onClick: () =>
|
|
557
|
-
className: `_cppay-select-btn ${
|
|
529
|
+
children: q.map((e) => /* @__PURE__ */ jsxs("button", {
|
|
530
|
+
onClick: () => j(e.symbol),
|
|
531
|
+
className: `_cppay-select-btn ${A === e.symbol ? "_cppay-selected" : ""}`,
|
|
558
532
|
children: [e.icon && /* @__PURE__ */ jsx("img", {
|
|
559
533
|
src: e.icon,
|
|
560
534
|
alt: e.symbol
|
|
@@ -562,7 +536,7 @@ var PaymentContent_default = ({ apikey: t, ott: n, plain: u, orderId: xe, amount
|
|
|
562
536
|
}, e.symbol))
|
|
563
537
|
})]
|
|
564
538
|
}),
|
|
565
|
-
|
|
539
|
+
_?.ChooseBottom,
|
|
566
540
|
/* @__PURE__ */ jsx("div", {
|
|
567
541
|
className: "_cppay-section",
|
|
568
542
|
children: /* @__PURE__ */ jsx("div", {
|
|
@@ -571,19 +545,19 @@ var PaymentContent_default = ({ apikey: t, ott: n, plain: u, orderId: xe, amount
|
|
|
571
545
|
className: "_cppay-price-row",
|
|
572
546
|
children: [/* @__PURE__ */ jsx("span", {
|
|
573
547
|
className: "_cppay-price-label",
|
|
574
|
-
children:
|
|
548
|
+
children: y.paymentAmount
|
|
575
549
|
}), /* @__PURE__ */ jsxs("div", {
|
|
576
550
|
className: "_cppay-price-amount",
|
|
577
551
|
children: [/* @__PURE__ */ jsxs("div", {
|
|
578
552
|
className: "_cppay-price-main",
|
|
579
553
|
children: [
|
|
580
|
-
|
|
554
|
+
Le ?? "-",
|
|
581
555
|
" ",
|
|
582
|
-
|
|
556
|
+
A ?? ""
|
|
583
557
|
]
|
|
584
558
|
}), /* @__PURE__ */ jsxs("div", {
|
|
585
559
|
className: "_cppay-price-sub",
|
|
586
|
-
children: ["≈ $",
|
|
560
|
+
children: ["≈ $", m]
|
|
587
561
|
})]
|
|
588
562
|
})]
|
|
589
563
|
})
|
|
@@ -591,10 +565,10 @@ var PaymentContent_default = ({ apikey: t, ott: n, plain: u, orderId: xe, amount
|
|
|
591
565
|
}),
|
|
592
566
|
/* @__PURE__ */ jsxs("div", {
|
|
593
567
|
className: "_cppay-section",
|
|
594
|
-
children: [
|
|
568
|
+
children: [T && /* @__PURE__ */ jsxs("div", {
|
|
595
569
|
className: "_cppay-error-tooltip-wrapper",
|
|
596
|
-
onMouseEnter: () =>
|
|
597
|
-
onMouseLeave: () =>
|
|
570
|
+
onMouseEnter: () => R(!0),
|
|
571
|
+
onMouseLeave: () => R(!1),
|
|
598
572
|
children: [/* @__PURE__ */ jsxs("div", {
|
|
599
573
|
className: "_cppay-error-tooltip",
|
|
600
574
|
children: [/* @__PURE__ */ jsx("svg", {
|
|
@@ -605,25 +579,25 @@ var PaymentContent_default = ({ apikey: t, ott: n, plain: u, orderId: xe, amount
|
|
|
605
579
|
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",
|
|
606
580
|
clipRule: "evenodd"
|
|
607
581
|
})
|
|
608
|
-
}), /* @__PURE__ */ jsx("span", { children:
|
|
609
|
-
}),
|
|
582
|
+
}), /* @__PURE__ */ jsx("span", { children: T })]
|
|
583
|
+
}), Ne && /* @__PURE__ */ jsx("div", {
|
|
610
584
|
className: "_cppay-error-tooltip-full",
|
|
611
|
-
children:
|
|
585
|
+
children: T
|
|
612
586
|
})]
|
|
613
587
|
}), /* @__PURE__ */ jsx("button", {
|
|
614
|
-
onClick:
|
|
615
|
-
disabled: !
|
|
588
|
+
onClick: We,
|
|
589
|
+
disabled: !O || !A || C,
|
|
616
590
|
className: "_cppay-btn _cppay-btn-primary",
|
|
617
|
-
children:
|
|
591
|
+
children: C ? y.processing : y.continuePayment
|
|
618
592
|
})]
|
|
619
593
|
})
|
|
620
594
|
] }) : /* @__PURE__ */ jsxs("div", { children: [
|
|
621
|
-
/* @__PURE__ */ jsx("div", {
|
|
595
|
+
De && /* @__PURE__ */ jsx("div", {
|
|
622
596
|
className: "_cppay-qr-container",
|
|
623
597
|
children: /* @__PURE__ */ jsx("div", {
|
|
624
598
|
className: "_cppay-qr-code",
|
|
625
|
-
children:
|
|
626
|
-
src:
|
|
599
|
+
children: /* @__PURE__ */ jsx("img", {
|
|
600
|
+
src: De,
|
|
627
601
|
alt: "Payment QR Code",
|
|
628
602
|
className: "_cppay-qr-image"
|
|
629
603
|
})
|
|
@@ -632,7 +606,7 @@ var PaymentContent_default = ({ apikey: t, ott: n, plain: u, orderId: xe, amount
|
|
|
632
606
|
/* @__PURE__ */ jsxs("div", {
|
|
633
607
|
className: "_cppay-section",
|
|
634
608
|
children: [
|
|
635
|
-
|
|
609
|
+
J && /* @__PURE__ */ jsx("div", {
|
|
636
610
|
className: "_cppay-info-box",
|
|
637
611
|
children: /* @__PURE__ */ jsx("div", {
|
|
638
612
|
className: "_cppay-info-flex-container",
|
|
@@ -640,10 +614,10 @@ var PaymentContent_default = ({ apikey: t, ott: n, plain: u, orderId: xe, amount
|
|
|
640
614
|
className: "_cppay-info-flex-child",
|
|
641
615
|
children: [/* @__PURE__ */ jsx("div", {
|
|
642
616
|
className: "_cppay-info-label",
|
|
643
|
-
children:
|
|
617
|
+
children: p === "subscription" ? y.authorizationAmount : y.paymentAmount
|
|
644
618
|
}), /* @__PURE__ */ jsxs("div", {
|
|
645
619
|
className: "_cppay-info-value _cppay-info-value-flex",
|
|
646
|
-
children: [
|
|
620
|
+
children: [W.current && /* @__PURE__ */ jsx("span", { children: p === "subscription" ? `${X(W.current.approveAmount, Y(J.symbol))} ${J.symbol}` : `${X(W.current.paymentAmount, Y(J.symbol))} ${J.symbol}` }), /* @__PURE__ */ jsxs("span", { children: ["≈ $", m] })]
|
|
647
621
|
})]
|
|
648
622
|
})
|
|
649
623
|
})
|
|
@@ -654,17 +628,17 @@ var PaymentContent_default = ({ apikey: t, ott: n, plain: u, orderId: xe, amount
|
|
|
654
628
|
className: "_cppay-info-flex-child",
|
|
655
629
|
children: [/* @__PURE__ */ jsxs("div", {
|
|
656
630
|
className: "_cppay-info-label _cppay-info-label-flex",
|
|
657
|
-
children: [/* @__PURE__ */ jsx("span", { children:
|
|
631
|
+
children: [/* @__PURE__ */ jsx("span", { children: p === "subscription" ? y.authorizationContractAddress : y.paymentAddress }), je && /* @__PURE__ */ jsxs("span", {
|
|
658
632
|
className: "_cppay-countdown",
|
|
659
|
-
children: ["⏰ ",
|
|
633
|
+
children: ["⏰ ", je]
|
|
660
634
|
})]
|
|
661
635
|
}), /* @__PURE__ */ jsxs("div", {
|
|
662
636
|
className: "_cppay-address-row",
|
|
663
|
-
children: [
|
|
664
|
-
onClick:
|
|
665
|
-
className: `_cppay-copy-btn ${
|
|
666
|
-
title:
|
|
667
|
-
children:
|
|
637
|
+
children: [W.current && /* @__PURE__ */ jsx("code", { children: p === "subscription" ? W.current.spenderAddress : W.current.receiveAddress }), /* @__PURE__ */ jsx("button", {
|
|
638
|
+
onClick: Ke,
|
|
639
|
+
className: `_cppay-copy-btn ${I ? "_cppay-copy-success" : ""}`,
|
|
640
|
+
title: I ? y.copied : y.copyAddress,
|
|
641
|
+
children: I ? /* @__PURE__ */ jsx("svg", {
|
|
668
642
|
className: "_cppay-copy-icon",
|
|
669
643
|
viewBox: "0 0 24 24",
|
|
670
644
|
fill: "currentColor",
|
|
@@ -688,22 +662,22 @@ var PaymentContent_default = ({ apikey: t, ott: n, plain: u, orderId: xe, amount
|
|
|
688
662
|
})]
|
|
689
663
|
})
|
|
690
664
|
}),
|
|
691
|
-
|
|
665
|
+
p === "subscription" && /* @__PURE__ */ jsxs("div", {
|
|
692
666
|
className: "_cppay-info-box _cppay-subscription-box",
|
|
693
667
|
children: [/* @__PURE__ */ jsx("div", {
|
|
694
668
|
className: "_cppay-info-label _cppay-subscription-label",
|
|
695
|
-
children:
|
|
669
|
+
children: y.subscriptionNotice
|
|
696
670
|
}), /* @__PURE__ */ jsx("div", {
|
|
697
671
|
className: "_cppay-info-value _cppay-subscription-message",
|
|
698
|
-
children:
|
|
672
|
+
children: y.subscriptionNoticeMessage
|
|
699
673
|
})]
|
|
700
674
|
})
|
|
701
675
|
]
|
|
702
676
|
}),
|
|
703
|
-
|
|
677
|
+
T && /* @__PURE__ */ jsxs("div", {
|
|
704
678
|
className: "_cppay-error-tooltip-wrapper",
|
|
705
|
-
onMouseEnter: () =>
|
|
706
|
-
onMouseLeave: () =>
|
|
679
|
+
onMouseEnter: () => R(!0),
|
|
680
|
+
onMouseLeave: () => R(!1),
|
|
707
681
|
children: [/* @__PURE__ */ jsxs("div", {
|
|
708
682
|
className: "_cppay-error-tooltip",
|
|
709
683
|
children: [/* @__PURE__ */ jsx("svg", {
|
|
@@ -714,30 +688,30 @@ var PaymentContent_default = ({ apikey: t, ott: n, plain: u, orderId: xe, amount
|
|
|
714
688
|
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",
|
|
715
689
|
clipRule: "evenodd"
|
|
716
690
|
})
|
|
717
|
-
}), /* @__PURE__ */ jsx("span", { children:
|
|
718
|
-
}),
|
|
691
|
+
}), /* @__PURE__ */ jsx("span", { children: T })]
|
|
692
|
+
}), Ne && /* @__PURE__ */ jsx("div", {
|
|
719
693
|
className: "_cppay-error-tooltip-full",
|
|
720
|
-
children:
|
|
694
|
+
children: T
|
|
721
695
|
})]
|
|
722
696
|
}),
|
|
723
|
-
!
|
|
697
|
+
!S && /* @__PURE__ */ jsx("div", {
|
|
724
698
|
className: "_cppay-section",
|
|
725
|
-
children:
|
|
726
|
-
onClick:
|
|
727
|
-
disabled:
|
|
699
|
+
children: N ? /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("button", {
|
|
700
|
+
onClick: He,
|
|
701
|
+
disabled: C,
|
|
728
702
|
className: "_cppay-btn _cppay-btn-primary",
|
|
729
|
-
children:
|
|
703
|
+
children: C ? p === "subscription" ? y.authorizing : y.processing : p === "subscription" ? `💳 ${y.walletAuthorize}` : `💳 ${y.walletPay}`
|
|
730
704
|
}), /* @__PURE__ */ jsxs("button", {
|
|
731
|
-
onClick:
|
|
732
|
-
disabled:
|
|
705
|
+
onClick: Pe,
|
|
706
|
+
disabled: C,
|
|
733
707
|
className: "_cppay-btn _cppay-wallet-address-btn",
|
|
734
|
-
title:
|
|
708
|
+
title: y.clickToModifyWallet,
|
|
735
709
|
children: [/* @__PURE__ */ jsxs("span", {
|
|
736
710
|
className: "_cppay-wallet-address-text",
|
|
737
711
|
children: [
|
|
738
|
-
|
|
712
|
+
N.slice(0, 10),
|
|
739
713
|
"...",
|
|
740
|
-
|
|
714
|
+
N.slice(-4)
|
|
741
715
|
]
|
|
742
716
|
}), /* @__PURE__ */ jsx("svg", {
|
|
743
717
|
className: "_cppay-wallet-arrow",
|
|
@@ -748,19 +722,19 @@ var PaymentContent_default = ({ apikey: t, ott: n, plain: u, orderId: xe, amount
|
|
|
748
722
|
children: /* @__PURE__ */ jsx("polyline", { points: "6 9 12 15 18 9" })
|
|
749
723
|
})]
|
|
750
724
|
})] }) : /* @__PURE__ */ jsx("button", {
|
|
751
|
-
onClick:
|
|
752
|
-
disabled:
|
|
725
|
+
onClick: Pe,
|
|
726
|
+
disabled: ke,
|
|
753
727
|
className: "_cppay-btn _cppay-btn-secondary _cppay-connect-wallet-btn",
|
|
754
|
-
children: /* @__PURE__ */ jsx("span", { children:
|
|
728
|
+
children: /* @__PURE__ */ jsx("span", { children: ke ? y.processing : `💳 ${y.connectWallet}` })
|
|
755
729
|
})
|
|
756
730
|
}),
|
|
757
731
|
/* @__PURE__ */ jsx("div", {
|
|
758
732
|
className: "_cppay-section",
|
|
759
733
|
children: /* @__PURE__ */ jsx("button", {
|
|
760
|
-
onClick:
|
|
761
|
-
disabled:
|
|
734
|
+
onClick: Ge,
|
|
735
|
+
disabled: S,
|
|
762
736
|
className: "_cppay-btn _cppay-btn-primary",
|
|
763
|
-
children:
|
|
737
|
+
children: S ? /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsxs("svg", {
|
|
764
738
|
className: "_cppay-spinner",
|
|
765
739
|
viewBox: "0 0 24 24",
|
|
766
740
|
fill: "none",
|
|
@@ -778,7 +752,7 @@ var PaymentContent_default = ({ apikey: t, ott: n, plain: u, orderId: xe, amount
|
|
|
778
752
|
strokeWidth: "3",
|
|
779
753
|
strokeLinecap: "round"
|
|
780
754
|
})]
|
|
781
|
-
}),
|
|
755
|
+
}), y.checking] }) : y.completedPayment
|
|
782
756
|
})
|
|
783
757
|
}),
|
|
784
758
|
/* @__PURE__ */ jsx("hr", { className: "_cppay-divider" }),
|
|
@@ -786,32 +760,32 @@ var PaymentContent_default = ({ apikey: t, ott: n, plain: u, orderId: xe, amount
|
|
|
786
760
|
className: "_cppay-section",
|
|
787
761
|
children: /* @__PURE__ */ jsx("button", {
|
|
788
762
|
onClick: () => {
|
|
789
|
-
|
|
763
|
+
x("select"), $();
|
|
790
764
|
},
|
|
791
|
-
disabled:
|
|
765
|
+
disabled: C || S,
|
|
792
766
|
className: "_cppay-btn _cppay-btn-text",
|
|
793
|
-
children:
|
|
767
|
+
children: y.changePaymentMethod
|
|
794
768
|
})
|
|
795
769
|
})
|
|
796
770
|
] })
|
|
797
771
|
});
|
|
798
|
-
}, PaymentDialog_default = ({ open: e, onClose: t, ott: n, apikey: i, plain:
|
|
799
|
-
let [
|
|
772
|
+
}, PaymentDialog_default = ({ open: e, onClose: t, ott: n, apikey: i, plain: a, orderId: o, amount: s, intervalDays: de, remark: fe, locale: c, onExpired: pe, onSuccess: me, onFailed: he, onError: ge, Slots: _e }) => {
|
|
773
|
+
let [l, ve] = useState("select"), u = useMemo(() => l !== "checking", [l]);
|
|
800
774
|
useEffect(() => {
|
|
801
|
-
e ||
|
|
775
|
+
e || ve("select");
|
|
802
776
|
}, [e]), useEffect(() => {
|
|
803
777
|
if (!e) return;
|
|
804
778
|
let t = (e) => {
|
|
805
|
-
e.key === "Escape" &&
|
|
779
|
+
e.key === "Escape" && u && d();
|
|
806
780
|
};
|
|
807
781
|
return window.addEventListener("keydown", t), () => window.removeEventListener("keydown", t);
|
|
808
|
-
}, [e,
|
|
809
|
-
let
|
|
810
|
-
|
|
811
|
-
},
|
|
782
|
+
}, [e, u]);
|
|
783
|
+
let d = () => {
|
|
784
|
+
u && t();
|
|
785
|
+
}, f = useMemo(() => getLocaleMessages(c), [c]);
|
|
812
786
|
return e ? /* @__PURE__ */ jsx("div", {
|
|
813
787
|
className: "_cppay-overlay",
|
|
814
|
-
onClick: (e) => e.target === e.currentTarget &&
|
|
788
|
+
onClick: (e) => e.target === e.currentTarget && d(),
|
|
815
789
|
children: /* @__PURE__ */ jsxs("div", {
|
|
816
790
|
className: "_cppay-dialog",
|
|
817
791
|
children: [/* @__PURE__ */ jsxs("div", {
|
|
@@ -819,19 +793,19 @@ var PaymentContent_default = ({ apikey: t, ott: n, plain: u, orderId: xe, amount
|
|
|
819
793
|
children: [/* @__PURE__ */ jsx("h2", {
|
|
820
794
|
className: "_cppay-title",
|
|
821
795
|
children: (() => {
|
|
822
|
-
switch (
|
|
823
|
-
case "success": return
|
|
824
|
-
case "expired": return
|
|
825
|
-
case "failed": return
|
|
826
|
-
case "error": return
|
|
796
|
+
switch (l) {
|
|
797
|
+
case "success": return f.paymentResult;
|
|
798
|
+
case "expired": return f.paymentExpired;
|
|
799
|
+
case "failed": return f.paymentFailed;
|
|
800
|
+
case "error": return f.error;
|
|
827
801
|
case "payment":
|
|
828
|
-
case "checking": return
|
|
829
|
-
default: return
|
|
802
|
+
case "checking": return f.completePayment;
|
|
803
|
+
default: return f.selectPaymentMethod;
|
|
830
804
|
}
|
|
831
805
|
})()
|
|
832
806
|
}), /* @__PURE__ */ jsx("button", {
|
|
833
|
-
onClick:
|
|
834
|
-
disabled: !
|
|
807
|
+
onClick: d,
|
|
808
|
+
disabled: !u,
|
|
835
809
|
className: "_cppay-close-btn",
|
|
836
810
|
children: /* @__PURE__ */ jsx("svg", {
|
|
837
811
|
fill: "none",
|
|
@@ -848,51 +822,51 @@ var PaymentContent_default = ({ apikey: t, ott: n, plain: u, orderId: xe, amount
|
|
|
848
822
|
}), /* @__PURE__ */ jsx(PaymentContent_default, {
|
|
849
823
|
apikey: i,
|
|
850
824
|
ott: n,
|
|
851
|
-
plain:
|
|
852
|
-
orderId:
|
|
853
|
-
amount:
|
|
854
|
-
intervalDays:
|
|
855
|
-
remark:
|
|
856
|
-
locale:
|
|
857
|
-
onSuccess:
|
|
858
|
-
onExpired:
|
|
859
|
-
onFailed:
|
|
860
|
-
onError:
|
|
861
|
-
Slots:
|
|
862
|
-
onPaymentStepChange:
|
|
825
|
+
plain: a,
|
|
826
|
+
orderId: o,
|
|
827
|
+
amount: s,
|
|
828
|
+
intervalDays: de,
|
|
829
|
+
remark: fe,
|
|
830
|
+
locale: c,
|
|
831
|
+
onSuccess: me,
|
|
832
|
+
onExpired: pe,
|
|
833
|
+
onFailed: he,
|
|
834
|
+
onError: ge,
|
|
835
|
+
Slots: _e,
|
|
836
|
+
onPaymentStepChange: ve
|
|
863
837
|
})]
|
|
864
838
|
})
|
|
865
839
|
}) : null;
|
|
866
840
|
}, CppayContext = createContext(null);
|
|
867
841
|
const CppayProvider = ({ children: e }) => {
|
|
868
|
-
let [t, n] = useState(!1), [r, i] = useState(null),
|
|
842
|
+
let [t, n] = useState(!1), [r, i] = useState(null), a = useCallback((e) => {
|
|
869
843
|
i(e), n(!0);
|
|
870
|
-
}, []),
|
|
844
|
+
}, []), o = useCallback(() => {
|
|
871
845
|
n(!1);
|
|
872
|
-
}, []),
|
|
846
|
+
}, []), s = useCallback(() => {
|
|
873
847
|
n(!1);
|
|
874
|
-
}, []),
|
|
848
|
+
}, []), de = useCallback((e) => {
|
|
875
849
|
r?.onSuccess?.(e);
|
|
876
|
-
}, [r]),
|
|
850
|
+
}, [r]), fe = useCallback((e) => {
|
|
877
851
|
r?.onExpired?.(e);
|
|
878
|
-
}, [r]),
|
|
852
|
+
}, [r]), c = useCallback((e) => {
|
|
879
853
|
r?.onFailed?.(e);
|
|
880
|
-
}, [r]),
|
|
854
|
+
}, [r]), pe = useCallback((e) => {
|
|
881
855
|
r?.onError?.(e);
|
|
882
856
|
}, [r]);
|
|
883
857
|
return /* @__PURE__ */ jsxs(CppayContext.Provider, {
|
|
884
858
|
value: {
|
|
885
|
-
showPayment:
|
|
886
|
-
closePayment:
|
|
859
|
+
showPayment: a,
|
|
860
|
+
closePayment: o
|
|
887
861
|
},
|
|
888
862
|
children: [e, r && /* @__PURE__ */ jsx(PaymentDialog_default, {
|
|
889
863
|
open: t,
|
|
890
|
-
onClose:
|
|
864
|
+
onClose: s,
|
|
891
865
|
...r,
|
|
892
|
-
onSuccess:
|
|
893
|
-
onExpired:
|
|
894
|
-
onFailed:
|
|
895
|
-
onError:
|
|
866
|
+
onSuccess: de,
|
|
867
|
+
onExpired: fe,
|
|
868
|
+
onFailed: c,
|
|
869
|
+
onError: pe
|
|
896
870
|
})]
|
|
897
871
|
});
|
|
898
872
|
}, useCppayPayment = () => {
|