coinley-pay 0.27.0 → 0.29.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-CCOXI1rx.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-fkUYCNSE.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";
@@ -2896,6 +2896,7 @@ const usePaymentFlow = (apiUrl, apiKey, apiSecret) => {
2896
2896
  __coinleySelectionSnapshot: (attemptMeta == null ? void 0 : attemptMeta.selectionSnapshot) ?? null
2897
2897
  };
2898
2898
  setPaymentData(enrichedPayment);
2899
+ setPaymentType("deposit");
2899
2900
  sdkAnalytics.trackPaymentCreated(
2900
2901
  (_g = response.payment) == null ? void 0 : _g.id,
2901
2902
  config.amount,
@@ -21120,7 +21121,7 @@ const WalletSelector = ({
21120
21121
  try {
21121
21122
  setAppKitError(null);
21122
21123
  setWalletConnectAddress(solanaAccountState.address);
21123
- const { createWalletConnectAdapter } = await import("./appKitSolana-CnR-9LnG.js");
21124
+ const { createWalletConnectAdapter } = await import("./appKitSolana-Brjblem7.js");
21124
21125
  const adapter = createWalletConnectAdapter(solanaAccountState.address);
21125
21126
  await solanaWallet.connectWalletConnect(adapter, solanaAccountState.address);
21126
21127
  console.log("✅ WalletConnect synced with SDK");
@@ -21225,7 +21226,7 @@ const WalletSelector = ({
21225
21226
  setAppKitLoading(true);
21226
21227
  setAppKitError(null);
21227
21228
  try {
21228
- const { initializeAppKitEVM, openAppKitModal } = await import("./appKitEVM-BWbPyL29.js");
21229
+ const { initializeAppKitEVM, openAppKitModal } = await import("./appKitEVM--PzCfGQT.js");
21229
21230
  await initializeAppKitEVM(wagmiConfig);
21230
21231
  await openAppKitModal();
21231
21232
  } catch (error) {
@@ -21245,7 +21246,7 @@ const WalletSelector = ({
21245
21246
  setAppKitError(null);
21246
21247
  try {
21247
21248
  console.log("📦 Loading AppKit Solana module...");
21248
- const { initializeAppKitSolana } = await import("./appKitSolana-CnR-9LnG.js");
21249
+ const { initializeAppKitSolana } = await import("./appKitSolana-Brjblem7.js");
21249
21250
  console.log("✅ Module loaded, initializing...");
21250
21251
  const modal = await initializeAppKitSolana(solanaWallet);
21251
21252
  console.log("✅ AppKit Solana initialized successfully");
@@ -23106,6 +23107,8 @@ const injectCoinleyFonts = () => {
23106
23107
  document.head.appendChild(style);
23107
23108
  };
23108
23109
  const CHECKOUT_BUILD = "checkout-2026-04-22b-route-destination-trials";
23110
+ const UNDERPAYMENT_RECOVERY_STORAGE_PREFIX = "coinley_underpayment_recovery:";
23111
+ const UNDERPAYMENT_RECOVERY_TTL_MS = 2 * 60 * 60 * 1e3;
23109
23112
  const normalizeEvmAddress = (value) => {
23110
23113
  if (typeof value !== "string") return null;
23111
23114
  const trimmed = value.trim();
@@ -23426,6 +23429,59 @@ const CoinleyPaymentInternal = ({
23426
23429
  const hasCommittedTransaction = Boolean(
23427
23430
  currentTransactionHash || (solanaTransaction == null ? void 0 : solanaTransaction.txSignature) || (paymentData == null ? void 0 : paymentData.transactionHash)
23428
23431
  );
23432
+ const getUnderpaymentRecoveryStorageKey = useCallback((paymentId = paymentData == null ? void 0 : paymentData.id) => {
23433
+ return paymentId ? `${UNDERPAYMENT_RECOVERY_STORAGE_PREFIX}${paymentId}` : null;
23434
+ }, [paymentData == null ? void 0 : paymentData.id]);
23435
+ const clearUnderpaymentRecovery = useCallback((paymentId = paymentData == null ? void 0 : paymentData.id) => {
23436
+ const storageKey = getUnderpaymentRecoveryStorageKey(paymentId);
23437
+ if (!storageKey || typeof window === "undefined" || !window.localStorage) return;
23438
+ try {
23439
+ window.localStorage.removeItem(storageKey);
23440
+ } catch (error2) {
23441
+ console.warn("[UnderpaymentRecovery] Failed to clear recovery state:", error2.message);
23442
+ }
23443
+ }, [getUnderpaymentRecoveryStorageKey, paymentData == null ? void 0 : paymentData.id]);
23444
+ const readUnderpaymentRecovery = useCallback((paymentId = paymentData == null ? void 0 : paymentData.id) => {
23445
+ const storageKey = getUnderpaymentRecoveryStorageKey(paymentId);
23446
+ if (!storageKey || typeof window === "undefined" || !window.localStorage) return null;
23447
+ try {
23448
+ const stored = window.localStorage.getItem(storageKey);
23449
+ if (!stored) return null;
23450
+ const parsed = JSON.parse(stored);
23451
+ const isExpired = !(parsed == null ? void 0 : parsed.timestamp) || Date.now() - parsed.timestamp > UNDERPAYMENT_RECOVERY_TTL_MS;
23452
+ const isSamePayment = (parsed == null ? void 0 : parsed.paymentId) === paymentId;
23453
+ const isValidChoice = (parsed == null ? void 0 : parsed.choice) === "offset" || (parsed == null ? void 0 : parsed.choice) === "refund";
23454
+ if (isExpired || !isSamePayment || !isValidChoice) {
23455
+ window.localStorage.removeItem(storageKey);
23456
+ return null;
23457
+ }
23458
+ return parsed;
23459
+ } catch (error2) {
23460
+ console.warn("[UnderpaymentRecovery] Failed to read recovery state:", error2.message);
23461
+ return null;
23462
+ }
23463
+ }, [getUnderpaymentRecoveryStorageKey, paymentData == null ? void 0 : paymentData.id]);
23464
+ const writeUnderpaymentRecovery = useCallback((choice, view = choice, infoOverride = underpaymentInfo) => {
23465
+ const storageKey = getUnderpaymentRecoveryStorageKey(paymentData == null ? void 0 : paymentData.id);
23466
+ if (!storageKey || typeof window === "undefined" || !window.localStorage) return;
23467
+ if (choice !== "offset" && choice !== "refund") return;
23468
+ try {
23469
+ window.localStorage.setItem(storageKey, JSON.stringify({
23470
+ paymentId: paymentData.id,
23471
+ choice,
23472
+ view: view === "refund" ? "refund" : "offset",
23473
+ expectedAmount: infoOverride == null ? void 0 : infoOverride.expectedAmount,
23474
+ receivedAmount: infoOverride == null ? void 0 : infoOverride.receivedAmount,
23475
+ shortfallAmount: infoOverride == null ? void 0 : infoOverride.shortfallAmount,
23476
+ tokenSymbol: infoOverride == null ? void 0 : infoOverride.tokenSymbol,
23477
+ refundNetworkLabel: infoOverride == null ? void 0 : infoOverride.refundNetworkLabel,
23478
+ paymentState: infoOverride == null ? void 0 : infoOverride.paymentState,
23479
+ timestamp: Date.now()
23480
+ }));
23481
+ } catch (error2) {
23482
+ console.warn("[UnderpaymentRecovery] Failed to persist recovery state:", error2.message);
23483
+ }
23484
+ }, [getUnderpaymentRecoveryStorageKey, paymentData == null ? void 0 : paymentData.id, underpaymentInfo]);
23429
23485
  const normalizeUnderpaymentInfo = useCallback((payment = {}) => {
23430
23486
  const raw = payment.underpayment || payment.underpaymentDetails || payment.shortPayment || payment.partialPayment || null;
23431
23487
  const statusText = String(payment.status || payment.depositStatus || (raw == null ? void 0 : raw.status) || "").toLowerCase();
@@ -23459,13 +23515,37 @@ const CoinleyPaymentInternal = ({
23459
23515
  const activateUnderpaymentFlow = useCallback((payment) => {
23460
23516
  const normalized = normalizeUnderpaymentInfo(payment);
23461
23517
  if (!normalized) return false;
23518
+ const recoveryState = readUnderpaymentRecovery((payment == null ? void 0 : payment.id) || (paymentData == null ? void 0 : paymentData.id));
23519
+ const recoveryChoice = (recoveryState == null ? void 0 : recoveryState.choice) === "offset" || (recoveryState == null ? void 0 : recoveryState.choice) === "refund" ? recoveryState.choice : null;
23520
+ const recoveryView = recoveryChoice ? (recoveryState == null ? void 0 : recoveryState.view) === "refund" ? "refund" : "offset" : null;
23462
23521
  setUnderpaymentInfo(normalized);
23463
- setUnderpaymentChoice(null);
23464
- setUnderpaymentView("choice");
23522
+ setUnderpaymentChoice((currentChoice) => currentChoice || recoveryChoice);
23523
+ setUnderpaymentView((currentView) => {
23524
+ if (currentView && currentView !== "choice") {
23525
+ return currentView;
23526
+ }
23527
+ return recoveryView || "choice";
23528
+ });
23465
23529
  setManualCheckStatus(null);
23466
- setRefundRequestSubmitted(false);
23530
+ setRefundRequestSubmitted((submitted) => recoveryChoice === "refund" ? submitted : false);
23467
23531
  return true;
23468
- }, [normalizeUnderpaymentInfo]);
23532
+ }, [normalizeUnderpaymentInfo, paymentData == null ? void 0 : paymentData.id, readUnderpaymentRecovery]);
23533
+ const activateUnderpaymentFromDepositBalance = useCallback((balanceResult) => {
23534
+ const received = Number((balanceResult == null ? void 0 : balanceResult.balance) ?? (balanceResult == null ? void 0 : balanceResult.balanceFormatted) ?? 0);
23535
+ const expected = Number((balanceResult == null ? void 0 : balanceResult.expectedAmount) ?? paymentAmount ?? 0);
23536
+ if (!received || !expected || received <= 0 || received >= expected) {
23537
+ return false;
23538
+ }
23539
+ return activateUnderpaymentFlow({
23540
+ status: "underpaid",
23541
+ paymentState: "underpaid",
23542
+ amount: expected,
23543
+ amountReceived: received,
23544
+ amountRemaining: Math.max(expected - received, 0),
23545
+ currency: (balanceResult == null ? void 0 : balanceResult.token) || (selectedToken == null ? void 0 : selectedToken.symbol),
23546
+ refundNetworkLabel: (selectedNetwork == null ? void 0 : selectedNetwork.displayName) || (selectedNetwork == null ? void 0 : selectedNetwork.name) || (selectedNetwork == null ? void 0 : selectedNetwork.shortName)
23547
+ });
23548
+ }, [activateUnderpaymentFlow, paymentAmount, selectedNetwork, selectedToken]);
23469
23549
  const selectedNetworkIsSolana = (selectedNetwork == null ? void 0 : selectedNetwork.chainType) === "solana" || (selectedNetwork == null ? void 0 : selectedNetwork.shortName) === "solana";
23470
23550
  const sourceNeedsMerchantBridge = Boolean(
23471
23551
  selectedNetwork && !selectedNetworkIsSolana && !isMerchantReceiveNetwork(selectedNetwork)
@@ -23927,6 +24007,7 @@ const CoinleyPaymentInternal = ({
23927
24007
  const txHash = statusResult.payment.depositTxHash || statusResult.payment.sweepTxHash || statusResult.payment.transactionHash;
23928
24008
  if ((status === "completed" || status === "swept") && txHash) {
23929
24009
  clearInterval(pollInterval);
24010
+ clearUnderpaymentRecovery(paymentData.id);
23930
24011
  setProcessingStatusMessage("");
23931
24012
  setCurrentStep(PAYMENT_STEPS.SUCCESS);
23932
24013
  sdkAnalytics.trackPaymentSuccess(
@@ -23955,6 +24036,7 @@ const CoinleyPaymentInternal = ({
23955
24036
  }
23956
24037
  } else if (status === "failed" || status === "sweep_failed") {
23957
24038
  clearInterval(pollInterval);
24039
+ clearUnderpaymentRecovery(paymentData.id);
23958
24040
  setProcessingStatusMessage("");
23959
24041
  sdkAnalytics.trackPaymentFailed(
23960
24042
  paymentData.id,
@@ -23979,9 +24061,9 @@ const CoinleyPaymentInternal = ({
23979
24061
  }
23980
24062
  }, 5e3);
23981
24063
  return () => clearInterval(pollInterval);
23982
- }, [currentStep, paymentData == null ? void 0 : paymentData.id, paymentData == null ? void 0 : paymentData.depositAddress, selectedNetwork, selectedToken, onSuccess, activateUnderpaymentFlow]);
24064
+ }, [currentStep, paymentData == null ? void 0 : paymentData.id, paymentData == null ? void 0 : paymentData.depositAddress, selectedNetwork, selectedToken, onSuccess, activateUnderpaymentFlow, clearUnderpaymentRecovery]);
23983
24065
  useEffect(() => {
23984
- const shouldPoll = (paymentData == null ? void 0 : paymentData.id) && (activeTab === PAYMENT_TABS.QR || activeTab === PAYMENT_TABS.TRANSFER) && currentStep === PAYMENT_STEPS.CONFIRM && !verifyingPayment && paymentType !== PAYMENT_TYPES.DEPOSIT;
24066
+ const shouldPoll = (paymentData == null ? void 0 : paymentData.id) && (activeTab === PAYMENT_TABS.QR || activeTab === PAYMENT_TABS.TRANSFER) && currentStep === PAYMENT_STEPS.CONFIRM && !verifyingPayment && paymentType !== PAYMENT_TYPES.DEPOSIT && !(paymentData == null ? void 0 : paymentData.isDepositPayment) && !(paymentData == null ? void 0 : paymentData.depositAddress);
23985
24067
  if (!shouldPoll) {
23986
24068
  return;
23987
24069
  }
@@ -24061,7 +24143,7 @@ const CoinleyPaymentInternal = ({
24061
24143
  console.log("🛑 Stopping auto-detection polling");
24062
24144
  clearInterval(pollInterval);
24063
24145
  };
24064
- }, [paymentData == null ? void 0 : paymentData.id, activeTab, currentStep, verifyingPayment, paymentType, selectedNetwork, selectedToken, onSuccess, paymentFlow.api]);
24146
+ }, [paymentData == null ? void 0 : paymentData.id, paymentData == null ? void 0 : paymentData.isDepositPayment, paymentData == null ? void 0 : paymentData.depositAddress, activeTab, currentStep, verifyingPayment, paymentType, selectedNetwork, selectedToken, onSuccess, paymentFlow.api]);
24065
24147
  const resetAllTransactionState = async () => {
24066
24148
  var _a2;
24067
24149
  invalidateCurrentAttempt("reset-all-transaction-state");
@@ -25516,6 +25598,7 @@ const CoinleyPaymentInternal = ({
25516
25598
  if ((status === "completed" || status === "swept") && txHash) {
25517
25599
  console.log("✅ Auto-detected: Deposit payment completed!");
25518
25600
  clearInterval(pollInterval);
25601
+ clearUnderpaymentRecovery(paymentData.id);
25519
25602
  setCurrentStep(PAYMENT_STEPS.SUCCESS);
25520
25603
  sdkAnalytics.trackPaymentSuccess(paymentData.id, config == null ? void 0 : config.amount, selectedNetwork == null ? void 0 : selectedNetwork.shortName, selectedToken == null ? void 0 : selectedToken.symbol, txHash);
25521
25604
  clarityAnalytics.trackPaymentSuccess(paymentData.id, config == null ? void 0 : config.amount, selectedNetwork == null ? void 0 : selectedNetwork.shortName, selectedToken == null ? void 0 : selectedToken.symbol, txHash);
@@ -25532,9 +25615,11 @@ const CoinleyPaymentInternal = ({
25532
25615
  } else if (status === "processing" || statusResult.payment.depositDetectedAt) {
25533
25616
  console.log("⏳ Auto-detected: Deposit received, processing...");
25534
25617
  clearInterval(pollInterval);
25618
+ clearUnderpaymentRecovery(paymentData.id);
25535
25619
  setCurrentStep(PAYMENT_STEPS.PROCESSING);
25536
25620
  } else if (status === "failed" || status === "expired") {
25537
25621
  clearInterval(pollInterval);
25622
+ clearUnderpaymentRecovery(paymentData.id);
25538
25623
  setError("Payment failed or expired. Please try again.");
25539
25624
  }
25540
25625
  }
@@ -25546,7 +25631,7 @@ const CoinleyPaymentInternal = ({
25546
25631
  console.log("🛑 Stopping deposit auto-detection polling");
25547
25632
  clearInterval(pollInterval);
25548
25633
  };
25549
- }, [paymentData == null ? void 0 : paymentData.id, paymentData == null ? void 0 : paymentData.depositAddress, paymentType, currentStep, verifyingPayment, expirationTime == null ? void 0 : expirationTime.expired, selectedNetwork, selectedToken, onSuccess, paymentFlow.api, activateUnderpaymentFlow]);
25634
+ }, [paymentData == null ? void 0 : paymentData.id, paymentData == null ? void 0 : paymentData.depositAddress, paymentType, currentStep, verifyingPayment, expirationTime == null ? void 0 : expirationTime.expired, selectedNetwork, selectedToken, onSuccess, paymentFlow.api, activateUnderpaymentFlow, clearUnderpaymentRecovery]);
25550
25635
  useEffect(() => {
25551
25636
  return () => {
25552
25637
  if (manualCheckTimeout.current) {
@@ -25555,17 +25640,40 @@ const CoinleyPaymentInternal = ({
25555
25640
  };
25556
25641
  }, []);
25557
25642
  useEffect(() => {
25643
+ const recoveryState = readUnderpaymentRecovery(paymentData == null ? void 0 : paymentData.id);
25644
+ if (recoveryState && recoveryState.shortfallAmount && (recoveryState.choice === "offset" || recoveryState.choice === "refund")) {
25645
+ setUnderpaymentInfo({
25646
+ expectedAmount: recoveryState.expectedAmount,
25647
+ receivedAmount: recoveryState.receivedAmount,
25648
+ shortfallAmount: recoveryState.shortfallAmount,
25649
+ tokenSymbol: recoveryState.tokenSymbol || (selectedToken == null ? void 0 : selectedToken.symbol) || "Token",
25650
+ refundNetworkLabel: recoveryState.refundNetworkLabel || (selectedNetwork == null ? void 0 : selectedNetwork.displayName) || (selectedNetwork == null ? void 0 : selectedNetwork.name) || (selectedNetwork == null ? void 0 : selectedNetwork.shortName) || "selected network",
25651
+ paymentState: recoveryState.paymentState || "underpaid"
25652
+ });
25653
+ setUnderpaymentChoice(recoveryState.choice);
25654
+ setUnderpaymentView(recoveryState.view === "refund" ? "refund" : "offset");
25655
+ setManualCheckStatus(null);
25656
+ setRefundRequestSubmitted(false);
25657
+ return;
25658
+ }
25558
25659
  setUnderpaymentInfo(null);
25559
25660
  setUnderpaymentChoice(null);
25560
25661
  setUnderpaymentView("choice");
25561
25662
  setRefundAddress("");
25562
25663
  setRefundRequestSubmitted(false);
25563
- }, [paymentData == null ? void 0 : paymentData.id]);
25664
+ }, [paymentData == null ? void 0 : paymentData.id, readUnderpaymentRecovery, selectedNetwork, selectedToken]);
25665
+ useEffect(() => {
25666
+ if (!(paymentData == null ? void 0 : paymentData.id) || !underpaymentInfo || !underpaymentChoice || underpaymentView === "choice") {
25667
+ return;
25668
+ }
25669
+ writeUnderpaymentRecovery(underpaymentChoice, underpaymentView, underpaymentInfo);
25670
+ }, [paymentData == null ? void 0 : paymentData.id, underpaymentInfo, underpaymentChoice, underpaymentView, writeUnderpaymentRecovery]);
25564
25671
  const handleRefundRequestSubmit = useCallback(() => {
25565
25672
  const trimmedAddress = refundAddress.trim();
25566
25673
  if (!trimmedAddress) return;
25567
25674
  setRefundRequestSubmitted(true);
25568
25675
  setManualCheckStatus(null);
25676
+ clearUnderpaymentRecovery(paymentData == null ? void 0 : paymentData.id);
25569
25677
  const refundPayload = {
25570
25678
  paymentId: paymentData == null ? void 0 : paymentData.id,
25571
25679
  refundAddress: trimmedAddress,
@@ -25582,7 +25690,7 @@ const CoinleyPaymentInternal = ({
25582
25690
  detail: refundPayload
25583
25691
  }));
25584
25692
  }
25585
- }, [config, refundAddress, paymentData == null ? void 0 : paymentData.id, selectedNetwork == null ? void 0 : selectedNetwork.shortName, selectedToken == null ? void 0 : selectedToken.symbol, underpaymentInfo]);
25693
+ }, [clearUnderpaymentRecovery, config, refundAddress, paymentData == null ? void 0 : paymentData.id, selectedNetwork == null ? void 0 : selectedNetwork.shortName, selectedToken == null ? void 0 : selectedToken.symbol, underpaymentInfo]);
25586
25694
  const handleDepositManualCheck = useCallback(async () => {
25587
25695
  if (manualCheckStatus === "checking" || !(paymentData == null ? void 0 : paymentData.id)) return;
25588
25696
  setManualCheckStatus("checking");
@@ -25596,6 +25704,7 @@ const CoinleyPaymentInternal = ({
25596
25704
  const txHash = statusResult.payment.depositTxHash || statusResult.payment.sweepTxHash || statusResult.payment.transactionHash;
25597
25705
  if ((status === "completed" || status === "swept") && txHash) {
25598
25706
  setManualCheckStatus(null);
25707
+ clearUnderpaymentRecovery(paymentData.id);
25599
25708
  setCurrentStep(PAYMENT_STEPS.SUCCESS);
25600
25709
  sdkAnalytics.trackPaymentSuccess(paymentData.id, config == null ? void 0 : config.amount, selectedNetwork == null ? void 0 : selectedNetwork.shortName, selectedToken == null ? void 0 : selectedToken.symbol, txHash);
25601
25710
  clarityAnalytics.trackPaymentSuccess(paymentData.id, config == null ? void 0 : config.amount, selectedNetwork == null ? void 0 : selectedNetwork.shortName, selectedToken == null ? void 0 : selectedToken.symbol, txHash);
@@ -25613,10 +25722,17 @@ const CoinleyPaymentInternal = ({
25613
25722
  }
25614
25723
  if (status === "processing" || statusResult.payment.depositDetectedAt) {
25615
25724
  setManualCheckStatus(null);
25725
+ clearUnderpaymentRecovery(paymentData.id);
25616
25726
  setCurrentStep(PAYMENT_STEPS.PROCESSING);
25617
25727
  return;
25618
25728
  }
25619
25729
  }
25730
+ if (paymentData == null ? void 0 : paymentData.depositAddress) {
25731
+ const balanceResult = await paymentFlow.api.getDepositBalance(paymentData.id);
25732
+ if ((balanceResult == null ? void 0 : balanceResult.success) && activateUnderpaymentFromDepositBalance(balanceResult)) {
25733
+ return;
25734
+ }
25735
+ }
25620
25736
  setManualCheckStatus("not_found");
25621
25737
  manualCheckTimeout.current = setTimeout(() => {
25622
25738
  setManualCheckStatus(null);
@@ -25628,7 +25744,7 @@ const CoinleyPaymentInternal = ({
25628
25744
  setManualCheckStatus(null);
25629
25745
  }, 1e4);
25630
25746
  }
25631
- }, [manualCheckStatus, paymentData == null ? void 0 : paymentData.id, paymentFlow.api, config == null ? void 0 : config.amount, selectedNetwork, selectedToken, onSuccess, activateUnderpaymentFlow]);
25747
+ }, [manualCheckStatus, paymentData == null ? void 0 : paymentData.id, paymentData == null ? void 0 : paymentData.depositAddress, paymentFlow.api, config == null ? void 0 : config.amount, selectedNetwork, selectedToken, onSuccess, activateUnderpaymentFlow, activateUnderpaymentFromDepositBalance, clearUnderpaymentRecovery]);
25632
25748
  if (!isOpen) return null;
25633
25749
  if (currentStep === PAYMENT_STEPS.PROCESSING) {
25634
25750
  return /* @__PURE__ */ jsxs("div", { id: SDK_ROOT_ID, className: `${SDK_ROOT_CLASS} fixed inset-0 z-50`, style: { fontFamily: FONT_FAMILY }, children: [
@@ -25809,11 +25925,13 @@ const CoinleyPaymentInternal = ({
25809
25925
  disabled: !underpaymentChoice,
25810
25926
  onClick: () => {
25811
25927
  setRefundRequestSubmitted(false);
25928
+ const nextView = underpaymentChoice === "refund" ? "refund" : "offset";
25929
+ writeUnderpaymentRecovery(underpaymentChoice, nextView, underpaymentInfo);
25812
25930
  if (underpaymentChoice === "offset") {
25813
25931
  modalOpenedAtRef.current = Date.now();
25814
25932
  setTimeRemaining(paymentTimeoutMs);
25815
25933
  }
25816
- setUnderpaymentView(underpaymentChoice === "refund" ? "refund" : "offset");
25934
+ setUnderpaymentView(nextView);
25817
25935
  },
25818
25936
  className: `h-11 w-full rounded-xl px-4 text-sm font-semibold text-white transition-colors ${underpaymentChoice ? "bg-[#7042D2] hover:bg-[#5b34b1]" : "cursor-not-allowed bg-[#B59AE9]"}`,
25819
25937
  children: "Continue"
@@ -25843,6 +25961,7 @@ const CoinleyPaymentInternal = ({
25843
25961
  null,
25844
25962
  "Send only the offset amount to the same address. Make sure to add network fees on top of this amount."
25845
25963
  ),
25964
+ manualCheckStatus === "not_found" && /* @__PURE__ */ jsx("div", { className: "mb-3 rounded-xl border border-amber-200 bg-amber-50 p-3", children: /* @__PURE__ */ jsx("p", { className: "text-sm leading-5 text-amber-700", children: "We have not detected the offset yet. It can take a few moments to appear on-chain, and we will keep checking automatically." }) }),
25846
25965
  /* @__PURE__ */ jsx(
25847
25966
  "button",
25848
25967
  {
@@ -26883,6 +27002,7 @@ const CoinleyPaymentInternal = ({
26883
27002
  setUnderpaymentView("choice");
26884
27003
  return;
26885
27004
  }
27005
+ clearUnderpaymentRecovery(paymentData == null ? void 0 : paymentData.id);
26886
27006
  setPaymentData((prev) => {
26887
27007
  if (!prev) return prev;
26888
27008
  return {
@@ -26993,4 +27113,4 @@ export {
26993
27113
  isFeatureEnabled as i,
26994
27114
  logo as l
26995
27115
  };
26996
- //# sourceMappingURL=CoinleyPayment-Dy4VNYcm.js.map
27116
+ //# sourceMappingURL=CoinleyPayment-DvR9sd7O.js.map
@@ -1,4 +1,4 @@
1
- import { i as isFeatureEnabled, F as FEATURES, c as chainTransports, W as WALLETCONNECT_PROJECT_ID, l as logo } from "./CoinleyPayment-Dy4VNYcm.js";
1
+ import { i as isFeatureEnabled, F as FEATURES, c as chainTransports, W as WALLETCONNECT_PROJECT_ID, l as logo } from "./CoinleyPayment-DvR9sd7O.js";
2
2
  let appKitInstance = null;
3
3
  let isInitializing = false;
4
4
  let initializationPromise = null;
@@ -112,4 +112,4 @@ export {
112
112
  initializeAppKitEVM,
113
113
  openAppKitModal
114
114
  };
115
- //# sourceMappingURL=appKitEVM-BWbPyL29.js.map
115
+ //# sourceMappingURL=appKitEVM--PzCfGQT.js.map
@@ -1,4 +1,4 @@
1
- import { F as FEATURES, l as logo, W as WALLETCONNECT_PROJECT_ID } from "./CoinleyPayment-Dy4VNYcm.js";
1
+ import { F as FEATURES, l as logo, W as WALLETCONNECT_PROJECT_ID } from "./CoinleyPayment-DvR9sd7O.js";
2
2
  let appKitInstance = null;
3
3
  let isInitializing = false;
4
4
  let initializationPromise = null;
@@ -242,4 +242,4 @@ export {
242
242
  disconnectWalletConnect,
243
243
  initializeAppKitSolana
244
244
  };
245
- //# sourceMappingURL=appKitSolana-CnR-9LnG.js.map
245
+ //# sourceMappingURL=appKitSolana-Brjblem7.js.map