cppay-sdk 0.0.2-beta.32 → 0.0.2-beta.34

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/vue.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { t as cppay_default } from "./cppay-C_gp2ZZ3.js";
2
- import { n as payment_dialog_default, t as injectStyle } from "./inject-style-DtFJ9cds.js";
2
+ import { n as injectStyle, r as payment_dialog_default, t as getLocaleMessages } from "./locales-DGvDecya.js";
3
3
  import { Fragment, computed, createApp, createCommentVNode, createElementBlock, createElementVNode, createVNode, defineComponent, h, normalizeClass, onMounted, onUnmounted, openBlock, ref, renderList, renderSlot, toDisplayString, watch, withCtx } from "vue";
4
4
  import * as QRCode from "qrcode";
5
5
  import { EMPTY, defer, timer } from "rxjs";
@@ -14,43 +14,43 @@ var _hoisted_1$1 = { class: "_cppay-content" }, _hoisted_2$1 = {
14
14
  }, _hoisted_3$1 = { class: "_cppay-state-title" }, _hoisted_4$1 = { class: "_cppay-state-message" }, _hoisted_5 = {
15
15
  key: 1,
16
16
  class: "_cppay-state-container"
17
- }, _hoisted_6 = ["disabled"], _hoisted_7 = {
17
+ }, _hoisted_6 = { class: "_cppay-state-title" }, _hoisted_7 = ["disabled"], _hoisted_8 = {
18
18
  key: 2,
19
19
  class: "_cppay-state-container"
20
- }, _hoisted_8 = {
20
+ }, _hoisted_9 = { class: "_cppay-state-title" }, _hoisted_10 = {
21
21
  key: 3,
22
22
  class: "_cppay-state-container"
23
- }, _hoisted_9 = { key: 4 }, _hoisted_10 = { class: "_cppay-section" }, _hoisted_11 = { class: "_cppay-grid" }, _hoisted_12 = ["onClick"], _hoisted_13 = ["src", "alt"], _hoisted_14 = { class: "_cppay-section" }, _hoisted_15 = { class: "_cppay-grid" }, _hoisted_16 = ["onClick"], _hoisted_17 = ["src", "alt"], _hoisted_18 = { class: "_cppay-section" }, _hoisted_19 = { class: "_cppay-price-box" }, _hoisted_20 = { class: "_cppay-price-row" }, _hoisted_21 = { class: "_cppay-price-amount" }, _hoisted_22 = { class: "_cppay-price-main" }, _hoisted_23 = { class: "_cppay-price-sub" }, _hoisted_24 = { class: "_cppay-section" }, _hoisted_25 = { class: "_cppay-error-tooltip" }, _hoisted_26 = {
23
+ }, _hoisted_11 = { class: "_cppay-state-title" }, _hoisted_12 = { key: 4 }, _hoisted_13 = { class: "_cppay-section" }, _hoisted_14 = { class: "_cppay-label" }, _hoisted_15 = { class: "_cppay-grid" }, _hoisted_16 = ["onClick"], _hoisted_17 = ["src", "alt"], _hoisted_18 = { class: "_cppay-section" }, _hoisted_19 = { class: "_cppay-label" }, _hoisted_20 = { class: "_cppay-grid" }, _hoisted_21 = ["onClick"], _hoisted_22 = ["src", "alt"], _hoisted_23 = { class: "_cppay-section" }, _hoisted_24 = { class: "_cppay-price-box" }, _hoisted_25 = { class: "_cppay-price-row" }, _hoisted_26 = { class: "_cppay-price-label" }, _hoisted_27 = { class: "_cppay-price-amount" }, _hoisted_28 = { class: "_cppay-price-main" }, _hoisted_29 = { class: "_cppay-price-sub" }, _hoisted_30 = { class: "_cppay-section" }, _hoisted_31 = { class: "_cppay-error-tooltip" }, _hoisted_32 = {
24
24
  key: 0,
25
25
  class: "_cppay-error-tooltip-full"
26
- }, _hoisted_27 = ["disabled"], _hoisted_28 = { key: 5 }, _hoisted_29 = { class: "_cppay-qr-container" }, _hoisted_30 = { class: "_cppay-qr-code" }, _hoisted_31 = ["src"], _hoisted_32 = { class: "_cppay-section" }, _hoisted_33 = {
26
+ }, _hoisted_33 = ["disabled"], _hoisted_34 = { key: 5 }, _hoisted_35 = { class: "_cppay-qr-container" }, _hoisted_36 = { class: "_cppay-qr-code" }, _hoisted_37 = ["src"], _hoisted_38 = { class: "_cppay-section" }, _hoisted_39 = {
27
27
  key: 0,
28
28
  class: "_cppay-info-box"
29
- }, _hoisted_34 = { class: "_cppay-info-flex-container" }, _hoisted_35 = { class: "_cppay-info-flex-child" }, _hoisted_36 = { class: "_cppay-info-label" }, _hoisted_37 = { class: "_cppay-info-value _cppay-info-value-flex" }, _hoisted_38 = { key: 0 }, _hoisted_39 = { class: "_cppay-info-box" }, _hoisted_40 = { class: "_cppay-info-flex-child" }, _hoisted_41 = { class: "_cppay-info-label _cppay-info-label-flex" }, _hoisted_42 = {
29
+ }, _hoisted_40 = { class: "_cppay-info-flex-container" }, _hoisted_41 = { class: "_cppay-info-flex-child" }, _hoisted_42 = { class: "_cppay-info-label" }, _hoisted_43 = { class: "_cppay-info-value _cppay-info-value-flex" }, _hoisted_44 = { key: 0 }, _hoisted_45 = { class: "_cppay-info-box" }, _hoisted_46 = { class: "_cppay-info-flex-child" }, _hoisted_47 = { class: "_cppay-info-label _cppay-info-label-flex" }, _hoisted_48 = {
30
30
  key: 0,
31
31
  class: "_cppay-countdown"
32
- }, _hoisted_43 = { class: "_cppay-address-row" }, _hoisted_44 = { key: 0 }, _hoisted_45 = ["title"], _hoisted_46 = {
32
+ }, _hoisted_49 = { class: "_cppay-address-row" }, _hoisted_50 = { key: 0 }, _hoisted_51 = ["title"], _hoisted_52 = {
33
33
  key: 0,
34
34
  class: "_cppay-copy-icon",
35
35
  viewBox: "0 0 24 24",
36
36
  fill: "none",
37
37
  stroke: "currentColor",
38
38
  "stroke-width": "2"
39
- }, _hoisted_47 = {
39
+ }, _hoisted_53 = {
40
40
  key: 1,
41
41
  class: "_cppay-copy-icon",
42
42
  viewBox: "0 0 24 24",
43
43
  fill: "currentColor"
44
- }, _hoisted_48 = {
44
+ }, _hoisted_54 = {
45
45
  key: 1,
46
46
  class: "_cppay-info-box _cppay-subscription-box"
47
- }, _hoisted_49 = { class: "_cppay-error-tooltip" }, _hoisted_50 = {
47
+ }, _hoisted_55 = { class: "_cppay-info-label _cppay-subscription-label" }, _hoisted_56 = { class: "_cppay-info-value _cppay-subscription-message" }, _hoisted_57 = { class: "_cppay-error-tooltip" }, _hoisted_58 = {
48
48
  key: 0,
49
49
  class: "_cppay-error-tooltip-full"
50
- }, _hoisted_51 = {
50
+ }, _hoisted_59 = {
51
51
  key: 1,
52
52
  class: "_cppay-section"
53
- }, _hoisted_52 = ["disabled"], _hoisted_53 = ["disabled"], _hoisted_54 = ["disabled"], _hoisted_55 = { class: "_cppay-wallet-address-text" }, PaymentContent_default = /* @__PURE__ */ defineComponent({
53
+ }, _hoisted_60 = ["disabled"], _hoisted_61 = ["disabled"], _hoisted_62 = ["disabled", "title"], _hoisted_63 = { class: "_cppay-wallet-address-text" }, _hoisted_64 = { class: "_cppay-section" }, _hoisted_65 = ["disabled"], _hoisted_66 = { class: "_cppay-section" }, _hoisted_67 = ["disabled"], PaymentContent_default = /* @__PURE__ */ defineComponent({
54
54
  __name: "PaymentContent",
55
55
  props: {
56
56
  apikey: {},
@@ -68,7 +68,8 @@ var _hoisted_1$1 = { class: "_cppay-content" }, _hoisted_2$1 = {
68
68
  default: !1
69
69
  },
70
70
  error: {},
71
- slots: {}
71
+ slots: {},
72
+ locale: {}
72
73
  },
73
74
  emits: [
74
75
  "update:paymentStep",
@@ -78,8 +79,8 @@ var _hoisted_1$1 = { class: "_cppay-content" }, _hoisted_2$1 = {
78
79
  "error",
79
80
  "update:error"
80
81
  ],
81
- setup(d, { emit: f }) {
82
- let g = d, _ = f, v = new cppay_default(g.apikey), y = ref([]), S = ref(), C = ref(), w = ref(), T = ref(), E = ref(!1), D = ref(), O = ref(""), k = ref(!1), A = ref(!1), j = ref(null), M = ref(null), N = ref(null), P = ref(null), F = () => {
82
+ setup(c, { emit: l }) {
83
+ let f = c, p = l, m = computed(() => getLocaleMessages(f.locale || "zh-CN")), g = new cppay_default(f.apikey), b = ref([]), S = ref(), C = ref(), w = ref(), T = ref(), E = ref(!1), D = ref(), O = ref(""), k = ref(!1), A = ref(!1), j = ref(null), M = ref(null), N = ref(null), P = ref(null), F = () => {
83
84
  typeof window < "u" && !j.value && (j.value = createAppKit({
84
85
  debug: !1,
85
86
  enableNetworkSwitch: !1,
@@ -101,20 +102,20 @@ var _hoisted_1$1 = { class: "_cppay-content" }, _hoisted_2$1 = {
101
102
  icons: ["https://cppay.com/icon.png"]
102
103
  },
103
104
  features: { analytics: !1 }
104
- }), T.value = j.value.getAddress(), D.value = j.value.getProvider("eip155"), j.value.subscribeAccount((t) => {
105
- t.isConnected ? T.value = t.address : (T.value = void 0, D.value = void 0);
106
- }), j.value.subscribeProviders((t) => {
107
- D.value = t?.eip155;
105
+ }), T.value = j.value.getAddress(), D.value = j.value.getProvider("eip155"), j.value.subscribeAccount((r) => {
106
+ r.isConnected ? T.value = r.address : (T.value = void 0, D.value = void 0);
107
+ }), j.value.subscribeProviders((r) => {
108
+ D.value = r?.eip155;
108
109
  }));
109
110
  }, I = async () => {
110
111
  try {
111
- E.value = !0, _("update:error", void 0), j.value && await j.value.open();
112
- } catch (t) {
113
- _("update:error", t instanceof Error ? t.message : "钱包连接失败"), _("error", t);
112
+ E.value = !0, p("update:error", void 0), j.value && await j.value.open();
113
+ } catch (r) {
114
+ p("update:error", r instanceof Error ? r.message : m.value.walletConnectionFailed), p("error", r);
114
115
  } finally {
115
116
  E.value = !1;
116
117
  }
117
- }, L = computed(() => y.value.find((t) => t.chain === S.value)), R = computed(() => L.value?.tokens || []), z = computed(() => R.value.find((t) => t.symbol === C.value)), B = (t) => [
118
+ }, L = computed(() => b.value.find((r) => r.chain === S.value)), R = computed(() => L.value?.tokens || []), z = computed(() => R.value.find((r) => r.symbol === C.value)), B = (r) => [
118
119
  "USDT",
119
120
  "USDC",
120
121
  "BUSD",
@@ -122,54 +123,54 @@ var _hoisted_1$1 = { class: "_cppay-content" }, _hoisted_2$1 = {
122
123
  "TUSD",
123
124
  "USDD",
124
125
  "FDUSD"
125
- ].includes(t.toUpperCase()) ? 2 : 6, V = (t, d) => {
126
- let f = parseFloat(t);
127
- return isNaN(f) ? "0" : f.toFixed(d).replace(/\.?0+$/, "");
128
- }, H = (t) => {
129
- if (t <= 0) return "已过期";
130
- let d = Math.floor(t / 3600), f = Math.floor(t % 3600 / 60), p = t % 60;
131
- return d > 0 ? `${d}时${f}分${p}秒` : `${f}分${p}秒`;
132
- }, U = (t) => {
126
+ ].includes(r.toUpperCase()) ? 2 : 6, V = (r, c) => {
127
+ let l = parseFloat(r);
128
+ return isNaN(l) ? "0" : l.toFixed(c).replace(/\.?0+$/, "");
129
+ }, H = (r) => {
130
+ if (r <= 0) return m.value.expired;
131
+ let c = Math.floor(r / 3600), l = Math.floor(r % 3600 / 60), u = r % 60;
132
+ return c > 0 ? `${c}${m.value.hours}${l}${m.value.minutes}${u}${m.value.seconds}` : `${l}${m.value.minutes}${u}${m.value.seconds}`;
133
+ }, U = (r) => {
133
134
  N.value && clearInterval(N.value);
134
- let d = () => {
135
- let d = t - Math.floor(Date.now() / 1e3);
136
- O.value = H(d), d <= 0 && (_("update:paymentStep", "expired"), W());
135
+ let c = () => {
136
+ let c = r - Math.floor(Date.now() / 1e3);
137
+ O.value = H(c), c <= 0 && (p("update:paymentStep", "expired"), W());
137
138
  };
138
- d(), N.value = setInterval(d, 1e3);
139
+ c(), N.value = setInterval(c, 1e3);
139
140
  }, W = () => {
140
141
  N.value &&= (clearInterval(N.value), null);
141
142
  }, G = computed(() => {
142
143
  if (!C.value || !z.value) return "0";
143
- let t = parseFloat(z.value.price);
144
- if (isNaN(t) || t === 0) return "0";
145
- let d = B(C.value);
146
- return V((parseFloat(g.amount) / t).toFixed(d), d);
144
+ let r = parseFloat(z.value.price);
145
+ if (isNaN(r) || r === 0) return "0";
146
+ let c = B(C.value);
147
+ return V((parseFloat(f.amount) / r).toFixed(c), c);
147
148
  }), K = async () => {
148
149
  try {
149
- _("update:error", void 0);
150
- let t = await v.getSupportedChains();
151
- y.value = t, t.length > 0 && (S.value = t[0].chain);
152
- } catch (t) {
153
- _("update:error", t instanceof Error ? t.message : "加载支付网络失败"), _("error", t);
150
+ p("update:error", void 0);
151
+ let r = await g.getSupportedChains();
152
+ b.value = r, r.length > 0 && (S.value = r[0].chain);
153
+ } catch (r) {
154
+ p("update:error", r instanceof Error ? r.message : m.value.loadPaymentNetworkFailed), p("error", r);
154
155
  }
155
- }, q = async (t) => {
156
+ }, q = async (r) => {
156
157
  if (D.value) try {
157
158
  await D.value.request({
158
159
  method: "wallet_switchEthereumChain",
159
- params: [{ chainId: `0x${t.toString(16)}` }]
160
+ params: [{ chainId: `0x${r.toString(16)}` }]
160
161
  });
161
- } catch (t) {
162
- throw t.code === 4902 ? Error("请在钱包中添加该网络") : t;
162
+ } catch (r) {
163
+ throw r.code === 4902 ? Error(m.value.pleaseAddNetwork) : r;
163
164
  }
164
165
  }, J = async () => {
165
166
  if (!(!T.value || !D.value || !P.value || !z.value || !L.value)) try {
166
- let t = P.value;
167
+ let r = P.value;
167
168
  await q(L.value.chainId);
168
- let d = createWalletClient({
169
+ let c = createWalletClient({
169
170
  account: T.value,
170
171
  transport: custom(D.value)
171
172
  });
172
- z.value.address ? await d.writeContract({
173
+ z.value.address ? await c.writeContract({
173
174
  address: z.value.address,
174
175
  abi: [{
175
176
  name: "transfer",
@@ -185,26 +186,26 @@ var _hoisted_1$1 = { class: "_cppay-content" }, _hoisted_2$1 = {
185
186
  outputs: [{ type: "bool" }]
186
187
  }],
187
188
  functionName: "transfer",
188
- args: [t.receiveAddress, parseUnits(t.paymentAmount, z.value.decimals)],
189
+ args: [r.receiveAddress, parseUnits(r.paymentAmount, z.value.decimals)],
189
190
  chain: null
190
- }) : await d.sendTransaction({
191
- to: t.receiveAddress,
192
- value: parseUnits(t.paymentAmount, z.value.decimals),
191
+ }) : await c.sendTransaction({
192
+ to: r.receiveAddress,
193
+ value: parseUnits(r.paymentAmount, z.value.decimals),
193
194
  chain: null
194
195
  }), w.value = void 0;
195
- } catch (t) {
196
- _("update:error", t instanceof Error ? t.message : "钱包支付失败"), _("error", t);
196
+ } catch (r) {
197
+ p("update:error", r instanceof Error ? r.message : m.value.walletPaymentFailed), p("error", r);
197
198
  }
198
199
  }, Y = async () => {
199
200
  if (!(!T.value || !D.value || !P.value || !z.value || !L.value)) try {
200
- let t = P.value;
201
+ let r = P.value;
201
202
  await q(L.value.chainId);
202
- let d = createWalletClient({
203
+ let c = createWalletClient({
203
204
  account: T.value,
204
205
  transport: custom(D.value)
205
206
  });
206
- if (!z.value.address) throw Error("订阅支付不支持原生代币");
207
- await d.writeContract({
207
+ if (!z.value.address) throw Error(m.value.subscriptionDoesNotSupportNative);
208
+ await c.writeContract({
208
209
  address: z.value.address,
209
210
  abi: [{
210
211
  name: "approve",
@@ -220,51 +221,51 @@ var _hoisted_1$1 = { class: "_cppay-content" }, _hoisted_2$1 = {
220
221
  outputs: [{ type: "bool" }]
221
222
  }],
222
223
  functionName: "approve",
223
- args: [t.spenderAddress, parseUnits(t.approveAmount, z.value.decimals)],
224
+ args: [r.spenderAddress, parseUnits(r.approveAmount, z.value.decimals)],
224
225
  chain: null
225
226
  }), w.value = void 0;
226
- } catch (t) {
227
- _("update:error", t instanceof Error ? t.message : "钱包授权失败"), _("error", t);
227
+ } catch (r) {
228
+ p("update:error", r instanceof Error ? r.message : m.value.walletPaymentFailed), p("error", r);
228
229
  }
229
230
  }, X = async () => {
230
231
  if (!T.value) {
231
- _("update:error", "请先连接钱包"), _("error", /* @__PURE__ */ Error("请先连接钱包"));
232
+ p("update:error", m.value.pleaseConnectWallet), p("error", Error(m.value.pleaseConnectWallet));
232
233
  return;
233
234
  }
234
- g.plain === "one-time" ? await J() : g.plain === "subscription" && await Y();
235
+ f.plain === "one-time" ? await J() : f.plain === "subscription" && await Y();
235
236
  }, Z = async () => {
236
237
  if (!(!S.value || !C.value)) try {
237
- _("update:error", void 0);
238
- let t = "";
239
- g.plain === "one-time" ? (P.value = await v.createOnetimePayment({
238
+ p("update:error", void 0);
239
+ let r = "";
240
+ f.plain === "one-time" ? (P.value = await g.createOnetimePayment({
240
241
  paymentChain: S.value,
241
242
  paymentToken: C.value,
242
- orderId: g.orderId,
243
+ orderId: f.orderId,
243
244
  amount: G.value
244
- }), t = `${S.value.toLowerCase()}:${P.value.receiveAddress}?amount=${P.value.paymentAmount}`, U(P.value.expireAt), Q({ paymentId: P.value.paymentId })) : g.plain === "subscription" && (P.value = await v.createSubscriptionPayment({
245
+ }), r = `${S.value.toLowerCase()}:${P.value.receiveAddress}?amount=${P.value.paymentAmount}`, U(P.value.expireAt), Q({ paymentId: P.value.paymentId })) : f.plain === "subscription" && (P.value = await g.createSubscriptionPayment({
245
246
  paymentChain: S.value,
246
247
  paymentToken: C.value,
247
- orderId: g.orderId,
248
+ orderId: f.orderId,
248
249
  amountOfUsd: G.value,
249
- intervalDays: g.intervalDays || 30
250
- }), t = `${S.value.toLowerCase()}:${P.value.spenderAddress}?amount=${P.value.approveAmount}`, U(P.value.expireAt), Q({ subscriptionId: P.value.subscriptionId })), _("update:paymentStep", "payment"), w.value = await QRCode.toDataURL(t, {
250
+ intervalDays: f.intervalDays || 30
251
+ }), r = `${S.value.toLowerCase()}:${P.value.spenderAddress}?amount=${P.value.approveAmount}`, U(P.value.expireAt), Q({ subscriptionId: P.value.subscriptionId })), p("update:paymentStep", "payment"), w.value = await QRCode.toDataURL(r, {
251
252
  width: 200,
252
253
  margin: 2,
253
254
  errorCorrectionLevel: "H"
254
255
  });
255
- } catch (t) {
256
- _("update:error", t instanceof Error ? t.message : "创建支付失败"), _("error", t);
256
+ } catch (r) {
257
+ p("update:error", r instanceof Error ? r.message : m.value.createPaymentFailed), p("error", r);
257
258
  }
258
- }, Q = (t) => {
259
+ }, Q = (r) => {
259
260
  M.value?.unsubscribe();
260
- let d = () => defer(() => g.plain === "subscription" ? v.checkSubscriptionPaymentStatus(t) : v.checkOnetimePaymentStatus(t)).pipe(timeout(15e3), retry({ delay: 2e3 }));
261
- M.value = d().pipe(expand((t) => t.status === "pending" ? timer(2e3).pipe(switchMap(() => d())) : EMPTY), tap((t) => {
262
- (t.status === "paid" || t.status === "approved") && (_("update:paymentStep", "success"), _("success", t)), t.status === "expired" && (_("update:paymentStep", "expired"), _("expired", t)), t.status === "failed" && (_("update:paymentStep", "failed"), _("failed", t));
261
+ let c = () => defer(() => f.plain === "subscription" ? g.checkSubscriptionPaymentStatus(r) : g.checkOnetimePaymentStatus(r)).pipe(timeout(15e3), retry({ delay: 2e3 }));
262
+ M.value = c().pipe(expand((r) => r.status === "pending" ? timer(2e3).pipe(switchMap(() => c())) : EMPTY), tap((r) => {
263
+ (r.status === "paid" || r.status === "approved") && (p("update:paymentStep", "success"), p("success", r)), r.status === "expired" && (p("update:paymentStep", "expired"), p("expired", r)), r.status === "failed" && (p("update:paymentStep", "failed"), p("failed", r));
263
264
  })).subscribe({
264
- error: (t) => {
265
+ error: (r) => {
265
266
  if (P.value) {
266
- let d = t instanceof Error ? t.message : "检查支付状态失败";
267
- _("update:paymentStep", "error"), _("update:error", d), _("error", t);
267
+ let c = r instanceof Error ? r.message : m.value.checkPaymentStatusFailed;
268
+ p("update:paymentStep", "error"), p("update:error", c), p("error", r);
268
269
  }
269
270
  },
270
271
  complete: () => {
@@ -273,133 +274,144 @@ var _hoisted_1$1 = { class: "_cppay-content" }, _hoisted_2$1 = {
273
274
  });
274
275
  }, $ = async () => {
275
276
  if (!P.value) return;
276
- let t = g.plain === "subscription" ? P.value.spenderAddress : P.value.receiveAddress;
277
- if (t) try {
278
- await navigator.clipboard.writeText(t), k.value = !0, setTimeout(() => {
277
+ let r = f.plain === "subscription" ? P.value.spenderAddress : P.value.receiveAddress;
278
+ if (r) try {
279
+ await navigator.clipboard.writeText(r), k.value = !0, setTimeout(() => {
279
280
  k.value = !1;
280
281
  }, 2e3);
281
- } catch (t) {
282
- console.error("复制失败:", t);
282
+ } catch (r) {
283
+ console.error("复制失败:", r);
283
284
  }
284
285
  };
285
- return watch(() => g.paymentStep, (t) => {
286
- t === "select" && y.value.length === 0 && K();
287
- }, { immediate: !0 }), watch(R, (t) => {
288
- t.length > 0 && !C.value && (C.value = t[0].symbol);
289
- }), watch(() => g.orderId, (t) => {
290
- t && Q({ orderId: t });
286
+ return watch(() => f.paymentStep, (r) => {
287
+ r === "select" && b.value.length === 0 && K();
288
+ }, { immediate: !0 }), watch(R, (r) => {
289
+ r.length > 0 && !C.value && (C.value = r[0].symbol);
290
+ }), watch(() => f.orderId, (r) => {
291
+ r && Q({ orderId: r });
291
292
  }), onMounted(() => {
292
293
  F();
293
294
  }), onUnmounted(() => {
294
295
  M.value?.unsubscribe(), W();
295
- }), (t, f) => (openBlock(), createElementBlock("div", _hoisted_1$1, [d.paymentStep === "success" ? (openBlock(), createElementBlock("div", _hoisted_2$1, [
296
- f[5] ||= createElementVNode("div", { class: "_cppay-state-icon" }, "✅", -1),
297
- createElementVNode("h3", _hoisted_3$1, toDisplayString(d.plain === "subscription" ? "授权成功!" : "支付成功!"), 1),
298
- createElementVNode("p", _hoisted_4$1, toDisplayString(d.plain === "subscription" ? "订阅已激活" : "交易已完成"), 1)
299
- ])) : d.paymentStep === "expired" ? (openBlock(), createElementBlock("div", _hoisted_5, [
300
- f[6] ||= createElementVNode("div", { class: "_cppay-state-icon" }, "⏰", -1),
301
- f[7] ||= createElementVNode("h3", { class: "_cppay-state-title" }, "支付已过期,请重选创建支付订单", -1),
296
+ }), (r, l) => (openBlock(), createElementBlock("div", _hoisted_1$1, [c.paymentStep === "success" ? (openBlock(), createElementBlock("div", _hoisted_2$1, [
297
+ l[7] ||= createElementVNode("div", { class: "_cppay-state-icon" }, "✅", -1),
298
+ createElementVNode("h3", _hoisted_3$1, toDisplayString(c.plain === "subscription" ? m.value.authorizationSuccess : m.value.paymentSuccess), 1),
299
+ createElementVNode("p", _hoisted_4$1, toDisplayString(c.plain === "subscription" ? m.value.subscriptionActivated : m.value.transactionCompleted), 1)
300
+ ])) : c.paymentStep === "expired" ? (openBlock(), createElementBlock("div", _hoisted_5, [
301
+ l[8] ||= createElementVNode("div", { class: "_cppay-state-icon" }, "⏰", -1),
302
+ createElementVNode("h3", _hoisted_6, toDisplayString(m.value.paymentExpired), 1),
302
303
  createElementVNode("button", {
303
- onClick: f[0] ||= (d) => t.$emit("update:paymentStep", "select"),
304
- disabled: d.loading || d.isCheckingPayment,
304
+ onClick: l[0] ||= (c) => r.$emit("update:paymentStep", "select"),
305
+ disabled: c.loading || c.isCheckingPayment,
305
306
  class: "_cppay-btn _cppay-btn-text"
306
- }, " 返回 ", 8, _hoisted_6)
307
- ])) : d.paymentStep === "error" ? (openBlock(), createElementBlock("div", _hoisted_7, [...f[8] ||= [createElementVNode("div", { class: "_cppay-state-icon" }, "❌", -1), createElementVNode("h3", { class: "_cppay-state-title" }, "检查订单支付状态失败!", -1)]])) : d.paymentStep === "failed" ? (openBlock(), createElementBlock("div", _hoisted_8, [...f[9] ||= [createElementVNode("div", { class: "_cppay-state-icon" }, "❌", -1), createElementVNode("h3", { class: "_cppay-state-title" }, "订单支付失败!", -1)]])) : d.paymentStep === "select" ? (openBlock(), createElementBlock("div", _hoisted_9, [
308
- renderSlot(t.$slots, "choose-top"),
309
- createElementVNode("div", _hoisted_10, [f[10] ||= createElementVNode("label", { class: "_cppay-label" }, "支付网络", -1), createElementVNode("div", _hoisted_11, [(openBlock(!0), createElementBlock(Fragment, null, renderList(y.value, (t) => (openBlock(), createElementBlock("button", {
310
- key: t.chain,
311
- onClick: (d) => S.value = t.chain,
312
- class: normalizeClass(["_cppay-select-btn", { "_cppay-selected": S.value === t.chain }])
313
- }, [t.icon ? (openBlock(), createElementBlock("img", {
307
+ }, toDisplayString(m.value.returnButton), 9, _hoisted_7)
308
+ ])) : c.paymentStep === "error" ? (openBlock(), createElementBlock("div", _hoisted_8, [l[9] ||= createElementVNode("div", { class: "_cppay-state-icon" }, "❌", -1), createElementVNode("h3", _hoisted_9, toDisplayString(m.value.checking), 1)])) : c.paymentStep === "failed" ? (openBlock(), createElementBlock("div", _hoisted_10, [l[10] ||= createElementVNode("div", { class: "_cppay-state-icon" }, "❌", -1), createElementVNode("h3", _hoisted_11, toDisplayString(m.value.paymentFailed), 1)])) : c.paymentStep === "select" ? (openBlock(), createElementBlock("div", _hoisted_12, [
309
+ renderSlot(r.$slots, "choose-top"),
310
+ createElementVNode("div", _hoisted_13, [createElementVNode("label", _hoisted_14, toDisplayString(m.value.paymentNetwork), 1), createElementVNode("div", _hoisted_15, [(openBlock(!0), createElementBlock(Fragment, null, renderList(b.value, (r) => (openBlock(), createElementBlock("button", {
311
+ key: r.chain,
312
+ onClick: (c) => S.value = r.chain,
313
+ class: normalizeClass(["_cppay-select-btn", { "_cppay-selected": S.value === r.chain }])
314
+ }, [r.icon ? (openBlock(), createElementBlock("img", {
314
315
  key: 0,
315
- src: t.icon,
316
- alt: t.chain
317
- }, null, 8, _hoisted_13)) : createCommentVNode("", !0), createElementVNode("span", null, toDisplayString(t.chain), 1)], 10, _hoisted_12))), 128))])]),
318
- createElementVNode("div", _hoisted_14, [f[11] ||= createElementVNode("label", { class: "_cppay-label" }, "支付代币", -1), createElementVNode("div", _hoisted_15, [(openBlock(!0), createElementBlock(Fragment, null, renderList(R.value, (t) => (openBlock(), createElementBlock("button", {
319
- key: t.symbol,
320
- onClick: (d) => C.value = t.symbol,
321
- class: normalizeClass(["_cppay-select-btn", { "_cppay-selected": C.value === t.symbol }])
322
- }, [t.icon ? (openBlock(), createElementBlock("img", {
316
+ src: r.icon,
317
+ alt: r.chain
318
+ }, null, 8, _hoisted_17)) : createCommentVNode("", !0), createElementVNode("span", null, toDisplayString(r.chain), 1)], 10, _hoisted_16))), 128))])]),
319
+ createElementVNode("div", _hoisted_18, [createElementVNode("label", _hoisted_19, toDisplayString(m.value.paymentToken), 1), createElementVNode("div", _hoisted_20, [(openBlock(!0), createElementBlock(Fragment, null, renderList(R.value, (r) => (openBlock(), createElementBlock("button", {
320
+ key: r.symbol,
321
+ onClick: (c) => C.value = r.symbol,
322
+ class: normalizeClass(["_cppay-select-btn", { "_cppay-selected": C.value === r.symbol }])
323
+ }, [r.icon ? (openBlock(), createElementBlock("img", {
323
324
  key: 0,
324
- src: t.icon,
325
- alt: t.symbol
326
- }, null, 8, _hoisted_17)) : createCommentVNode("", !0), createElementVNode("span", null, toDisplayString(t.symbol), 1)], 10, _hoisted_16))), 128))])]),
327
- renderSlot(t.$slots, "choose-bottom"),
328
- createElementVNode("div", _hoisted_18, [createElementVNode("div", _hoisted_19, [createElementVNode("div", _hoisted_20, [f[12] ||= createElementVNode("span", { class: "_cppay-price-label" }, "支付金额", -1), createElementVNode("div", _hoisted_21, [createElementVNode("div", _hoisted_22, toDisplayString(G.value ?? "-") + " " + toDisplayString(C.value ?? ""), 1), createElementVNode("div", _hoisted_23, "≈ $" + toDisplayString(d.amount), 1)])])])]),
329
- createElementVNode("div", _hoisted_24, [d.error ? (openBlock(), createElementBlock("div", {
325
+ src: r.icon,
326
+ alt: r.symbol
327
+ }, null, 8, _hoisted_22)) : createCommentVNode("", !0), createElementVNode("span", null, toDisplayString(r.symbol), 1)], 10, _hoisted_21))), 128))])]),
328
+ renderSlot(r.$slots, "choose-bottom"),
329
+ createElementVNode("div", _hoisted_23, [createElementVNode("div", _hoisted_24, [createElementVNode("div", _hoisted_25, [createElementVNode("span", _hoisted_26, toDisplayString(m.value.paymentAmount), 1), createElementVNode("div", _hoisted_27, [createElementVNode("div", _hoisted_28, toDisplayString(G.value ?? "-") + " " + toDisplayString(C.value ?? ""), 1), createElementVNode("div", _hoisted_29, "≈ $" + toDisplayString(c.amount), 1)])])])]),
330
+ createElementVNode("div", _hoisted_30, [c.error ? (openBlock(), createElementBlock("div", {
330
331
  key: 0,
331
332
  class: "_cppay-error-tooltip-wrapper",
332
- onMouseenter: f[1] ||= (t) => A.value = !0,
333
- onMouseleave: f[2] ||= (t) => A.value = !1
334
- }, [createElementVNode("div", _hoisted_25, [f[13] ||= createElementVNode("svg", {
333
+ onMouseenter: l[1] ||= (r) => A.value = !0,
334
+ onMouseleave: l[2] ||= (r) => A.value = !1
335
+ }, [createElementVNode("div", _hoisted_31, [l[11] ||= createElementVNode("svg", {
335
336
  viewBox: "0 0 20 20",
336
337
  fill: "currentColor"
337
338
  }, [createElementVNode("path", {
338
339
  "fill-rule": "evenodd",
339
340
  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",
340
341
  "clip-rule": "evenodd"
341
- })], -1), createElementVNode("span", null, toDisplayString(d.error), 1)]), A.value ? (openBlock(), createElementBlock("div", _hoisted_26, toDisplayString(d.error), 1)) : createCommentVNode("", !0)], 32)) : createCommentVNode("", !0), createElementVNode("button", {
342
+ })], -1), createElementVNode("span", null, toDisplayString(c.error), 1)]), A.value ? (openBlock(), createElementBlock("div", _hoisted_32, toDisplayString(c.error), 1)) : createCommentVNode("", !0)], 32)) : createCommentVNode("", !0), createElementVNode("button", {
342
343
  onClick: Z,
343
- disabled: !S.value || !C.value || d.loading,
344
+ disabled: !S.value || !C.value || c.loading,
344
345
  class: "_cppay-btn _cppay-btn-primary"
345
- }, toDisplayString(d.loading ? "处理中..." : "继续支付"), 9, _hoisted_27)])
346
- ])) : (openBlock(), createElementBlock("div", _hoisted_28, [
347
- createElementVNode("div", _hoisted_29, [createElementVNode("div", _hoisted_30, [w.value ? (openBlock(), createElementBlock("img", {
346
+ }, toDisplayString(c.loading ? m.value.processing : m.value.continuePayment), 9, _hoisted_33)])
347
+ ])) : (openBlock(), createElementBlock("div", _hoisted_34, [
348
+ createElementVNode("div", _hoisted_35, [createElementVNode("div", _hoisted_36, [w.value ? (openBlock(), createElementBlock("img", {
348
349
  key: 0,
349
350
  src: w.value,
350
351
  alt: "Payment QR Code",
351
352
  class: "_cppay-qr-image"
352
- }, null, 8, _hoisted_31)) : createCommentVNode("", !0)])]),
353
- createElementVNode("div", _hoisted_32, [
354
- z.value ? (openBlock(), createElementBlock("div", _hoisted_33, [createElementVNode("div", _hoisted_34, [createElementVNode("div", _hoisted_35, [createElementVNode("div", _hoisted_36, toDisplayString(d.plain === "subscription" ? "授权金额" : "支付金额"), 1), createElementVNode("div", _hoisted_37, [P.value ? (openBlock(), createElementBlock("span", _hoisted_38, toDisplayString(d.plain === "subscription" ? `${V(P.value.approveAmount, B(z.value.symbol))} ${z.value.symbol}` : `${V(P.value.paymentAmount, B(z.value.symbol))} ${z.value.symbol}`), 1)) : createCommentVNode("", !0), createElementVNode("span", null, "≈ $" + toDisplayString(d.amount), 1)])])])])) : createCommentVNode("", !0),
355
- createElementVNode("div", _hoisted_39, [createElementVNode("div", _hoisted_40, [createElementVNode("div", _hoisted_41, [createElementVNode("span", null, toDisplayString(d.plain === "subscription" ? "授权合约地址" : "支付地址"), 1), O.value ? (openBlock(), createElementBlock("span", _hoisted_42, "⏰ " + toDisplayString(O.value), 1)) : createCommentVNode("", !0)]), createElementVNode("div", _hoisted_43, [P.value ? (openBlock(), createElementBlock("code", _hoisted_44, toDisplayString(d.plain === "subscription" ? P.value.spenderAddress : P.value.receiveAddress), 1)) : createCommentVNode("", !0), createElementVNode("button", {
353
+ }, null, 8, _hoisted_37)) : createCommentVNode("", !0)])]),
354
+ createElementVNode("div", _hoisted_38, [
355
+ z.value ? (openBlock(), createElementBlock("div", _hoisted_39, [createElementVNode("div", _hoisted_40, [createElementVNode("div", _hoisted_41, [createElementVNode("div", _hoisted_42, toDisplayString(c.plain === "subscription" ? m.value.authorizationAmount : m.value.paymentAmount), 1), createElementVNode("div", _hoisted_43, [P.value ? (openBlock(), createElementBlock("span", _hoisted_44, toDisplayString(c.plain === "subscription" ? `${V(P.value.approveAmount, B(z.value.symbol))} ${z.value.symbol}` : `${V(P.value.paymentAmount, B(z.value.symbol))} ${z.value.symbol}`), 1)) : createCommentVNode("", !0), createElementVNode("span", null, "≈ $" + toDisplayString(c.amount), 1)])])])])) : createCommentVNode("", !0),
356
+ createElementVNode("div", _hoisted_45, [createElementVNode("div", _hoisted_46, [createElementVNode("div", _hoisted_47, [createElementVNode("span", null, toDisplayString(c.plain === "subscription" ? m.value.authorizationContractAddress : m.value.paymentAddress), 1), O.value ? (openBlock(), createElementBlock("span", _hoisted_48, "⏰ " + toDisplayString(O.value), 1)) : createCommentVNode("", !0)]), createElementVNode("div", _hoisted_49, [P.value ? (openBlock(), createElementBlock("code", _hoisted_50, toDisplayString(c.plain === "subscription" ? P.value.spenderAddress : P.value.receiveAddress), 1)) : createCommentVNode("", !0), createElementVNode("button", {
356
357
  onClick: $,
357
358
  class: normalizeClass(["_cppay-copy-btn", { "_cppay-copy-success": k.value }]),
358
- title: k.value ? "已复制!" : "复制地址"
359
- }, [k.value ? (openBlock(), createElementBlock("svg", _hoisted_47, [...f[15] ||= [createElementVNode("path", { d: "M9 16.17L4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41z" }, null, -1)]])) : (openBlock(), createElementBlock("svg", _hoisted_46, [...f[14] ||= [createElementVNode("path", { d: "M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2" }, null, -1), createElementVNode("rect", {
359
+ title: k.value ? m.value.copied : m.value.copyAddress
360
+ }, [k.value ? (openBlock(), createElementBlock("svg", _hoisted_53, [...l[13] ||= [createElementVNode("path", { d: "M9 16.17L4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41z" }, null, -1)]])) : (openBlock(), createElementBlock("svg", _hoisted_52, [...l[12] ||= [createElementVNode("path", { d: "M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2" }, null, -1), createElementVNode("rect", {
360
361
  x: "8",
361
362
  y: "2",
362
363
  width: "8",
363
364
  height: "4",
364
365
  rx: "1",
365
366
  ry: "1"
366
- }, null, -1)]]))], 10, _hoisted_45)])])]),
367
- d.plain === "subscription" ? (openBlock(), createElementBlock("div", _hoisted_48, [...f[16] ||= [createElementVNode("div", { class: "_cppay-info-label _cppay-subscription-label" }, "📌 订阅说明", -1), createElementVNode("div", { class: "_cppay-info-value _cppay-subscription-message" }, " 订阅支付需要授权代币给合约地址,系统将按周期自动扣款。授权后无需每次手动支付。 ", -1)]])) : createCommentVNode("", !0)
367
+ }, null, -1)]]))], 10, _hoisted_51)])])]),
368
+ c.plain === "subscription" ? (openBlock(), createElementBlock("div", _hoisted_54, [createElementVNode("div", _hoisted_55, toDisplayString(m.value.subscriptionNotice), 1), createElementVNode("div", _hoisted_56, toDisplayString(m.value.subscriptionNoticeMessage), 1)])) : createCommentVNode("", !0)
368
369
  ]),
369
- d.error ? (openBlock(), createElementBlock("div", {
370
+ c.error ? (openBlock(), createElementBlock("div", {
370
371
  key: 0,
371
372
  class: "_cppay-error-tooltip-wrapper",
372
- onMouseenter: f[3] ||= (t) => A.value = !0,
373
- onMouseleave: f[4] ||= (t) => A.value = !1
374
- }, [createElementVNode("div", _hoisted_49, [f[17] ||= createElementVNode("svg", {
373
+ onMouseenter: l[3] ||= (r) => A.value = !0,
374
+ onMouseleave: l[4] ||= (r) => A.value = !1
375
+ }, [createElementVNode("div", _hoisted_57, [l[14] ||= createElementVNode("svg", {
375
376
  viewBox: "0 0 20 20",
376
377
  fill: "currentColor"
377
378
  }, [createElementVNode("path", {
378
379
  "fill-rule": "evenodd",
379
380
  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",
380
381
  "clip-rule": "evenodd"
381
- })], -1), createElementVNode("span", null, toDisplayString(d.error), 1)]), A.value ? (openBlock(), createElementBlock("div", _hoisted_50, toDisplayString(d.error), 1)) : createCommentVNode("", !0)], 32)) : createCommentVNode("", !0),
382
- d.isCheckingPayment ? createCommentVNode("", !0) : (openBlock(), createElementBlock("div", _hoisted_51, [T.value ? (openBlock(), createElementBlock(Fragment, { key: 1 }, [createElementVNode("button", {
382
+ })], -1), createElementVNode("span", null, toDisplayString(c.error), 1)]), A.value ? (openBlock(), createElementBlock("div", _hoisted_58, toDisplayString(c.error), 1)) : createCommentVNode("", !0)], 32)) : createCommentVNode("", !0),
383
+ c.isCheckingPayment ? createCommentVNode("", !0) : (openBlock(), createElementBlock("div", _hoisted_59, [T.value ? (openBlock(), createElementBlock(Fragment, { key: 1 }, [createElementVNode("button", {
383
384
  onClick: X,
384
- disabled: d.loading,
385
+ disabled: c.loading,
385
386
  class: "_cppay-btn _cppay-btn-primary"
386
- }, toDisplayString(d.loading ? d.plain === "subscription" ? "授权中..." : "支付中..." : d.plain === "subscription" ? "💳 钱包授权" : "💳 钱包支付"), 9, _hoisted_53), createElementVNode("button", {
387
+ }, toDisplayString(c.loading ? c.plain === "subscription" ? m.value.authorizing : m.value.processing : (c.plain, m.value.walletPay)), 9, _hoisted_61), createElementVNode("button", {
387
388
  onClick: I,
388
- disabled: d.loading,
389
+ disabled: c.loading,
389
390
  class: "_cppay-btn _cppay-wallet-address-btn",
390
- title: "点击修改或查看钱包状态"
391
- }, [createElementVNode("span", _hoisted_55, toDisplayString(T.value.slice(0, 10)) + "..." + toDisplayString(T.value.slice(-4)), 1), f[18] ||= createElementVNode("svg", {
391
+ title: m.value.clickToModifyWallet
392
+ }, [createElementVNode("span", _hoisted_63, toDisplayString(T.value.slice(0, 10)) + "..." + toDisplayString(T.value.slice(-4)), 1), l[15] ||= createElementVNode("svg", {
392
393
  class: "_cppay-wallet-arrow",
393
394
  viewBox: "0 0 24 24",
394
395
  fill: "none",
395
396
  stroke: "currentColor",
396
397
  "stroke-width": "2"
397
- }, [createElementVNode("polyline", { points: "6 9 12 15 18 9" })], -1)], 8, _hoisted_54)], 64)) : (openBlock(), createElementBlock("button", {
398
+ }, [createElementVNode("polyline", { points: "6 9 12 15 18 9" })], -1)], 8, _hoisted_62)], 64)) : (openBlock(), createElementBlock("button", {
398
399
  key: 0,
399
400
  onClick: I,
400
401
  disabled: E.value,
401
402
  class: "_cppay-btn _cppay-btn-secondary _cppay-connect-wallet-btn"
402
- }, [createElementVNode("span", null, toDisplayString(E.value ? "连接中..." : "💳 连接钱包"), 1)], 8, _hoisted_52))]))
403
+ }, [createElementVNode("span", null, toDisplayString(E.value ? m.value.processing : m.value.connectWallet), 1)], 8, _hoisted_60))])),
404
+ createElementVNode("div", _hoisted_64, [createElementVNode("button", {
405
+ onClick: l[5] ||= (c) => r.$emit("update:paymentStep", "payment"),
406
+ disabled: c.isCheckingPayment,
407
+ class: "_cppay-btn _cppay-btn-primary"
408
+ }, toDisplayString(c.isCheckingPayment ? m.value.checking : m.value.completedPayment), 9, _hoisted_65)]),
409
+ l[16] ||= createElementVNode("hr", { class: "_cppay-divider" }, null, -1),
410
+ createElementVNode("div", _hoisted_66, [createElementVNode("button", {
411
+ onClick: l[6] ||= (c) => r.$emit("update:paymentStep", "select"),
412
+ disabled: c.loading || c.isCheckingPayment,
413
+ class: "_cppay-btn _cppay-btn-text"
414
+ }, toDisplayString(m.value.changePaymentMethod), 9, _hoisted_67)])
403
415
  ]))]));
404
416
  }
405
417
  }), _hoisted_1 = { class: "_cppay-dialog" }, _hoisted_2 = { class: "_cppay-header" }, _hoisted_3 = { class: "_cppay-title" }, _hoisted_4 = ["disabled"], PaymentDialog_default = /* @__PURE__ */ defineComponent({
@@ -410,7 +422,8 @@ var _hoisted_1$1 = { class: "_cppay-content" }, _hoisted_2$1 = {
410
422
  orderId: {},
411
423
  amount: {},
412
424
  plain: { default: "one-time" },
413
- intervalDays: { default: 30 }
425
+ intervalDays: { default: 30 },
426
+ locale: { default: "zh-CN" }
414
427
  },
415
428
  emits: [
416
429
  "update:modelValue",
@@ -419,43 +432,43 @@ var _hoisted_1$1 = { class: "_cppay-content" }, _hoisted_2$1 = {
419
432
  "failed",
420
433
  "error"
421
434
  ],
422
- setup(t, { emit: d }) {
423
- let f = t, p = d, m = ref("select"), g = ref(!1), v = ref(!1), y = ref();
424
- watch(() => m.value, (t) => {
425
- t === "success" && setTimeout(() => {
426
- b();
435
+ setup(r, { emit: c }) {
436
+ let l = r, d = c, f = computed(() => getLocaleMessages(l.locale)), m = ref("select"), g = ref(!1), _ = ref(!1), v = ref();
437
+ watch(() => m.value, (r) => {
438
+ r === "success" && setTimeout(() => {
439
+ y();
427
440
  }, 1e3);
428
- }), watch(() => f.modelValue, (t) => {
429
- t || (m.value = "select", y.value = void 0, g.value = !1, v.value = !1);
441
+ }), watch(() => l.modelValue, (r) => {
442
+ r || (m.value = "select", v.value = void 0, g.value = !1, _.value = !1);
430
443
  }), onMounted(() => {
431
- let t = (t) => {
432
- t.key === "Escape" && f.modelValue && !g.value && !v.value && b();
444
+ let r = (r) => {
445
+ r.key === "Escape" && l.modelValue && !g.value && !_.value && y();
433
446
  };
434
- return window.addEventListener("keydown", t), () => {
435
- window.removeEventListener("keydown", t);
447
+ return window.addEventListener("keydown", r), () => {
448
+ window.removeEventListener("keydown", r);
436
449
  };
437
450
  });
438
- let b = () => {
439
- g.value || v.value || p("update:modelValue", !1);
451
+ let y = () => {
452
+ g.value || _.value || d("update:modelValue", !1);
440
453
  }, x = () => {
441
454
  switch (m.value) {
442
- case "success": return "支付结果";
443
- case "expired": return "支付已过期";
444
- case "failed": return "支付失败";
445
- case "error": return "出错";
446
- case "payment": return "完成支付";
447
- default: return "选择支付方式";
455
+ case "success": return f.value.paymentResult;
456
+ case "expired": return f.value.paymentExpired;
457
+ case "failed": return f.value.paymentFailed;
458
+ case "error": return f.value.error;
459
+ case "payment": return f.value.completePayment;
460
+ default: return f.value.selectPaymentMethod;
448
461
  }
449
462
  };
450
- return (d, f) => t.modelValue ? (openBlock(), createElementBlock("div", {
463
+ return (c, l) => r.modelValue ? (openBlock(), createElementBlock("div", {
451
464
  key: 0,
452
465
  class: "_cppay-overlay",
453
- onClick: f[6] ||= (t) => t.target === t.currentTarget && !g.value && !v.value && b()
466
+ onClick: l[6] ||= (r) => r.target === r.currentTarget && !g.value && !_.value && y()
454
467
  }, [createElementVNode("div", _hoisted_1, [createElementVNode("div", _hoisted_2, [createElementVNode("h2", _hoisted_3, toDisplayString(x()), 1), createElementVNode("button", {
455
- onClick: b,
456
- disabled: g.value || v.value,
468
+ onClick: y,
469
+ disabled: g.value || _.value,
457
470
  class: "_cppay-close-btn"
458
- }, [...f[7] ||= [createElementVNode("svg", {
471
+ }, [...l[7] ||= [createElementVNode("svg", {
459
472
  fill: "none",
460
473
  stroke: "currentColor",
461
474
  viewBox: "0 0 24 24"
@@ -465,24 +478,25 @@ var _hoisted_1$1 = { class: "_cppay-content" }, _hoisted_2$1 = {
465
478
  "stroke-width": "2",
466
479
  d: "M6 18L18 6M6 6l12 12"
467
480
  })], -1)]], 8, _hoisted_4)]), createVNode(PaymentContent_default, {
468
- apikey: t.apikey,
469
- orderId: t.orderId,
470
- amount: t.amount,
471
- plain: t.plain,
472
- intervalDays: t.intervalDays,
481
+ apikey: r.apikey,
482
+ orderId: r.orderId,
483
+ amount: r.amount,
484
+ plain: r.plain,
485
+ intervalDays: r.intervalDays,
486
+ locale: r.locale,
473
487
  paymentStep: m.value,
474
488
  loading: g.value,
475
- isCheckingPayment: v.value,
476
- error: y.value,
477
- "onUpdate:paymentStep": f[0] ||= (t) => m.value = t,
478
- "onUpdate:error": f[1] ||= (t) => y.value = t,
479
- onSuccess: f[2] ||= (t) => p("success", t),
480
- onExpired: f[3] ||= (t) => p("expired", t),
481
- onFailed: f[4] ||= (t) => p("failed", t),
482
- onError: f[5] ||= (t) => p("error", t)
489
+ isCheckingPayment: _.value,
490
+ error: v.value,
491
+ "onUpdate:paymentStep": l[0] ||= (r) => m.value = r,
492
+ "onUpdate:error": l[1] ||= (r) => v.value = r,
493
+ onSuccess: l[2] ||= (r) => d("success", r),
494
+ onExpired: l[3] ||= (r) => d("expired", r),
495
+ onFailed: l[4] ||= (r) => d("failed", r),
496
+ onError: l[5] ||= (r) => d("error", r)
483
497
  }, {
484
- "choose-top": withCtx(() => [renderSlot(d.$slots, "choose-top")]),
485
- "choose-bottom": withCtx(() => [renderSlot(d.$slots, "choose-bottom")]),
498
+ "choose-top": withCtx(() => [renderSlot(c.$slots, "choose-top")]),
499
+ "choose-bottom": withCtx(() => [renderSlot(c.$slots, "choose-bottom")]),
486
500
  _: 3
487
501
  }, 8, [
488
502
  "apikey",
@@ -490,6 +504,7 @@ var _hoisted_1$1 = { class: "_cppay-content" }, _hoisted_2$1 = {
490
504
  "amount",
491
505
  "plain",
492
506
  "intervalDays",
507
+ "locale",
493
508
  "paymentStep",
494
509
  "loading",
495
510
  "isCheckingPayment",
@@ -501,35 +516,35 @@ var _hoisted_1$1 = { class: "_cppay-content" }, _hoisted_2$1 = {
501
516
  open: !1,
502
517
  options: null
503
518
  });
504
- const showPayment = (t) => {
505
- cppayState.value.options = t, cppayState.value.open = !0;
519
+ const showPayment = (r) => {
520
+ cppayState.value.options = r, cppayState.value.open = !0;
506
521
  }, closePayment = () => {
507
522
  cppayState.value.open = !1;
508
523
  };
509
524
  var handleClose = () => {
510
525
  cppayState.value.open = !1;
511
- }, handleSuccess = (t) => {
512
- cppayState.value.options?.onSuccess?.(t), setTimeout(() => {
526
+ }, handleSuccess = (r) => {
527
+ cppayState.value.options?.onSuccess?.(r), setTimeout(() => {
513
528
  cppayState.value.open = !1;
514
529
  }, 1e3);
515
- }, handleExpired = (t) => {
516
- cppayState.value.options?.onExpired?.(t);
517
- }, handleFailed = (t) => {
518
- cppayState.value.options?.onFailed?.(t);
519
- }, handleError = (t) => {
520
- cppayState.value.options?.onError?.(t);
530
+ }, handleExpired = (r) => {
531
+ cppayState.value.options?.onExpired?.(r);
532
+ }, handleFailed = (r) => {
533
+ cppayState.value.options?.onFailed?.(r);
534
+ }, handleError = (r) => {
535
+ cppayState.value.options?.onError?.(r);
521
536
  };
522
- const CppayPlugin = { install(t, d) {
523
- if (!d?.apikey) throw Error("Cppay plugin requires an apikey");
524
- cppayState.value.apikey = d.apikey, t.config.globalProperties.$showPayment = showPayment, t.config.globalProperties.$closePayment = closePayment;
525
- let f = (t) => {
526
- t.key === "Escape" && cppayState.value.open && handleClose();
527
- }, p = document.createElement("div");
528
- document.body.appendChild(p), createApp({ setup() {
537
+ const CppayPlugin = { install(r, c) {
538
+ if (!c?.apikey) throw Error("Cppay plugin requires an apikey");
539
+ cppayState.value.apikey = c.apikey, r.config.globalProperties.$showPayment = showPayment, r.config.globalProperties.$closePayment = closePayment;
540
+ let l = (r) => {
541
+ r.key === "Escape" && cppayState.value.open && handleClose();
542
+ }, u = document.createElement("div");
543
+ document.body.appendChild(u), createApp({ setup() {
529
544
  return () => cppayState.value.options ? h(PaymentDialog_default, {
530
545
  modelValue: cppayState.value.open,
531
- "onUpdate:modelValue": (t) => {
532
- cppayState.value.open = t, t || handleClose();
546
+ "onUpdate:modelValue": (r) => {
547
+ cppayState.value.open = r, r || handleClose();
533
548
  },
534
549
  apikey: cppayState.value.apikey,
535
550
  plain: cppayState.value.options.plain,
@@ -541,8 +556,8 @@ const CppayPlugin = { install(t, d) {
541
556
  onFailed: handleFailed,
542
557
  onError: handleError
543
558
  }) : null;
544
- } }).mount(p), cppayState.value.open && document.addEventListener("keydown", f), t.config.globalProperties.$watchEffect?.(() => {
545
- cppayState.value.open ? document.addEventListener("keydown", f) : document.removeEventListener("keydown", f);
559
+ } }).mount(u), cppayState.value.open && document.addEventListener("keydown", l), r.config.globalProperties.$watchEffect?.(() => {
560
+ cppayState.value.open ? document.addEventListener("keydown", l) : document.removeEventListener("keydown", l);
546
561
  });
547
562
  } }, useCppayPayment = () => {
548
563
  if (!cppayState.value.apikey) throw Error("useCppayPayment must be used after installing CppayPlugin");