coinley-pay 0.55.0 → 0.57.0

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.
@@ -5,7 +5,7 @@ import { jsxs, jsx, Fragment } from "react/jsx-runtime";
5
5
  import { useState, useRef, useEffect, useCallback, useMemo } from "react";
6
6
  import { useConnect, useAccount, useSwitchChain, useSendTransaction, useWaitForTransactionReceipt, WagmiProvider, useDisconnect } from "wagmi";
7
7
  import { QueryClientProvider, QueryClient } from "@tanstack/react-query";
8
- import { s as sdkAnalytics, c as clarityAnalytics, d as dist, a as Buffer2, B as Buffer$1, g as getCurrencyInfo, p as prefetchRates, i as isSupportedCurrency, b as convertToUSD, f as formatCurrency } from "./index-Bp7JOqpt.js";
8
+ import { s as sdkAnalytics, c as clarityAnalytics, d as dist, a as Buffer2, B as Buffer$1, g as getCurrencyInfo, p as prefetchRates, i as isSupportedCurrency, b as convertToUSD, f as formatCurrency } from "./index-M3kJQHOT.js";
9
9
  import { createConfig, fallback, http, getAccount as getAccount$1, getWalletClient, simulateContract, writeContract, readContract, waitForTransactionReceipt, estimateFeesPerGas as estimateFeesPerGas$1 } from "@wagmi/core";
10
10
  import { injected, metaMask, coinbaseWallet, walletConnect } from "@wagmi/connectors";
11
11
  import { defineChain as defineChain$1, erc20Abi, http as http$1, createPublicClient, fallback as fallback$1 } from "viem";
