coinley-checkout 0.6.0 → 0.6.2
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.
@@ -20591,15 +20591,42 @@ const PaymentStatus = ({
|
|
20591
20591
|
status,
|
20592
20592
|
message,
|
20593
20593
|
theme: theme2 = "light",
|
20594
|
-
//
|
20594
|
+
// Props for success screen
|
20595
20595
|
payment = null,
|
20596
20596
|
transactionHash = null,
|
20597
20597
|
selectedPaymentMethod = null,
|
20598
20598
|
merchantName = "Merchant",
|
20599
|
-
onClose = null
|
20600
|
-
//
|
20599
|
+
onClose = null,
|
20600
|
+
// The onClose prop for the close button
|
20601
|
+
// New props for enhanced processing feedback
|
20602
|
+
processingStartTime = null,
|
20603
|
+
// Time when processing started
|
20604
|
+
paymentNetwork = null
|
20605
|
+
// Current payment network
|
20601
20606
|
}) => {
|
20602
20607
|
const [copiedHash, setCopiedHash] = useState(false);
|
20608
|
+
const [processingSeconds, setProcessingSeconds] = useState(0);
|
20609
|
+
const [showEarlySuccessOption, setShowEarlySuccessOption] = useState(false);
|
20610
|
+
const [progressStage, setProgressStage] = useState(1);
|
20611
|
+
useEffect(() => {
|
20612
|
+
let timer;
|
20613
|
+
if (status === "processing" && processingStartTime) {
|
20614
|
+
timer = setInterval(() => {
|
20615
|
+
const elapsed = Math.floor((Date.now() - processingStartTime) / 1e3);
|
20616
|
+
setProcessingSeconds(elapsed);
|
20617
|
+
if (elapsed >= 5 && progressStage === 1) {
|
20618
|
+
setProgressStage(2);
|
20619
|
+
}
|
20620
|
+
if (elapsed >= 15 && progressStage === 2) {
|
20621
|
+
setProgressStage(3);
|
20622
|
+
}
|
20623
|
+
if (elapsed >= 30 && !showEarlySuccessOption) {
|
20624
|
+
setShowEarlySuccessOption(true);
|
20625
|
+
}
|
20626
|
+
}, 1e3);
|
20627
|
+
}
|
20628
|
+
return () => clearInterval(timer);
|
20629
|
+
}, [status, processingStartTime, progressStage, showEarlySuccessOption]);
|
20603
20630
|
const copyTransactionHash = () => __async(void 0, null, function* () {
|
20604
20631
|
if (transactionHash) {
|
20605
20632
|
try {
|
@@ -20611,6 +20638,17 @@ const PaymentStatus = ({
|
|
20611
20638
|
}
|
20612
20639
|
}
|
20613
20640
|
});
|
20641
|
+
const handleClose = () => {
|
20642
|
+
console.log("Payment success screen close button clicked");
|
20643
|
+
if (onClose) {
|
20644
|
+
onClose();
|
20645
|
+
}
|
20646
|
+
};
|
20647
|
+
const handleEarlySuccess = () => {
|
20648
|
+
if (onClose) {
|
20649
|
+
onClose();
|
20650
|
+
}
|
20651
|
+
};
|
20614
20652
|
const formatTransactionHash = (hash2) => {
|
20615
20653
|
if (!hash2)
|
20616
20654
|
return "";
|
@@ -20627,6 +20665,16 @@ const PaymentStatus = ({
|
|
20627
20665
|
};
|
20628
20666
|
return names2[network] || network;
|
20629
20667
|
};
|
20668
|
+
const getEstimatedConfirmationTime = (network) => {
|
20669
|
+
const times = {
|
20670
|
+
ethereum: "1-2 minutes",
|
20671
|
+
bsc: "15-30 seconds",
|
20672
|
+
tron: "30-60 seconds",
|
20673
|
+
algorand: "5-10 seconds",
|
20674
|
+
solana: "10-15 seconds"
|
20675
|
+
};
|
20676
|
+
return times[network] || "1-2 minutes";
|
20677
|
+
};
|
20630
20678
|
const formatRecipientAddress = (address) => {
|
20631
20679
|
if (!address)
|
20632
20680
|
return "N/A";
|
@@ -20634,6 +20682,11 @@ const PaymentStatus = ({
|
|
20634
20682
|
return address;
|
20635
20683
|
return `${address.slice(0, 6)}...${address.slice(-4)}`;
|
20636
20684
|
};
|
20685
|
+
const formatTime = (seconds) => {
|
20686
|
+
const mins = Math.floor(seconds / 60);
|
20687
|
+
const secs = seconds % 60;
|
20688
|
+
return `${mins}:${secs < 10 ? "0" : ""}${secs}`;
|
20689
|
+
};
|
20637
20690
|
const renderIcon = () => {
|
20638
20691
|
switch (status) {
|
20639
20692
|
case "processing":
|
@@ -20747,7 +20800,7 @@ const PaymentStatus = ({
|
|
20747
20800
|
onClose && /* @__PURE__ */ jsxRuntimeExports.jsx(
|
20748
20801
|
"button",
|
20749
20802
|
{
|
20750
|
-
onClick:
|
20803
|
+
onClick: handleClose,
|
20751
20804
|
className: "w-full py-3 px-4 bg-[#7042D2] text-white font-medium rounded-2xl text-lg shadow-md hover:bg-[#5b34b1] transition-colors",
|
20752
20805
|
style: { borderRadius: "1.5rem" },
|
20753
20806
|
children: "Close"
|
@@ -20755,12 +20808,66 @@ const PaymentStatus = ({
|
|
20755
20808
|
)
|
20756
20809
|
] });
|
20757
20810
|
}
|
20811
|
+
if (status === "processing") {
|
20812
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-col items-center justify-center py-6", children: [
|
20813
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "mb-4", children: renderIcon() }),
|
20814
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("h3", { className: `text-xl font-bold mb-2 ${theme2 === "dark" ? "text-white" : "text-gray-900"}`, children: getStatusTitle() }),
|
20815
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: `text-center ${getMessageClasses()}`, children: message }),
|
20816
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "w-full mt-6 mb-2", children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "w-full bg-gray-200 rounded-full h-2.5", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
20817
|
+
"div",
|
20818
|
+
{
|
20819
|
+
className: "bg-blue-600 h-2.5 rounded-full transition-all duration-500",
|
20820
|
+
style: {
|
20821
|
+
width: `${Math.min(100, progressStage / 3 * 100)}%`
|
20822
|
+
}
|
20823
|
+
}
|
20824
|
+
) }) }),
|
20825
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "w-full grid grid-cols-3 gap-1 mb-4", children: [
|
20826
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: `text-xs text-center ${progressStage >= 1 ? "text-blue-600 font-medium" : "text-gray-400"}`, children: "Submitted" }),
|
20827
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: `text-xs text-center ${progressStage >= 2 ? "text-blue-600 font-medium" : "text-gray-400"}`, children: "Detected" }),
|
20828
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: `text-xs text-center ${progressStage >= 3 ? "text-blue-600 font-medium" : "text-gray-400"}`, children: "Confirming" })
|
20829
|
+
] }),
|
20830
|
+
transactionHash && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "w-full my-3 px-4", children: [
|
20831
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xs text-center text-gray-600 mb-2", children: "Transaction ID:" }),
|
20832
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "bg-gray-50 border border-gray-200 rounded-md p-2 text-center", children: /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-xs font-mono text-gray-700", children: formatTransactionHash(transactionHash) }) })
|
20833
|
+
] }),
|
20834
|
+
paymentNetwork && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "w-full mt-4 mb-2 p-3 bg-blue-50 rounded-md text-center", children: [
|
20835
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("p", { className: "text-xs text-blue-800", children: [
|
20836
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "font-medium", children: "Estimated confirmation time:" }),
|
20837
|
+
" ",
|
20838
|
+
getEstimatedConfirmationTime(paymentNetwork)
|
20839
|
+
] }),
|
20840
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("p", { className: "text-xs text-blue-600 mt-1", children: [
|
20841
|
+
"Processing time: ",
|
20842
|
+
formatTime(processingSeconds)
|
20843
|
+
] })
|
20844
|
+
] }),
|
20845
|
+
showEarlySuccessOption && onClose && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "w-full mt-4", children: [
|
20846
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "mb-2 p-3 bg-yellow-50 rounded-md", children: /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xs text-center text-yellow-800", children: "Taking longer than expected? Your payment may already be complete. You can proceed now or continue waiting for confirmation." }) }),
|
20847
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
20848
|
+
"button",
|
20849
|
+
{
|
20850
|
+
onClick: handleEarlySuccess,
|
20851
|
+
className: "w-full py-2 px-4 bg-gray-200 text-purple-600 font-medium rounded-md hover:bg-gray-300 transition-colors",
|
20852
|
+
children: "Continue to Order Confirmation"
|
20853
|
+
}
|
20854
|
+
)
|
20855
|
+
] }),
|
20856
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: `mt-4 text-xs ${theme2 === "dark" ? "text-gray-400" : "text-gray-500"}`, children: "Blockchain transactions can take a few moments to confirm. Please wait..." })
|
20857
|
+
] });
|
20858
|
+
}
|
20859
|
+
if (status === "error") {
|
20860
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-col items-center justify-center py-6", children: [
|
20861
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "mb-4", children: renderIcon() }),
|
20862
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("h3", { className: `text-xl font-bold mb-2 ${theme2 === "dark" ? "text-white" : "text-gray-900"}`, children: "Payment Failed" }),
|
20863
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: `text-center ${getMessageClasses()}`, children: message }),
|
20864
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: `mt-4 p-2 rounded ${theme2 === "dark" ? "bg-gray-700" : "bg-gray-100"}`, children: /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: `text-xs ${theme2 === "dark" ? "text-gray-300" : "text-gray-600"}`, children: "Please try again or contact support if the problem persists." }) })
|
20865
|
+
] });
|
20866
|
+
}
|
20758
20867
|
return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-col items-center justify-center py-6", children: [
|
20759
20868
|
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "mb-4", children: renderIcon() }),
|
20760
20869
|
/* @__PURE__ */ jsxRuntimeExports.jsx("h3", { className: `text-xl font-bold mb-2 ${theme2 === "dark" ? "text-white" : "text-gray-900"}`, children: getStatusTitle() }),
|
20761
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: `text-center ${getMessageClasses()}`, children: message })
|
20762
|
-
status === "processing" && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: `mt-4 text-xs ${theme2 === "dark" ? "text-gray-400" : "text-gray-500"}`, children: "This may take a few moments. Please do not close this window." }),
|
20763
|
-
status === "error" && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: `mt-4 p-2 rounded ${theme2 === "dark" ? "bg-gray-700" : "bg-gray-100"}`, children: /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: `text-xs ${theme2 === "dark" ? "text-gray-300" : "text-gray-600"}`, children: "Please try again or contact support if the problem persists." }) })
|
20870
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: `text-center ${getMessageClasses()}`, children: message })
|
20764
20871
|
] });
|
20765
20872
|
};
|
20766
20873
|
const PaymentMethods = ({ onSelect, selected, theme: theme2 = "light", supportedNetworks = [] }) => {
|
@@ -21136,7 +21243,12 @@ const CoinleyModal = ({
|
|
21136
21243
|
supportedWallets = [],
|
21137
21244
|
step = "select-currency",
|
21138
21245
|
merchantWalletAddresses = {},
|
21139
|
-
debug = false
|
21246
|
+
debug = false,
|
21247
|
+
// New props for enhanced processing feedback
|
21248
|
+
processingStartTime = null,
|
21249
|
+
transactionDetected = false,
|
21250
|
+
paymentNetwork = null,
|
21251
|
+
onEarlySuccess = null
|
21140
21252
|
}) => {
|
21141
21253
|
const [paymentType, setPaymentType] = useState("wallet");
|
21142
21254
|
const getWalletAddressForNetwork = () => {
|
@@ -21152,7 +21264,16 @@ const CoinleyModal = ({
|
|
21152
21264
|
return "No wallet address configured for this network";
|
21153
21265
|
};
|
21154
21266
|
const handleSuccessClose = () => {
|
21155
|
-
|
21267
|
+
console.log("Success screen close button clicked");
|
21268
|
+
if (onClose) {
|
21269
|
+
onClose();
|
21270
|
+
}
|
21271
|
+
};
|
21272
|
+
const handleEarlySuccess = () => {
|
21273
|
+
console.log("Early success button clicked");
|
21274
|
+
if (onEarlySuccess) {
|
21275
|
+
onEarlySuccess();
|
21276
|
+
}
|
21156
21277
|
};
|
21157
21278
|
const formatAmount = (amount) => {
|
21158
21279
|
return parseFloat(amount).toFixed(2);
|
@@ -21201,7 +21322,7 @@ const CoinleyModal = ({
|
|
21201
21322
|
/* @__PURE__ */ jsxRuntimeExports.jsx("img", { src: logo, className: "w-auto h-auto", alt: "Coinley Logo" }),
|
21202
21323
|
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-lg font-semibold text-gray-800", children: "Payment Details" })
|
21203
21324
|
] }),
|
21204
|
-
step !== "success" && /* @__PURE__ */ jsxRuntimeExports.jsx(
|
21325
|
+
step !== "success" && step !== "processing" && /* @__PURE__ */ jsxRuntimeExports.jsx(
|
21205
21326
|
"button",
|
21206
21327
|
{
|
21207
21328
|
onClick: onClose,
|
@@ -21380,7 +21501,11 @@ const CoinleyModal = ({
|
|
21380
21501
|
{
|
21381
21502
|
status: "processing",
|
21382
21503
|
theme: theme2,
|
21383
|
-
message: "Processing your payment..."
|
21504
|
+
message: transactionDetected ? "Transaction detected! Waiting for blockchain confirmation..." : "Processing your payment...",
|
21505
|
+
processingStartTime,
|
21506
|
+
paymentNetwork: paymentNetwork || (selectedPaymentMethod == null ? void 0 : selectedPaymentMethod.network),
|
21507
|
+
transactionHash,
|
21508
|
+
onEarlySuccess: handleEarlySuccess
|
21384
21509
|
}
|
21385
21510
|
),
|
21386
21511
|
step === "success" && /* @__PURE__ */ jsxRuntimeExports.jsx(
|
@@ -21447,7 +21572,12 @@ const CoinleyCheckout = forwardRef(({
|
|
21447
21572
|
testMode = false,
|
21448
21573
|
supportedNetworks = [],
|
21449
21574
|
preferredNetwork = NETWORK_TYPES.ETHEREUM,
|
21450
|
-
preferredWallet = WALLET_TYPES.METAMASK
|
21575
|
+
preferredWallet = WALLET_TYPES.METAMASK,
|
21576
|
+
// New props for payment processing
|
21577
|
+
confirmations = 1,
|
21578
|
+
// Minimum confirmations required (lower = faster)
|
21579
|
+
fastMode = false
|
21580
|
+
// When true, will show success screen faster with fewer confirmations
|
21451
21581
|
}, ref) => {
|
21452
21582
|
const coinleyContext = useCoinley();
|
21453
21583
|
const { theme: contextTheme } = useTheme();
|
@@ -21461,6 +21591,10 @@ const CoinleyCheckout = forwardRef(({
|
|
21461
21591
|
const [availableWallets, setAvailableWallets] = useState({});
|
21462
21592
|
const [step, setStep] = useState("select-currency");
|
21463
21593
|
const [actualMerchantWallets, setActualMerchantWallets] = useState({});
|
21594
|
+
const [processingStartTime, setProcessingStartTime] = useState(null);
|
21595
|
+
const [transactionDetected, setTransactionDetected] = useState(false);
|
21596
|
+
const [checkingInterval, setCheckingInterval] = useState(null);
|
21597
|
+
const processingTimerRef = useRef(null);
|
21464
21598
|
const effectiveApiKey = apiKey || (coinleyContext == null ? void 0 : coinleyContext.apiKey);
|
21465
21599
|
const effectiveApiSecret = apiSecret || (coinleyContext == null ? void 0 : coinleyContext.apiSecret);
|
21466
21600
|
apiUrl || (coinleyContext == null ? void 0 : coinleyContext.apiUrl);
|
@@ -21498,6 +21632,86 @@ const CoinleyCheckout = forwardRef(({
|
|
21498
21632
|
detectWalletsAsync();
|
21499
21633
|
}
|
21500
21634
|
}, [effectiveDebug]);
|
21635
|
+
useEffect(() => {
|
21636
|
+
return () => {
|
21637
|
+
if (processingTimerRef.current) {
|
21638
|
+
clearTimeout(processingTimerRef.current);
|
21639
|
+
}
|
21640
|
+
if (checkingInterval) {
|
21641
|
+
clearInterval(checkingInterval);
|
21642
|
+
}
|
21643
|
+
};
|
21644
|
+
}, [checkingInterval]);
|
21645
|
+
useEffect(() => {
|
21646
|
+
if (transactionHash && paymentStatus === "loading" && step === "processing" && !checkingInterval) {
|
21647
|
+
setTransactionDetected(true);
|
21648
|
+
if (!testMode) {
|
21649
|
+
const interval = setInterval(() => __async(void 0, null, function* () {
|
21650
|
+
try {
|
21651
|
+
const processingTime = Date.now() - processingStartTime;
|
21652
|
+
if (fastMode && processingTime > getMinimumProcessingTime()) {
|
21653
|
+
log("Fast mode: Moving to success state early");
|
21654
|
+
clearInterval(interval);
|
21655
|
+
setCheckingInterval(null);
|
21656
|
+
handleEarlySuccess();
|
21657
|
+
return;
|
21658
|
+
}
|
21659
|
+
} catch (err) {
|
21660
|
+
log("Error checking transaction status:", err);
|
21661
|
+
}
|
21662
|
+
}), 5e3);
|
21663
|
+
setCheckingInterval(interval);
|
21664
|
+
}
|
21665
|
+
}
|
21666
|
+
return () => {
|
21667
|
+
if (checkingInterval) {
|
21668
|
+
clearInterval(checkingInterval);
|
21669
|
+
}
|
21670
|
+
};
|
21671
|
+
}, [transactionHash, paymentStatus, step, testMode, processingStartTime, fastMode]);
|
21672
|
+
const getMinimumProcessingTime = () => {
|
21673
|
+
if (!selectedPaymentMethod)
|
21674
|
+
return 2e4;
|
21675
|
+
const times = {
|
21676
|
+
[NETWORK_TYPES.ETHEREUM]: 15e3,
|
21677
|
+
// 15 seconds for Ethereum
|
21678
|
+
[NETWORK_TYPES.BSC]: 1e4,
|
21679
|
+
// 10 seconds for BSC
|
21680
|
+
[NETWORK_TYPES.TRON]: 8e3,
|
21681
|
+
// 8 seconds for Tron
|
21682
|
+
[NETWORK_TYPES.ALGORAND]: 5e3
|
21683
|
+
// 5 seconds for Algorand
|
21684
|
+
};
|
21685
|
+
return times[selectedPaymentMethod.network] || 15e3;
|
21686
|
+
};
|
21687
|
+
const handleEarlySuccess = () => __async(void 0, null, function* () {
|
21688
|
+
if (!payment || !selectedPaymentMethod || !transactionHash) {
|
21689
|
+
return;
|
21690
|
+
}
|
21691
|
+
log("Moving to early success state with transaction:", transactionHash);
|
21692
|
+
try {
|
21693
|
+
const processResponse = yield processPayment({
|
21694
|
+
paymentId: payment.id,
|
21695
|
+
transactionHash,
|
21696
|
+
network: selectedPaymentMethod.network,
|
21697
|
+
currency: selectedPaymentMethod.currency,
|
21698
|
+
senderAddress: walletConnection == null ? void 0 : walletConnection.address,
|
21699
|
+
early: true
|
21700
|
+
});
|
21701
|
+
log("Early payment processed:", processResponse);
|
21702
|
+
setPaymentStatus("success");
|
21703
|
+
setStep("success");
|
21704
|
+
if (onSuccess) {
|
21705
|
+
onSuccess(payment.id, transactionHash, {
|
21706
|
+
network: selectedPaymentMethod.network,
|
21707
|
+
currency: selectedPaymentMethod.currency,
|
21708
|
+
amount: payment.totalAmount || payment.amount
|
21709
|
+
});
|
21710
|
+
}
|
21711
|
+
} catch (err) {
|
21712
|
+
log("Early success processing error:", err);
|
21713
|
+
}
|
21714
|
+
});
|
21501
21715
|
useImperativeHandle(ref, () => ({
|
21502
21716
|
open: (paymentDetails) => {
|
21503
21717
|
handleOpen(paymentDetails);
|
@@ -21554,11 +21768,21 @@ const CoinleyCheckout = forwardRef(({
|
|
21554
21768
|
}
|
21555
21769
|
});
|
21556
21770
|
const handleClose = () => {
|
21771
|
+
if (checkingInterval) {
|
21772
|
+
clearInterval(checkingInterval);
|
21773
|
+
setCheckingInterval(null);
|
21774
|
+
}
|
21775
|
+
if (processingTimerRef.current) {
|
21776
|
+
clearTimeout(processingTimerRef.current);
|
21777
|
+
processingTimerRef.current = null;
|
21778
|
+
}
|
21557
21779
|
setIsOpen(false);
|
21558
21780
|
setTransactionHash(null);
|
21559
21781
|
setWalletConnection(null);
|
21560
21782
|
setSelectedPaymentMethod(null);
|
21561
21783
|
setStep("select-currency");
|
21784
|
+
setProcessingStartTime(null);
|
21785
|
+
setTransactionDetected(false);
|
21562
21786
|
if (onClose)
|
21563
21787
|
onClose();
|
21564
21788
|
};
|
@@ -21621,11 +21845,14 @@ const CoinleyCheckout = forwardRef(({
|
|
21621
21845
|
setPaymentStatus("loading");
|
21622
21846
|
setTransactionHash(null);
|
21623
21847
|
setStep("processing");
|
21848
|
+
setProcessingStartTime(Date.now());
|
21849
|
+
setTransactionDetected(false);
|
21624
21850
|
try {
|
21625
21851
|
let txHash;
|
21626
21852
|
if (testMode) {
|
21627
21853
|
log("Test mode: Generating mock transaction...");
|
21628
21854
|
txHash = `test_${Date.now().toString(16)}_${Math.random().toString(16).substring(2, 10)}`;
|
21855
|
+
yield new Promise((resolve) => setTimeout(resolve, 2e3));
|
21629
21856
|
} else {
|
21630
21857
|
let merchantAddress;
|
21631
21858
|
if (payment.recipientWallet) {
|
@@ -21648,24 +21875,46 @@ const CoinleyCheckout = forwardRef(({
|
|
21648
21875
|
}
|
21649
21876
|
log("Transaction hash:", txHash);
|
21650
21877
|
setTransactionHash(txHash);
|
21651
|
-
|
21652
|
-
|
21653
|
-
|
21654
|
-
|
21655
|
-
|
21656
|
-
|
21657
|
-
|
21658
|
-
|
21659
|
-
|
21660
|
-
|
21661
|
-
|
21662
|
-
|
21663
|
-
|
21664
|
-
|
21878
|
+
if (testMode) {
|
21879
|
+
processingTimerRef.current = setTimeout(() => {
|
21880
|
+
log("Test mode: Moving to success state");
|
21881
|
+
setPaymentStatus("success");
|
21882
|
+
setStep("success");
|
21883
|
+
if (onSuccess) {
|
21884
|
+
log("Calling onSuccess callback...");
|
21885
|
+
onSuccess(payment.id, txHash, {
|
21886
|
+
network: selectedPaymentMethod.network,
|
21887
|
+
currency: selectedPaymentMethod.currency,
|
21888
|
+
amount: payment.totalAmount || payment.amount
|
21889
|
+
});
|
21890
|
+
}
|
21891
|
+
}, 2e3);
|
21892
|
+
return;
|
21893
|
+
}
|
21894
|
+
try {
|
21895
|
+
log("Processing payment with backend...");
|
21896
|
+
const processResponse = yield processPayment({
|
21897
|
+
paymentId: payment.id,
|
21898
|
+
transactionHash: txHash,
|
21665
21899
|
network: selectedPaymentMethod.network,
|
21666
21900
|
currency: selectedPaymentMethod.currency,
|
21667
|
-
|
21901
|
+
senderAddress: walletConnection == null ? void 0 : walletConnection.address,
|
21902
|
+
confirmations
|
21903
|
+
// Use specified confirmation level
|
21668
21904
|
});
|
21905
|
+
log("Payment processed successfully:", processResponse);
|
21906
|
+
setPaymentStatus("success");
|
21907
|
+
setStep("success");
|
21908
|
+
if (onSuccess) {
|
21909
|
+
log("Calling onSuccess callback...");
|
21910
|
+
onSuccess(payment.id, txHash, {
|
21911
|
+
network: selectedPaymentMethod.network,
|
21912
|
+
currency: selectedPaymentMethod.currency,
|
21913
|
+
amount: payment.totalAmount || payment.amount
|
21914
|
+
});
|
21915
|
+
}
|
21916
|
+
} catch (processError) {
|
21917
|
+
log("Payment processing error, but transaction was sent:", processError);
|
21669
21918
|
}
|
21670
21919
|
} catch (err) {
|
21671
21920
|
log("Payment error:", err);
|
@@ -21704,7 +21953,11 @@ const CoinleyCheckout = forwardRef(({
|
|
21704
21953
|
supportedWallets: getSupportedWallets(),
|
21705
21954
|
step,
|
21706
21955
|
merchantWalletAddresses: actualMerchantWallets,
|
21707
|
-
debug: effectiveDebug
|
21956
|
+
debug: effectiveDebug,
|
21957
|
+
processingStartTime,
|
21958
|
+
transactionDetected,
|
21959
|
+
paymentNetwork: selectedPaymentMethod == null ? void 0 : selectedPaymentMethod.network,
|
21960
|
+
onEarlySuccess: handleEarlySuccess
|
21708
21961
|
}
|
21709
21962
|
) });
|
21710
21963
|
});
|