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

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