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/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-BU7nq14n.js";
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: d, amount: f, intervalDays: p, remark: xe, locale: Se, onSuccess: Ce, onExpired: we, onFailed: Te, onError: m, Slots: h, onPaymentStepChange: Ee }) => {
13
- let g = useMemo(() => new cppay_default(t, n), [t, n]), _ = useMemo(() => getLocaleMessages(Se), [Se]), [v, y] = useState("select"), b = useMemo(() => v === "checking", [v]), [x, S] = useState(!1), [C, w] = useState(), [T, De] = useState([]), [E, D] = useState(), [O, k] = useState(), [A, Oe] = useState(), [j, M] = useState(), [ke, Ae] = useState(!1), [N, P] = useState(), [je, Me] = useState(""), [F, I] = useState(!1), [Ne, L] = useState(!1), [R, z] = useState(""), B = useRef(null), V = useRef(null), H = useRef(null), U = useRef(null), W = 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" && !B.current && (B.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: u, orderId: d, amount:
33
33
  icons: ["https://cppay.com/icon.png"]
34
34
  },
35
35
  features: { analytics: !1 }
36
- }), M(B.current.getAddress()), P(B.current.getProvider("eip155")), B.current.subscribeAccount((e) => {
37
- e.isConnected ? M(e.address) : (M(void 0), P(void 0));
38
- }), B.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
- P(t);
40
+ N(t);
41
41
  }));
42
42
  }, []), useEffect(() => {
43
- Ee?.(v);
44
- }, [v]);
45
- let Pe = async () => {
43
+ De?.(_);
44
+ }, [_]);
45
+ let Fe = async () => {
46
46
  try {
47
- Ae(!0), w(void 0), B.current && await B.current.open();
47
+ je(!0), C(void 0), z.current && await z.current.open();
48
48
  } catch (e) {
49
- console.error("钱包连接失败:", e), w(e instanceof Error ? e.message : _.walletConnectionFailed), m?.(e);
49
+ console.error("钱包连接失败:", e), C(e instanceof Error ? e.message : g.walletConnectionFailed), p?.(e);
50
50
  } finally {
51
- Ae(!1);
51
+ je(!1);
52
52
  }
53
- }, G = useMemo(() => T.find((e) => e.chain === E), [T, E]), K = useMemo(() => G?.tokens || [], [G]), q = useMemo(() => K.find((e) => e.symbol === O), [K, O]), J = (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: u, orderId: d, amount:
58
58
  "TUSD",
59
59
  "USDD",
60
60
  "FDUSD"
61
- ].includes(e.toUpperCase()) ? 2 : 6, Y = (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
- }, Fe = (e) => {
65
- if (e <= 0) return _.expired;
66
- let t = Math.floor(e / 3600), n = Math.floor(e % 3600 / 60), r = e % 60;
67
- return t > 0 ? `${t}${_.hours}${n}${_.minutes}${r}${_.seconds}` : `${n}${_.minutes}${r}${_.seconds}`;
68
- }, X = (e) => {
69
- H.current && clearInterval(H.current);
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 (v === "checking") {
72
- Z();
71
+ if (_ === "checking") {
72
+ X();
73
73
  return;
74
74
  }
75
75
  let t = e - Math.floor(Date.now() / 1e3);
76
- Me(Fe(t)), t <= 0 && (y("expired"), Z());
76
+ Ne(Ie(t)), t <= 0 && X();
77
77
  };
78
- t(), H.current = setInterval(t, 1e3);
79
- }, Z = () => {
80
- H.current &&= (clearInterval(H.current), null);
81
- }, Q = useMemo(() => {
82
- if (!O || !q) return "0";
83
- let e = parseFloat(q.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 = J(O);
86
- return Y((parseFloat(f) / e).toFixed(t), t);
85
+ let t = q(D);
86
+ return J((parseFloat(d) / e).toFixed(t), t);
87
87
  }, [
88
- f,
89
- O,
90
- q
91
- ]), Ie = async () => {
88
+ d,
89
+ D,
90
+ K
91
+ ]), Le = async () => {
92
92
  try {
93
- S(!0), w(void 0);
94
- let e = await g.getSupportedChains();
95
- De(e), e.length > 0 && D(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
- w(e instanceof Error ? e.message : _.loadPaymentNetworkFailed), m?.(e);
97
+ C(e instanceof Error ? e.message : g.loadPaymentNetworkFailed), p?.(e);
98
98
  } finally {
99
- S(!1);
99
+ x(!1);
100
100
  }
101
- }, Le = async (e) => {
102
- if (N) try {
103
- await N.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(_.pleaseAddNetwork) : e;
108
+ throw e.code === 4902 ? Error(g.pleaseAddNetwork) : e;
109
109
  }
110
- }, Re = async () => {
111
- if (!(!j || !N || !U.current || !q || !G)) try {
112
- S(!0);
113
- let e = U.current;
114
- await Le(G.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: j,
117
- transport: custom(N)
116
+ account: A,
117
+ transport: custom(M)
118
118
  });
119
- if (q.address) {
119
+ if (K.address) {
120
120
  let n = await t.writeContract({
121
- address: q.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, q.decimals)],
136
+ args: [e.receiveAddress, parseUnits(e.paymentAmount, K.decimals)],
137
137
  chain: null
138
138
  });
139
- console.log("转账交易哈希:", n), z(n), W.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, q.decimals),
143
+ value: parseUnits(e.paymentAmount, K.decimals),
144
144
  chain: null
145
145
  });
