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.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: f, orderId: p, amount: m, intervalDays: h, remark: ye, locale: g, onSuccess: be, onExpired: xe, onFailed: Se, onError: _, Slots: v, onPaymentStepChange: Ce }) => {
13
- let y = useMemo(() => new cppay_default(t, n), [t, n]), b = useMemo(() => getLocaleMessages(g), [g]), [x, S] = useState("select"), C = useMemo(() => x === "checking", [x]), [w, T] = useState(!1), [E, D] = useState(), [O, we] = useState([]), [k, A] = useState(), [j, Te] = useState(), [Ee, De] = useState(), [M, N] = useState(), [Oe, ke] = useState(!1), [P, F] = useState(), [Ae, je] = useState(""), [I, L] = useState(!1), [Me, R] = useState(!1), [z, B] = useState(""), V = useRef(null), H = useRef(null), U = useRef(null), W = useRef(null), G = useRef("");
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" && !V.current && (V.current = createAppKit({
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
- }), N(V.current.getAddress()), F(V.current.getProvider("eip155")), V.current.subscribeAccount((e) => {
37
- e.isConnected ? N(e.address) : (N(void 0), F(void 0));
38
- }), V.current.subscribeProviders((e) => {
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
- F(t);
40
+ N(t);
41
41
  }));
42
42
  }, []), useEffect(() => {
43
- Ce?.(x);
44
- }, [x]);
45
- let Ne = async () => {
43
+ De?.(_);
44
+ }, [_]);
45
+ let Fe = async () => {
46
46
  try {
47
- ke(!0), D(void 0), V.current && await V.current.open();
47
+ je(!0), C(void 0), z.current && await z.current.open();
48
48
  } catch (e) {
49
- console.error("钱包连接失败:", e), D(e instanceof Error ? e.message : b.walletConnectionFailed), _?.(e);
49
+ console.error("钱包连接失败:", e), C(e instanceof Error ? e.message : g.walletConnectionFailed), p?.(e);
50
50
  } finally {
51
- ke(!1);
51
+ je(!1);
52
52
  }
53
- }, K = useMemo(() => O.find((e) => e.chain === k), [O, k]), q = useMemo(() => K?.tokens || [], [K]), J = useMemo(() => q.find((e) => e.symbol === j), [q, j]), Y = (e) => [
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, X = (e, t) => {
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
- }, Pe = (e) => {
65
- if (e <= 0) return b.expired;
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
- }, Fe = (e) => {
69
- U.current && clearInterval(U.current);
68
+ }, Y = (e) => {
69
+ V.current && clearInterval(V.current);
70
70
  let t = () => {
71
- if (x === "checking") {
72
- Z();
71
+ if (_ === "checking") {
72
+ X();
73
73
  return;
74
74
  }
75
75
  let t = e - Math.floor(Date.now() / 1e3);
76
- je(Pe(t)), t <= 0 && (S("expired"), Z());
76
+ Ne(Ie(t)), t <= 0 && X();
77
77
  };
78
- t(), U.current = setInterval(t, 1e3);
79
- }, Z = () => {
80
- U.current &&= (clearInterval(U.current), null);
81
- }, Q = useMemo(() => {
82
- if (!j || !J) return "0";
83
- let e = parseFloat(J.price);
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 = Y(j);
86
- return X((parseFloat(m) / e).toFixed(t), t);
85
+ let t = q(D);
86
+ return J((parseFloat(d) / e).toFixed(t), t);
87
87
  }, [
88
- m,
89
- j,
90
- J
91
- ]), Ie = async () => {
88
+ d,
89
+ D,
90
+ K
91
+ ]), Le = async () => {
92
92
  try {
93
- T(!0), D(void 0);
94
- let e = await y.getSupportedChains();
95
- we(e), e.length > 0 && A(e[0].chain);
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
- D(e instanceof Error ? e.message : b.loadPaymentNetworkFailed), _?.(e);
97
+ C(e instanceof Error ? e.message : g.loadPaymentNetworkFailed), p?.(e);
98
98
  } finally {
99
- T(!1);
99
+ x(!1);
100
100
  }
101
- }, Le = async (e) => {
102
- if (P) try {
103
- await P.request({
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(b.pleaseAddNetwork) : e;
108
+ throw e.code === 4902 ? Error(g.pleaseAddNetwork) : e;
109
109
  }
110
- }, Re = async () => {
111
- if (!(!M || !P || !W.current || !J || !K)) try {
112
- T(!0);
113
- let e = W.current;
114
- await Le(K.chainId);
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: M,
117
- transport: custom(P)
116
+ account: A,
117
+ transport: custom(M)
118
118
  });
119
- if (J.address) {
119
+ if (K.address) {
120
120
  let n = await t.writeContract({
121
- address: J.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, J.decimals)],
136
+ args: [e.receiveAddress, parseUnits(e.paymentAmount, K.decimals)],
137
137
  chain: null
138
138
  });
139
- console.log("转账交易哈希:", n), B(n), G.current = 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, J.decimals),
143
+ value: parseUnits(e.paymentAmount, K.decimals),
144
144
  chain: null
145
145
  });
