cppay-sdk 0.0.2-beta.40 → 0.0.2-beta.42

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