146
- console.log("转账交易哈希:", n), z(n), W.current = n;
146
+ console.log("转账交易哈希:", n), R(n), U.current = n;
147
147
  }
148
- S(!1), y("checking");
148
+ x(!1), v("checking"), Q({ paymentId: e.paymentId });
149
149
  } catch (e) {
150
- console.error("钱包支付失败:", e), w(e instanceof Error ? e.message : _.walletPaymentFailed), m?.(e), S(!1);
150
+ console.error("钱包支付失败:", e), C(e instanceof Error ? e.message : g.walletPaymentFailed), p?.(e), x(!1);
151
151
  }
152
- }, ze = async () => {
153
- if (!(!j || !N || !U.current || !q || !G)) try {
154
- S(!0);
155
- let e = U.current;
156
- await Le(G.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: j,
159
- transport: custom(N)
158
+ account: A,
159
+ transport: custom(M)
160
160
  });
161
- if (!q.address) throw Error(_.subscriptionDoesNotSupportNative);
161
+ if (!K.address) throw Error(g.subscriptionDoesNotSupportNative);
162
162
  let n = await t.writeContract({
163
- address: q.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, q.decimals)],
178
+ args: [e.spenderAddress, parseUnits(e.approveAmount, K.decimals)],
179
179
  chain: null
180
180
  });
181
- console.log("授权交易哈希:", n), z(n), W.current = n, S(!1), y("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), w(e instanceof Error ? e.message : _.walletPaymentFailed), m?.(e), S(!1);
183
+ console.error("钱包授权失败:", e), C(e instanceof Error ? e.message : g.walletPaymentFailed), p?.(e), x(!1);
184
184
  }