146
- console.log("转账交易哈希:", n), B(n), G.current = n;
146
+ console.log("转账交易哈希:", n), R(n), U.current = n;
147
147
  }
148
- T(!1), S("checking");
148
+ x(!1), v("checking"), Q({ paymentId: e.paymentId });
149
149
  } catch (e) {
150
- console.error("钱包支付失败:", e), D(e instanceof Error ? e.message : b.walletPaymentFailed), _?.(e), T(!1);
150
+ console.error("钱包支付失败:", e), C(e instanceof Error ? e.message : g.walletPaymentFailed), p?.(e), x(!1);
151
151
  }
152
- }, ze = async () => {
153
- if (!(!M || !P || !W.current || !J || !K)) try {
154
- T(!0);
155
- let e = W.current;
156
- await Le(K.chainId);
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: M,
159
- transport: custom(P)
158
+ account: A,
159
+ transport: custom(M)
160
160
  });
161
- if (!J.address) throw Error(b.subscriptionDoesNotSupportNative);
161
+ if (!K.address) throw Error(g.subscriptionDoesNotSupportNative);
162
162
  let n = await t.writeContract({
163
- address: J.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, J.decimals)],
178
+ args: [e.spenderAddress, parseUnits(e.approveAmount, K.decimals)],
179
179
  chain: null
180
180
  });
181
- console.log("授权交易哈希:", n), B(n), G.current = n, T(!1), S("checking");
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), D(e instanceof Error ? e.message : b.walletPaymentFailed), _?.(e), T(!1);
183
+ console.error("钱包授权失败:", e), C(e instanceof Error ? e.message : g.walletPaymentFailed), p?.(e), x(!1);
184
184
  }
