cppay-sdk 0.0.2-beta.40 → 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/{locales-BU7nq14n.js → locales-4xPBXjL_.js} +11 -1
- package/dist/{locales-ChrHW5Qd.cjs → locales-Cm9yIiVb.cjs} +1 -1
- package/dist/react.cjs +1 -1
- package/dist/react.js +390 -239
- package/dist/vue.cjs +1 -1
- package/dist/vue.js +361 -262
- package/package.json +1 -1
package/dist/react.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { t as cppay_default } from "./cppay-Db8t1Cra.js";
|
|
2
|
-
import { n as injectStyle, r as payment_dialog_default, t as getLocaleMessages } from "./locales-
|
|
2
|
+
import { n as injectStyle, r as payment_dialog_default, t as getLocaleMessages } from "./locales-4xPBXjL_.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";
|
|
@@ -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: u, orderId:
|
|
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: u, orderId: d, 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: u, orderId: d, 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
|
|
66
|
-
let t = Math.floor(e / 3600), n = Math.floor(e % 3600 / 60), r = e % 60;
|
|
67
|
-
return t > 0 ? `${t}
|
|
68
|
-
},
|
|
69
|
-
|
|
64
|
+
}, Ie = (e) => {
|
|
65
|
+
if (e <= 0) return g.expired;
|
|
66
|
+
let t = Math.floor(e / 3600), n = Math.floor(e % 3600 / 60), r = e % 60, i = (e) => e.toString().padStart(2, "0");
|
|
67
|
+
return t > 0 ? `${t}:${i(n)}:${i(r)}` : `${n}:${i(r)}`;
|
|
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: u, orderId: d, 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: u, orderId: d, 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
|
-
u === "instant" ? await
|
|
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 (u === "instant")
|
|
197
|
-
paymentChain:
|
|
198
|
-
paymentToken:
|
|
199
|
-
orderId:
|
|
200
|
-
amount:
|
|
201
|
-
remark:
|
|
202
|
-
}), 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
203
|
else if (u === "subscription") {
|
|
204
|
-
if (!
|
|
205
|
-
|
|
206
|
-
paymentChain:
|
|
207
|
-
paymentToken:
|
|
208
|
-
orderId:
|
|
209
|
-
amountOfUsd:
|
|
210
|
-
intervalDays:
|
|
211
|
-
}), e = `${
|
|
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(() => u === "subscription" ?
|
|
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,38 +342,26 @@ var PaymentContent_default = ({ apikey: t, ott: n, plain: u, orderId: d, amount:
|
|
|
259
342
|
}),
|
|
260
343
|
/* @__PURE__ */ jsx("h3", {
|
|
261
344
|
className: "_cppay-state-title _cppay-state-title-success",
|
|
262
|
-
children: u === "subscription" ?
|
|
345
|
+
children: u === "subscription" ? g.authorizationSuccess : g.paymentSuccess
|
|
263
346
|
}),
|
|
264
|
-
/* @__PURE__ */
|
|
265
|
-
className: "_cppay-state-message",
|
|
266
|
-
children: u === "subscription" ? _.subscriptionActivated : _.transactionCompleted
|
|
267
|
-
}),
|
|
268
|
-
R && /* @__PURE__ */ jsxs("div", {
|
|
347
|
+
L && /* @__PURE__ */ jsxs("div", {
|
|
269
348
|
className: "_cppay-state-hash-container",
|
|
270
349
|
children: [/* @__PURE__ */ jsx("div", {
|
|
271
350
|
className: "_cppay-state-label",
|
|
272
|
-
children:
|
|
351
|
+
children: g.transactionHash
|
|
273
352
|
}), /* @__PURE__ */ jsxs("div", {
|
|
274
353
|
className: "_cppay-hash-row",
|
|
275
354
|
children: [/* @__PURE__ */ jsxs("code", {
|
|
276
355
|
className: "_cppay-state-hash",
|
|
277
356
|
children: [
|
|
278
|
-
|
|
357
|
+
L.slice(0, 18),
|
|
279
358
|
"...",
|
|
280
|
-
|
|
359
|
+
L.slice(-18)
|
|
281
360
|
]
|
|
282
361
|
}), /* @__PURE__ */ jsx("button", {
|
|
283
|
-
onClick:
|
|
284
|
-
if (R) try {
|
|
285
|
-
await navigator.clipboard.writeText(R), I(!0), setTimeout(() => {
|
|
286
|
-
I(!1);
|
|
287
|
-
}, 2e3);
|
|
288
|
-
} catch (e) {
|
|
289
|
-
console.error("复制失败:", e);
|
|
290
|
-
}
|
|
291
|
-
},
|
|
362
|
+
onClick: Ge,
|
|
292
363
|
className: "_cppay-state-copy-btn",
|
|
293
|
-
title:
|
|
364
|
+
title: g.copyAddress,
|
|
294
365
|
children: /* @__PURE__ */ jsxs("svg", {
|
|
295
366
|
viewBox: "0 0 24 24",
|
|
296
367
|
fill: "none",
|
|
@@ -308,13 +379,77 @@ var PaymentContent_default = ({ apikey: t, ott: n, plain: u, orderId: d, amount:
|
|
|
308
379
|
})]
|
|
309
380
|
})]
|
|
310
381
|
}),
|
|
311
|
-
/* @__PURE__ */
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
382
|
+
H.current && /* @__PURE__ */ jsxs("div", {
|
|
383
|
+
className: "_cppay-success-details",
|
|
384
|
+
children: [
|
|
385
|
+
/* @__PURE__ */ jsxs("div", {
|
|
386
|
+
className: "_cppay-detail-item",
|
|
387
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
388
|
+
className: "_cppay-detail-label",
|
|
389
|
+
children: g.orderId
|
|
390
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
391
|
+
className: "_cppay-detail-value",
|
|
392
|
+
children: H.current.orderId
|
|
393
|
+
})]
|
|
394
|
+
}),
|
|
395
|
+
/* @__PURE__ */ jsxs("div", {
|
|
396
|
+
className: "_cppay-detail-item",
|
|
397
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
398
|
+
className: "_cppay-detail-label",
|
|
399
|
+
children: u === "subscription" ? g.authorizationAmount : g.paymentAmount
|
|
400
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
401
|
+
className: "_cppay-detail-value",
|
|
402
|
+
children: u === "subscription" ? `${J(H.current.approveAmount, q(D))} ${D}` : `${J(H.current.paymentAmount, q(D))} ${D}`
|
|
403
|
+
})]
|
|
404
|
+
}),
|
|
405
|
+
/* @__PURE__ */ jsxs("div", {
|
|
406
|
+
className: "_cppay-detail-item",
|
|
407
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
408
|
+
className: "_cppay-detail-label",
|
|
409
|
+
children: g.paymentNetwork
|
|
410
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
411
|
+
className: "_cppay-detail-value",
|
|
412
|
+
children: H.current.paymentChain
|
|
413
|
+
})]
|
|
414
|
+
}),
|
|
415
|
+
/* @__PURE__ */ jsxs("div", {
|
|
416
|
+
className: "_cppay-detail-item",
|
|
417
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
418
|
+
className: "_cppay-detail-label",
|
|
419
|
+
children: g.paymentToken
|
|
420
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
421
|
+
className: "_cppay-detail-value",
|
|
422
|
+
children: H.current.paymentToken
|
|
423
|
+
})]
|
|
424
|
+
}),
|
|
425
|
+
u === "subscription" && /* @__PURE__ */ jsxs("div", {
|
|
426
|
+
className: "_cppay-detail-item",
|
|
427
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
428
|
+
className: "_cppay-detail-label",
|
|
429
|
+
children: g.renewalInterval
|
|
430
|
+
}), /* @__PURE__ */ jsxs("span", {
|
|
431
|
+
className: "_cppay-detail-value",
|
|
432
|
+
children: [
|
|
433
|
+
H.current.intervalDays,
|
|
434
|
+
" ",
|
|
435
|
+
g.days
|
|
436
|
+
]
|
|
437
|
+
})]
|
|
438
|
+
}),
|
|
439
|
+
/* @__PURE__ */ jsxs("div", {
|
|
440
|
+
className: "_cppay-detail-item",
|
|
441
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
442
|
+
className: "_cppay-detail-label",
|
|
443
|
+
children: u === "subscription" ? g.subscriptionId : g.paymentId
|
|
444
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
445
|
+
className: "_cppay-detail-value _cppay-detail-id",
|
|
446
|
+
children: u === "subscription" ? H.current.subscriptionId : H.current.paymentId
|
|
447
|
+
})]
|
|
448
|
+
})
|
|
449
|
+
]
|
|
315
450
|
})
|
|
316
451
|
]
|
|
317
|
-
}) :
|
|
452
|
+
}) : _ === "expired" ? m?.Expired ? /* @__PURE__ */ jsx(m.Expired, { paymentInfo: H.current }) : /* @__PURE__ */ jsxs("div", {
|
|
318
453
|
className: "_cppay-state-container",
|
|
319
454
|
children: [
|
|
320
455
|
/* @__PURE__ */ jsx("div", {
|
|
@@ -326,20 +461,22 @@ var PaymentContent_default = ({ apikey: t, ott: n, plain: u, orderId: d, amount:
|
|
|
326
461
|
}),
|
|
327
462
|
/* @__PURE__ */ jsx("h3", {
|
|
328
463
|
className: "_cppay-state-title _cppay-state-title-expired",
|
|
329
|
-
children:
|
|
464
|
+
children: g.paymentExpired
|
|
330
465
|
}),
|
|
331
466
|
/* @__PURE__ */ jsx("p", {
|
|
332
467
|
className: "_cppay-state-message",
|
|
333
|
-
children:
|
|
468
|
+
children: g.pleaseInitiatePaymentAgain
|
|
334
469
|
}),
|
|
335
470
|
/* @__PURE__ */ jsx("button", {
|
|
336
|
-
onClick: () =>
|
|
337
|
-
|
|
471
|
+
onClick: () => {
|
|
472
|
+
v("select"), $();
|
|
473
|
+
},
|
|
474
|
+
disabled: b || y,
|
|
338
475
|
className: "_cppay-btn _cppay-btn-primary _cppay-state-btn",
|
|
339
|
-
children:
|
|
476
|
+
children: g.returnButton
|
|
340
477
|
})
|
|
341
478
|
]
|
|
342
|
-
}) :
|
|
479
|
+
}) : _ === "error" ? m?.Error ? /* @__PURE__ */ jsx(m.Error, { paymentInfo: H.current }) : /* @__PURE__ */ jsxs("div", {
|
|
343
480
|
className: "_cppay-state-container",
|
|
344
481
|
children: [
|
|
345
482
|
/* @__PURE__ */ jsx("div", {
|
|
@@ -351,20 +488,22 @@ var PaymentContent_default = ({ apikey: t, ott: n, plain: u, orderId: d, amount:
|
|
|
351
488
|
}),
|
|
352
489
|
/* @__PURE__ */ jsx("h3", {
|
|
353
490
|
className: "_cppay-state-title _cppay-state-title-error",
|
|
354
|
-
children:
|
|
491
|
+
children: S || g.error
|
|
355
492
|
}),
|
|
356
493
|
/* @__PURE__ */ jsx("p", {
|
|
357
494
|
className: "_cppay-state-message",
|
|
358
|
-
children:
|
|
495
|
+
children: g.checkStatusFailed
|
|
359
496
|
}),
|
|
360
497
|
/* @__PURE__ */ jsx("button", {
|
|
361
|
-
onClick: () =>
|
|
362
|
-
|
|
498
|
+
onClick: () => {
|
|
499
|
+
v("select"), $();
|
|
500
|
+
},
|
|
501
|
+
disabled: b || y,
|
|
363
502
|
className: "_cppay-btn _cppay-btn-primary _cppay-state-btn",
|
|
364
|
-
children:
|
|
503
|
+
children: g.returnButton
|
|
365
504
|
})
|
|
366
505
|
]
|
|
367
|
-
}) :
|
|
506
|
+
}) : _ === "failed" ? m?.Failed ? /* @__PURE__ */ jsx(m.Failed, { paymentInfo: H.current }) : /* @__PURE__ */ jsxs("div", {
|
|
368
507
|
className: "_cppay-state-container",
|
|
369
508
|
children: [
|
|
370
509
|
/* @__PURE__ */ jsx("div", {
|
|
@@ -376,31 +515,33 @@ var PaymentContent_default = ({ apikey: t, ott: n, plain: u, orderId: d, amount:
|
|
|
376
515
|
}),
|
|
377
516
|
/* @__PURE__ */ jsx("h3", {
|
|
378
517
|
className: "_cppay-state-title _cppay-state-title-failed",
|
|
379
|
-
children:
|
|
518
|
+
children: g.paymentFailed
|
|
380
519
|
}),
|
|
381
520
|
/* @__PURE__ */ jsx("p", {
|
|
382
521
|
className: "_cppay-state-message",
|
|
383
|
-
children:
|
|
522
|
+
children: g.pleaseInitiatePaymentAgain
|
|
384
523
|
}),
|
|
385
524
|
/* @__PURE__ */ jsx("button", {
|
|
386
|
-
onClick: () =>
|
|
387
|
-
|
|
525
|
+
onClick: () => {
|
|
526
|
+
v("select"), $();
|
|
527
|
+
},
|
|
528
|
+
disabled: b || y,
|
|
388
529
|
className: "_cppay-btn _cppay-btn-primary _cppay-state-btn",
|
|
389
|
-
children:
|
|
530
|
+
children: g.returnButton
|
|
390
531
|
})
|
|
391
532
|
]
|
|
392
|
-
}) :
|
|
393
|
-
|
|
533
|
+
}) : _ === "select" ? /* @__PURE__ */ jsxs("div", { children: [
|
|
534
|
+
m?.ChooseTop,
|
|
394
535
|
/* @__PURE__ */ jsxs("div", {
|
|
395
536
|
className: "_cppay-section",
|
|
396
537
|
children: [/* @__PURE__ */ jsx("label", {
|
|
397
538
|
className: "_cppay-label",
|
|
398
|
-
children:
|
|
539
|
+
children: g.paymentNetwork
|
|
399
540
|
}), /* @__PURE__ */ jsx("div", {
|
|
400
541
|
className: "_cppay-grid",
|
|
401
|
-
children:
|
|
402
|
-
onClick: () =>
|
|
403
|
-
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" : ""}`,
|
|
404
545
|
children: [e.icon && /* @__PURE__ */ jsx("img", {
|
|
405
546
|
src: e.icon,
|
|
406
547
|
alt: e.chain
|
|
@@ -412,12 +553,12 @@ var PaymentContent_default = ({ apikey: t, ott: n, plain: u, orderId: d, amount:
|
|
|
412
553
|
className: "_cppay-section",
|
|
413
554
|
children: [/* @__PURE__ */ jsx("label", {
|
|
414
555
|
className: "_cppay-label",
|
|
415
|
-
children:
|
|
556
|
+
children: g.paymentToken
|
|
416
557
|
}), /* @__PURE__ */ jsx("div", {
|
|
417
558
|
className: "_cppay-grid",
|
|
418
|
-
children:
|
|
419
|
-
onClick: () =>
|
|
420
|
-
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" : ""}`,
|
|
421
562
|
children: [e.icon && /* @__PURE__ */ jsx("img", {
|
|
422
563
|
src: e.icon,
|
|
423
564
|
alt: e.symbol
|
|
@@ -425,7 +566,7 @@ var PaymentContent_default = ({ apikey: t, ott: n, plain: u, orderId: d, amount:
|
|
|
425
566
|
}, e.symbol))
|
|
426
567
|
})]
|
|
427
568
|
}),
|
|
428
|
-
|
|
569
|
+
m?.ChooseBottom,
|
|
429
570
|
/* @__PURE__ */ jsx("div", {
|
|
430
571
|
className: "_cppay-section",
|
|
431
572
|
children: /* @__PURE__ */ jsx("div", {
|
|
@@ -434,19 +575,19 @@ var PaymentContent_default = ({ apikey: t, ott: n, plain: u, orderId: d, amount:
|
|
|
434
575
|
className: "_cppay-price-row",
|
|
435
576
|
children: [/* @__PURE__ */ jsx("span", {
|
|
436
577
|
className: "_cppay-price-label",
|
|
437
|
-
children:
|
|
578
|
+
children: g.paymentAmount
|
|
438
579
|
}), /* @__PURE__ */ jsxs("div", {
|
|
439
580
|
className: "_cppay-price-amount",
|
|
440
581
|
children: [/* @__PURE__ */ jsxs("div", {
|
|
441
582
|
className: "_cppay-price-main",
|
|
442
583
|
children: [
|
|
443
|
-
|
|
584
|
+
Z ?? "-",
|
|
444
585
|
" ",
|
|
445
|
-
|
|
586
|
+
D ?? ""
|
|
446
587
|
]
|
|
447
588
|
}), /* @__PURE__ */ jsxs("div", {
|
|
448
589
|
className: "_cppay-price-sub",
|
|
449
|
-
children: ["≈ $",
|
|
590
|
+
children: ["≈ $", d]
|
|
450
591
|
})]
|
|
451
592
|
})]
|
|
452
593
|
})
|
|
@@ -454,10 +595,10 @@ var PaymentContent_default = ({ apikey: t, ott: n, plain: u, orderId: d, amount:
|
|
|
454
595
|
}),
|
|
455
596
|
/* @__PURE__ */ jsxs("div", {
|
|
456
597
|
className: "_cppay-section",
|
|
457
|
-
children: [
|
|
598
|
+
children: [S && /* @__PURE__ */ jsxs("div", {
|
|
458
599
|
className: "_cppay-error-tooltip-wrapper",
|
|
459
|
-
onMouseEnter: () =>
|
|
460
|
-
onMouseLeave: () =>
|
|
600
|
+
onMouseEnter: () => I(!0),
|
|
601
|
+
onMouseLeave: () => I(!1),
|
|
461
602
|
children: [/* @__PURE__ */ jsxs("div", {
|
|
462
603
|
className: "_cppay-error-tooltip",
|
|
463
604
|
children: [/* @__PURE__ */ jsx("svg", {
|
|
@@ -468,16 +609,16 @@ var PaymentContent_default = ({ apikey: t, ott: n, plain: u, orderId: d, amount:
|
|
|
468
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",
|
|
469
610
|
clipRule: "evenodd"
|
|
470
611
|
})
|
|
471
|
-
}), /* @__PURE__ */ jsx("span", { children:
|
|
472
|
-
}),
|
|
612
|
+
}), /* @__PURE__ */ jsx("span", { children: S })]
|
|
613
|
+
}), Pe && /* @__PURE__ */ jsx("div", {
|
|
473
614
|
className: "_cppay-error-tooltip-full",
|
|
474
|
-
children:
|
|
615
|
+
children: S
|
|
475
616
|
})]
|
|
476
617
|
}), /* @__PURE__ */ jsx("button", {
|
|
477
|
-
onClick:
|
|
478
|
-
disabled: !
|
|
618
|
+
onClick: He,
|
|
619
|
+
disabled: !T || !D || b,
|
|
479
620
|
className: "_cppay-btn _cppay-btn-primary",
|
|
480
|
-
children:
|
|
621
|
+
children: b ? g.processing : g.continuePayment
|
|
481
622
|
})]
|
|
482
623
|
})
|
|
483
624
|
] }) : /* @__PURE__ */ jsxs("div", { children: [
|
|
@@ -485,8 +626,8 @@ var PaymentContent_default = ({ apikey: t, ott: n, plain: u, orderId: d, amount:
|
|
|
485
626
|
className: "_cppay-qr-container",
|
|
486
627
|
children: /* @__PURE__ */ jsx("div", {
|
|
487
628
|
className: "_cppay-qr-code",
|
|
488
|
-
children:
|
|
489
|
-
src:
|
|
629
|
+
children: ke && /* @__PURE__ */ jsx("img", {
|
|
630
|
+
src: ke,
|
|
490
631
|
alt: "Payment QR Code",
|
|
491
632
|
className: "_cppay-qr-image"
|
|
492
633
|
})
|
|
@@ -495,7 +636,7 @@ var PaymentContent_default = ({ apikey: t, ott: n, plain: u, orderId: d, amount:
|
|
|
495
636
|
/* @__PURE__ */ jsxs("div", {
|
|
496
637
|
className: "_cppay-section",
|
|
497
638
|
children: [
|
|
498
|
-
|
|
639
|
+
K && /* @__PURE__ */ jsx("div", {
|
|
499
640
|
className: "_cppay-info-box",
|
|
500
641
|
children: /* @__PURE__ */ jsx("div", {
|
|
501
642
|
className: "_cppay-info-flex-container",
|
|
@@ -503,10 +644,10 @@ var PaymentContent_default = ({ apikey: t, ott: n, plain: u, orderId: d, amount:
|
|
|
503
644
|
className: "_cppay-info-flex-child",
|
|
504
645
|
children: [/* @__PURE__ */ jsx("div", {
|
|
505
646
|
className: "_cppay-info-label",
|
|
506
|
-
children: u === "subscription" ?
|
|
647
|
+
children: u === "subscription" ? g.authorizationAmount : g.paymentAmount
|
|
507
648
|
}), /* @__PURE__ */ jsxs("div", {
|
|
508
649
|
className: "_cppay-info-value _cppay-info-value-flex",
|
|
509
|
-
children: [/* @__PURE__ */ jsx("span", { children: u === "subscription" ? `${
|
|
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] })]
|
|
510
651
|
})]
|
|
511
652
|
})
|
|
512
653
|
})
|
|
@@ -517,27 +658,17 @@ var PaymentContent_default = ({ apikey: t, ott: n, plain: u, orderId: d, amount:
|
|
|
517
658
|
className: "_cppay-info-flex-child",
|
|
518
659
|
children: [/* @__PURE__ */ jsxs("div", {
|
|
519
660
|
className: "_cppay-info-label _cppay-info-label-flex",
|
|
520
|
-
children: [/* @__PURE__ */ jsx("span", { children: u === "subscription" ?
|
|
661
|
+
children: [/* @__PURE__ */ jsx("span", { children: u === "subscription" ? g.authorizationContractAddress : g.paymentAddress }), Me && /* @__PURE__ */ jsxs("span", {
|
|
521
662
|
className: "_cppay-countdown",
|
|
522
|
-
children: ["⏰ ",
|
|
663
|
+
children: ["⏰ ", Me]
|
|
523
664
|
})]
|
|
524
665
|
}), /* @__PURE__ */ jsxs("div", {
|
|
525
666
|
className: "_cppay-address-row",
|
|
526
|
-
children: [/* @__PURE__ */ jsx("code", { children: u === "subscription" ?
|
|
527
|
-
onClick:
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
await navigator.clipboard.writeText(e), I(!0), setTimeout(() => {
|
|
532
|
-
I(!1);
|
|
533
|
-
}, 2e3);
|
|
534
|
-
} catch (e) {
|
|
535
|
-
console.error("复制失败:", e);
|
|
536
|
-
}
|
|
537
|
-
},
|
|
538
|
-
className: `_cppay-copy-btn ${F ? "_cppay-copy-success" : ""}`,
|
|
539
|
-
title: F ? _.copied : _.copyAddress,
|
|
540
|
-
children: F ? /* @__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", {
|
|
541
672
|
className: "_cppay-copy-icon",
|
|
542
673
|
viewBox: "0 0 24 24",
|
|
543
674
|
fill: "currentColor",
|
|
@@ -565,18 +696,18 @@ var PaymentContent_default = ({ apikey: t, ott: n, plain: u, orderId: d, amount:
|
|
|
565
696
|
className: "_cppay-info-box _cppay-subscription-box",
|
|
566
697
|
children: [/* @__PURE__ */ jsx("div", {
|
|
567
698
|
className: "_cppay-info-label _cppay-subscription-label",
|
|
568
|
-
children:
|
|
699
|
+
children: g.subscriptionNotice
|
|
569
700
|
}), /* @__PURE__ */ jsx("div", {
|
|
570
701
|
className: "_cppay-info-value _cppay-subscription-message",
|
|
571
|
-
children:
|
|
702
|
+
children: g.subscriptionNoticeMessage
|
|
572
703
|
})]
|
|
573
704
|
})
|
|
574
705
|
]
|
|
575
706
|
}),
|
|
576
|
-
|
|
707
|
+
S && /* @__PURE__ */ jsxs("div", {
|
|
577
708
|
className: "_cppay-error-tooltip-wrapper",
|
|
578
|
-
onMouseEnter: () =>
|
|
579
|
-
onMouseLeave: () =>
|
|
709
|
+
onMouseEnter: () => I(!0),
|
|
710
|
+
onMouseLeave: () => I(!1),
|
|
580
711
|
children: [/* @__PURE__ */ jsxs("div", {
|
|
581
712
|
className: "_cppay-error-tooltip",
|
|
582
713
|
children: [/* @__PURE__ */ jsx("svg", {
|
|
@@ -587,30 +718,30 @@ var PaymentContent_default = ({ apikey: t, ott: n, plain: u, orderId: d, amount:
|
|
|
587
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",
|
|
588
719
|
clipRule: "evenodd"
|
|
589
720
|
})
|
|
590
|
-
}), /* @__PURE__ */ jsx("span", { children:
|
|
591
|
-
}),
|
|
721
|
+
}), /* @__PURE__ */ jsx("span", { children: S })]
|
|
722
|
+
}), Pe && /* @__PURE__ */ jsx("div", {
|
|
592
723
|
className: "_cppay-error-tooltip-full",
|
|
593
|
-
children:
|
|
724
|
+
children: S
|
|
594
725
|
})]
|
|
595
726
|
}),
|
|
596
|
-
!
|
|
727
|
+
!y && /* @__PURE__ */ jsx("div", {
|
|
597
728
|
className: "_cppay-section",
|
|
598
|
-
children:
|
|
599
|
-
onClick:
|
|
600
|
-
disabled:
|
|
729
|
+
children: A ? /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("button", {
|
|
730
|
+
onClick: Ve,
|
|
731
|
+
disabled: b,
|
|
601
732
|
className: "_cppay-btn _cppay-btn-primary",
|
|
602
|
-
children:
|
|
733
|
+
children: b ? u === "subscription" ? g.authorizing : g.processing : u === "subscription" ? `💳 ${g.connectWallet}` : `💳 ${g.walletPay}`
|
|
603
734
|
}), /* @__PURE__ */ jsxs("button", {
|
|
604
|
-
onClick:
|
|
605
|
-
disabled:
|
|
735
|
+
onClick: Fe,
|
|
736
|
+
disabled: b,
|
|
606
737
|
className: "_cppay-btn _cppay-wallet-address-btn",
|
|
607
|
-
title:
|
|
738
|
+
title: g.clickToModifyWallet,
|
|
608
739
|
children: [/* @__PURE__ */ jsxs("span", {
|
|
609
740
|
className: "_cppay-wallet-address-text",
|
|
610
741
|
children: [
|
|
611
|
-
|
|
742
|
+
A.slice(0, 10),
|
|
612
743
|
"...",
|
|
613
|
-
|
|
744
|
+
A.slice(-4)
|
|
614
745
|
]
|
|
615
746
|
}), /* @__PURE__ */ jsx("svg", {
|
|
616
747
|
className: "_cppay-wallet-arrow",
|
|
@@ -621,34 +752,54 @@ var PaymentContent_default = ({ apikey: t, ott: n, plain: u, orderId: d, amount:
|
|
|
621
752
|
children: /* @__PURE__ */ jsx("polyline", { points: "6 9 12 15 18 9" })
|
|
622
753
|
})]
|
|
623
754
|
})] }) : /* @__PURE__ */ jsx("button", {
|
|
624
|
-
onClick:
|
|
625
|
-
disabled:
|
|
755
|
+
onClick: Fe,
|
|
756
|
+
disabled: Ae,
|
|
626
757
|
className: "_cppay-btn _cppay-btn-secondary _cppay-connect-wallet-btn",
|
|
627
|
-
children: /* @__PURE__ */ jsx("span", { children:
|
|
758
|
+
children: /* @__PURE__ */ jsx("span", { children: Ae ? g.processing : `💳 ${g.connectWallet}` })
|
|
628
759
|
})
|
|
629
760
|
}),
|
|
630
761
|
/* @__PURE__ */ jsx("div", {
|
|
631
762
|
className: "_cppay-section",
|
|
632
763
|
children: /* @__PURE__ */ jsx("button", {
|
|
633
|
-
onClick:
|
|
634
|
-
disabled:
|
|
764
|
+
onClick: Ue,
|
|
765
|
+
disabled: y,
|
|
635
766
|
className: "_cppay-btn _cppay-btn-primary",
|
|
636
|
-
children:
|
|
767
|
+
children: y ? /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsxs("svg", {
|
|
768
|
+
className: "_cppay-spinner",
|
|
769
|
+
viewBox: "0 0 24 24",
|
|
770
|
+
fill: "none",
|
|
771
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
772
|
+
children: [/* @__PURE__ */ jsx("circle", {
|
|
773
|
+
cx: "12",
|
|
774
|
+
cy: "12",
|
|
775
|
+
r: "10",
|
|
776
|
+
stroke: "currentColor",
|
|
777
|
+
strokeWidth: "3",
|
|
778
|
+
strokeOpacity: "0.25"
|
|
779
|
+
}), /* @__PURE__ */ jsx("path", {
|
|
780
|
+
d: "M12 2a10 10 0 0 1 10 10",
|
|
781
|
+
stroke: "currentColor",
|
|
782
|
+
strokeWidth: "3",
|
|
783
|
+
strokeLinecap: "round"
|
|
784
|
+
})]
|
|
785
|
+
}), g.checking] }) : g.completedPayment
|
|
637
786
|
})
|
|
638
787
|
}),
|
|
639
788
|
/* @__PURE__ */ jsx("hr", { className: "_cppay-divider" }),
|
|
640
789
|
/* @__PURE__ */ jsx("div", {
|
|
641
790
|
className: "_cppay-section",
|
|
642
791
|
children: /* @__PURE__ */ jsx("button", {
|
|
643
|
-
onClick: () =>
|
|
644
|
-
|
|
792
|
+
onClick: () => {
|
|
793
|
+
v("select"), $();
|
|
794
|
+
},
|
|
795
|
+
disabled: b || y,
|
|
645
796
|
className: "_cppay-btn _cppay-btn-text",
|
|
646
|
-
children:
|
|
797
|
+
children: g.changePaymentMethod
|
|
647
798
|
})
|
|
648
799
|
})
|
|
649
800
|
] })
|
|
650
801
|
});
|
|
651
|
-
}, PaymentDialog_default = ({ open: e, onClose: t, ott: n, apikey:
|
|
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 }) => {
|
|
652
803
|
let [o, be] = useState("select"), s = useMemo(() => o !== "checking", [o]);
|
|
653
804
|
useEffect(() => {
|
|
654
805
|
e || be("select");
|
|
@@ -699,10 +850,10 @@ var PaymentContent_default = ({ apikey: t, ott: n, plain: u, orderId: d, amount:
|
|
|
699
850
|
})
|
|
700
851
|
})]
|
|
701
852
|
}), /* @__PURE__ */ jsx(PaymentContent_default, {
|
|
702
|
-
apikey:
|
|
853
|
+
apikey: i,
|
|
703
854
|
ott: n,
|
|
704
|
-
plain:
|
|
705
|
-
orderId:
|
|
855
|
+
plain: ue,
|
|
856
|
+
orderId: de,
|
|
706
857
|
amount: fe,
|
|
707
858
|
intervalDays: pe,
|
|
708
859
|
remark: me,
|
|
@@ -718,9 +869,9 @@ var PaymentContent_default = ({ apikey: t, ott: n, plain: u, orderId: d, amount:
|
|
|
718
869
|
}) : null;
|
|
719
870
|
}, CppayContext = createContext(null);
|
|
720
871
|
const CppayProvider = ({ children: e }) => {
|
|
721
|
-
let [t, n] = useState(!1), [r,
|
|
722
|
-
|
|
723
|
-
}, []),
|
|
872
|
+
let [t, n] = useState(!1), [r, i] = useState(null), ue = useCallback((e) => {
|
|
873
|
+
i(e), n(!0);
|
|
874
|
+
}, []), de = useCallback(() => {
|
|
724
875
|
n(!1);
|
|
725
876
|
}, []), fe = useCallback(() => {
|
|
726
877
|
n(!1);
|
|
@@ -735,8 +886,8 @@ const CppayProvider = ({ children: e }) => {
|
|
|
735
886
|
}, [r]);
|
|
736
887
|
return /* @__PURE__ */ jsxs(CppayContext.Provider, {
|
|
737
888
|
value: {
|
|
738
|
-
showPayment:
|
|
739
|
-
closePayment:
|
|
889
|
+
showPayment: ue,
|
|
890
|
+
closePayment: de
|
|
740
891
|
},
|
|
741
892
|
children: [e, r && /* @__PURE__ */ jsx(PaymentDialog_default, {
|
|
742
893
|
open: t,
|