@@ -21126,7 +21126,7 @@ const WalletSelector = ({
21126
21126
  try {
21127
21127
  setAppKitError(null);
21128
21128
  setWalletConnectAddress(solanaAccountState.address);
21129
- const { createWalletConnectAdapter } = await import("./appKitSolana-FcW9To4k.js");
21129
+ const { createWalletConnectAdapter } = await import("./appKitSolana-PRcbceg-.js");
21130
21130
  const adapter = createWalletConnectAdapter(solanaAccountState.address);
21131
21131
  await solanaWallet.connectWalletConnect(adapter, solanaAccountState.address);
21132
21132
  console.log("✅ WalletConnect synced with SDK");
@@ -21231,7 +21231,7 @@ const WalletSelector = ({
21231
21231
  setAppKitLoading(true);
21232
21232
  setAppKitError(null);
21233
21233
  try {
21234
- const { initializeAppKitEVM, openAppKitModal } = await import("./appKitEVM-B3xgIRTz.js");
21234
+ const { initializeAppKitEVM, openAppKitModal } = await import("./appKitEVM-BAdtRD8N.js");
21235
21235
  await initializeAppKitEVM(wagmiConfig);
21236
21236
  await openAppKitModal();
21237
21237
  } catch (error) {
@@ -21251,7 +21251,7 @@ const WalletSelector = ({
21251
21251
  setAppKitError(null);
21252
21252
  try {
21253
21253
  console.log("📦 Loading AppKit Solana module...");
21254
- const { initializeAppKitSolana } = await import("./appKitSolana-FcW9To4k.js");
21254
+ const { initializeAppKitSolana } = await import("./appKitSolana-PRcbceg-.js");
21255
21255
  console.log("✅ Module loaded, initializing...");
21256
21256
  const modal = await initializeAppKitSolana(solanaWallet);
21257
21257
  console.log("✅ AppKit Solana initialized successfully");
@@ -22943,10 +22943,6 @@ const generateQRPaymentURI = (paymentData, selectedToken, selectedNetwork, confi
22943
22943
  return null;
22944
22944
  }
22945
22945
  };
22946
- const isInDAppBrowser = () => {
22947
- if (typeof window === "undefined" || !window.ethereum) return false;
22948
- return !!(window.ethereum.isMetaMask || window.ethereum.isTrust || window.ethereum.isCoinbaseWallet || window.ethereum.isZerion || window.ethereum.isRabby || window.ethereum.isRainbow);
22949
- };
22950
22946
  const openPaymentPageInWallet = (walletType, paymentData, selectedNetwork = null, selectedToken = null, apiUrl = null) => {
22951
22947
  const paymentScreenUrl = getHostedPaymentUrl(paymentData, walletType, selectedToken, selectedNetwork, apiUrl);
22952
22948
  if (!paymentScreenUrl) return false;
@@ -22989,7 +22985,6 @@ const deepLinkUtils = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defin
22989
22985
  getHostedPaymentUrl,
22990
22986
  getSupportedMobileWallets,
22991
22987
  getWalletAppStoreLink,
22992
- isInDAppBrowser,
22993
22988
  normalizeWalletType,
22994
22989
  openPaymentPageInWallet
22995
22990
  }, Symbol.toStringTag, { value: "Module" }));
@@ -23185,6 +23180,7 @@ const CoinleyPaymentInternal = ({
23185
23180
  var _a;
23186
23181
  const paymentFlow = usePaymentFlow(apiUrl, publicKey2 || apiKey, publicKey2 ? null : apiSecret);
23187
23182
  const walletConnection = useWalletConnection();
23183
+ const failedPaymentReportsRef = useRef(/* @__PURE__ */ new Set());
23188
23184
  const solanaWallet = useSolanaWallet();
23189
23185
  const chainType = useMemo(() => {
23190
23186
  if (!paymentFlow.selectedNetwork) return CHAIN_TYPES.EVM;
@@ -23449,7 +23445,7 @@ const CoinleyPaymentInternal = ({
23449
23445
  createPayment,
23450
23446
  createDepositPayment,
23451
23447
  isDepositSupported,
23452
- failPayment,
23448
+ failPayment: rawFailPayment,
23453
23449
  resetState,
23454
23450
  setSelectedNetwork,
23455
23451
  setSelectedToken,
@@ -23463,6 +23459,18 @@ const CoinleyPaymentInternal = ({
23463
23459
  } = paymentFlow;
23464
23460
  const activeTransferPaymentId = (paymentData == null ? void 0 : paymentData.id) || (ccResult == null ? void 0 : ccResult.id) || (ccResult == null ? void 0 : ccResult.paymentId);
23465
23461
  const activeTransferDepositAddress = (paymentData == null ? void 0 : paymentData.depositAddress) || (ccResult == null ? void 0 : ccResult.relayDepositAddress) || (ccResult == null ? void 0 : ccResult.depositAddress);
23462
+ const failPayment = useCallback(async (reason = "Payment cancelled by user", status = "failed") => {
23463
+ const paymentId = activeTransferPaymentId;
23464
+ if (!paymentId || currentStep === PAYMENT_STEPS.SUCCESS) return;
23465
+ const dedupeKey = `${paymentId}:${status}:${reason || ""}`;
23466
+ if (failedPaymentReportsRef.current.has(dedupeKey)) return;
23467
+ failedPaymentReportsRef.current.add(dedupeKey);
23468
+ try {
23469
+ await paymentFlow.api.failPayment(paymentId, reason, status);
23470
+ } catch (error2) {
23471
+ await rawFailPayment(reason, status);
23472
+ }
23473
+ }, [activeTransferPaymentId, currentStep, paymentFlow.api, rawFailPayment]);
23466
23474
  const merchantReceiveNetworks = (merchantNetworks == null ? void 0 : merchantNetworks.length) ? merchantNetworks : networks;
23467
23475
  const isConfiguredMerchantReceiveNetwork = useCallback((network) => {
23468
23476
  var _a2;
@@ -24083,6 +24091,7 @@ const CoinleyPaymentInternal = ({
24083
24091
  useEffect(() => {
24084
24092
  if (isOpen) {
24085
24093
  console.log(`[Coinley] Build: ${CHECKOUT_BUILD}`);
24094
+ failedPaymentReportsRef.current = /* @__PURE__ */ new Set();
24086
24095
  loadData();
24087
24096
  resetState();
24088
24097
  setMobileStep("method-select");
@@ -24399,13 +24408,9 @@ const CoinleyPaymentInternal = ({
24399
24408
  onClose();
24400
24409
  };
24401
24410
  const handleMobileTabSelect = (tab) => {
24402
- if (tab === PAYMENT_TABS.WALLET && isMobile && !isInDAppBrowser()) {
24403
- setActiveTab(tab);
24404
- setShowMobileWalletPicker(true);
24405
- setMobileStep("content");
24406
- return;
24407
- }
24408
24411
  setShowMobileWalletPicker(false);
24412
+ setSelectedMobileWallet(null);
24413
+ setMobileWalletRedirecting(null);
24409
24414
  setActiveTab(tab);
24410
24415
  setMobileStep("content");
24411
24416
  };
@@ -25380,6 +25385,9 @@ const CoinleyPaymentInternal = ({
25380
25385
  } else if (status.phase === "settled" && !ccSucceeded.current) {
25381
25386
  finishRecoveryLoading(() => {
25382
25387
  ccSucceeded.current = true;
25388
+ setCcRefundPendingInfo(null);
25389
+ setCcManualCheckStatus(null);
25390
+ setCurrentStep(PAYMENT_STEPS.SUCCESS);
25383
25391
  onSuccess == null ? void 0 : onSuccess(status);
25384
25392
  });
25385
25393
  } else if (status.phase === "received") {
@@ -25439,6 +25447,8 @@ const CoinleyPaymentInternal = ({
25439
25447
  } else if (s.phase === "settled" && !ccSucceeded.current) {
25440
25448
  ccSucceeded.current = true;
25441
25449
  setCcRefundPendingInfo(null);
25450
+ setCcManualCheckStatus(null);
25451
+ setCurrentStep(PAYMENT_STEPS.SUCCESS);
25442
25452
  onSuccess == null ? void 0 : onSuccess(s);
25443
25453
  }
25444
25454
  } catch {
@@ -27083,7 +27093,7 @@ const CoinleyPaymentInternal = ({
27083
27093
  className: "h-8 w-full rounded-lg border border-[#E5E7EB] bg-white px-3 text-xs text-[#1F2430] outline-none placeholder:text-[#A9ABB2] focus:border-[#B49AF0]"
27084
27094
  }
27085
27095
  ) }),
27086
- /* @__PURE__ */ jsx("div", { className: "grid grid-cols-1 gap-2 min-[360px]:grid-cols-2", children: visibleWalletNetworkOptions.length > 0 ? visibleWalletNetworkOptions.map((network) => /* @__PURE__ */ jsxs(
27096
+ /* @__PURE__ */ jsx("div", { className: "grid grid-cols-2 gap-2", children: visibleWalletNetworkOptions.length > 0 ? visibleWalletNetworkOptions.map((network) => /* @__PURE__ */ jsxs(
27087
27097
  "button",
27088
27098
  {
27089
27099
  type: "button",
@@ -27093,7 +27103,7 @@ const CoinleyPaymentInternal = ({
27093
27103
  setPaymentData(null);
27094
27104
  setWalletNetworkSearch("");
27095
27105
  },
27096
- className: "flex min-h-10 items-center gap-2 rounded-xl bg-[#FAFAFB] px-3 py-2 text-left text-sm text-[#1F2430] transition-colors hover:bg-purple-50",
27106
+ className: "flex min-h-10 min-w-0 items-center gap-2 rounded-xl bg-[#FAFAFB] px-3 py-2 text-left text-sm text-[#1F2430] transition-colors hover:bg-purple-50",
27097
27107
  children: [
27098
27108
  /* @__PURE__ */ jsx(
27099
27109
  "img",
@@ -27167,7 +27177,7 @@ const CoinleyPaymentInternal = ({
27167
27177
  className: "mb-2 h-8 w-full rounded-lg border border-[#E5E7EB] bg-white px-3 text-xs text-[#1F2430] outline-none placeholder:text-[#A9ABB2] focus:border-[#B49AF0]"
27168
27178
  }
27169
27179
  ),
27170
- /* @__PURE__ */ jsx("div", { className: "grid grid-cols-1 gap-2 min-[360px]:grid-cols-2", children: visibleWalletTokens.length > 0 ? visibleWalletTokens.map((token) => /* @__PURE__ */ jsxs(
27180
+ /* @__PURE__ */ jsx("div", { className: "grid grid-cols-2 gap-2", children: visibleWalletTokens.length > 0 ? visibleWalletTokens.map((token) => /* @__PURE__ */ jsxs(
27171
27181
  "button",
27172
27182
  {
27173
27183
  type: "button",
@@ -27176,7 +27186,7 @@ const CoinleyPaymentInternal = ({
27176
27186
  setTokenSearch("");
27177
27187
  setPaymentData(null);
27178
27188
  },
27179
- className: "flex min-h-10 items-center gap-2 rounded-xl bg-[#FAFAFB] px-3 py-2 text-left text-sm text-[#1F2430] transition-colors hover:bg-purple-50",
27189
+ className: "flex min-h-10 min-w-0 items-center gap-2 rounded-xl bg-[#FAFAFB] px-3 py-2 text-left text-sm text-[#1F2430] transition-colors hover:bg-purple-50",
27180
27190
  children: [
27181
27191
  /* @__PURE__ */ jsx(
27182
27192
  "img",
@@ -27265,13 +27275,13 @@ const CoinleyPaymentInternal = ({
27265
27275
  }
27266
27276
  }),
27267
27277
  /* @__PURE__ */ jsx("p", { className: "mb-2 text-xs font-medium text-[#1F2430]", children: "Please select your wallet app" }),
27268
- /* @__PURE__ */ jsx("div", { className: "mb-3 grid grid-cols-1 gap-1.5 min-[360px]:grid-cols-3", children: qrWalletOptions.map((wallet) => /* @__PURE__ */ jsxs(
27278
+ /* @__PURE__ */ jsx("div", { className: "mb-3 grid grid-cols-3 gap-1.5", children: qrWalletOptions.map((wallet) => /* @__PURE__ */ jsxs(
27269
27279
  "button",
27270
27280
  {
27271
27281
  type: "button",
27272
27282
  onClick: () => handleQrWalletSelect(wallet.id),
27273
27283
  disabled: !selectedNetwork || !selectedToken || qrLoading || isConverting,
27274
- className: `relative flex min-h-[64px] flex-row items-center gap-2 rounded-lg border bg-[#FAFAFB] px-3 py-3 text-left transition-colors min-[360px]:h-[76px] min-[360px]:flex-col min-[360px]:items-start min-[360px]:justify-between ${preferredWallet === wallet.id ? "border-[#7042D2] bg-[#FBF8FF]" : "border-[#EEF0F4] hover:border-[#C9B8F6]"} disabled:cursor-not-allowed disabled:opacity-60`,
27284
+ className: `relative flex h-[76px] min-w-0 flex-col items-start justify-between rounded-lg border bg-[#FAFAFB] px-2.5 py-3 text-left transition-colors ${preferredWallet === wallet.id ? "border-[#7042D2] bg-[#FBF8FF]" : "border-[#EEF0F4] hover:border-[#C9B8F6]"} disabled:cursor-not-allowed disabled:opacity-60`,
27275
27285
  children: [
27276
27286
  preferredWallet === wallet.id && qrWalletChoiceConfirmed && /* @__PURE__ */ jsx("span", { className: "absolute right-[-5px] top-[-6px] flex h-4 w-4 items-center justify-center rounded-full border border-[#7042D2] bg-white text-[#7042D2]", children: /* @__PURE__ */ jsx("svg", { className: "h-2.5 w-2.5", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 3, d: "M5 13l4 4L19 7" }) }) }),
27277
27287
  /* @__PURE__ */ jsx(
@@ -27285,7 +27295,7 @@ const CoinleyPaymentInternal = ({
27285
27295
  }
27286
27296
  }
27287
27297
  ),
27288
- /* @__PURE__ */ jsx("span", { className: "min-w-0 truncate text-sm font-medium text-[#111827]", children: wallet.name })
27298
+ /* @__PURE__ */ jsx("span", { className: "min-w-0 max-w-full truncate text-[13px] font-medium text-[#111827]", children: wallet.name })
27289
27299
  ]
27290
27300
  },
27291
27301
  wallet.id
@@ -27661,7 +27671,7 @@ const CoinleyPaymentInternal = ({
27661
27671
  }
27662
27672
  ),
27663
27673
  /* @__PURE__ */ jsx("span", { className: "text-sm font-medium", children: selectedNetwork.name })
27664
- ] }) : /* @__PURE__ */ jsx("div", { className: "grid grid-cols-1 gap-2 min-[380px]:grid-cols-2", children: merchantFilteredNetworks.map((network) => /* @__PURE__ */ jsxs(
27674
+ ] }) : /* @__PURE__ */ jsx("div", { className: "grid grid-cols-2 gap-2", children: merchantFilteredNetworks.map((network) => /* @__PURE__ */ jsxs(
27665
27675
  "button",
27666
27676
  {
27667
27677
  onClick: () => handleNetworkSelect(network),
@@ -27710,7 +27720,7 @@ const CoinleyPaymentInternal = ({
27710
27720
  className: "w-full mb-3 px-3 py-2 text-sm border border-gray-200 rounded-xl focus:outline-none focus:ring-2 focus:ring-[#7042D2] focus:border-transparent"
27711
27721
  }
27712
27722
  ),
27713
- /* @__PURE__ */ jsx("div", { className: "grid grid-cols-1 gap-2 min-[380px]:grid-cols-2", children: availableTokens.filter((t) => {
27723
+ /* @__PURE__ */ jsx("div", { className: "grid grid-cols-2 gap-2", children: availableTokens.filter((t) => {
27714
27724
  var _a3;
27715
27725
  return !tokenSearch || t.symbol.toLowerCase().includes(tokenSearch.toLowerCase()) || ((_a3 = t.name) == null ? void 0 : _a3.toLowerCase().includes(tokenSearch.toLowerCase()));
27716
27726
  }).map((token) => /* @__PURE__ */ jsxs(
@@ -28122,4 +28132,4 @@ export {
28122
28132
  chainTransports as c,
28123
28133
  isFeatureEnabled as i
28124
28134
  };
28125
- //# sourceMappingURL=CoinleyPayment-BD6rtaxd.js.map
28135
+ //# sourceMappingURL=CoinleyPayment-CvhX-WMY.js.map
@@ -1,4 +1,4 @@
1
- import { i as isFeatureEnabled, F as FEATURES, c as chainTransports, W as WALLETCONNECT_PROJECT_ID } from "./CoinleyPayment-BD6rtaxd.js";
1
+ import { i as isFeatureEnabled, F as FEATURES, c as chainTransports, W as WALLETCONNECT_PROJECT_ID } from "./CoinleyPayment-CvhX-WMY.js";
2
2
  const logo = "https://coinley.io/logo.png";
3
3
  let appKitInstance = null;
4
4
  let isInitializing = false;
@@ -113,4 +113,4 @@ export {
113
113
  initializeAppKitEVM,
114
114
  openAppKitModal
115
115
  };
116
- //# sourceMappingURL=appKitEVM-B3xgIRTz.js.map
116
+ //# sourceMappingURL=appKitEVM-BAdtRD8N.js.map
@@ -1,4 +1,4 @@
1
- import { F as FEATURES, W as WALLETCONNECT_PROJECT_ID } from "./CoinleyPayment-BD6rtaxd.js";
1
+ import { F as FEATURES, W as WALLETCONNECT_PROJECT_ID } from "./CoinleyPayment-CvhX-WMY.js";
2
2
  const logo = "https://coinley.io/logo.png";
3
3
  let appKitInstance = null;
4
4
  let isInitializing = false;
@@ -243,4 +243,4 @@ export {
243
243
  disconnectWalletConnect,
244
244
  initializeAppKitSolana
245
245
  };
246
- //# sourceMappingURL=appKitSolana-FcW9To4k.js.map
246
+ //# sourceMappingURL=appKitSolana-PRcbceg-.js.map