also capturing pending paypal status

This commit is contained in:
Hugo LAMY
2026-02-11 12:33:52 +01:00
parent 17afb658af
commit cae655af7e
3 changed files with 19 additions and 12 deletions

View File

@@ -34,8 +34,11 @@ export async function onApprove(data, actions) {
throw new Error(`${errorDetail.description} (${orderData.debug_id})`);
}
else if (!orderData.purchase_units) {
// Check if error was a server-side issue but PayPal confirmed payment
if (orderData.ERROR_TREATMENT) {
console.log("Capture result",orderData);
console.log("Capture result - Server processing error, but payment may be valid:",orderData);
// Display problem message - payment succeeded on PayPal but failed locally
// User stays on page to see the message
resultMessage(PLGNTLS_data.paypal_message_problem);
}
else {
@@ -48,15 +51,14 @@ export async function onApprove(data, actions) {
const transaction =
orderData?.purchase_units?.[0]?.payments?.captures?.[0] ||
orderData?.purchase_units?.[0]?.payments?.authorizations?.[0];
console.log("Capture result",orderData);
console.log("Capture result - Success:",orderData);
resultMessage(PLGNTLS_data.paypal_message_success);
actions.redirect(PLGNTLS_data.paypal_redirection_success);
}
}
catch (error) {
console.error(error);
console.error("Payment approval error:", error);
resultMessage(PLGNTLS_data.paypal_message_failure);
actions.redirect(PLGNTLS_data.paypal_redirection_failure);
}
}