cppay-sdk 0.0.2-beta.23 → 0.0.2-beta.25

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.
Files changed (140) hide show
  1. package/dist/AlertController-BPGQ5PgH.js +12787 -0
  2. package/dist/AlertController-CjTbf-Vd.cjs +10 -0
  3. package/dist/ApiController-Crww70p3.js +5652 -0
  4. package/dist/ApiController-DB43iwF1.cjs +4 -0
  5. package/dist/CaipNetworkUtil-Bd4HeTLY.js +204 -0
  6. package/dist/CaipNetworkUtil-Bg22uavB.cjs +1 -0
  7. package/dist/HelpersUtil-CeTmhhZv.js +1415 -0
  8. package/dist/HelpersUtil-L0eeYoE2.cjs +225 -0
  9. package/dist/PhArrowCircleDown-BBy_VuPx.js +46 -0
  10. package/dist/PhArrowCircleDown-BU4QSsA3.cjs +14 -0
  11. package/dist/PhArrowClockwise-D8C24T6J.js +46 -0
  12. package/dist/PhArrowClockwise-DWqhijc2.cjs +14 -0
  13. package/dist/PhArrowDown-Qm1T2ueY.cjs +14 -0
  14. package/dist/PhArrowDown-p9Tekztm.js +46 -0
  15. package/dist/PhArrowLeft-CEtyMFdq.cjs +14 -0
  16. package/dist/PhArrowLeft-CgSKs9Xe.js +46 -0
  17. package/dist/PhArrowRight-ZatyoD6R.cjs +14 -0
  18. package/dist/PhArrowRight-dMdzUgrx.js +46 -0
  19. package/dist/PhArrowSquareOut-CbP71Gny.js +46 -0
  20. package/dist/PhArrowSquareOut-HyssV9za.cjs +14 -0
  21. package/dist/PhArrowUp-Cz127u8b.cjs +14 -0
  22. package/dist/PhArrowUp-DNn-RQ7v.js +46 -0
  23. package/dist/PhArrowUpRight-BX6LlOL0.cjs +14 -0
  24. package/dist/PhArrowUpRight-OyGUhoGi.js +46 -0
  25. package/dist/PhArrowsClockwise-B6w_d2Gy.cjs +14 -0
  26. package/dist/PhArrowsClockwise-BWITTwAP.js +46 -0
  27. package/dist/PhArrowsDownUp-CHHtczH8.js +46 -0
  28. package/dist/PhArrowsDownUp-WYzjhvmQ.cjs +14 -0
  29. package/dist/PhArrowsLeftRight-BA0fjcLn.js +46 -0
  30. package/dist/PhArrowsLeftRight-bgyrYWLt.cjs +14 -0
  31. package/dist/PhBank-BInxTxLw.js +46 -0
  32. package/dist/PhBank-CZ_uTsAN.cjs +14 -0
  33. package/dist/PhBrowser--6CxS13p.js +46 -0
  34. package/dist/PhBrowser-BzOw0W8k.cjs +14 -0
  35. package/dist/PhCaretDown-D-zrPZN9.js +46 -0
  36. package/dist/PhCaretDown-DvF3M2iu.cjs +14 -0
  37. package/dist/PhCaretLeft-DND0SNkF.cjs +14 -0
  38. package/dist/PhCaretLeft-Dm6NsnIS.js +46 -0
  39. package/dist/PhCaretRight-BkRzbZ5m.js +46 -0
  40. package/dist/PhCaretRight-xQkT3bmO.cjs +14 -0
  41. package/dist/PhCaretUp-BEk_5jnn.cjs +14 -0
  42. package/dist/PhCaretUp-DZRZQ-T1.js +46 -0
  43. package/dist/PhCheck-BmwCUZuW.js +46 -0
  44. package/dist/PhCheck-C-u2QP3y.cjs +14 -0
  45. package/dist/PhCircleHalf--TfGDEAT.js +46 -0
  46. package/dist/PhCircleHalf-keQfI7pU.cjs +14 -0
  47. package/dist/PhClock-BvmbjmRx.cjs +14 -0
  48. package/dist/PhClock-DNCf5CVD.js +46 -0
  49. package/dist/PhCompass-B6tcbOFZ.js +46 -0
  50. package/dist/PhCompass-rWCQ_cR8.cjs +14 -0
  51. package/dist/PhCopy-CzC1olDO.cjs +14 -0
  52. package/dist/PhCopy-rbBTM6ME.js +46 -0
  53. package/dist/PhCreditCard-DOpOB0Pl.js +46 -0
  54. package/dist/PhCreditCard-D_qRVKuY.cjs +14 -0
  55. package/dist/PhCurrencyDollar-4EASQkjs.js +46 -0
  56. package/dist/PhCurrencyDollar-RVJJ6bQ3.cjs +14 -0
  57. package/dist/PhDesktop-CPaC-lRj.cjs +14 -0
  58. package/dist/PhDesktop-DZPux6RD.js +46 -0
  59. package/dist/PhDeviceMobile-BnXs4f3Q.cjs +14 -0
  60. package/dist/PhDeviceMobile-CcdKzyah.js +46 -0
  61. package/dist/PhDotsThree-19bbXQaM.js +46 -0
  62. package/dist/PhDotsThree-DSmFeW6i.cjs +14 -0
  63. package/dist/PhEnvelope-F7RF6h58.js +46 -0
  64. package/dist/PhEnvelope-QuTMQbE9.cjs +14 -0
  65. package/dist/PhFunnelSimple-B_FRP21W.js +46 -0
  66. package/dist/PhFunnelSimple-D4Ztu4ri.cjs +14 -0
  67. package/dist/PhGlobe-B8GrTk4S.cjs +14 -0
  68. package/dist/PhGlobe-BSPoRqTV.js +46 -0
  69. package/dist/PhIdentificationCard-fGDBGII0.cjs +14 -0
  70. package/dist/PhIdentificationCard-giQnti3K.js +46 -0
  71. package/dist/PhImage-BpUk8j27.cjs +14 -0
  72. package/dist/PhImage-PtBaftbW.js +46 -0
  73. package/dist/PhInfo-DQEDS02h.js +46 -0
  74. package/dist/PhInfo-V5wKJJoK.cjs +14 -0
  75. package/dist/PhLightbulb-Cisg0Myw.js +46 -0
  76. package/dist/PhLightbulb-xP9kaUlD.cjs +14 -0
  77. package/dist/PhMagnifyingGlass-C1cVSYf2.cjs +14 -0
  78. package/dist/PhMagnifyingGlass-DlkOfQXn.js +46 -0
  79. package/dist/PhPaperPlaneRight-C7Jp2jl_.js +46 -0
  80. package/dist/PhPaperPlaneRight-Kh3uxxIy.cjs +14 -0
  81. package/dist/PhPlus-BgHn57eW.js +46 -0
  82. package/dist/PhPlus-hJ6DZNjc.cjs +14 -0
  83. package/dist/PhPower-C369g1jk.js +46 -0
  84. package/dist/PhPower-DZ-SpUrD.cjs +14 -0
  85. package/dist/PhPuzzlePiece-B0oABcWl.js +46 -0
  86. package/dist/PhPuzzlePiece-DLtOLrcw.cjs +14 -0
  87. package/dist/PhQrCode-BT_hyeEa.js +46 -0
  88. package/dist/PhQrCode-yI6bLoYY.cjs +14 -0
  89. package/dist/PhQuestion-B1UeE96D.js +46 -0
  90. package/dist/PhQuestion-icSeWABx.cjs +14 -0
  91. package/dist/PhQuestionMark-CBVW9Awo.js +46 -0
  92. package/dist/PhQuestionMark-Cmhqu81E.cjs +14 -0
  93. package/dist/PhSealCheck-DTKS5QAx.cjs +14 -0
  94. package/dist/PhSealCheck-Dm2I2X7k.js +46 -0
  95. package/dist/PhSignOut-25xp33w2.cjs +14 -0
  96. package/dist/PhSignOut-BTTDADPY.js +46 -0
  97. package/dist/PhSpinner-Dbua7p0Y.js +46 -0
  98. package/dist/PhSpinner-DtpwblyA.cjs +14 -0
  99. package/dist/PhTrash-B3wUg10m.cjs +14 -0
  100. package/dist/PhTrash-gZghJkGX.js +46 -0
  101. package/dist/PhUser-Bvcv05IM.js +46 -0
  102. package/dist/PhUser-COPP3N-M.cjs +14 -0
  103. package/dist/PhVault-CFa5lrPU.cjs +14 -0
  104. package/dist/PhVault-DvlBF0VI.js +46 -0
  105. package/dist/PhWallet-CzJcybaO.cjs +14 -0
  106. package/dist/PhWallet-Do_lf9BX.js +46 -0
  107. package/dist/PhWarning-BrbSc7gQ.cjs +14 -0
  108. package/dist/PhWarning-DiIpJVsx.js +46 -0
  109. package/dist/PhWarningCircle-DE9BlEIc.js +46 -0
  110. package/dist/PhWarningCircle-F5Piypme.cjs +14 -0
  111. package/dist/PhX-BK3VZT8X.cjs +14 -0
  112. package/dist/PhX-CNlXuiat.js +46 -0
  113. package/dist/basic-C16-Uba1.js +3796 -0
  114. package/dist/basic-ChiCOE6E.cjs +1329 -0
  115. package/dist/chunk-2qRSBEuq.js +18 -0
  116. package/dist/chunk-DT80SxnK.cjs +1 -0
  117. package/dist/core-DKXmyfMB.js +2337 -0
  118. package/dist/core-PuDBroil.cjs +1 -0
  119. package/dist/dijkstra-CNhLvnjU.cjs +1 -0
  120. package/dist/dijkstra-kFl0HtsI.js +56 -0
  121. package/dist/features-BYfQH2hG.cjs +2 -0
  122. package/dist/features-_5Pi-gXV.js +245 -0
  123. package/dist/index.cjs +1 -1
  124. package/dist/index.es-DDV8bPq_.js +8311 -0
  125. package/dist/index.es-fgFnvPDP.cjs +19 -0
  126. package/dist/property-Dil4gG0H.cjs +3 -0
  127. package/dist/property-JsW5AM1M.js +578 -0
  128. package/dist/react.cjs +1 -1
  129. package/dist/react.js +133 -131
  130. package/dist/vue.cjs +1 -1
  131. package/dist/vue.js +107 -105
  132. package/dist/w3m-modal-BBvmkTyb.cjs +2416 -0
  133. package/dist/w3m-modal-CFhImDZN.js +5286 -0
  134. package/dist/walletconnect-B0zXLUON.cjs +17 -0
  135. package/dist/walletconnect-Bb4rv9-G.js +11314 -0
  136. package/dist/wui-list-item-BGvfYb1W.cjs +1452 -0
  137. package/dist/wui-list-item-C4wJpGBn.js +2123 -0
  138. package/package.json +2 -3
  139. package/dist/walletconnect-B0L70Mgc.js +0 -1239
  140. package/dist/walletconnect-B_n5YF-h.cjs +0 -8
