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/{inject-style-Cd5D3aj8.cjs → locales-DAKREZkH.cjs} +1 -1
- package/dist/{inject-style-DtFJ9cds.js → locales-DGvDecya.js} +108 -3
- package/dist/react.cjs +1 -1
- package/dist/react.d.ts +6 -0
- package/dist/react.js +245 -223
- package/dist/vue.cjs +1 -1
- package/dist/vue.d.ts +6 -0
- package/dist/vue.js +230 -215
- package/package.json +1 -1
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
|
|
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"],
|
|
17
|
+
}, _hoisted_6 = { class: "_cppay-state-title" }, _hoisted_7 = ["disabled"], _hoisted_8 = {
|
|
18
18
|
key: 2,
|
|
19
19
|
class: "_cppay-state-container"
|
|
20
|
-
},
|
|
20
|
+
}, _hoisted_9 = { class: "_cppay-state-title" }, _hoisted_10 = {
|
|
21
21
|
key: 3,
|
|
22
22
|
class: "_cppay-state-container"
|
|
23
|
-
},
|
|
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
|
-
},
|
|
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
|
-
},
|
|
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
|
-
},
|
|
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
|
-
},
|
|
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
|
-
},
|
|
44
|
+
}, _hoisted_54 = {
|
|
45
45
|
key: 1,
|
|
46
46
|
class: "_cppay-info-box _cppay-subscription-box"
|
|
47
|
-
},
|
|
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
|
-
},
|
|
50
|
+
}, _hoisted_59 = {
|
|
51
51
|
key: 1,
|
|
52
52
|
class: "_cppay-section"
|
|
53
|
-
},
|
|
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(
|
|
82
|
-
let
|
|
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((
|
|
105
|
-
|
|
106
|
-
}), j.value.subscribeProviders((
|
|
107
|
-
D.value =
|
|
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,
|
|
112
|
-
} catch (
|
|
113
|
-
|
|
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(() =>
|
|
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(
|
|
126
|
-
let
|
|
127
|
-
return isNaN(
|
|
128
|
-
}, H = (
|
|
129
|
-
if (
|
|
130
|
-
let
|
|
131
|
-
return
|
|
132
|
-
}, U = (
|
|
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
|
|
135
|
-
let
|
|
136
|
-
O.value = H(
|
|
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
|
-
|
|
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
|
|
144
|
-
if (isNaN(
|
|
145
|
-
let
|
|
146
|
-
return V((parseFloat(
|
|
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
|
-
|
|
150
|
-
let
|
|
151
|
-
|
|
152
|
-
} catch (
|
|
153
|
-
|
|
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 (
|
|
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${
|
|
160
|
+
params: [{ chainId: `0x${r.toString(16)}` }]
|
|
160
161
|
});
|
|
161
|
-
} catch (
|
|
162
|
-
throw
|
|
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
|
|
167
|
+
let r = P.value;
|
|
167
168
|
await q(L.value.chainId);
|
|
168
|
-
let
|
|
169
|
+
let c = createWalletClient({
|
|
169
170
|
account: T.value,
|
|
170
171
|
transport: custom(D.value)
|
|
171
172
|
});
|
|
172
|
-
z.value.address ? await
|
|
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: [
|
|
189
|
+
args: [r.receiveAddress, parseUnits(r.paymentAmount, z.value.decimals)],
|
|
189
190
|
chain: null
|
|
190
|
-
}) : await
|
|
191
|
-
to:
|
|
192
|
-
value: parseUnits(
|
|
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 (
|
|
196
|
-
|
|
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
|
|
201
|
+
let r = P.value;
|
|
201
202
|
await q(L.value.chainId);
|
|
202
|
-
let
|
|
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
|
|
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: [
|
|
224
|
+
args: [r.spenderAddress, parseUnits(r.approveAmount, z.value.decimals)],
|
|
224
225
|
chain: null
|
|
225
226
|
}), w.value = void 0;
|
|
226
|
-
} catch (
|
|
227
|
-
|
|
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
|
-
|
|
232
|
+
p("update:error", m.value.pleaseConnectWallet), p("error", Error(m.value.pleaseConnectWallet));
|
|
232
233
|
return;
|
|
233
234
|
}
|
|
234
|
-
|
|
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
|
-
|
|
238
|
-
let
|
|
239
|
-
|
|
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:
|
|
243
|
+
orderId: f.orderId,
|
|
243
244
|
amount: G.value
|
|
244
|
-
}),
|
|
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:
|
|
248
|
+
orderId: f.orderId,
|
|
248
249
|
amountOfUsd: G.value,
|
|
249
|
-
intervalDays:
|
|
250
|
-
}),
|
|
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 (
|
|
256
|
-
|
|
256
|
+
} catch (r) {
|
|
257
|
+
p("update:error", r instanceof Error ? r.message : m.value.createPaymentFailed), p("error", r);
|
|
257
258
|
}
|
|
258
|
-
}, Q = (
|
|
259
|
+
}, Q = (r) => {
|
|
259
260
|
M.value?.unsubscribe();
|
|
260
|
-
let
|
|
261
|
-
M.value =
|
|
262
|
-
(
|
|
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: (
|
|
265
|
+
error: (r) => {
|
|
265
266
|
if (P.value) {
|
|
266
|
-
let
|
|
267
|
-
|
|
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
|
|
277
|
-
if (
|
|
278
|
-
await navigator.clipboard.writeText(
|
|
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 (
|
|
282
|
-
console.error("复制失败:",
|
|
282
|
+
} catch (r) {
|
|
283
|
+
console.error("复制失败:", r);
|
|
283
284
|
}
|
|
284
285
|
};
|
|
285
|
-
return watch(() =>
|
|
286
|
-
|
|
287
|
-
}, { immediate: !0 }), watch(R, (
|
|
288
|
-
|
|
289
|
-
}), watch(() =>
|
|
290
|
-
|
|
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
|
-
}), (
|
|
296
|
-
|
|
297
|
-
createElementVNode("h3", _hoisted_3$1, toDisplayString(
|
|
298
|
-
createElementVNode("p", _hoisted_4$1, toDisplayString(
|
|
299
|
-
])) :
|
|
300
|
-
|
|
301
|
-
|
|
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:
|
|
304
|
-
disabled:
|
|
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
|
-
},
|
|
307
|
-
])) :
|
|
308
|
-
renderSlot(
|
|
309
|
-
createElementVNode("div",
|
|
310
|
-
key:
|
|
311
|
-
onClick: (
|
|
312
|
-
class: normalizeClass(["_cppay-select-btn", { "_cppay-selected": S.value ===
|
|
313
|
-
}, [
|
|
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:
|
|
316
|
-
alt:
|
|
317
|
-
}, null, 8,
|
|
318
|
-
createElementVNode("div",
|
|
319
|
-
key:
|
|
320
|
-
onClick: (
|
|
321
|
-
class: normalizeClass(["_cppay-select-btn", { "_cppay-selected": C.value ===
|
|
322
|
-
}, [
|
|
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:
|
|
325
|
-
alt:
|
|
326
|
-
}, null, 8,
|
|
327
|
-
renderSlot(
|
|
328
|
-
createElementVNode("div",
|
|
329
|
-
createElementVNode("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:
|
|
333
|
-
onMouseleave:
|
|
334
|
-
}, [createElementVNode("div",
|
|
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(
|
|
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 ||
|
|
344
|
+
disabled: !S.value || !C.value || c.loading,
|
|
344
345
|
class: "_cppay-btn _cppay-btn-primary"
|
|
345
|
-
}, toDisplayString(
|
|
346
|
-
])) : (openBlock(), createElementBlock("div",
|
|
347
|
-
createElementVNode("div",
|
|
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,
|
|
353
|
-
createElementVNode("div",
|
|
354
|
-
z.value ? (openBlock(), createElementBlock("div",
|
|
355
|
-
createElementVNode("div",
|
|
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",
|
|
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,
|
|
367
|
-
|
|
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
|
-
|
|
370
|
+
c.error ? (openBlock(), createElementBlock("div", {
|
|
370
371
|
key: 0,
|
|
371
372
|
class: "_cppay-error-tooltip-wrapper",
|
|
372
|
-
onMouseenter:
|
|
373
|
-
onMouseleave:
|
|
374
|
-
}, [createElementVNode("div",
|
|
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(
|
|
382
|
-
|
|
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:
|
|
385
|
+
disabled: c.loading,
|
|
385
386
|
class: "_cppay-btn _cppay-btn-primary"
|
|
386
|
-
}, toDisplayString(
|
|
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:
|
|
389
|
+
disabled: c.loading,
|
|
389
390
|
class: "_cppay-btn _cppay-wallet-address-btn",
|
|
390
|
-
title:
|
|
391
|
-
}, [createElementVNode("span",
|
|
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,
|
|
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 ?
|
|
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(
|
|
423
|
-
let
|
|
424
|
-
watch(() => m.value, (
|
|
425
|
-
|
|
426
|
-
|
|
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(() =>
|
|
429
|
-
|
|
441
|
+
}), watch(() => l.modelValue, (r) => {
|
|
442
|
+
r || (m.value = "select", v.value = void 0, g.value = !1, _.value = !1);
|
|
430
443
|
}), onMounted(() => {
|
|
431
|
-
let
|
|
432
|
-
|
|
444
|
+
let r = (r) => {
|
|
445
|
+
r.key === "Escape" && l.modelValue && !g.value && !_.value && y();
|
|
433
446
|
};
|
|
434
|
-
return window.addEventListener("keydown",
|
|
435
|
-
window.removeEventListener("keydown",
|
|
447
|
+
return window.addEventListener("keydown", r), () => {
|
|
448
|
+
window.removeEventListener("keydown", r);
|
|
436
449
|
};
|
|
437
450
|
});
|
|
438
|
-
let
|
|
439
|
-
g.value ||
|
|
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 (
|
|
463
|
+
return (c, l) => r.modelValue ? (openBlock(), createElementBlock("div", {
|
|
451
464
|
key: 0,
|
|
452
465
|
class: "_cppay-overlay",
|
|
453
|
-
onClick:
|
|
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:
|
|
456
|
-
disabled: g.value ||
|
|
468
|
+
onClick: y,
|
|
469
|
+
disabled: g.value || _.value,
|
|
457
470
|
class: "_cppay-close-btn"
|
|
458
|
-
}, [...
|
|
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:
|
|
469
|
-
orderId:
|
|
470
|
-
amount:
|
|
471
|
-
plain:
|
|
472
|
-
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:
|
|
476
|
-
error:
|
|
477
|
-
"onUpdate:paymentStep":
|
|
478
|
-
"onUpdate:error":
|
|
479
|
-
onSuccess:
|
|
480
|
-
onExpired:
|
|
481
|
-
onFailed:
|
|
482
|
-
onError:
|
|
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(
|
|
485
|
-
"choose-bottom": withCtx(() => [renderSlot(
|
|
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 = (
|
|
505
|
-
cppayState.value.options =
|
|
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 = (
|
|
512
|
-
cppayState.value.options?.onSuccess?.(
|
|
526
|
+
}, handleSuccess = (r) => {
|
|
527
|
+
cppayState.value.options?.onSuccess?.(r), setTimeout(() => {
|
|
513
528
|
cppayState.value.open = !1;
|
|
514
529
|
}, 1e3);
|
|
515
|
-
}, handleExpired = (
|
|
516
|
-
cppayState.value.options?.onExpired?.(
|
|
517
|
-
}, handleFailed = (
|
|
518
|
-
cppayState.value.options?.onFailed?.(
|
|
519
|
-
}, handleError = (
|
|
520
|
-
cppayState.value.options?.onError?.(
|
|
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(
|
|
523
|
-
if (!
|
|
524
|
-
cppayState.value.apikey =
|
|
525
|
-
let
|
|
526
|
-
|
|
527
|
-
},
|
|
528
|
-
document.body.appendChild(
|
|
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": (
|
|
532
|
-
cppayState.value.open =
|
|
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(
|
|
545
|
-
cppayState.value.open ? document.addEventListener("keydown",
|
|
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");
|