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