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