cppay-sdk 0.0.2-beta.35 → 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/{locales-DGvDecya.js → locales-KW7cSv4d.js} +8 -8
- package/dist/locales-mdiXS8LU.cjs +1 -0
- package/dist/react.cjs +1 -1
- package/dist/react.d.ts +7 -11
- package/dist/react.js +205 -205
- package/dist/vue.cjs +1 -1
- package/dist/vue.d.ts +6 -12
- package/dist/vue.js +283 -277
- package/package.json +1 -1
- package/dist/locales-DAKREZkH.cjs +0 -1
package/dist/vue.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
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-
|
|
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(
|
|
83
|
-
let
|
|
84
|
-
typeof window < "u" && !
|
|
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
|
-
}),
|
|
106
|
-
|
|
107
|
-
}),
|
|
108
|
-
|
|
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
|
-
}
|
|
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
|
-
|
|
113
|
-
} catch (
|
|
114
|
-
|
|
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
|
-
|
|
118
|
+
D.value = !1;
|
|
117
119
|
}
|
|
118
|
-
},
|
|
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(
|
|
127
|
-
let
|
|
128
|
-
return isNaN(
|
|
129
|
-
},
|
|
130
|
-
if (
|
|
131
|
-
let
|
|
132
|
-
return
|
|
133
|
-
},
|
|
134
|
-
|
|
135
|
-
let
|
|
136
|
-
let
|
|
137
|
-
|
|
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
|
-
|
|
140
|
-
},
|
|
141
|
-
|
|
142
|
-
},
|
|
143
|
-
if (!
|
|
144
|
-
let
|
|
145
|
-
if (isNaN(
|
|
146
|
-
let
|
|
147
|
-
return
|
|
148
|
-
}),
|
|
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
|
-
|
|
151
|
-
let
|
|
152
|
-
|
|
153
|
-
} catch (
|
|
154
|
-
|
|
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
|
-
},
|
|
157
|
-
if (
|
|
158
|
-
await
|
|
158
|
+
}, J = async (e) => {
|
|
159
|
+
if (O.value) try {
|
|
160
|
+
await O.value.request({
|
|
159
161
|
method: "wallet_switchEthereumChain",
|
|
160
|
-
params: [{ chainId: `0x${
|
|
162
|
+
params: [{ chainId: `0x${e.toString(16)}` }]
|
|
161
163
|
});
|
|
162
|
-
} catch (
|
|
163
|
-
throw
|
|
164
|
+
} catch (e) {
|
|
165
|
+
throw e.code === 4902 ? Error(s.value.pleaseAddNetwork) : e;
|
|
164
166
|
}
|
|
165
|
-
},
|
|
166
|
-
if (!(!
|
|
167
|
-
let
|
|
168
|
-
await
|
|
169
|
-
let
|
|
170
|
-
account:
|
|
171
|
-
transport: custom(
|
|
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
|
-
|
|
174
|
-
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: [
|
|
191
|
+
args: [e.receiveAddress, parseUnits(e.paymentAmount, B.value.decimals)],
|
|
190
192
|
chain: null
|
|
191
|
-
}) : await
|
|
192
|
-
to:
|
|
193
|
-
value: parseUnits(
|
|
193
|
+
}) : await t.sendTransaction({
|
|
194
|
+
to: e.receiveAddress,
|
|
195
|
+
value: parseUnits(e.paymentAmount, B.value.decimals),
|
|
194
196
|
chain: null
|
|
195
|
-
}),
|
|
196
|
-
} catch (
|
|
197
|
-
|
|
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
|
-
},
|
|
200
|
-
if (!(!
|
|
201
|
-
let
|
|
202
|
-
await
|
|
203
|
-
let
|
|
204
|
-
account:
|
|
205
|
-
transport: custom(
|
|
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 (!
|
|
208
|
-
await
|
|
209
|
-
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: [
|
|
226
|
+
args: [e.spenderAddress, parseUnits(e.approveAmount, B.value.decimals)],
|
|
225
227
|
chain: null
|
|
226
|
-
}),
|
|
227
|
-
} catch (
|
|
228
|
-
|
|
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
|
-
},
|
|
231
|
-
if (!
|
|
232
|
-
|
|
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
|
-
|
|
236
|
-
},
|
|
237
|
-
if (!(!
|
|
238
|
-
|
|
239
|
-
let
|
|
240
|
-
|
|
241
|
-
paymentChain:
|
|
242
|
-
paymentToken:
|
|
243
|
-
orderId:
|
|
244
|
-
amount:
|
|
245
|
-
}),
|
|
246
|
-
paymentChain:
|
|
247
|
-
paymentToken:
|
|
248
|
-
orderId:
|
|
249
|
-
amountOfUsd:
|
|
250
|
-
intervalDays:
|
|
251
|
-
}),
|
|
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 (
|
|
257
|
-
|
|
258
|
+
} catch (e) {
|
|
259
|
+
x.value = e instanceof Error ? e.message : s.value.createPaymentFailed, o("error", e);
|
|
258
260
|
}
|
|
259
|
-
},
|
|
260
|
-
|
|
261
|
-
let
|
|
262
|
-
|
|
263
|
-
(
|
|
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: (
|
|
266
|
-
if (
|
|
267
|
-
let
|
|
268
|
-
|
|
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
|
-
|
|
274
|
+
N.value?.unsubscribe();
|
|
273
275
|
}
|
|
274
276
|
});
|
|
275
|
-
},
|
|
276
|
-
if (!
|
|
277
|
-
let
|
|
278
|
-
if (
|
|
279
|
-
await navigator.clipboard.writeText(
|
|
280
|
-
|
|
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 (
|
|
283
|
-
console.error("复制失败:",
|
|
284
|
+
} catch (e) {
|
|
285
|
+
console.error("复制失败:", e);
|
|
284
286
|
}
|
|
285
287
|
};
|
|
286
|
-
return watch(() => f.
|
|
287
|
-
|
|
288
|
-
}, { immediate: !0 }), watch(
|
|
289
|
-
|
|
290
|
-
}), watch(() =>
|
|
291
|
-
|
|
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
|
-
|
|
295
|
+
I();
|
|
294
296
|
}), onUnmounted(() => {
|
|
295
|
-
|
|
296
|
-
}), (
|
|
297
|
-
|
|
298
|
-
createElementVNode("h3", _hoisted_3$1, toDisplayString(
|
|
299
|
-
createElementVNode("p", _hoisted_4$1, toDisplayString(
|
|
300
|
-
])) :
|
|
301
|
-
|
|
302
|
-
createElementVNode("h3", _hoisted_6, toDisplayString(
|
|
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:
|
|
305
|
-
disabled:
|
|
306
|
+
onClick: n[0] ||= (e) => f.value = "select",
|
|
307
|
+
disabled: y.value || b.value,
|
|
306
308
|
class: "_cppay-btn _cppay-btn-text"
|
|
307
|
-
}, toDisplayString(
|
|
308
|
-
])) :
|
|
309
|
-
renderSlot(
|
|
310
|
-
createElementVNode("div", _hoisted_13, [createElementVNode("label", _hoisted_14, toDisplayString(
|
|
311
|
-
key:
|
|
312
|
-
onClick: (
|
|
313
|
-
class: normalizeClass(["_cppay-select-btn", { "_cppay-selected":
|
|
314
|
-
}, [
|
|
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:
|
|
317
|
-
alt:
|
|
318
|
-
}, null, 8, _hoisted_17)) : createCommentVNode("", !0), createElementVNode("span", null, toDisplayString(
|
|
319
|
-
createElementVNode("div", _hoisted_18, [createElementVNode("label", _hoisted_19, toDisplayString(
|
|
320
|
-
key:
|
|
321
|
-
onClick: (
|
|
322
|
-
class: normalizeClass(["_cppay-select-btn", { "_cppay-selected":
|
|
323
|
-
}, [
|
|
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:
|
|
326
|
-
alt:
|
|
327
|
-
}, null, 8, _hoisted_22)) : createCommentVNode("", !0), createElementVNode("span", null, toDisplayString(
|
|
328
|
-
renderSlot(
|
|
329
|
-
createElementVNode("div", _hoisted_23, [createElementVNode("div", _hoisted_24, [createElementVNode("div", _hoisted_25, [createElementVNode("span", _hoisted_26, toDisplayString(
|
|
330
|
-
createElementVNode("div", _hoisted_30, [
|
|
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:
|
|
334
|
-
onMouseleave:
|
|
335
|
-
}, [createElementVNode("div", _hoisted_31, [
|
|
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(
|
|
343
|
-
onClick:
|
|
344
|
-
disabled: !
|
|
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(
|
|
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, [
|
|
350
|
+
createElementVNode("div", _hoisted_35, [createElementVNode("div", _hoisted_36, [T.value ? (openBlock(), createElementBlock("img", {
|
|
349
351
|
key: 0,
|
|
350
|
-
src:
|
|
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
|
-
|
|
356
|
-
createElementVNode("div", _hoisted_45, [createElementVNode("div", _hoisted_46, [createElementVNode("div", _hoisted_47, [createElementVNode("span", null, toDisplayString(
|
|
357
|
-
onClick:
|
|
358
|
-
class: normalizeClass(["_cppay-copy-btn", { "_cppay-copy-success":
|
|
359
|
-
title:
|
|
360
|
-
}, [
|
|
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
|
-
|
|
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
|
-
|
|
372
|
+
x.value ? (openBlock(), createElementBlock("div", {
|
|
371
373
|
key: 0,
|
|
372
374
|
class: "_cppay-error-tooltip-wrapper",
|
|
373
|
-
onMouseenter:
|
|
374
|
-
onMouseleave:
|
|
375
|
-
}, [createElementVNode("div", _hoisted_57, [
|
|
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(
|
|
383
|
-
|
|
384
|
-
onClick:
|
|
385
|
-
disabled:
|
|
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(
|
|
388
|
-
onClick:
|
|
389
|
-
disabled:
|
|
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:
|
|
392
|
-
}, [createElementVNode("span", _hoisted_63, toDisplayString(
|
|
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:
|
|
401
|
-
disabled:
|
|
402
|
+
onClick: L,
|
|
403
|
+
disabled: D.value,
|
|
402
404
|
class: "_cppay-btn _cppay-btn-secondary _cppay-connect-wallet-btn"
|
|
403
|
-
}, [createElementVNode("span", null, toDisplayString(
|
|
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:
|
|
406
|
-
disabled:
|
|
407
|
+
onClick: n[5] ||= (e) => f.value = "payment",
|
|
408
|
+
disabled: b.value,
|
|
407
409
|
class: "_cppay-btn _cppay-btn-primary"
|
|
408
|
-
}, toDisplayString(
|
|
409
|
-
|
|
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:
|
|
412
|
-
disabled:
|
|
413
|
+
onClick: n[6] ||= (e) => f.value = "select",
|
|
414
|
+
disabled: y.value || b.value,
|
|
413
415
|
class: "_cppay-btn _cppay-btn-text"
|
|
414
|
-
}, toDisplayString(
|
|
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(
|
|
436
|
-
let
|
|
437
|
-
watch(() =>
|
|
438
|
-
|
|
439
|
-
|
|
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(() =>
|
|
442
|
-
|
|
443
|
-
})
|
|
444
|
-
|
|
445
|
-
|
|
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",
|
|
448
|
-
window.removeEventListener("keydown",
|
|
459
|
+
return window.addEventListener("keydown", e), () => {
|
|
460
|
+
window.removeEventListener("keydown", e);
|
|
449
461
|
};
|
|
450
462
|
});
|
|
451
|
-
let
|
|
452
|
-
|
|
453
|
-
},
|
|
454
|
-
switch (
|
|
455
|
-
case "success": return
|
|
456
|
-
case "expired": return
|
|
457
|
-
case "failed": return
|
|
458
|
-
case "error": return
|
|
459
|
-
case "payment": return
|
|
460
|
-
default: return
|
|
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 (
|
|
475
|
+
return (t, n) => e.modelValue ? (openBlock(), createElementBlock("div", {
|
|
464
476
|
key: 0,
|
|
465
477
|
class: "_cppay-overlay",
|
|
466
|
-
onClick:
|
|
467
|
-
}, [createElementVNode("div", _hoisted_1, [createElementVNode("div", _hoisted_2, [createElementVNode("h2", _hoisted_3, toDisplayString(
|
|
468
|
-
onClick:
|
|
469
|
-
disabled:
|
|
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
|
-
}, [...
|
|
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:
|
|
482
|
-
orderId:
|
|
483
|
-
amount:
|
|
484
|
-
plain:
|
|
485
|
-
intervalDays:
|
|
486
|
-
locale:
|
|
487
|
-
paymentStep:
|
|
488
|
-
loading:
|
|
489
|
-
isCheckingPayment:
|
|
490
|
-
error:
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
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(
|
|
499
|
-
"choose-bottom": withCtx(() => [renderSlot(
|
|
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 = (
|
|
520
|
-
cppayState.value.options =
|
|
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 = (
|
|
527
|
-
cppayState.value.options?.onSuccess?.(
|
|
532
|
+
}, handleSuccess = (e) => {
|
|
533
|
+
cppayState.value.options?.onSuccess?.(e), setTimeout(() => {
|
|
528
534
|
cppayState.value.open = !1;
|
|
529
535
|
}, 1e3);
|
|
530
|
-
}, handleExpired = (
|
|
531
|
-
cppayState.value.options?.onExpired?.(
|
|
532
|
-
}, handleFailed = (
|
|
533
|
-
cppayState.value.options?.onFailed?.(
|
|
534
|
-
}, handleError = (
|
|
535
|
-
cppayState.value.options?.onError?.(
|
|
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(
|
|
538
|
-
if (!
|
|
539
|
-
cppayState.value.apikey =
|
|
540
|
-
let
|
|
541
|
-
|
|
542
|
-
},
|
|
543
|
-
document.body.appendChild(
|
|
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": (
|
|
547
|
-
cppayState.value.open =
|
|
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(
|
|
560
|
-
cppayState.value.open ? document.addEventListener("keydown",
|
|
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");
|