185
- }, Be = async () => {
186
- if (!j) {
187
- let e = _.pleaseConnectWallet;
188
- w(e), m?.(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
- u === "instant" ? await Re() : u === "subscription" && await ze();
192
- }, Ve = async () => {
193
- if (!(!E || !O)) try {
194
- S(!0), w(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 (u === "instant") U.current = await g.createOnetimePayment({
197
- paymentChain: E,
198
- paymentToken: O,
199
- orderId: d,
200
- amount: Q,
201
- remark: xe
202
- }), e = `${E.toLowerCase()}:${U.current.receiveAddress}?amount=${U.current.paymentAmount}`, X(U.current.expireAt), $({ paymentId: U.current.paymentId });
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 (!p) throw Error(`Invalid Renewal Days: ${p ?? ""}`);
205
- U.current = await g.createSubscriptionPayment({
206
- paymentChain: E,
207
- paymentToken: O,
208
- orderId: d,
209
- amountOfUsd: Q,
210
- intervalDays: p
211
- }), e = `${E.toLowerCase()}:${U.current.spenderAddress}?amount=${U.current.approveAmount}`, X(U.current.expireAt), $({ subscriptionId: U.current.subscriptionId });
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
- y("payment"), Oe(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
- w(e instanceof Error ? e.message : _.createPaymentFailed), m?.(e);
219
+ C(e instanceof Error ? e.message : g.createPaymentFailed), p?.(e);
220
220
  } finally {
221
- S(!1);
221
+ x(!1);
222
222
  }
223
- }, He = () => {
224
- U.current && (y("checking"), w(void 0));
225
- }, $ = (e) => {
226
- V.current?.unsubscribe();
227
- let t = () => defer(() => u === "subscription" ? g.checkSubscriptionPaymentStatus(e) : g.checkOnetimePaymentStatus(e)).pipe(timeout(15e3), retry({ delay: 2e3 }));
228
- V.current = t().pipe(expand((e) => e.status === "pending" ? timer(2e3).pipe(switchMap(() => t())) : EMPTY), tap((e) => {
229
- (e.status === "paid" || e.status === "approved") && (y("success"), Ce?.(e)), e.status === "expired" && (y("expired"), we?.(e)), e.status === "failed" && (y("failed"), Te?.(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 (U.current) {
233
- let t = e instanceof Error ? e.message : _.checkPaymentStatusFailed;
234
- y("error"), w(t), m?.(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
- V.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
- T.length === 0 && Ie();
315
+ w.length === 0 && Le();
244
316
  }, []), useEffect(() => {
245
- K.length > 0 && k(K[0].symbol);
246
- }, [K]), useEffect(() => (d && $({ orderId: d }), () => {
247
- V.current?.unsubscribe(), Z();
248
- }), [d]), /* @__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: v === "success" ? h?.Success ? /* @__PURE__ */ jsx(h.Success, { paymentInfo: U.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,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" ? _.authorizationSuccess : _.paymentSuccess
345
+ children: u === "subscription" ? g.authorizationSuccess : g.paymentSuccess
263
346
  }),
264
- /* @__PURE__ */ jsx("p", {
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: _.transactionHash
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
- R.slice(0, 20),
357
+ L.slice(0, 18),
279
358
  "...",
280
- R.slice(-20)
359
+ L.slice(-18)
281
360
  ]
282
361
  }), /* @__PURE__ */ jsx("button", {
283
- onClick: async () => {
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: _.copyAddress,
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__ */ jsx("button", {
312
- onClick: () => y("select"),
313
- className: "_cppay-btn _cppay-btn-primary _cppay-state-btn",
314
- children: _.returnButton
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
- }) : v === "expired" ? h?.Expired ? /* @__PURE__ */ jsx(h.Expired, { paymentInfo: U.current }) : /* @__PURE__ */ jsxs("div", {
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: _.paymentExpired
464
+ children: g.paymentExpired
330
465
  }),
331
466
  /* @__PURE__ */ jsx("p", {
332
467
  className: "_cppay-state-message",
333
- children: _.pleaseInitiatePaymentAgain
468
+ children: g.pleaseInitiatePaymentAgain
334
469
  }),
335
470
  /* @__PURE__ */ jsx("button", {
336
- onClick: () => y("select"),
337
- disabled: x || b,
471
+ onClick: () => {
472
+ v("select"), $();
473
+ },
474
+ disabled: b || y,
338
475
  className: "_cppay-btn _cppay-btn-primary _cppay-state-btn",
339
- children: _.returnButton
476
+ children: g.returnButton
340
477
  })
341
478
  ]
342
- }) : v === "error" ? h?.Error ? /* @__PURE__ */ jsx(h.Error, { paymentInfo: U.current }) : /* @__PURE__ */ jsxs("div", {
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: C || _.error
491
+ children: S || g.error
355
492
  }),
356
493
  /* @__PURE__ */ jsx("p", {
357
494
  className: "_cppay-state-message",
358
- children: _.checkStatusFailed
495
+ children: g.checkStatusFailed
359
496
  }),
360
497
  /* @__PURE__ */ jsx("button", {
361
- onClick: () => y("select"),
362
- disabled: x || b,
498
+ onClick: () => {
499
+ v("select"), $();
500
+ },
501
+ disabled: b || y,
363
502
  className: "_cppay-btn _cppay-btn-primary _cppay-state-btn",
364
- children: _.returnButton
503
+ children: g.returnButton
365
504
  })
366
505
  ]
367
- }) : v === "failed" ? h?.Failed ? /* @__PURE__ */ jsx(h.Failed, { paymentInfo: U.current }) : /* @__PURE__ */ jsxs("div", {
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: _.paymentFailed
518
+ children: g.paymentFailed
380
519
  }),
381
520
  /* @__PURE__ */ jsx("p", {
382
521
  className: "_cppay-state-message",
383
- children: _.pleaseInitiatePaymentAgain
522
+ children: g.pleaseInitiatePaymentAgain
384
523
  }),
385
524
  /* @__PURE__ */ jsx("button", {
386
- onClick: () => y("select"),
387
- disabled: x || b,
525
+ onClick: () => {
526
+ v("select"), $();
527
+ },
528
+ disabled: b || y,
388
529
  className: "_cppay-btn _cppay-btn-primary _cppay-state-btn",
389
- children: _.returnButton
530
+ children: g.returnButton
390
531
  })
391
532
  ]
392
- }) : v === "select" ? /* @__PURE__ */ jsxs("div", { children: [
393
- h?.ChooseTop,
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: _.paymentNetwork
539
+ children: g.paymentNetwork
399
540
  }), /* @__PURE__ */ jsx("div", {
400
541
  className: "_cppay-grid",
401
- children: T.map((e) => /* @__PURE__ */ jsxs("button", {
402
- onClick: () => D(e.chain),
403
- className: `_cppay-select-btn ${E === 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" : ""}`,
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: _.paymentToken
556
+ children: g.paymentToken
416
557
  }), /* @__PURE__ */ jsx("div", {
417
558
  className: "_cppay-grid",
418
- children: K.map((e) => /* @__PURE__ */ jsxs("button", {
419
- onClick: () => k(e.symbol),
420
- className: `_cppay-select-btn ${O === 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" : ""}`,
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
- h?.ChooseBottom,
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: _.paymentAmount
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
- Q ?? "-",
584
+ Z ?? "-",
444
585
  " ",
445
- O ?? ""
586
+ D ?? ""
446
587
  ]
447
588
  }), /* @__PURE__ */ jsxs("div", {
448
589
  className: "_cppay-price-sub",
449
- children: ["≈ $", f]
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: [C && /* @__PURE__ */ jsxs("div", {
598
+ children: [S && /* @__PURE__ */ jsxs("div", {
458
599
  className: "_cppay-error-tooltip-wrapper",
459
- onMouseEnter: () => L(!0),
460
- onMouseLeave: () => L(!1),
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: C })]
472
- }), Ne && /* @__PURE__ */ jsx("div", {
612
+ }), /* @__PURE__ */ jsx("span", { children: S })]
613
+ }), Pe && /* @__PURE__ */ jsx("div", {
473
614
  className: "_cppay-error-tooltip-full",
474
- children: C
615
+ children: S
475
616
  })]
476
617
  }), /* @__PURE__ */ jsx("button", {
477
- onClick: Ve,
478
- disabled: !E || !O || x,
618
+ onClick: He,
619
+ disabled: !T || !D || b,
479
620
  className: "_cppay-btn _cppay-btn-primary",
480
- children: x ? _.processing : _.continuePayment
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: A && /* @__PURE__ */ jsx("img", {
489
- src: A,
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
- q && /* @__PURE__ */ jsx("div", {
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" ? _.authorizationAmount : _.paymentAmount
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" ? `${Y(U.current.approveAmount, J(q.symbol))} ${q.symbol}` : `${Y(U.current.paymentAmount, J(q.symbol))} ${q.symbol}` }), /* @__PURE__ */ jsxs("span", { children: ["≈ $", f] })]
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" ? _.authorizationContractAddress : _.paymentAddress }), je && /* @__PURE__ */ jsxs("span", {
661
+ children: [/* @__PURE__ */ jsx("span", { children: u === "subscription" ? g.authorizationContractAddress : g.paymentAddress }), Me && /* @__PURE__ */ jsxs("span", {
521
662
  className: "_cppay-countdown",
522
- children: ["⏰ ", je]
663
+ children: ["⏰ ", Me]
523
664
  })]
524
665
  }), /* @__PURE__ */ jsxs("div", {
525
666
  className: "_cppay-address-row",
526
- children: [/* @__PURE__ */ jsx("code", { children: u === "subscription" ? U.current.spenderAddress : U.current.receiveAddress }), /* @__PURE__ */ jsx("button", {
527
- onClick: async () => {
528
- if (!U.current) return;
529
- let e = u === "subscription" ? U.current.spenderAddress : U.current.receiveAddress;
530
- if (e) try {
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: _.subscriptionNotice
699
+ children: g.subscriptionNotice
569
700
  }), /* @__PURE__ */ jsx("div", {
570
701
  className: "_cppay-info-value _cppay-subscription-message",
571
- children: _.subscriptionNoticeMessage
702
+ children: g.subscriptionNoticeMessage
572
703
  })]
573
704
  })
574
705
  ]
575
706
  }),
576
- C && /* @__PURE__ */ jsxs("div", {
707
+ S && /* @__PURE__ */ jsxs("div", {
577
708
  className: "_cppay-error-tooltip-wrapper",
578
- onMouseEnter: () => L(!0),
579
- onMouseLeave: () => L(!1),
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: C })]
591
- }), Ne && /* @__PURE__ */ jsx("div", {
721
+ }), /* @__PURE__ */ jsx("span", { children: S })]
722
+ }), Pe && /* @__PURE__ */ jsx("div", {
592
723
  className: "_cppay-error-tooltip-full",
593
- children: C
724
+ children: S
594
725
  })]
595
726
  }),
596
- !b && /* @__PURE__ */ jsx("div", {
727
+ !y && /* @__PURE__ */ jsx("div", {
597
728
  className: "_cppay-section",
598
- children: j ? /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("button", {
599
- onClick: Be,
600
- disabled: x,
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: x ? u === "subscription" ? _.authorizing : _.processing : u === "subscription" ? `💳 ${_.connectWallet}` : `💳 ${_.walletPay}`
733
+ children: b ? u === "subscription" ? g.authorizing : g.processing : u === "subscription" ? `💳 ${g.connectWallet}` : `💳 ${g.walletPay}`
603
734
  }), /* @__PURE__ */ jsxs("button", {
604
- onClick: Pe,
605
- disabled: x,
735
+ onClick: Fe,
736
+ disabled: b,
606
737
  className: "_cppay-btn _cppay-wallet-address-btn",
607
- title: _.clickToModifyWallet,
738
+ title: g.clickToModifyWallet,
608
739
  children: [/* @__PURE__ */ jsxs("span", {
609
740
  className: "_cppay-wallet-address-text",
610
741
  children: [
611
- j.slice(0, 10),
742
+ A.slice(0, 10),
612
743
  "...",
613
- j.slice(-4)
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: Pe,
625
- disabled: ke,
755
+ onClick: Fe,
756
+ disabled: Ae,
626
757
  className: "_cppay-btn _cppay-btn-secondary _cppay-connect-wallet-btn",
627
- children: /* @__PURE__ */ jsx("span", { children: ke ? _.processing : `💳 ${_.connectWallet}` })
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: He,
634
- disabled: b,
764
+ onClick: Ue,
765
+ disabled: y,
635
766
  className: "_cppay-btn _cppay-btn-primary",
636
- children: b ? _.checking : _.completedPayment
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: () => y("select"),
644
- disabled: x || b,
792
+ onClick: () => {
793
+ v("select"), $();
794
+ },
795
+ disabled: b || y,
645
796
  className: "_cppay-btn _cppay-btn-text",
646
- children: _.changePaymentMethod
797
+ children: g.changePaymentMethod
647
798
  })
648
799
  })
649
800
  ] })
650
801
  });
651
- }, PaymentDialog_default = ({ open: e, onClose: t, ott: n, apikey: ue, plain: de, orderId: i, amount: fe, intervalDays: pe, remark: me, locale: a, onExpired: he, onSuccess: ge, onFailed: _e, onError: ve, Slots: ye }) => {
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: ue,
853
+ apikey: i,
703
854
  ott: n,
704
- plain: de,
705
- orderId: i,
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, ue] = useState(null), de = useCallback((e) => {
722
- ue(e), n(!0);
723
- }, []), i = useCallback(() => {
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: de,
739
- closePayment: i
889
+ showPayment: ue,
890
+ closePayment: de
740
891
  },
741
892
  children: [e, r && /* @__PURE__ */ jsx(PaymentDialog_default, {
742
893
  open: t,