@volr/react-ui 0.1.134 → 0.1.135
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/index.cjs +25 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +25 -1
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -6021,6 +6021,15 @@ function usePaymentModalState(open, onOpenChange) {
|
|
|
6021
6021
|
});
|
|
6022
6022
|
createdPaymentId = payment.id;
|
|
6023
6023
|
dispatch({ type: "SET_CREATED_PAYMENT", payment });
|
|
6024
|
+
if (payment.status !== "PENDING") {
|
|
6025
|
+
const alreadyProcessedError = new Error(
|
|
6026
|
+
payment.status === "CONFIRMED" ? "This payment has already been completed. If you used an idempotencyKey, the original payment was already processed." : `Payment already processed with status: ${payment.status}. If you used an idempotencyKey, the original payment was already processed.`
|
|
6027
|
+
);
|
|
6028
|
+
alreadyProcessedError.code = "PAYMENT_ALREADY_PROCESSED";
|
|
6029
|
+
alreadyProcessedError.paymentStatus = payment.status;
|
|
6030
|
+
alreadyProcessedError.payment = payment;
|
|
6031
|
+
throw alreadyProcessedError;
|
|
6032
|
+
}
|
|
6024
6033
|
paymentOptions.options.handlers?.onCreated?.({ id: payment.id });
|
|
6025
6034
|
const evmClient = evm.client(tokenInfo.chainId);
|
|
6026
6035
|
dispatch({ type: "SET_PROCESSING_STEP", step: "broadcasting" });
|
|
@@ -6066,13 +6075,28 @@ function usePaymentModalState(open, onOpenChange) {
|
|
|
6066
6075
|
}
|
|
6067
6076
|
} catch (err) {
|
|
6068
6077
|
console.error("Payment failed:", err);
|
|
6069
|
-
|
|
6078
|
+
const isAlreadyProcessed = err.code === "PAYMENT_ALREADY_PROCESSED";
|
|
6079
|
+
if (createdPaymentId && !isAlreadyProcessed) {
|
|
6070
6080
|
try {
|
|
6071
6081
|
await failPendingPayment(createdPaymentId);
|
|
6072
6082
|
} catch (failErr) {
|
|
6073
6083
|
console.error("Failed to mark payment as failed:", failErr);
|
|
6074
6084
|
}
|
|
6075
6085
|
}
|
|
6086
|
+
if (isAlreadyProcessed && err.payment) {
|
|
6087
|
+
dispatch({ type: "PAYMENT_SUCCESS", payment: err.payment });
|
|
6088
|
+
if (err.payment.status === "CONFIRMED") {
|
|
6089
|
+
paymentOptions?.onComplete?.(err.payment);
|
|
6090
|
+
} else {
|
|
6091
|
+
const paymentError2 = {
|
|
6092
|
+
code: err.code || "PAYMENT_ALREADY_PROCESSED",
|
|
6093
|
+
message: err.message || "Payment already processed."
|
|
6094
|
+
};
|
|
6095
|
+
dispatch({ type: "PAYMENT_ERROR", error: paymentError2 });
|
|
6096
|
+
paymentOptions?.onError?.(paymentError2);
|
|
6097
|
+
}
|
|
6098
|
+
return;
|
|
6099
|
+
}
|
|
6076
6100
|
const paymentError = {
|
|
6077
6101
|
code: err.code || "PAYMENT_FAILED",
|
|
6078
6102
|
message: err.message || "Payment failed. Please try again."
|