coinley-pay 0.30.0 → 0.31.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.
- package/dist/{CoinleyPayment-BUCxlaSN.js → CoinleyPayment-BvxUgI2r.js} +61 -14
- package/dist/{appKitEVM--OanO4zO.js → appKitEVM-DolBzIzZ.js} +2 -2
- package/dist/{appKitSolana-CNQLFPw3.js → appKitSolana-CHASGJ9W.js} +2 -2
- package/dist/coinley-vanilla.min.js +576 -576
- package/dist/{index-EgEF0eVy.js → index-DLEW836a.js} +3 -3
- package/dist/{index-DXIE_oad.js → index-H-42A54A.js} +3 -3
- package/dist/index.esm.js +1 -1
- package/dist/index.umd.js +2 -2
- package/package.json +1 -1
|
@@ -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-
|
|
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-DLEW836a.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";
|
|
@@ -2428,6 +2428,18 @@ class SimplePaymentAPI {
|
|
|
2428
2428
|
async getDepositBalance(paymentId) {
|
|
2429
2429
|
return await this.request(`/api/deposits/balance/${paymentId}`);
|
|
2430
2430
|
}
|
|
2431
|
+
/**
|
|
2432
|
+
* Request refund for an underpaid deposit payment
|
|
2433
|
+
* @param {string} paymentId - Payment ID
|
|
2434
|
+
* @param {string} refundAddress - Customer refund wallet address
|
|
2435
|
+
* @returns {Promise<{success: boolean, payment: Object}>}
|
|
2436
|
+
*/
|
|
2437
|
+
async requestDepositRefund(paymentId, refundAddress) {
|
|
2438
|
+
return await this.request(`/api/deposits/refund-request/${paymentId}`, {
|
|
2439
|
+
method: "POST",
|
|
2440
|
+
body: JSON.stringify({ refundAddress })
|
|
2441
|
+
});
|
|
2442
|
+
}
|
|
2431
2443
|
// ==================== BRIDGE ROUTING API ====================
|
|
2432
2444
|
async getBridgeRoute(params) {
|
|
2433
2445
|
const response = await this.request("/api/bridge/quote", {
|
|
@@ -21121,7 +21133,7 @@ const WalletSelector = ({
|
|
|
21121
21133
|
try {
|
|
21122
21134
|
setAppKitError(null);
|
|
21123
21135
|
setWalletConnectAddress(solanaAccountState.address);
|
|
21124
|
-
const { createWalletConnectAdapter } = await import("./appKitSolana-
|
|
21136
|
+
const { createWalletConnectAdapter } = await import("./appKitSolana-CHASGJ9W.js");
|
|
21125
21137
|
const adapter = createWalletConnectAdapter(solanaAccountState.address);
|
|
21126
21138
|
await solanaWallet.connectWalletConnect(adapter, solanaAccountState.address);
|
|
21127
21139
|
console.log("✅ WalletConnect synced with SDK");
|
|
@@ -21226,7 +21238,7 @@ const WalletSelector = ({
|
|
|
21226
21238
|
setAppKitLoading(true);
|
|
21227
21239
|
setAppKitError(null);
|
|
21228
21240
|
try {
|
|
21229
|
-
const { initializeAppKitEVM, openAppKitModal } = await import("./appKitEVM
|
|
21241
|
+
const { initializeAppKitEVM, openAppKitModal } = await import("./appKitEVM-DolBzIzZ.js");
|
|
21230
21242
|
await initializeAppKitEVM(wagmiConfig);
|
|
21231
21243
|
await openAppKitModal();
|
|
21232
21244
|
} catch (error) {
|
|
@@ -21246,7 +21258,7 @@ const WalletSelector = ({
|
|
|
21246
21258
|
setAppKitError(null);
|
|
21247
21259
|
try {
|
|
21248
21260
|
console.log("📦 Loading AppKit Solana module...");
|
|
21249
|
-
const { initializeAppKitSolana } = await import("./appKitSolana-
|
|
21261
|
+
const { initializeAppKitSolana } = await import("./appKitSolana-CHASGJ9W.js");
|
|
21250
21262
|
console.log("✅ Module loaded, initializing...");
|
|
21251
21263
|
const modal = await initializeAppKitSolana(solanaWallet);
|
|
21252
21264
|
console.log("✅ AppKit Solana initialized successfully");
|
|
@@ -23290,6 +23302,8 @@ const CoinleyPaymentInternal = ({
|
|
|
23290
23302
|
const [underpaymentView, setUnderpaymentView] = useState("choice");
|
|
23291
23303
|
const [refundAddress, setRefundAddress] = useState("");
|
|
23292
23304
|
const [refundRequestSubmitted, setRefundRequestSubmitted] = useState(false);
|
|
23305
|
+
const [refundRequestStatus, setRefundRequestStatus] = useState(null);
|
|
23306
|
+
const [refundRequestMessage, setRefundRequestMessage] = useState("");
|
|
23293
23307
|
const manualCheckTimeout = useRef(null);
|
|
23294
23308
|
const [copiedField, setCopiedField] = useState(null);
|
|
23295
23309
|
const [expirationTime, setExpirationTime] = useState(null);
|
|
@@ -23528,6 +23542,8 @@ const CoinleyPaymentInternal = ({
|
|
|
23528
23542
|
});
|
|
23529
23543
|
setManualCheckStatus(null);
|
|
23530
23544
|
setRefundRequestSubmitted((submitted) => recoveryChoice === "refund" ? submitted : false);
|
|
23545
|
+
setRefundRequestStatus((status) => status);
|
|
23546
|
+
setRefundRequestMessage((message) => message);
|
|
23531
23547
|
return true;
|
|
23532
23548
|
}, [normalizeUnderpaymentInfo, paymentData == null ? void 0 : paymentData.id, readUnderpaymentRecovery]);
|
|
23533
23549
|
const activateUnderpaymentFromDepositBalance = useCallback((balanceResult) => {
|
|
@@ -23922,6 +23938,13 @@ const CoinleyPaymentInternal = ({
|
|
|
23922
23938
|
}, [paymentTimeoutMs, timeRemaining > 0]);
|
|
23923
23939
|
useEffect(() => {
|
|
23924
23940
|
if (timeRemaining === 0 && currentStep !== PAYMENT_STEPS.SUCCESS) {
|
|
23941
|
+
if (refundRequestSubmitted || refundRequestStatus === "submitting" || refundRequestStatus === "pending" || refundRequestStatus === "refunded") {
|
|
23942
|
+
console.log("[CheckoutTimer] Timeout reached after refund request; leaving refund flow open.", {
|
|
23943
|
+
paymentId: paymentData == null ? void 0 : paymentData.id,
|
|
23944
|
+
refundRequestStatus
|
|
23945
|
+
});
|
|
23946
|
+
return;
|
|
23947
|
+
}
|
|
23925
23948
|
if (hasCommittedTransaction || transactionStep === "settlement_pending") {
|
|
23926
23949
|
console.warn("[CheckoutTimer] Timeout reached after transaction commit; keeping payment in processing state.", {
|
|
23927
23950
|
paymentId: paymentData == null ? void 0 : paymentData.id,
|
|
@@ -23964,7 +23987,7 @@ const CoinleyPaymentInternal = ({
|
|
|
23964
23987
|
}
|
|
23965
23988
|
onClose();
|
|
23966
23989
|
}
|
|
23967
|
-
}, [currentStep, hasCommittedTransaction, onClose, onError, paymentData == null ? void 0 : paymentData.id, selectedNetwork == null ? void 0 : selectedNetwork.shortName, selectedToken == null ? void 0 : selectedToken.symbol, config == null ? void 0 : config.amount, config == null ? void 0 : config.callbackUrl, timeRemaining, transactionStep]);
|
|
23990
|
+
}, [currentStep, hasCommittedTransaction, onClose, onError, paymentData == null ? void 0 : paymentData.id, selectedNetwork == null ? void 0 : selectedNetwork.shortName, selectedToken == null ? void 0 : selectedToken.symbol, config == null ? void 0 : config.amount, config == null ? void 0 : config.callbackUrl, timeRemaining, transactionStep, refundRequestSubmitted, refundRequestStatus]);
|
|
23968
23991
|
const formatCountdown = useCallback((ms) => {
|
|
23969
23992
|
if (ms <= 0) return "00:00";
|
|
23970
23993
|
const totalSeconds = Math.floor(ms / 1e3);
|
|
@@ -25656,6 +25679,8 @@ const CoinleyPaymentInternal = ({
|
|
|
25656
25679
|
setUnderpaymentView(recoveryState.view === "refund" ? "refund" : "offset");
|
|
25657
25680
|
setManualCheckStatus(null);
|
|
25658
25681
|
setRefundRequestSubmitted(false);
|
|
25682
|
+
setRefundRequestStatus(null);
|
|
25683
|
+
setRefundRequestMessage("");
|
|
25659
25684
|
return;
|
|
25660
25685
|
}
|
|
25661
25686
|
setUnderpaymentInfo(null);
|
|
@@ -25663,6 +25688,8 @@ const CoinleyPaymentInternal = ({
|
|
|
25663
25688
|
setUnderpaymentView("choice");
|
|
25664
25689
|
setRefundAddress("");
|
|
25665
25690
|
setRefundRequestSubmitted(false);
|
|
25691
|
+
setRefundRequestStatus(null);
|
|
25692
|
+
setRefundRequestMessage("");
|
|
25666
25693
|
}, [paymentData == null ? void 0 : paymentData.id, readUnderpaymentRecovery, selectedNetwork, selectedToken]);
|
|
25667
25694
|
useEffect(() => {
|
|
25668
25695
|
if (!(paymentData == null ? void 0 : paymentData.id) || !underpaymentInfo || !underpaymentChoice || underpaymentView === "choice") {
|
|
@@ -25670,10 +25697,12 @@ const CoinleyPaymentInternal = ({
|
|
|
25670
25697
|
}
|
|
25671
25698
|
writeUnderpaymentRecovery(underpaymentChoice, underpaymentView, underpaymentInfo);
|
|
25672
25699
|
}, [paymentData == null ? void 0 : paymentData.id, underpaymentInfo, underpaymentChoice, underpaymentView, writeUnderpaymentRecovery]);
|
|
25673
|
-
const handleRefundRequestSubmit = useCallback(() => {
|
|
25700
|
+
const handleRefundRequestSubmit = useCallback(async () => {
|
|
25701
|
+
var _a2;
|
|
25674
25702
|
const trimmedAddress = refundAddress.trim();
|
|
25675
|
-
if (!trimmedAddress) return;
|
|
25676
|
-
|
|
25703
|
+
if (!trimmedAddress || !(paymentData == null ? void 0 : paymentData.id) || refundRequestStatus === "submitting") return;
|
|
25704
|
+
setRefundRequestStatus("submitting");
|
|
25705
|
+
setRefundRequestMessage("");
|
|
25677
25706
|
setManualCheckStatus(null);
|
|
25678
25707
|
clearUnderpaymentRecovery(paymentData == null ? void 0 : paymentData.id);
|
|
25679
25708
|
const refundPayload = {
|
|
@@ -25692,7 +25721,21 @@ const CoinleyPaymentInternal = ({
|
|
|
25692
25721
|
detail: refundPayload
|
|
25693
25722
|
}));
|
|
25694
25723
|
}
|
|
25695
|
-
|
|
25724
|
+
try {
|
|
25725
|
+
const result = await paymentFlow.api.requestDepositRefund(paymentData.id, trimmedAddress);
|
|
25726
|
+
const refundStatus = ((_a2 = result == null ? void 0 : result.payment) == null ? void 0 : _a2.refundStatus) || "pending";
|
|
25727
|
+
setRefundRequestSubmitted(true);
|
|
25728
|
+
setRefundRequestStatus(refundStatus === "refunded" ? "refunded" : "pending");
|
|
25729
|
+
setRefundRequestMessage(
|
|
25730
|
+
refundStatus === "refunded" ? "Refund sent successfully." : "Refund request received. We will process it automatically; if network gas is low, it may remain pending until the sweeper wallet is funded."
|
|
25731
|
+
);
|
|
25732
|
+
} catch (error2) {
|
|
25733
|
+
console.warn("[RefundRequest] Error:", error2.message);
|
|
25734
|
+
setRefundRequestSubmitted(false);
|
|
25735
|
+
setRefundRequestStatus("error");
|
|
25736
|
+
setRefundRequestMessage(error2.message || "Failed to submit refund request. Please try again.");
|
|
25737
|
+
}
|
|
25738
|
+
}, [clearUnderpaymentRecovery, config, refundAddress, refundRequestStatus, paymentData == null ? void 0 : paymentData.id, paymentFlow.api, selectedNetwork == null ? void 0 : selectedNetwork.shortName, selectedToken == null ? void 0 : selectedToken.symbol, underpaymentInfo]);
|
|
25696
25739
|
const handleDepositManualCheck = useCallback(async () => {
|
|
25697
25740
|
if (manualCheckStatus === "checking" || !(paymentData == null ? void 0 : paymentData.id)) return;
|
|
25698
25741
|
setManualCheckStatus("checking");
|
|
@@ -25887,6 +25930,8 @@ const CoinleyPaymentInternal = ({
|
|
|
25887
25930
|
onClick: () => {
|
|
25888
25931
|
setUnderpaymentChoice(choice);
|
|
25889
25932
|
setRefundRequestSubmitted(false);
|
|
25933
|
+
setRefundRequestStatus(null);
|
|
25934
|
+
setRefundRequestMessage("");
|
|
25890
25935
|
},
|
|
25891
25936
|
className: `relative flex min-h-[118px] flex-1 flex-col items-start rounded-xl border p-3 text-left transition-colors ${selected ? "border-[#8B5CF6] bg-[#F4EEFF]" : "border-[#ECEEF2] bg-white hover:border-[#D7C5FF]"}`,
|
|
25892
25937
|
children: [
|
|
@@ -26001,13 +26046,13 @@ const CoinleyPaymentInternal = ({
|
|
|
26001
26046
|
"button",
|
|
26002
26047
|
{
|
|
26003
26048
|
type: "button",
|
|
26004
|
-
disabled: !refundAddress.trim(),
|
|
26049
|
+
disabled: !refundAddress.trim() || refundRequestStatus === "submitting" || refundRequestStatus === "pending" || refundRequestStatus === "refunded",
|
|
26005
26050
|
onClick: handleRefundRequestSubmit,
|
|
26006
|
-
className: `h-11 w-full rounded-xl px-4 text-sm font-semibold text-white transition-colors ${refundAddress.trim() ? "bg-[#7042D2] hover:bg-[#5b34b1]" : "cursor-not-allowed bg-[#B59AE9]"}`,
|
|
26007
|
-
children: refundRequestSubmitted ? "Refund request submitted" : "Submit refund request"
|
|
26051
|
+
className: `h-11 w-full rounded-xl px-4 text-sm font-semibold text-white transition-colors ${refundAddress.trim() && refundRequestStatus !== "submitting" && refundRequestStatus !== "pending" && refundRequestStatus !== "refunded" ? "bg-[#7042D2] hover:bg-[#5b34b1]" : "cursor-not-allowed bg-[#B59AE9]"}`,
|
|
26052
|
+
children: refundRequestStatus === "submitting" ? "Submitting refund request..." : refundRequestSubmitted ? "Refund request submitted" : "Submit refund request"
|
|
26008
26053
|
}
|
|
26009
26054
|
),
|
|
26010
|
-
|
|
26055
|
+
refundRequestMessage && /* @__PURE__ */ jsx("p", { className: `mt-2 text-center text-xs leading-5 ${refundRequestStatus === "error" ? "text-red-600" : "text-[#8B8E98]"}`, children: refundRequestMessage })
|
|
26011
26056
|
] });
|
|
26012
26057
|
const transferNetworks = networks.filter((network) => {
|
|
26013
26058
|
const chainId = parseInt(network.chainId);
|
|
@@ -27021,6 +27066,8 @@ const CoinleyPaymentInternal = ({
|
|
|
27021
27066
|
setUnderpaymentView("choice");
|
|
27022
27067
|
setRefundAddress("");
|
|
27023
27068
|
setRefundRequestSubmitted(false);
|
|
27069
|
+
setRefundRequestStatus(null);
|
|
27070
|
+
setRefundRequestMessage("");
|
|
27024
27071
|
await resetAllTransactionState();
|
|
27025
27072
|
setActiveTab(PAYMENT_TABS.TRANSFER);
|
|
27026
27073
|
};
|
|
@@ -27115,4 +27162,4 @@ export {
|
|
|
27115
27162
|
isFeatureEnabled as i,
|
|
27116
27163
|
logo as l
|
|
27117
27164
|
};
|
|
27118
|
-
//# sourceMappingURL=CoinleyPayment-
|
|
27165
|
+
//# sourceMappingURL=CoinleyPayment-BvxUgI2r.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-
|
|
1
|
+
import { i as isFeatureEnabled, F as FEATURES, c as chainTransports, W as WALLETCONNECT_PROJECT_ID, l as logo } from "./CoinleyPayment-BvxUgI2r.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
|
|
115
|
+
//# sourceMappingURL=appKitEVM-DolBzIzZ.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { F as FEATURES, l as logo, W as WALLETCONNECT_PROJECT_ID } from "./CoinleyPayment-
|
|
1
|
+
import { F as FEATURES, l as logo, W as WALLETCONNECT_PROJECT_ID } from "./CoinleyPayment-BvxUgI2r.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-
|
|
245
|
+
//# sourceMappingURL=appKitSolana-CHASGJ9W.js.map
|