185
- }, Be = async () => {
186
- if (!M) {
187
- let e = b.pleaseConnectWallet;
188
- D(e), _?.(Error(e));
185
+ }, Ve = async () => {
186
+ if (!A) {
187
+ let e = g.pleaseConnectWallet;
188
+ C(e), p?.(Error(e));
189
189
  return;
190
190
  }
191
- f === "instant" ? await Re() : f === "subscription" && await ze();
192
- }, Ve = async () => {
193
- if (!(!k || !j)) try {
194
- T(!0), D(void 0);
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 (f === "instant") W.current = await y.createOnetimePayment({
197
- paymentChain: k,
198
- paymentToken: j,
199
- orderId: p,
200
- amount: Q,
201
- remark: ye
202
- }), e = `${k.toLowerCase()}:${W.current.receiveAddress}?amount=${W.current.paymentAmount}`, Fe(W.current.expireAt), $({ paymentId: W.current.paymentId });
203
- else if (f === "subscription") {
204
- if (!h) throw Error(`Invalid Renewal Days: ${h ?? ""}`);
205
- W.current = await y.createSubscriptionPayment({
206
- paymentChain: k,
207
- paymentToken: j,
208
- orderId: p,
209
- amountOfUsd: Q,
210
- intervalDays: h
211
- }), e = `${k.toLowerCase()}:${W.current.spenderAddress}?amount=${W.current.approveAmount}`, Fe(W.current.expireAt), $({ subscriptionId: W.current.subscriptionId });
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
- S("payment"), De(await QRCode.toDataURL(e, {
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
- D(e instanceof Error ? e.message : b.createPaymentFailed), _?.(e);
219
+ C(e instanceof Error ? e.message : g.createPaymentFailed), p?.(e);
220
220
  } finally {
221
- T(!1);
221
+ x(!1);
222
222
  }
223
- }, He = () => {
224
- W.current && (S("checking"), D(void 0));
225
- }, $ = (e) => {
226
- H.current?.unsubscribe();
227
- let t = () => defer(() => f === "subscription" ? y.checkSubscriptionPaymentStatus(e) : y.checkOnetimePaymentStatus(e)).pipe(timeout(15e3), retry({ delay: 2e3 }));
228
- H.current = t().pipe(expand((e) => e.status === "pending" ? timer(2e3).pipe(switchMap(() => t())) : EMPTY), tap((e) => {
229
- (e.status === "paid" || e.status === "approved") && (S("success"), be?.(e)), e.status === "expired" && (S("expired"), xe?.(e)), e.status === "failed" && (S("failed"), Se?.(e));
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 (W.current) {
233
- let t = e instanceof Error ? e.message : b.checkPaymentStatusFailed;
234
- S("error"), D(t), _?.(e);
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
- H.current?.unsubscribe();
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
- O.length === 0 && Ie();
315
+ w.length === 0 && Le();
244
316
  }, []), useEffect(() => {
245
- q.length > 0 && Te(q[0].symbol);
246
- }, [q]), useEffect(() => (p && $({ orderId: p }), () => {
247
- H.current?.unsubscribe(), Z();
248
- }), [p]), /* @__PURE__ */ jsx("div", {
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: x === "success" ? v?.Success ? /* @__PURE__ */ jsx(v.Success, { paymentInfo: W.current }) : /* @__PURE__ */ jsxs("div", {
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: f === "subscription" ? b.authorizationSuccess : b.paymentSuccess
345
+ children: u === "subscription" ? g.authorizationSuccess : g.paymentSuccess
263
346
  }),
264
- z && /* @__PURE__ */ jsxs("div", {
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: b.transactionHash
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
- z.slice(0, 18),
357
+ L.slice(0, 18),
275
358
  "...",
276
- z.slice(-18)
359
+ L.slice(-18)
277
360
  ]
278
361
  }), /* @__PURE__ */ jsx("button", {
279
- onClick: async () => {
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: b.copyAddress,
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
- W.current && /* @__PURE__ */ jsxs("div", {
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: b.orderId
389
+ children: g.orderId
315
390
  }), /* @__PURE__ */ jsx("span", {
316
391
  className: "_cppay-detail-value",
317
- children: W.current.orderId
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: f === "subscription" ? b.authorizationAmount : b.paymentAmount
399
+ children: u === "subscription" ? g.authorizationAmount : g.paymentAmount
325
400
  }), /* @__PURE__ */ jsx("span", {
326
401
  className: "_cppay-detail-value",
327
- children: f === "subscription" ? `${X(W.current.approveAmount, Y(j))} ${j}` : `${X(W.current.paymentAmount, Y(j))} ${j}`
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: b.paymentNetwork
409
+ children: g.paymentNetwork
335
410
  }), /* @__PURE__ */ jsx("span", {
336
411
  className: "_cppay-detail-value",
337
- children: W.current.paymentChain
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: b.paymentToken
419
+ children: g.paymentToken
345
420
  }), /* @__PURE__ */ jsx("span", {
346
421
  className: "_cppay-detail-value",
347
- children: W.current.paymentToken
422
+ children: H.current.paymentToken
348
423
  })]
349
424
  }),
350
- f === "subscription" && /* @__PURE__ */ jsxs("div", {
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: b.renewalInterval
429
+ children: g.renewalInterval
355
430
  }), /* @__PURE__ */ jsxs("span", {
356
431
  className: "_cppay-detail-value",
357
432
  children: [
358
- W.current.intervalDays,
433
+ H.current.intervalDays,
359
434
  " ",
360
- b.days
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: f === "subscription" ? b.subscriptionId : b.paymentId
443
+ children: u === "subscription" ? g.subscriptionId : g.paymentId
369
444
  }), /* @__PURE__ */ jsx("span", {
370
445
  className: "_cppay-detail-value _cppay-detail-id",
371
- children: f === "subscription" ? W.current.subscriptionId : W.current.paymentId
446
+ children: u === "subscription" ? H.current.subscriptionId : H.current.paymentId
372
447
  })]
373
448
  })
374
449
  ]
375
450
  })
376
451
  ]
377
- }) : x === "expired" ? v?.Expired ? /* @__PURE__ */ jsx(v.Expired, { paymentInfo: W.current }) : /* @__PURE__ */ jsxs("div", {
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: b.paymentExpired
464
+ children: g.paymentExpired
390
465
  }),
391
466
  /* @__PURE__ */ jsx("p", {
392
467
  className: "_cppay-state-message",
393
- children: b.pleaseInitiatePaymentAgain
468
+ children: g.pleaseInitiatePaymentAgain
394
469
  }),
395
470
  /* @__PURE__ */ jsx("button", {
396
- onClick: () => S("select"),
397
- disabled: w || C,
471
+ onClick: () => {
472
+ v("select"), $();
473
+ },
474
+ disabled: b || y,
398
475
  className: "_cppay-btn _cppay-btn-primary _cppay-state-btn",
399
- children: b.returnButton
476
+ children: g.returnButton
400
477
  })
401
478
  ]
