cppay-sdk 0.0.2-beta.35 → 0.0.2-beta.37

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