package/dist/vue.js CHANGED
@@ -1,11 +1,13 @@
1
- import { a as payment_dialog_default, i as injectStyle, n as metamask_default, o as __toESM, r as require_browser, t as walletconnect_default } from "./walletconnect-B0L70Mgc.js";
1
+ import { o as __toESM } from "./chunk-2qRSBEuq.js";
2
2
  import { t as cppay_default } from "./cppay-BcCDwXlg.js";
3
+ import { a as injectStyle, i as require_browser, n as metamask_default, o as payment_dialog_default, r as E, t as walletconnect_default } from "./walletconnect-Bb4rv9-G.js";
4
+ import "./dijkstra-kFl0HtsI.js";
5
+ import "./index.es-DDV8bPq_.js";
3
6
  import { Fragment, Teleport, Transition, computed, createApp, createBlock, createCommentVNode, createElementBlock, createElementVNode, createVNode, defineComponent, h, normalizeClass, onUnmounted, openBlock, ref, renderList, toDisplayString, unref, watch, withCtx, withModifiers } from "vue";
4
7
  import { EMPTY, defer, timer } from "rxjs";
5
8
  import { expand, retry, switchMap, tap, timeout } from "rxjs/operators";
6
9
  import { createWalletClient, custom, parseUnits } from "viem";