402
- }) : x === "error" ? v?.Error ? /* @__PURE__ */ jsx(v.Error, { paymentInfo: W.current }) : /* @__PURE__ */ jsxs("div", {
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: E || b.error
491
+ children: S || g.error
415
492
  }),
416
493
  /* @__PURE__ */ jsx("p", {
417
494
  className: "_cppay-state-message",
418
- children: b.checkStatusFailed
495
+ children: g.checkStatusFailed
419
496
  }),
420
497
  /* @__PURE__ */ jsx("button", {
421
- onClick: () => S("select"),
422
- disabled: w || C,
498
+ onClick: () => {
499
+ v("select"), $();
500
+ },
501
+ disabled: b || y,
423
502
  className: "_cppay-btn _cppay-btn-primary _cppay-state-btn",
424
- children: b.returnButton
503
+ children: g.returnButton
425
504
  })
426
505
  ]
427
- }) : x === "failed" ? v?.Failed ? /* @__PURE__ */ jsx(v.Failed, { paymentInfo: W.current }) : /* @__PURE__ */ jsxs("div", {
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: b.paymentFailed
518
+ children: g.paymentFailed
440
519
  }),
441
520
  /* @__PURE__ */ jsx("p", {
442
521
  className: "_cppay-state-message",
443
- children: b.pleaseInitiatePaymentAgain
522
+ children: g.pleaseInitiatePaymentAgain
444
523
  }),
445
524
  /* @__PURE__ */ jsx("button", {
446
- onClick: () => S("select"),
447
- disabled: w || C,
525
+ onClick: () => {
526
+ v("select"), $();
527
+ },
528
+ disabled: b || y,
448
529
  className: "_cppay-btn _cppay-btn-primary _cppay-state-btn",
449
- children: b.returnButton
530
+ children: g.returnButton
450
531
  })
451
532
  ]
