coinley-pay 0.64.0 → 0.65.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.
@@ -6,7 +6,7 @@ import { useState, useRef, useEffect, useCallback, useMemo } from "react";
6
6
  import ReactDOM, { createPortal } from "react-dom";
7
7
  import { useConnect, useAccount, useSwitchChain, useSendTransaction, useWaitForTransactionReceipt, WagmiProvider, useDisconnect } from "wagmi";
8
8
  import { QueryClientProvider, QueryClient } from "@tanstack/react-query";
9
- 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-TmTTxz2j.js";
9
+ 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-DlWS8_3x.js";
10
10
  import { createConfig, fallback, http, getAccount as getAccount$1, getWalletClient, simulateContract, writeContract, readContract, waitForTransactionReceipt, estimateFeesPerGas as estimateFeesPerGas$1 } from "@wagmi/core";
11
11
  import { injected, metaMask, coinbaseWallet, walletConnect } from "@wagmi/connectors";
12
12
  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-bPi9q207.js");
21129
+ const { createWalletConnectAdapter } = await import("./appKitSolana-De-Lx7eT.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-xLzaRFEg.js");
21234
+ const { initializeAppKitEVM, openAppKitModal } = await import("./appKitEVM-CGJ7ZTpW.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-bPi9q207.js");
21254
+ const { initializeAppKitSolana } = await import("./appKitSolana-De-Lx7eT.js");
21255
21255
  console.log("✅ Module loaded, initializing...");
21256
21256
  const modal = await initializeAppKitSolana(solanaWallet);
21257
21257
  console.log("✅ AppKit Solana initialized successfully");
@@ -23187,6 +23187,10 @@ const CC_CHAIN_NAMES = {
23187
23187
  81457: "Blast"
23188
23188
  };
23189
23189
  const ccChainName = (id) => CC_CHAIN_NAMES[Number(id)] || `Chain ${id}`;
23190
+ const prettyNetworkLabel = (label) => {
23191
+ const match = /^chain\s+(\d+)$/i.exec(String(label).trim());
23192
+ return match ? ccChainName(match[1]) : label;
23193
+ };
23190
23194
  const ccChainIcon = (id) => `https://assets.relay.link/icons/${Number(id)}/light.png`;
23191
23195
  const renderInPortal = (content) => typeof document !== "undefined" && document.body ? createPortal(content, document.body) : content;