7
10
  import { arbitrum, base, bsc, mainnet, optimism, polygon } from "viem/chains";
8
- import EthereumProvider from "@walletconnect/ethereum-provider";
9
11
  var import_browser = /* @__PURE__ */ __toESM(require_browser(), 1), _hoisted_1 = { class: "_cppay-dialog" }, _hoisted_2 = { class: "_cppay-header" }, _hoisted_3 = { class: "_cppay-title" }, _hoisted_4 = ["disabled"], _hoisted_5 = { class: "_cppay-content" }, _hoisted_6 = {
10
12
  key: 0,
11
13
  style: {
@@ -40,10 +42,10 @@ var import_browser = /* @__PURE__ */ __toESM(require_browser(), 1), _hoisted_1 =
40
42
  "margin-top": "8px",
41
43
  "font-size": "12px",
42
44
  color: "#666"
43
- } }, _hoisted_47 = { class: "_cppay-section" }, _hoisted_48 = ["disabled"], _hoisted_49 = { class: "_cppay-section" }, _hoisted_50 = ["disabled"], PaymentDialog_default = /* @__PURE__ */ ((e, v) => {
44
- let y = e.__vccOpts || e;
45
- for (let [e, b] of v) y[e] = b;
46
- return y;
45
+ } }, _hoisted_47 = { class: "_cppay-section" }, _hoisted_48 = ["disabled"], _hoisted_49 = { class: "_cppay-section" }, _hoisted_50 = ["disabled"], PaymentDialog_default = /* @__PURE__ */ ((e, _) => {
46
+ let v = e.__vccOpts || e;
47
+ for (let [e, y] of _) v[e] = y;
48
+ return v;
47
49
  })(/* @__PURE__ */ defineComponent({
48
50
  __name: "PaymentDialog",
49
51
  props: {
@@ -60,7 +62,7 @@ var import_browser = /* @__PURE__ */ __toESM(require_browser(), 1), _hoisted_1 =
60
62
  "error"
61
63
  ],
62
64
  setup(e, { emit: v }) {
63
- let b = e, x = v, S = new cppay_default(b.apikey), C = ref("select"), w = ref(!1), T = ref([]), E = ref(""), D = ref(""), O = ref(null), k = ref(""), A = ref(""), j = ref(!1), M = ref(!0), N = ref(null), P = ref(null), F = ref(null), I = computed(() => T.value.find((e) => e.chain === E.value)), L = computed(() => I.value?.tokens || []), R = computed(() => L.value.find((e) => e.symbol === D.value)), z = (e) => [
65
+ let y = e, b = v, x = new cppay_default(y.apikey), S = ref("select"), C = ref(!1), w = ref([]), T = ref(""), D = ref(""), O = ref(null), k = ref(""), A = ref(""), j = ref(!1), M = ref(!0), N = ref(null), P = ref(null), F = ref(null), I = computed(() => w.value.find((e) => e.chain === T.value)), L = computed(() => I.value?.tokens || []), R = computed(() => L.value.find((e) => e.symbol === D.value)), z = (e) => [
64
66
  "USDT",
65
67
  "USDC",
66
68
  "BUSD",
@@ -68,28 +70,28 @@ var import_browser = /* @__PURE__ */ __toESM(require_browser(), 1), _hoisted_1 =
68
70
  "TUSD",
69
71
  "USDD",
70
72
  "FDUSD"
71
- ].includes(e.toUpperCase()) ? 2 : 6, B = (e, v) => {
72
- let y = parseFloat(e);
73
- return isNaN(y) ? "0" : y.toFixed(v).replace(/\.?0+$/, "");
73
+ ].includes(e.toUpperCase()) ? 2 : 6, B = (e, _) => {
74
+ let v = parseFloat(e);
75
+ return isNaN(v) ? "0" : v.toFixed(_).replace(/\.?0+$/, "");
74
76
  }, V = computed(() => {
75
77
  if (!D.value || !R.value) return "0";
76
78
  let e = parseFloat(R.value.price);
77
79
  if (isNaN(e) || e === 0) return "0";
78
- let v = z(D.value);
79
- return B((parseFloat(b.amount) / e).toFixed(v), v);
80
+ let _ = z(D.value);
81
+ return B((parseFloat(y.amount) / e).toFixed(_), _);
80
82
  }), H = () => {
81
- O.value && (w.value = !0, b.plain === "one-time" ? Q(O.value.paymentId) : b.plain === "subscription" && Q(O.value.subscriptionId));
83
+ O.value && (C.value = !0, y.plain === "one-time" ? Q(O.value.paymentId) : y.plain === "subscription" && Q(O.value.subscriptionId));
82
84
  }, U = () => {
83
- w.value || (x("update:modelValue", !1), setTimeout(() => {
84
- C.value = "select", O.value = null;
85
+ C.value || (b("update:modelValue", !1), setTimeout(() => {
86
+ S.value = "select", O.value = null;
85
87
  }, 300));
86
88
  }, W = async () => {
87
89
  try {
88
- w.value = !0, T.value = await S.getSupportedChains(), T.value.length > 0 && (E.value = T.value[0].chain);
90
+ C.value = !0, w.value = await x.getSupportedChains(), w.value.length > 0 && (T.value = w.value[0].chain);
89
91
  } catch (e) {
90
- x("error", e);
92
+ b("error", e);
91
93
  } finally {
92
- w.value = !1;
94
+ C.value = !1;
93
95
  }
94
96
  }, G = (e) => ({
95
97
  ETH: mainnet,
@@ -111,7 +113,7 @@ var import_browser = /* @__PURE__ */ __toESM(require_browser(), 1), _hoisted_1 =
111
113
  throw Error("请安装 MetaMask 扩展");
112
114
  }
113
115
  if (e === "walletconnect") {
114
- let e = await EthereumProvider.init({
116
+ let e = await E.init({
115
117
  projectId: "8d2e1854d3f1782e45aa15fbd8938894",
116
118
  chains: [1],
117
119
  showQrModal: !0,
@@ -146,18 +148,18 @@ var import_browser = /* @__PURE__ */ __toESM(require_browser(), 1), _hoisted_1 =
146
148
  }
147
149
  });
148
150
  await e.enable();
149
- let v = await e.request({ method: "eth_accounts" });
150
- v && v.length > 0 && (A.value = v[0], N.value = "walletconnect", P.value = e, M.value = !1);
151
+ let _ = await e.request({ method: "eth_accounts" });
152
+ _ && _.length > 0 && (A.value = _[0], N.value = "walletconnect", P.value = e, M.value = !1);
151
153
  }
152
154
  } catch (e) {
153
- console.error("钱包连接失败:", e), x("error", e);
155
+ console.error("钱包连接失败:", e), b("error", e);
154
156
  } finally {
155
157
  j.value = !1;
156
158
  }
157
159
  }, q = async (e) => {
158
- let v;
159
- if (v = N.value === "walletconnect" ? P.value : window.ethereum, v) try {
160
- await v.request({
160
+ let _;
161
+ if (_ = N.value === "walletconnect" ? P.value : window.ethereum, _) try {
162
+ await _.request({
161
163
  method: "wallet_switchEthereumChain",
162
164
  params: [{ chainId: `0x${e.toString(16)}` }]
163
165
  });
@@ -166,16 +168,16 @@ var import_browser = /* @__PURE__ */ __toESM(require_browser(), 1), _hoisted_1 =
166
168
  }
167
169
  }, J = async () => {
168
170
  if (!(!A.value || !O.value || !R.value)) try {
169
- w.value = !0;
170
- let e = O.value, v = G(E.value);
171
+ C.value = !0;
172
+ let e = O.value, _ = G(T.value);
171
173
  await q(I.value.chainId);
172
- let y = createWalletClient({
174
+ let v = createWalletClient({
173
175
  account: A.value,
174
- chain: v,
176
+ chain: _,
175
177
  transport: custom(N.value === "walletconnect" ? P.value : window.ethereum)
176
178
  });
177
179
  if (R.value.address) {
178
- let v = await y.writeContract({
180
+ let _ = await v.writeContract({
179
181
  address: R.value.address,
180
182
  abi: [{
181
183
  name: "transfer",
@@ -194,33 +196,33 @@ var import_browser = /* @__PURE__ */ __toESM(require_browser(), 1), _hoisted_1 =
194
196
  args: [e.receiveAddress, parseUnits(e.paymentAmount, R.value.decimals)],
195
197
  chain: null
196
198
  });
197
- console.log("转账交易哈希:", v);
199
+ console.log("转账交易哈希:", _);
198
200
  } else {
199
- let v = await y.sendTransaction({
201
+ let _ = await v.sendTransaction({
200
202
  to: e.receiveAddress,
201
203
  value: parseUnits(e.paymentAmount, R.value.decimals),
202
204
  chain: null
203
205
  });
204
- console.log("转账交易哈希:", v);
206
+ console.log("转账交易哈希:", _);
205
207
  }
206
208
  Q(e.paymentId);
207
209
  } catch (e) {
208
- console.error("钱包支付失败:", e), x("error", e);
210
+ console.error("钱包支付失败:", e), b("error", e);
209
211
  } finally {
210
- w.value = !1;
212
+ C.value = !1;
211
213
  }
212
214
  }, Y = async () => {
213
215
  if (!(!A.value || !O.value || !R.value)) try {
214
- w.value = !0;
215
- let e = O.value, v = G(E.value);
216
+ C.value = !0;
217
+ let e = O.value, _ = G(T.value);
216
218
  await q(I.value.chainId);
217
- let y = createWalletClient({
219
+ let v = createWalletClient({
218
220
  account: A.value,
219
- chain: v,
221
+ chain: _,
220
222
  transport: custom(N.value === "walletconnect" ? P.value : window.ethereum)
221
223
  });
222
224
  if (!R.value.address) throw Error("订阅支付不支持原生代币");
223
- let b = await y.writeContract({
225
+ let y = await v.writeContract({
224
226
  address: R.value.address,
225
227
  abi: [{
226
228
  name: "approve",
@@ -239,80 +241,80 @@ var import_browser = /* @__PURE__ */ __toESM(require_browser(), 1), _hoisted_1 =
239
241
  args: [e.receiveAddress, parseUnits(e.paymentAmount, R.value.decimals)],
240
242
  chain: null
241
243
  });
242
- console.log("授权交易哈希:", b), Q(e.paymentId);
244
+ console.log("授权交易哈希:", y), Q(e.paymentId);
243
245
  } catch (e) {
244
- console.error("钱包授权失败:", e), x("error", e);
246
+ console.error("钱包授权失败:", e), b("error", e);
245
247
  } finally {
246
- w.value = !1;
248
+ C.value = !1;
247
249
  }
248
250
  }, X = async () => {
249
251
  if (!A.value) {
250
252
  M.value = !0;
251
253
  return;
252
254
  }
253
- b.plain === "one-time" ? await J() : b.plain === "subscription" && await Y();
255
+ y.plain === "one-time" ? await J() : y.plain === "subscription" && await Y();
254
256
  }, Z = async () => {
255
- if (!(!E.value || !D.value)) try {
256
- w.value = !0;
257
+ if (!(!T.value || !D.value)) try {
258
+ C.value = !0;
257
259
  let e;
258
- b.plain === "one-time" ? e = await S.createPayment("one-time", {
259
- paymentChain: E.value,
260
+ y.plain === "one-time" ? e = await x.createPayment("one-time", {
261
+ paymentChain: T.value,
260
262
  paymentToken: D.value,
261
- orderId: b.orderId,
263
+ orderId: y.orderId,
262
264
  amount: V.value
263
- }) : b.plain === "subscription" && (e = await S.createPayment("subscription", {
264
- paymentChain: E.value,
265
+ }) : y.plain === "subscription" && (e = await x.createPayment("subscription", {
266
+ paymentChain: T.value,
265
267
  paymentToken: D.value,
266
- orderId: b.orderId,
268
+ orderId: y.orderId,
267
269
  amountOfUsd: V.value,
268
- intervalDays: b.intervalDays || 30
270
+ intervalDays: y.intervalDays || 30
269
271
  })), O.value = {
270
272
  paymentId: e.paymentId || e.subscriptionId,
271
273
  paymentAmount: e.paymentAmount || e.approveAmount,
272
274
  receiveAddress: e.receiveAddress || e.spenderAddress || ""
273
275
  };
274
- let v = `${E.value.toLowerCase()}:${O.value.receiveAddress}?amount=${O.value.paymentAmount}`;
275
- k.value = await import_browser.toDataURL(v, {
276
+ let _ = `${T.value.toLowerCase()}:${O.value.receiveAddress}?amount=${O.value.paymentAmount}`;
277
+ k.value = await import_browser.toDataURL(_, {
276
278
  width: 200,
277
279
  margin: 2,
278
280
  errorCorrectionLevel: "H"
279
- }), C.value = "payment";
281
+ }), S.value = "payment";
280
282
  } catch (e) {
281
- x("error", e);
283
+ b("error", e);
282
284
  } finally {
283
- w.value = !1;
285
+ C.value = !1;
284
286
  }
285
287
  }, Q = (e) => {
286
- let v = () => defer(() => b.plain === "subscription" ? S.checkSubscriptionPaymentStatus({ subscriptionId: e }) : S.checkOnetimePaymentStatus({ paymentId: e })).pipe(timeout(15e3), retry({
288
+ let _ = () => defer(() => y.plain === "subscription" ? x.checkSubscriptionPaymentStatus({ subscriptionId: e }) : x.checkOnetimePaymentStatus({ paymentId: e })).pipe(timeout(15e3), retry({
287
289
  count: 3,
288
290
  delay: 2e3
289
291
  }));
290
- F.value?.unsubscribe(), F.value = v().pipe(expand((e) => e.status === "pending" ? timer(2e3).pipe(switchMap(() => v())) : EMPTY), tap((e) => {
291
- e.status === "expired" && (w.value = !1), e.status === "paid" && (w.value = !1, C.value = "success", x("success", e)), e.status === "failed" && (w.value = !1), e.status === "approved" && (w.value = !1, C.value = "success", x("success", e));
292
+ F.value?.unsubscribe(), F.value = _().pipe(expand((e) => e.status === "pending" ? timer(2e3).pipe(switchMap(() => _())) : EMPTY), tap((e) => {
293
+ e.status === "expired" && (C.value = !1), e.status === "paid" && (C.value = !1, S.value = "success", b("success", e)), e.status === "failed" && (C.value = !1), e.status === "approved" && (C.value = !1, S.value = "success", b("success", e));
292
294
  })).subscribe({ error: (e) => {
293
- console.error("支付状态检查错误:", e), w.value = !1, x("error", e);
295
+ console.error("支付状态检查错误:", e), C.value = !1, b("error", e);
294
296
  } });
295
297
  }, $ = async () => {
296
298
  O.value?.receiveAddress && await navigator.clipboard.writeText(O.value.receiveAddress);
297
299
  };
298
- return watch(() => b.modelValue, (e) => {
299
- e && T.value.length === 0 && W();
300
- }), watch(E, () => {
300
+ return watch(() => y.modelValue, (e) => {
301
+ e && w.value.length === 0 && W();
302
+ }), watch(T, () => {
301
303
  L.value.length > 0 && (D.value = L.value[0].symbol);
302
- }), watch(C, (e) => {
304
+ }), watch(S, (e) => {
303
305
  e === "payment" && O.value && Q(O.value.paymentId);
304
306
  }), onUnmounted(() => {
305
307
  F.value?.unsubscribe();
306
- }), (v, x) => (openBlock(), createBlock(Teleport, { to: "body" }, [createVNode(Transition, { name: "_cppay-fade" }, {
308
+ }), (_, v) => (openBlock(), createBlock(Teleport, { to: "body" }, [createVNode(Transition, { name: "_cppay-fade" }, {
307
309
  default: withCtx(() => [e.modelValue ? (openBlock(), createElementBlock("div", {
308
310
  key: 0,
309
311
  class: "_cppay-overlay",
310
- onClick: x[3] ||= withModifiers((e) => !w.value && U(), ["self"])
311
- }, [createElementVNode("div", _hoisted_1, [createElementVNode("div", _hoisted_2, [createElementVNode("h2", _hoisted_3, toDisplayString(C.value === "select" ? "选择支付方式" : C.value === "success" ? "支付结果" : "完成支付"), 1), createElementVNode("button", {
312
+ onClick: v[3] ||= withModifiers((e) => !C.value && U(), ["self"])
313
+ }, [createElementVNode("div", _hoisted_1, [createElementVNode("div", _hoisted_2, [createElementVNode("h2", _hoisted_3, toDisplayString(S.value === "select" ? "选择支付方式" : S.value === "success" ? "支付结果" : "完成支付"), 1), createElementVNode("button", {
312
314
  onClick: U,
313
315
  class: "_cppay-close-btn",
314
- disabled: w.value
315
- }, [...x[4] ||= [createElementVNode("svg", {
316
+ disabled: C.value
317
+ }, [...v[4] ||= [createElementVNode("svg", {
316
318
  fill: "none",
317
319
  stroke: "currentColor",
318
320
  viewBox: "0 0 24 24"
@@ -321,39 +323,39 @@ var import_browser = /* @__PURE__ */ __toESM(require_browser(), 1), _hoisted_1 =
321
323
  "stroke-linejoin": "round",
322
324
  "stroke-width": "2",
323
325
  d: "M6 18L18 6M6 6l12 12"
324
- })], -1)]], 8, _hoisted_4)]), createElementVNode("div", _hoisted_5, [C.value === "success" ? (openBlock(), createElementBlock("div", _hoisted_6, [
325
- x[5] ||= createElementVNode("div", { style: {
326
+ })], -1)]], 8, _hoisted_4)]), createElementVNode("div", _hoisted_5, [S.value === "success" ? (openBlock(), createElementBlock("div", _hoisted_6, [
327
+ v[5] ||= createElementVNode("div", { style: {
326
328
  "font-size": "64px",
327
329
  "margin-bottom": "1rem"
328
330
  } }, "✅", -1),
329
- createElementVNode("h3", _hoisted_7, toDisplayString(b.plain === "subscription" ? "授权成功!" : "支付成功!"), 1),
330
- createElementVNode("p", _hoisted_8, toDisplayString(b.plain === "subscription" ? "订阅已激活" : "交易已完成"), 1)
331
- ])) : createCommentVNode("", !0), C.value === "select" ? (openBlock(), createElementBlock("div", _hoisted_9, [
332
- createElementVNode("div", _hoisted_10, [x[6] ||= createElementVNode("label", { class: "_cppay-label" }, "支付网络", -1), createElementVNode("div", _hoisted_11, [(openBlock(!0), createElementBlock(Fragment, null, renderList(T.value, (e) => (openBlock(), createElementBlock("button", {
331
+ createElementVNode("h3", _hoisted_7, toDisplayString(y.plain === "subscription" ? "授权成功!" : "支付成功!"), 1),
332
+ createElementVNode("p", _hoisted_8, toDisplayString(y.plain === "subscription" ? "订阅已激活" : "交易已完成"), 1)
333
+ ])) : createCommentVNode("", !0), S.value === "select" ? (openBlock(), createElementBlock("div", _hoisted_9, [
334
+ createElementVNode("div", _hoisted_10, [v[6] ||= createElementVNode("label", { class: "_cppay-label" }, "支付网络", -1), createElementVNode("div", _hoisted_11, [(openBlock(!0), createElementBlock(Fragment, null, renderList(w.value, (e) => (openBlock(), createElementBlock("button", {
333
335
  key: e.chain,
334
- onClick: (v) => E.value = e.chain,
335
- class: normalizeClass(["_cppay-select-btn", E.value === e.chain ? "_cppay-selected" : ""])
336
+ onClick: (_) => T.value = e.chain,
337
+ class: normalizeClass(["_cppay-select-btn", T.value === e.chain ? "_cppay-selected" : ""])
336
338
  }, [e.icon ? (openBlock(), createElementBlock("img", {
337
339
  key: 0,
338
340
  src: e.icon,
339
341
  alt: e.chain
340
342
  }, null, 8, _hoisted_13)) : createCommentVNode("", !0), createElementVNode("span", null, toDisplayString(e.chain), 1)], 10, _hoisted_12))), 128))])]),
341
- createElementVNode("div", _hoisted_14, [x[7] ||= createElementVNode("label", { class: "_cppay-label" }, "支付代币", -1), createElementVNode("div", _hoisted_15, [(openBlock(!0), createElementBlock(Fragment, null, renderList(L.value, (e) => (openBlock(), createElementBlock("button", {
343
+ createElementVNode("div", _hoisted_14, [v[7] ||= createElementVNode("label", { class: "_cppay-label" }, "支付代币", -1), createElementVNode("div", _hoisted_15, [(openBlock(!0), createElementBlock(Fragment, null, renderList(L.value, (e) => (openBlock(), createElementBlock("button", {
342
344
  key: e.symbol,
343
- onClick: (v) => D.value = e.symbol,
345
+ onClick: (_) => D.value = e.symbol,
344
346
  class: normalizeClass(["_cppay-select-btn", D.value === e.symbol ? "_cppay-selected" : ""])
345
347
  }, [e.icon ? (openBlock(), createElementBlock("img", {
346
348
  key: 0,
347
349
  src: e.icon,
348
350
  alt: e.symbol
349
351
  }, null, 8, _hoisted_17)) : createCommentVNode("", !0), createElementVNode("span", null, toDisplayString(e.symbol), 1)], 10, _hoisted_16))), 128))])]),
350
- createElementVNode("div", _hoisted_18, [createElementVNode("div", _hoisted_19, [createElementVNode("div", _hoisted_20, [x[8] ||= createElementVNode("span", { class: "_cppay-price-label" }, "支付金额", -1), createElementVNode("div", _hoisted_21, [createElementVNode("div", _hoisted_22, toDisplayString(V.value) + " " + toDisplayString(D.value), 1), createElementVNode("div", _hoisted_23, "≈ $" + toDisplayString(e.amount), 1)])])])]),
352
+ createElementVNode("div", _hoisted_18, [createElementVNode("div", _hoisted_19, [createElementVNode("div", _hoisted_20, [v[8] ||= createElementVNode("span", { class: "_cppay-price-label" }, "支付金额", -1), createElementVNode("div", _hoisted_21, [createElementVNode("div", _hoisted_22, toDisplayString(V.value) + " " + toDisplayString(D.value), 1), createElementVNode("div", _hoisted_23, "≈ $" + toDisplayString(e.amount), 1)])])])]),
351
353
  createElementVNode("div", _hoisted_24, [createElementVNode("button", {
352
354
  onClick: Z,
353
- disabled: !E.value || !D.value || w.value,
355
+ disabled: !T.value || !D.value || C.value,
354
356
  class: "_cppay-btn _cppay-btn-primary"
355
- }, toDisplayString(w.value ? "处理中..." : "继续支付"), 9, _hoisted_25)])
356
- ])) : C.value === "payment" && O.value ? (openBlock(), createElementBlock("div", _hoisted_26, [
357
+ }, toDisplayString(C.value ? "处理中..." : "继续支付"), 9, _hoisted_25)])
358
+ ])) : S.value === "payment" && O.value ? (openBlock(), createElementBlock("div", _hoisted_26, [
357
359
  createElementVNode("div", _hoisted_27, [createElementVNode("div", _hoisted_28, [k.value ? (openBlock(), createElementBlock("img", {
358
360
  key: 0,
359
361
  src: k.value,
@@ -365,12 +367,12 @@ var import_browser = /* @__PURE__ */ __toESM(require_browser(), 1), _hoisted_1 =
365
367
  }
366
368
  }, null, 8, _hoisted_29)) : createCommentVNode("", !0)])]),
367
369
  createElementVNode("div", _hoisted_30, [
368
- createElementVNode("div", _hoisted_31, [createElementVNode("div", _hoisted_32, toDisplayString(b.plain === "subscription" ? "授权金额" : "支付金额"), 1), createElementVNode("div", _hoisted_33, toDisplayString(O.value.paymentAmount) + " " + toDisplayString(D.value), 1)]),
369
- createElementVNode("div", _hoisted_34, [createElementVNode("div", _hoisted_35, toDisplayString(b.plain === "subscription" ? "授权合约地址" : "支付地址"), 1), createElementVNode("div", _hoisted_36, [createElementVNode("code", null, toDisplayString(O.value.receiveAddress), 1), createElementVNode("button", {
370
+ createElementVNode("div", _hoisted_31, [createElementVNode("div", _hoisted_32, toDisplayString(y.plain === "subscription" ? "授权金额" : "支付金额"), 1), createElementVNode("div", _hoisted_33, toDisplayString(O.value.paymentAmount) + " " + toDisplayString(D.value), 1)]),
371
+ createElementVNode("div", _hoisted_34, [createElementVNode("div", _hoisted_35, toDisplayString(y.plain === "subscription" ? "授权合约地址" : "支付地址"), 1), createElementVNode("div", _hoisted_36, [createElementVNode("code", null, toDisplayString(O.value.receiveAddress), 1), createElementVNode("button", {
370
372
  onClick: $,
371
373
  class: "_cppay-copy-btn",
372
374
  title: "复制地址"
373
- }, [...x[9] ||= [createElementVNode("svg", {
375
+ }, [...v[9] ||= [createElementVNode("svg", {
374
376
  fill: "none",
375
377
  stroke: "currentColor",
376
378
  viewBox: "0 0 24 24"
@@ -380,7 +382,7 @@ var import_browser = /* @__PURE__ */ __toESM(require_browser(), 1), _hoisted_1 =
380
382
  "stroke-width": "2",
381
383
  d: "M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"
382
384
  })], -1)]])])]),
383
- b.plain === "subscription" ? (openBlock(), createElementBlock("div", _hoisted_37, [...x[10] ||= [createElementVNode("div", {
385
+ y.plain === "subscription" ? (openBlock(), createElementBlock("div", _hoisted_37, [...v[10] ||= [createElementVNode("div", {
384
386
  class: "_cppay-info-label",
385
387
  style: { color: "#856404" }
386
388
  }, "📌 订阅说明", -1), createElementVNode("div", {
@@ -393,10 +395,10 @@ var import_browser = /* @__PURE__ */ __toESM(require_browser(), 1), _hoisted_1 =
393
395
  ]),
394
396
  createElementVNode("div", _hoisted_38, [A.value ? (openBlock(), createElementBlock("div", _hoisted_44, [createElementVNode("button", {
395
397
  onClick: X,
396
- disabled: w.value,
398
+ disabled: C.value,
397
399
  class: "_cppay-btn _cppay-btn-primary"
398
- }, toDisplayString(w.value ? e.plain === "subscription" ? "授权中..." : "支付中..." : e.plain === "subscription" ? "💳 钱包授权" : "💳 钱包支付"), 9, _hoisted_45), createElementVNode("div", _hoisted_46, " 已连接: " + toDisplayString(A.value.slice(0, 6)) + "..." + toDisplayString(A.value.slice(-4)), 1)])) : (openBlock(), createElementBlock("div", _hoisted_39, [createElementVNode("button", {
399
- onClick: x[0] ||= () => K("metamask"),
400
+ }, toDisplayString(C.value ? e.plain === "subscription" ? "授权中..." : "支付中..." : e.plain === "subscription" ? "💳 钱包授权" : "💳 钱包支付"), 9, _hoisted_45), createElementVNode("div", _hoisted_46, " 已连接: " + toDisplayString(A.value.slice(0, 6)) + "..." + toDisplayString(A.value.slice(-4)), 1)])) : (openBlock(), createElementBlock("div", _hoisted_39, [createElementVNode("button", {
401
+ onClick: v[0] ||= () => K("metamask"),
400
402
  disabled: j.value,
401
403
  class: "_cppay-btn _cppay-btn-secondary",
402
404
  style: {
@@ -415,8 +417,8 @@ var import_browser = /* @__PURE__ */ __toESM(require_browser(), 1), _hoisted_1 =
415
417
  width: "20px",
416
418
  height: "20px"
417
419
  }
418
- }, null, 8, _hoisted_41), x[11] ||= createElementVNode("span", null, "MetaMask", -1)], 8, _hoisted_40), createElementVNode("button", {
419
- onClick: x[1] ||= () => K("walletconnect"),
420
+ }, null, 8, _hoisted_41), v[11] ||= createElementVNode("span", null, "MetaMask", -1)], 8, _hoisted_40), createElementVNode("button", {
421
+ onClick: v[1] ||= () => K("walletconnect"),
420
422
  disabled: j.value,
421
423
  class: "_cppay-btn _cppay-btn-secondary",
422
424
  style: {
@@ -435,15 +437,15 @@ var import_browser = /* @__PURE__ */ __toESM(require_browser(), 1), _hoisted_1 =
435
437
  width: "20px",
436
438
  height: "20px"
437
439
  }
438
- }, null, 8, _hoisted_43), x[12] ||= createElementVNode("span", null, "WalletConnect", -1)], 8, _hoisted_42)]))]),
440
+ }, null, 8, _hoisted_43), v[12] ||= createElementVNode("span", null, "WalletConnect", -1)], 8, _hoisted_42)]))]),
439
441
  createElementVNode("div", _hoisted_47, [createElementVNode("button", {
440
442
  onClick: H,
441
- disabled: w.value,
443
+ disabled: C.value,
442
444
  class: "_cppay-btn _cppay-btn-primary"
443
- }, toDisplayString(w.value ? "检查中..." : "我已完成支付"), 9, _hoisted_48)]),
445
+ }, toDisplayString(C.value ? "检查中..." : "我已完成支付"), 9, _hoisted_48)]),
444
446
  createElementVNode("div", _hoisted_49, [createElementVNode("button", {
445
- onClick: x[2] ||= (e) => C.value = "select",
446
- disabled: w.value,
447
+ onClick: v[2] ||= (e) => S.value = "select",
448
+ disabled: C.value,
447
449
  class: "_cppay-btn _cppay-btn-text"
448
450
  }, " 更改支付方式 ", 8, _hoisted_50)])
449
451
  ])) : createCommentVNode("", !0)])])])) : createCommentVNode("", !0)]),
@@ -465,11 +467,11 @@ var handleClose = () => {
465
467
  }, handleError = (e) => {
466
468
  cppayState.value.options?.onError?.(e);
467
469
  };
468
- const CppayPlugin = { install(e, v) {
469
- if (!v?.apikey) throw Error("Cppay plugin requires an apikey");
470
- cppayState.value.apikey = v.apikey, e.config.globalProperties.$showPayment = showPayment;
471
- let y = document.createElement("div");
472
- document.body.appendChild(y), createApp({ setup() {
470
+ const CppayPlugin = { install(e, _) {
471
+ if (!_?.apikey) throw Error("Cppay plugin requires an apikey");
472
+ cppayState.value.apikey = _.apikey, e.config.globalProperties.$showPayment = showPayment;
473
+ let v = document.createElement("div");
474
+ document.body.appendChild(v), createApp({ setup() {
473
475
  return () => cppayState.value.options ? h(PaymentDialog_default, {
474
476
  modelValue: cppayState.value.open,
475
477
  "onUpdate:modelValue": (e) => {
@@ -483,7 +485,7 @@ const CppayPlugin = { install(e, v) {
483
485
  onSuccess: handleSuccess,
484
486
  onError: handleError
485
487
  }) : null;
486
- } }).mount(y);
488
+ } }).mount(v);
487
489
  } }, useCppayPayment = () => {
488
490
  if (!cppayState.value.apikey) throw Error("useCppayPayment must be used after installing CppayPlugin");
489
491
  return { showPayment };