452
- }) : x === "select" ? /* @__PURE__ */ jsxs("div", { children: [
453
- v?.ChooseTop,
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: b.paymentNetwork
539
+ children: g.paymentNetwork
459
540
  }), /* @__PURE__ */ jsx("div", {
460
541
  className: "_cppay-grid",
461
- children: O.map((e) => /* @__PURE__ */ jsxs("button", {
462
- onClick: () => A(e.chain),
463
- className: `_cppay-select-btn ${k === e.chain ? "_cppay-selected" : ""}`,
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: b.paymentToken
556
+ children: g.paymentToken
476
557
  }), /* @__PURE__ */ jsx("div", {
477
558
  className: "_cppay-grid",
478
- children: q.map((e) => /* @__PURE__ */ jsxs("button", {
479
- onClick: () => Te(e.symbol),
480
- className: `_cppay-select-btn ${j === e.symbol ? "_cppay-selected" : ""}`,
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
- v?.ChooseBottom,
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: b.paymentAmount
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
- Q ?? "-",
584
+ Z ?? "-",
504
585
  " ",
505
- j ?? ""
586
+ D ?? ""
506
587
  ]
507
588
  }), /* @__PURE__ */ jsxs("div", {
508
589
  className: "_cppay-price-sub",
509
- children: ["≈ $", m]
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: [E && /* @__PURE__ */ jsxs("div", {
598
+ children: [S && /* @__PURE__ */ jsxs("div", {
518
599
  className: "_cppay-error-tooltip-wrapper",
519
- onMouseEnter: () => R(!0),
520
- onMouseLeave: () => R(!1),
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: E })]
532
- }), Me && /* @__PURE__ */ jsx("div", {
612
+ }), /* @__PURE__ */ jsx("span", { children: S })]
613
+ }), Pe && /* @__PURE__ */ jsx("div", {
533
614
  className: "_cppay-error-tooltip-full",
534
- children: E
615
+ children: S
535
616
  })]
536
617
  }), /* @__PURE__ */ jsx("button", {
537
- onClick: Ve,
538
- disabled: !k || !j || w,
618
+ onClick: He,
619
+ disabled: !T || !D || b,
539
620
  className: "_cppay-btn _cppay-btn-primary",
540
- children: w ? b.processing : b.continuePayment
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: Ee && /* @__PURE__ */ jsx("img", {
549
- src: Ee,
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
- J && /* @__PURE__ */ jsx("div", {
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: f === "subscription" ? b.authorizationAmount : b.paymentAmount
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: f === "subscription" ? `${X(W.current.approveAmount, Y(J.symbol))} ${J.symbol}` : `${X(W.current.paymentAmount, Y(J.symbol))} ${J.symbol}` }), /* @__PURE__ */ jsxs("span", { children: ["≈ $", m] })]
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: f === "subscription" ? b.authorizationContractAddress : b.paymentAddress }), Ae && /* @__PURE__ */ jsxs("span", {
661
+ children: [/* @__PURE__ */ jsx("span", { children: u === "subscription" ? g.authorizationContractAddress : g.paymentAddress }), Me && /* @__PURE__ */ jsxs("span", {
581
662
  className: "_cppay-countdown",
582
- children: ["⏰ ", Ae]
663
+ children: ["⏰ ", Me]
583
664
  })]
584
665
  }), /* @__PURE__ */ jsxs("div", {
585
666
  className: "_cppay-address-row",
586
- children: [/* @__PURE__ */ jsx("code", { children: f === "subscription" ? W.current.spenderAddress : W.current.receiveAddress }), /* @__PURE__ */ jsx("button", {
587
- onClick: async () => {
588
- if (!W.current) return;
589
- let e = f === "subscription" ? W.current.spenderAddress : W.current.receiveAddress;
590
- if (e) try {
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
- f === "subscription" && /* @__PURE__ */ jsxs("div", {
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: b.subscriptionNotice
699
+ children: g.subscriptionNotice
629
700
  }), /* @__PURE__ */ jsx("div", {
630
701
  className: "_cppay-info-value _cppay-subscription-message",
631
- children: b.subscriptionNoticeMessage
702
+ children: g.subscriptionNoticeMessage
632
703
  })]
633
704
  })
634
705
  ]
635
706
  }),
636
- E && /* @__PURE__ */ jsxs("div", {
707
+ S && /* @__PURE__ */ jsxs("div", {
637
708
  className: "_cppay-error-tooltip-wrapper",
638
- onMouseEnter: () => R(!0),
639
- onMouseLeave: () => R(!1),
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: E })]
651
- }), Me && /* @__PURE__ */ jsx("div", {
721
+ }), /* @__PURE__ */ jsx("span", { children: S })]
722
+ }), Pe && /* @__PURE__ */ jsx("div", {
652
723
  className: "_cppay-error-tooltip-full",
653
- children: E
724
+ children: S
654
725
  })]
655
726
  }),
