added another state of error in payment if the payment is a success but the treatment has an error
This commit is contained in:
@@ -20,6 +20,7 @@ export async function onApprove(data, actions) {
|
||||
// (1) Recoverable INSTRUMENT_DECLINED -> call actions.restart()
|
||||
// (2) Other non-recoverable errors -> Show a failure message
|
||||
// (3) Successful transaction -> Show confirmation or thank you message
|
||||
// + hugogogo treatment error but success order
|
||||
|
||||
const errorDetail = orderData?.details?.[0];
|
||||
|
||||
@@ -33,7 +34,13 @@ export async function onApprove(data, actions) {
|
||||
throw new Error(`${errorDetail.description} (${orderData.debug_id})`);
|
||||
}
|
||||
else if (!orderData.purchase_units) {
|
||||
throw new Error(JSON.stringify(orderData));
|
||||
if (orderData.ERROR_TREATMENT) {
|
||||
console.log("Capture result",orderData);
|
||||
resultMessage(PLGNTLS_data.paypal_message_problem);
|
||||
}
|
||||
else {
|
||||
throw new Error(JSON.stringify(orderData));
|
||||
}
|
||||
}
|
||||
else {
|
||||
// (3) Successful transaction -> Show confirmation or thank you message
|
||||
@@ -45,7 +52,8 @@ export async function onApprove(data, actions) {
|
||||
resultMessage(PLGNTLS_data.paypal_message_success);
|
||||
actions.redirect(PLGNTLS_data.paypal_redirection_success);
|
||||
}
|
||||
} catch (error) {
|
||||
}
|
||||
catch (error) {
|
||||
console.error(error);
|
||||
resultMessage(PLGNTLS_data.paypal_message_failure);
|
||||
actions.redirect(PLGNTLS_data.paypal_redirection_failure);
|
||||
|
||||
Reference in New Issue
Block a user