coinley-checkout 0.8.2 → 0.8.4
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.
@@ -21751,65 +21751,46 @@ const CoinleyCheckout = forwardRef(({
|
|
21751
21751
|
}
|
21752
21752
|
};
|
21753
21753
|
}, [checkingInterval]);
|
21754
|
-
useEffect(() => {
|
21755
|
-
if (transactionHash && pendingBackendConfirmation && paymentStatus === "loading") {
|
21756
|
-
const interval = setInterval(() => __async(void 0, null, function* () {
|
21757
|
-
try {
|
21758
|
-
log("Checking payment status with backend...");
|
21759
|
-
const processResponse = yield processPayment({
|
21760
|
-
paymentId: payment.id,
|
21761
|
-
transactionHash,
|
21762
|
-
network: selectedPaymentMethod.network,
|
21763
|
-
currency: selectedPaymentMethod.currency,
|
21764
|
-
senderAddress: walletConnection == null ? void 0 : walletConnection.address,
|
21765
|
-
confirmations,
|
21766
|
-
check: true
|
21767
|
-
// Just check status, don't process again
|
21768
|
-
});
|
21769
|
-
if (processResponse.status === "success") {
|
21770
|
-
log("Payment confirmed by backend!");
|
21771
|
-
clearInterval(interval);
|
21772
|
-
setCheckingInterval(null);
|
21773
|
-
setPendingBackendConfirmation(false);
|
21774
|
-
setPaymentStatus("success");
|
21775
|
-
}
|
21776
|
-
} catch (err) {
|
21777
|
-
log("Error checking payment status:", err);
|
21778
|
-
}
|
21779
|
-
}), 1e4);
|
21780
|
-
setCheckingInterval(interval);
|
21781
|
-
return () => {
|
21782
|
-
clearInterval(interval);
|
21783
|
-
};
|
21784
|
-
}
|
21785
|
-
}, [transactionHash, pendingBackendConfirmation, paymentStatus, payment, selectedPaymentMethod, walletConnection, confirmations]);
|
21786
21754
|
const processBackendConfirmation = () => __async(void 0, null, function* () {
|
21787
21755
|
if (!payment || !selectedPaymentMethod || !transactionHash) {
|
21756
|
+
log("Missing required data for backend confirmation:", {
|
21757
|
+
hasPayment: !!payment,
|
21758
|
+
hasPaymentMethod: !!selectedPaymentMethod,
|
21759
|
+
hasTransactionHash: !!transactionHash
|
21760
|
+
});
|
21788
21761
|
return;
|
21789
21762
|
}
|
21790
21763
|
try {
|
21791
|
-
log("Processing payment with backend..."
|
21764
|
+
log("Processing payment with backend...", {
|
21765
|
+
paymentId: payment.id,
|
21766
|
+
transactionHash,
|
21767
|
+
network: selectedPaymentMethod.network,
|
21768
|
+
currency: selectedPaymentMethod.currency
|
21769
|
+
});
|
21792
21770
|
const processResponse = yield processPayment({
|
21793
21771
|
paymentId: payment.id,
|
21794
21772
|
transactionHash,
|
21795
21773
|
network: selectedPaymentMethod.network,
|
21796
|
-
|
21797
|
-
senderAddress: walletConnection == null ? void 0 : walletConnection.address,
|
21798
|
-
confirmations
|
21774
|
+
senderAddress: walletConnection == null ? void 0 : walletConnection.address
|
21799
21775
|
});
|
21800
|
-
log("Payment processed successfully:", processResponse);
|
21776
|
+
log("Payment processed successfully with backend:", processResponse);
|
21801
21777
|
setPendingBackendConfirmation(false);
|
21778
|
+
setPaymentStatus("success");
|
21802
21779
|
if (onSuccess) {
|
21803
21780
|
log("Calling onSuccess callback...");
|
21804
21781
|
onSuccess(payment.id, transactionHash, {
|
21805
21782
|
network: selectedPaymentMethod.network,
|
21806
21783
|
currency: selectedPaymentMethod.currency,
|
21807
|
-
amount: payment.totalAmount || payment.amount
|
21784
|
+
amount: payment.totalAmount || payment.amount,
|
21785
|
+
processResponse
|
21808
21786
|
});
|
21809
21787
|
}
|
21810
21788
|
} catch (processError) {
|
21811
|
-
log("Payment processing
|
21789
|
+
log("Payment processing failed:", processError);
|
21812
21790
|
setPendingBackendConfirmation(true);
|
21791
|
+
setTimeout(() => {
|
21792
|
+
processBackendConfirmation();
|
21793
|
+
}, 1e4);
|
21813
21794
|
}
|
21814
21795
|
});
|
21815
21796
|
useImperativeHandle(ref, () => ({
|
@@ -21975,6 +21956,7 @@ const CoinleyCheckout = forwardRef(({
|
|
21975
21956
|
log("Transaction hash obtained:", txHash);
|
21976
21957
|
setTransactionHash(txHash);
|
21977
21958
|
setStep("success");
|
21959
|
+
setPaymentStatus("success");
|
21978
21960
|
processBackendConfirmation();
|
21979
21961
|
} catch (err) {
|
21980
21962
|
log("Payment error:", err);
|