656
- !C && /* @__PURE__ */ jsx("div", {
727
+ !y && /* @__PURE__ */ jsx("div", {
657
728
  className: "_cppay-section",
658
- children: M ? /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("button", {
659
- onClick: Be,
660
- disabled: w,
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: w ? f === "subscription" ? b.authorizing : b.processing : f === "subscription" ? `💳 ${b.connectWallet}` : `💳 ${b.walletPay}`
733
+ children: b ? u === "subscription" ? g.authorizing : g.processing : u === "subscription" ? `💳 ${g.connectWallet}` : `💳 ${g.walletPay}`
663
734
  }), /* @__PURE__ */ jsxs("button", {
664
- onClick: Ne,
665
- disabled: w,
735
+ onClick: Fe,
736
+ disabled: b,
666
737
  className: "_cppay-btn _cppay-wallet-address-btn",
667
- title: b.clickToModifyWallet,
738
+ title: g.clickToModifyWallet,
668
739
  children: [/* @__PURE__ */ jsxs("span", {
669
740
  className: "_cppay-wallet-address-text",
670
741
  children: [
671
- M.slice(0, 10),
742
+ A.slice(0, 10),
672
743
  "...",
673
- M.slice(-4)
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: Ne,
685
- disabled: Oe,
755
+ onClick: Fe,
756
+ disabled: Ae,
686
757
  className: "_cppay-btn _cppay-btn-secondary _cppay-connect-wallet-btn",
687
- children: /* @__PURE__ */ jsx("span", { children: Oe ? b.processing : `💳 ${b.connectWallet}` })
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: He,
694
- disabled: C,
764
+ onClick: Ue,
765
+ disabled: y,
695
766
  className: "_cppay-btn _cppay-btn-primary",
696
- children: C ? /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsxs("svg", {
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
- }), b.checking] }) : b.completedPayment
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: () => S("select"),
722
- disabled: w || C,
792
+ onClick: () => {
793
+ v("select"), $();
794
+ },
795
+ disabled: b || y,
723
796
  className: "_cppay-btn _cppay-btn-text",
724
- children: b.changePaymentMethod
797
+ children: g.changePaymentMethod
725
798
  })
726
799
  })
727
800
  ] })
728
801
  });
729
- }, PaymentDialog_default = ({ open: e, onClose: t, ott: n, apikey: i, plain: a, orderId: ue, amount: de, intervalDays: fe, remark: o, locale: s, onExpired: pe, onSuccess: me, onFailed: he, onError: ge, Slots: _e }) => {
730
- let [c, ve] = useState("select"), l = useMemo(() => c !== "checking", [c]);
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 || ve("select");
805
+ e || be("select");
733
806
  }, [e]), useEffect(() => {
734
807
  if (!e) return;
735
808
  let t = (e) => {
736
- e.key === "Escape" && l && u();
809
+ e.key === "Escape" && s && c();
737
810
  };
738
811
  return window.addEventListener("keydown", t), () => window.removeEventListener("keydown", t);
739
- }, [e, l]);
740
- let u = () => {
741
- l && t();
742
- }, d = useMemo(() => getLocaleMessages(s), [s]);
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 && u(),
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 (c) {
754
- case "success": return d.paymentResult;
755
- case "expired": return d.paymentExpired;
756
- case "failed": return d.paymentFailed;
757
- case "error": return d.error;
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 d.completePayment;
760
- default: return d.selectPaymentMethod;
832
+ case "checking": return l.completePayment;
833
+ default: return l.selectPaymentMethod;
761
834
  }
762
835
  })()
763
836
  }), /* @__PURE__ */ jsx("button", {
764
- onClick: u,
765
- disabled: !l,
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: a,
783
- orderId: ue,
784
- amount: de,
785
- intervalDays: fe,
786
- remark: o,
787
- locale: s,
788
- onSuccess: me,
789
- onExpired: pe,
790
- onFailed: he,
791
- onError: ge,
792
- Slots: _e,
793
- onPaymentStepChange: ve
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), a = useCallback((e) => {
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((e) => {
876
+ }, []), fe = useCallback(() => {
877
+ n(!1);
878
+ }, []), pe = useCallback((e) => {
806
879
  r?.onSuccess?.(e);
807
- }, [r]), o = useCallback((e) => {
880
+ }, [r]), me = useCallback((e) => {
808
881
  r?.onExpired?.(e);
809
- }, [r]), s = useCallback((e) => {
882
+ }, [r]), a = useCallback((e) => {
810
883
  r?.onFailed?.(e);
811
- }, [r]), pe = useCallback((e) => {
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: a,
817
- closePayment: ue
889
+ showPayment: ue,
890
+ closePayment: de
818
891
  },
819
892
  children: [e, r && /* @__PURE__ */ jsx(PaymentDialog_default, {
820
893
  open: t,
821
- onClose: de,
894
+ onClose: fe,
822
895
  ...r,
823
- onSuccess: fe,
824
- onExpired: o,
825
- onFailed: s,
826
- onError: pe
896
+ onSuccess: pe,
897
+ onExpired: me,
898
+ onFailed: a,
899
+ onError: he
827
900
  })]
828
901
  });
829
902
  }, useCppayPayment = () => {