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