23192
23196
  const CoinleyPaymentInternal = ({
@@ -23373,6 +23377,10 @@ const CoinleyPaymentInternal = ({
23373
23377
  const [underpaymentInfo, setUnderpaymentInfo] = useState(null);
23374
23378
  const [underpaymentChoice, setUnderpaymentChoice] = useState(null);
23375
23379
  const [underpaymentView, setUnderpaymentView] = useState("choice");
23380
+ const [isCrossChainFailedBridge, setIsCrossChainFailedBridge] = useState(false);
23381
+ const [payAgainAfterRefund, setPayAgainAfterRefund] = useState(false);
23382
+ const payAgainResetRef = useRef(() => {
23383
+ });
23376
23384
  const [refundAddress, setRefundAddress] = useState("");
23377
23385
  const [refundRequestSubmitted, setRefundRequestSubmitted] = useState(false);
23378
23386
  const [refundRequestStatus, setRefundRequestStatus] = useState(null);
@@ -23394,6 +23402,7 @@ const CoinleyPaymentInternal = ({
23394
23402
  const MOBILE_BRIDGE_PLACEHOLDER_ADDRESS = "0x0000000000000000000000000000000000000001";
23395
23403
  const DEPOSIT_SUPPORTED_CHAINS = [8453, 56, 42161, 137, 10, 43114, 143, 59144, 534352, 130];
23396
23404
  const [timeRemaining, setTimeRemaining] = useState(STANDARD_PAYMENT_TIMEOUT_MS);
23405
+ const timeoutHandledRef = useRef(false);
23397
23406
  const modalOpenedAtRef = useRef(Date.now());
23398
23407
  const [mobileStep, setMobileStep] = useState("content");
23399
23408
  const [showMobileWalletPicker, setShowMobileWalletPicker] = useState(false);
@@ -23760,7 +23769,8 @@ const CoinleyPaymentInternal = ({
23760
23769
  const shortfall = Number(
23761
23770
  (raw == null ? void 0 : raw.shortfallAmount) ?? (raw == null ? void 0 : raw.remainingAmount) ?? (raw == null ? void 0 : raw.amountRemaining) ?? (raw == null ? void 0 : raw.offsetAmount) ?? payment.shortfallAmount ?? payment.remainingAmount ?? payment.amountRemaining ?? payment.offsetAmount ?? Math.max(expected - received, 0)
23762
23771
  );
23763
- if (!shortfall || shortfall <= 0) {
23772
+ const refundableNoShortfall = String((raw == null ? void 0 : raw.reason) || "").toLowerCase().includes("refundable") || String((raw == null ? void 0 : raw.status) || "").toLowerCase() === "refundable" || paymentStateText === "bridge_failed" || String((raw == null ? void 0 : raw.paymentState) || "").toLowerCase() === "bridge_failed";
23773
+ if ((!shortfall || shortfall <= 0) && !refundableNoShortfall) {
23764
23774
  return null;
23765
23775
  }
23766
23776
  return {
@@ -23768,7 +23778,7 @@ const CoinleyPaymentInternal = ({
23768
23778
  receivedAmount: received,
23769
23779
  shortfallAmount: shortfall,
23770
23780
  tokenSymbol: (raw == null ? void 0 : raw.tokenSymbol) || (raw == null ? void 0 : raw.currency) || payment.currency || (selectedToken == null ? void 0 : selectedToken.symbol) || "Token",
23771
- refundNetworkLabel: (raw == null ? void 0 : raw.refundNetworkLabel) || (raw == null ? void 0 : raw.refundNetwork) || payment.refundNetworkLabel || (selectedNetwork == null ? void 0 : selectedNetwork.displayName) || (selectedNetwork == null ? void 0 : selectedNetwork.name) || (selectedNetwork == null ? void 0 : selectedNetwork.shortName) || "selected network",
23781
+ refundNetworkLabel: prettyNetworkLabel((raw == null ? void 0 : raw.refundNetworkLabel) || (raw == null ? void 0 : raw.refundNetwork) || payment.refundNetworkLabel || (selectedNetwork == null ? void 0 : selectedNetwork.displayName) || (selectedNetwork == null ? void 0 : selectedNetwork.name) || (selectedNetwork == null ? void 0 : selectedNetwork.shortName) || "selected network"),
23772
23782
  paymentState: payment.paymentState || (raw == null ? void 0 : raw.paymentState) || statusText || "underpaid"
23773
23783
  };
23774
23784
  }, [paymentAmount, selectedNetwork, selectedToken]);
@@ -23816,6 +23826,8 @@ const CoinleyPaymentInternal = ({
23816
23826
  const relay = statusResult.relay || {};
23817
23827
  const rawPayment = statusResult.payment || statusResult;
23818
23828
  const underpayment = statusResult.underpayment || statusResult.underpaymentDetails || rawPayment.underpayment || rawPayment.underpaymentDetails || null;
23829
+ const isFailedBridge = statusResult.refundable === true && statusResult.bridgeStatus === "failed";
23830
+ setIsCrossChainFailedBridge(isFailedBridge);
23819
23831
  return activateUnderpaymentFlow({
23820
23832
  ...rawPayment,
23821
23833
  id: rawPayment.id || statusResult.paymentId || (ccResult == null ? void 0 : ccResult.id),
@@ -23823,17 +23835,25 @@ const CoinleyPaymentInternal = ({
23823
23835
  status: rawPayment.status || statusResult.status,
23824
23836
  paymentState: rawPayment.paymentState || statusResult.paymentState,
23825
23837
  amount: (underpayment == null ? void 0 : underpayment.expectedAmount) ?? rawPayment.expectedAmount ?? rawPayment.amount ?? statusResult.expectedAmount ?? statusResult.amount,
23826
- amountReceived: (underpayment == null ? void 0 : underpayment.receivedAmount) ?? (underpayment == null ? void 0 : underpayment.amountReceived) ?? rawPayment.amountReceived ?? statusResult.amountReceived,
23838
+ // refundableAmount is the server-authoritative claimable amount after bridge fees;
23839
+ // prefer it over generic receivedAmount fields when present.
23840
+ amountReceived: (underpayment == null ? void 0 : underpayment.receivedAmount) ?? (underpayment == null ? void 0 : underpayment.amountReceived) ?? rawPayment.amountReceived ?? statusResult.amountReceived ?? statusResult.refundableAmount,
23827
23841
  amountRemaining: (underpayment == null ? void 0 : underpayment.shortfallAmount) ?? (underpayment == null ? void 0 : underpayment.remainingAmount) ?? rawPayment.amountRemaining ?? statusResult.amountRemaining,
23828
- currency: (underpayment == null ? void 0 : underpayment.tokenSymbol) || (underpayment == null ? void 0 : underpayment.currency) || rawPayment.currency || statusResult.currency || (ccOriginToken == null ? void 0 : ccOriginToken.symbol),
23829
- refundNetworkLabel: (underpayment == null ? void 0 : underpayment.refundNetworkLabel) || rawPayment.refundNetworkLabel || ccChainName(relay.originChainId || (ccResult == null ? void 0 : ccResult.originChainId) || ccOriginChainId),
23842
+ currency: (underpayment == null ? void 0 : underpayment.tokenSymbol) || (underpayment == null ? void 0 : underpayment.currency) || rawPayment.currency || statusResult.currency || statusResult.refundTokenSymbol || (ccOriginToken == null ? void 0 : ccOriginToken.symbol),
23843
+ refundNetworkLabel: (underpayment == null ? void 0 : underpayment.refundNetworkLabel) || rawPayment.refundNetworkLabel || statusResult.refundNetworkLabel || ccChainName(relay.originChainId || (ccResult == null ? void 0 : ccResult.originChainId) || ccOriginChainId),
23830
23844
  underpayment
23831
- }, { forceRefund: true });
23845
+ }, {
23846
+ // For a failed bridge the funds already came back — show the choice panel.
23847
+ // For live underpayments route straight to the refund view.
23848
+ forceRefund: !isFailedBridge
23849
+ });
23832
23850
  }, [activateUnderpaymentFlow, ccOriginChainId, ccOriginToken == null ? void 0 : ccOriginToken.symbol, ccResult == null ? void 0 : ccResult.id, ccResult == null ? void 0 : ccResult.originChainId, ccResult == null ? void 0 : ccResult.relayDepositAddress]);
23833
23851
  const clearUnderpaymentUiState = useCallback((paymentId) => {
23834
23852
  setUnderpaymentInfo(null);
23835
23853
  setUnderpaymentChoice(null);
23836
23854
  setUnderpaymentView("choice");
23855
+ setIsCrossChainFailedBridge(false);
23856
+ setPayAgainAfterRefund(false);
23837
23857
  setManualCheckStatus(null);
23838
23858
  setCcManualCheckStatus(null);
23839
23859
  setRecoveryLoadingAction(null);
@@ -24226,7 +24246,12 @@ const CoinleyPaymentInternal = ({
24226
24246
  return () => clearInterval(interval);
24227
24247
  }, [paymentTimeoutMs, timeRemaining > 0]);
24228
24248
  useEffect(() => {
24229
- if (timeRemaining === 0 && currentStep !== PAYMENT_STEPS.SUCCESS) {
24249
+ if (timeRemaining !== 0) {
24250
+ timeoutHandledRef.current = false;
24251
+ return;
24252
+ }
24253
+ if (timeRemaining === 0 && currentStep !== PAYMENT_STEPS.SUCCESS && !timeoutHandledRef.current) {
24254
+ timeoutHandledRef.current = true;
24230
24255
  if (refundRequestSubmitted || refundRequestStatus === "submitting" || refundRequestStatus === "pending" || refundRequestStatus === "refunded") {
24231
24256
  console.log("[CheckoutTimer] Timeout reached after refund request; leaving refund flow open.", {
24232
24257
  paymentId: paymentData == null ? void 0 : paymentData.id,
@@ -26504,6 +26529,17 @@ const CoinleyPaymentInternal = ({
26504
26529
  try {
26505
26530
  const result = await paymentFlow.api.requestDepositRefund(activeTransferPaymentId, trimmedAddress);
26506
26531
  const refundStatus = ((_a2 = result == null ? void 0 : result.payment) == null ? void 0 : _a2.refundStatus) || "pending";
26532
+ if (payAgainAfterRefund) {
26533
+ setRefundRequestSubmitted(true);
26534
+ setRefundRequestStatus(refundStatus === "refunded" ? "refunded" : "pending");
26535
+ setPayAgainAfterRefund(false);
26536
+ refundPendingStartedAt.current = 0;
26537
+ finishRecoveryLoading(() => {
26538
+ var _a3;
26539
+ (_a3 = payAgainResetRef.current) == null ? void 0 : _a3.call(payAgainResetRef);
26540
+ });
26541
+ return;
26542
+ }
26507
26543
  setRefundRequestSubmitted(true);
26508
26544
  setRefundRequestStatus(refundStatus === "refunded" ? "refunded" : "pending");
26509
26545
  if (refundStatus === "refunded") {
@@ -26542,7 +26578,7 @@ const CoinleyPaymentInternal = ({
26542
26578
  setRefundRequestMessage(error2.message || "Failed to submit refund request. Please try again.");
26543
26579
  });
26544
26580
  }
26545
- }, [activeTransferPaymentId, captureRefundSuccessDetails, ccOriginChainId, ccOriginToken == null ? void 0 : ccOriginToken.symbol, ccResult, clearUnderpaymentRecovery, config, finishRecoveryLoading, getCrossChainRefundPendingStatus, getRefundPendingStatus, holdRecoveryLoading, refundAddress, refundRequestStatus, paymentFlow.api, selectedNetwork == null ? void 0 : selectedNetwork.shortName, selectedToken == null ? void 0 : selectedToken.symbol, startRecoveryLoading, underpaymentInfo]);
26581
+ }, [activeTransferPaymentId, captureRefundSuccessDetails, ccOriginChainId, ccOriginToken == null ? void 0 : ccOriginToken.symbol, ccResult, clearUnderpaymentRecovery, config, finishRecoveryLoading, getCrossChainRefundPendingStatus, getRefundPendingStatus, holdRecoveryLoading, payAgainAfterRefund, refundAddress, refundRequestStatus, paymentFlow.api, selectedNetwork == null ? void 0 : selectedNetwork.shortName, selectedToken == null ? void 0 : selectedToken.symbol, startRecoveryLoading, underpaymentInfo]);
26546
26582
  const handleOverpaymentRefundSubmit = useCallback(async () => {
26547
26583
  var _a2;
26548
26584
  const trimmedAddress = refundAddress.trim();
@@ -27006,7 +27042,9 @@ const CoinleyPaymentInternal = ({
27006
27042
  }
27007
27043
  const paymentAmountLabel = isConverting ? "..." : `$${formatAmount(paymentAmount || (config == null ? void 0 : config.amount) || 0)}`;
27008
27044
  const underpaymentOffsetAmountLabel = underpaymentInfo ? `${formatAmount(underpaymentInfo.shortfallAmount || 0)} ${underpaymentInfo.tokenSymbol || (selectedToken == null ? void 0 : selectedToken.symbol) || ""}`.trim() : paymentAmountLabel;
27009
- const summaryPaymentAmountLabel = underpaymentInfo && (underpaymentView === "offset" || underpaymentView === "refund") ? underpaymentOffsetAmountLabel : paymentAmountLabel;
27045
+ const underpaymentRefundAmountLabel = underpaymentInfo ? `${formatAmount(underpaymentInfo.receivedAmount || 0)} ${underpaymentInfo.tokenSymbol || (selectedToken == null ? void 0 : selectedToken.symbol) || ""}`.trim() : paymentAmountLabel;
27046
+ const summaryPaymentAmountLabel = underpaymentInfo && underpaymentView === "refund" ? underpaymentRefundAmountLabel : underpaymentInfo && underpaymentView === "offset" ? underpaymentOffsetAmountLabel : paymentAmountLabel;
27047
+ const summaryAmountCaption = underpaymentInfo && underpaymentView === "refund" ? "Refund:" : "To Pay:";
27010
27048
  const getTokenDisplaySymbol = (token) => (token == null ? void 0 : token.symbol) || (token == null ? void 0 : token.tokenSymbol) || (token == null ? void 0 : token.currency) || (token == null ? void 0 : token.ticker) || (token == null ? void 0 : token.name) || "Token";
27011
27049
  const getLogoFallbackUrl = (label = "?", background = "7042D2") => {
27012
27050
  const safeLabel = String(label || "?").slice(0, 2).toUpperCase();
@@ -27047,7 +27085,7 @@ const CoinleyPaymentInternal = ({
27047
27085
  ] }),
27048
27086
  /* @__PURE__ */ jsx("div", { className: "flex-1 pt-[13px] border-t border-dashed border-[#DFE1E7]" }),
27049
27087
  /* @__PURE__ */ jsxs("div", { className: "text-right", children: [
27050
- /* @__PURE__ */ jsx("p", { className: "text-[11px] leading-none text-[#9EA0A8] mb-1", children: "To Pay:" }),
27088
+ /* @__PURE__ */ jsx("p", { className: "text-[11px] leading-none text-[#9EA0A8] mb-1", children: summaryAmountCaption }),
27051
27089
  /* @__PURE__ */ jsx("p", { className: "text-xs font-semibold text-[#1F2430]", children: summaryPaymentAmountLabel })
27052
27090
  ] })
27053
27091
  ] }),
@@ -27104,11 +27142,30 @@ const CoinleyPaymentInternal = ({
27104
27142
  );
27105
27143
  };
27106
27144
  const renderUnderpaymentChoicePanel = () => /* @__PURE__ */ jsxs("div", { className: "pt-1", children: [
27107
- renderUnderpaymentWarning(
27145
+ isCrossChainFailedBridge ? renderUnderpaymentWarning(
27146
+ "Bridge failed — funds returned",
27147
+ `We received ${underpaymentInfo.receivedAmount ? `${formatAmount(underpaymentInfo.receivedAmount)} ${underpaymentInfo.tokenSymbol || ""} ` : ""}but could not complete the bridge payment. Choose how to proceed.`
27148
+ ) : renderUnderpaymentWarning(
27108
27149
  "Amount received is less than expected",
27109
27150
  `We received $${formatAmount(underpaymentInfo.receivedAmount || 0)} but expected $${formatAmount(underpaymentInfo.expectedAmount || paymentAmount || 0)}. Your transaction is on hold, please choose how to proceed.`
27110
27151
  ),
27111
- /* @__PURE__ */ jsxs("div", { className: "mb-5 grid grid-cols-2 gap-2", children: [
27152
+ /* @__PURE__ */ jsx("div", { className: "mb-5 grid grid-cols-2 gap-2", children: isCrossChainFailedBridge ? /* @__PURE__ */ jsxs(Fragment, { children: [
27153
+ renderUnderpaymentOptionCard({
27154
+ choice: "pay-again",
27155
+ title: "Pay again",
27156
+ description: "Start a new checkout for the full payment amount",
27157
+ icon: /* @__PURE__ */ jsx("svg", { className: "h-6 w-6", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 1.8, d: "M4 4v6h6M20 20v-6h-6M5.5 15.5A7 7 0 0017.7 18M18.5 8.5A7 7 0 006.3 6" }) })
27158
+ }),
27159
+ renderUnderpaymentOptionCard({
27160
+ choice: "refund",
27161
+ title: "Get a refund",
27162
+ description: "Receive your funds back to a wallet address you provide",
27163
+ icon: /* @__PURE__ */ jsxs("svg", { className: "h-6 w-6", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: [
27164
+ /* @__PURE__ */ jsx("circle", { cx: "12", cy: "12", r: "9", strokeWidth: 1.8 }),
27165
+ /* @__PURE__ */ jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 1.8, d: "M9 9l6 6m0-6l-6 6" })
27166
+ ] })
27167
+ })
27168
+ ] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
27112
27169
  renderUnderpaymentOptionCard({
27113
27170
  choice: "offset",
27114
27171
  title: "Send offset",
@@ -27124,7 +27181,7 @@ const CoinleyPaymentInternal = ({
27124
27181
  /* @__PURE__ */ jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 1.8, d: "M9 9l6 6m0-6l-6 6" })
27125
27182
  ] })
27126
27183
  })
27127
- ] })
27184
+ ] }) })
27128
27185
  ] });
27129
27186
  const renderRecoveryLoadingPanel = ({ title, description, detail }) => /* @__PURE__ */ jsxs("div", { className: "flex min-h-[292px] flex-col items-center justify-center px-3 py-4 text-center", children: [
27130
27187
  /* @__PURE__ */ jsxs("div", { className: "relative mb-4 flex h-28 w-40 items-center justify-center", children: [
@@ -27174,8 +27231,11 @@ const CoinleyPaymentInternal = ({
27174
27231
  description: (recoveryLoadingStatus == null ? void 0 : recoveryLoadingStatus.action) === "refund" ? recoveryLoadingStatus.description : "We are submitting your refund request and checking whether it can be sent immediately.",
27175
27232
  detail: (recoveryLoadingStatus == null ? void 0 : recoveryLoadingStatus.action) === "refund" ? recoveryLoadingStatus.detail : `Refunding the received ${underpaymentInfo.tokenSymbol} on ${underpaymentInfo.refundNetworkLabel}.`
27176
27233
  }) : /* @__PURE__ */ jsxs("div", { className: "pt-1", children: [
27177
- renderUnderpaymentWarning(
27178
- `Refund of $${formatAmount(underpaymentInfo.receivedAmount || 0)} ${underpaymentInfo.tokenSymbol}`,
27234
+ payAgainAfterRefund ? renderUnderpaymentWarning(
27235
+ `Return ${formatAmount(underpaymentInfo.receivedAmount || 0)} ${underpaymentInfo.tokenSymbol}, then pay again`,
27236
+ `First provide a ${underpaymentInfo.tokenSymbol} wallet address on ${underpaymentInfo.refundNetworkLabel} to receive your returned funds (network fees deducted). We'll then start a fresh checkout so you can pay again.`
27237
+ ) : renderUnderpaymentWarning(
27238
+ `Refund of ${formatAmount(underpaymentInfo.receivedAmount || 0)} ${underpaymentInfo.tokenSymbol}`,
27179
27239
  `Provide a ${underpaymentInfo.tokenSymbol} wallet address on the same network (${underpaymentInfo.refundNetworkLabel}) to receive your refund. Network fees will be deducted.`
27180
27240
  ),
27181
27241
  /* @__PURE__ */ jsxs("label", { className: "mb-2 block text-xs font-medium text-[#111827]", children: [
@@ -27750,8 +27810,30 @@ const CoinleyPaymentInternal = ({
27750
27810
  children: label
27751
27811
  }
27752
27812
  );
27813
+ const handleCrossChainPayAgain = async () => {
27814
+ const paymentId = ccResult == null ? void 0 : ccResult.id;
27815
+ clearUnderpaymentUiState(paymentId);
27816
+ setIsCrossChainFailedBridge(false);
27817
+ setCcResult(null);
27818
+ setCcQrCode("");
27819
+ setCcPhase("idle");
27820
+ setCcError(null);
27821
+ setCcManualCheckStatus("idle");
27822
+ ccSucceeded.current = false;
27823
+ setPaymentData(null);
27824
+ await resetAllTransactionState();
27825
+ };
27826
+ payAgainResetRef.current = handleCrossChainPayAgain;
27753
27827
  const handleUnderpaymentChoiceContinue = () => {
27754
27828
  if (!underpaymentChoice) return;
27829
+ if (underpaymentChoice === "pay-again") {
27830
+ refundPendingStartedAt.current = 0;
27831
+ setRefundRequestSubmitted(false);
27832
+ setPayAgainAfterRefund(true);
27833
+ writeUnderpaymentRecovery(underpaymentChoice, "refund", underpaymentInfo);
27834
+ setUnderpaymentView("refund");
27835
+ return;
27836
+ }
27755
27837
  refundPendingStartedAt.current = 0;
27756
27838
  setRefundRequestSubmitted(false);
27757
27839
  const nextView = underpaymentChoice === "refund" ? "refund" : "offset";
@@ -27831,9 +27913,9 @@ const CoinleyPaymentInternal = ({
27831
27913
  return null;
27832
27914
  }
27833
27915
  return renderFooterPrimaryButton({
27834
- label: refundRequestSubmitted ? "Refund request submitted" : "Submit Refund request",
27916
+ label: payAgainAfterRefund ? refundRequestStatus === "submitting" ? "Submitting..." : "Return funds & pay again" : refundRequestSubmitted ? "Refund request submitted" : "Submit Refund request",
27835
27917
  onClick: handleRefundRequestSubmit,
27836
- disabled: !refundAddress.trim() || refundRequestStatus === "submitting" || refundRequestStatus === "pending" || refundRequestStatus === "refunded"
27918
+ disabled: !refundAddress.trim() || refundRequestStatus === "submitting" || !payAgainAfterRefund && (refundRequestStatus === "pending" || refundRequestStatus === "refunded")
27837
27919
  });
27838
27920
  }
27839
27921
  }
@@ -28467,4 +28549,4 @@ export {
28467
28549
  chainTransports as c,
28468
28550
  isFeatureEnabled as i
28469
28551
  };
28470
- //# sourceMappingURL=CoinleyPayment-DpJjSgAk.js.map
28552
+ //# sourceMappingURL=CoinleyPayment-BovUsM20.js.map
@@ -1,4 +1,4 @@
1
- import { i as isFeatureEnabled, F as FEATURES, c as chainTransports, W as WALLETCONNECT_PROJECT_ID } from "./CoinleyPayment-DpJjSgAk.js";
1
+ import { i as isFeatureEnabled, F as FEATURES, c as chainTransports, W as WALLETCONNECT_PROJECT_ID } from "./CoinleyPayment-BovUsM20.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-xLzaRFEg.js.map
116
+ //# sourceMappingURL=appKitEVM-CGJ7ZTpW.js.map
@@ -1,4 +1,4 @@
1
- import { F as FEATURES, W as WALLETCONNECT_PROJECT_ID } from "./CoinleyPayment-DpJjSgAk.js";
1
+ import { F as FEATURES, W as WALLETCONNECT_PROJECT_ID } from "./CoinleyPayment-BovUsM20.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-bPi9q207.js.map
246
+ //# sourceMappingURL=appKitSolana-De-Lx7eT.js.map