- wip payment
- already solved success and failure messages and redirection - solved increase date multiple times - users redirection works if error AND partner to posts instead of project
This commit is contained in:
@@ -37,25 +37,30 @@ export async function onApprove(data, actions) {
|
||||
} else if (!orderData.purchase_units) {
|
||||
throw new Error(JSON.stringify(orderData));
|
||||
} else {
|
||||
// (3) Successful transaction -> Show confirmation or thank you message
|
||||
// Or go to another URL: actions.redirect('thank_you.html');
|
||||
const transaction =
|
||||
orderData?.purchase_units?.[0]?.payments?.captures?.[0] ||
|
||||
orderData?.purchase_units?.[0]?.payments?.authorizations?.[0];
|
||||
// to show a message on page
|
||||
//resultMessage(`Transaction ${transaction.status}: ${transaction.id}<br><br>See console for all available details`,);
|
||||
console.log(
|
||||
"Capture result",
|
||||
orderData,
|
||||
JSON.stringify(orderData, null, 2),
|
||||
);
|
||||
actions.redirect('https://local_fipfcard_plugin.com/');
|
||||
try {
|
||||
// (3) Successful transaction -> Show confirmation or thank you message
|
||||
// Or go to another URL: actions.redirect('thank_you.html');
|
||||
const transaction =
|
||||
orderData?.purchase_units?.[0]?.payments?.captures?.[0] ||
|
||||
orderData?.purchase_units?.[0]?.payments?.authorizations?.[0];
|
||||
// to show a message on page
|
||||
//resultMessage(`Transaction ${transaction.status}: ${transaction.id}<br><br>See console for all available details`);
|
||||
resultMessage(eval(PLGNTLS_data.paypal_message_success));
|
||||
console.log(
|
||||
"Capture result",
|
||||
orderData,
|
||||
JSON.stringify(orderData, null, 2),
|
||||
);
|
||||
actions.redirect(PLGNTLS_data.paypal_redirection_success);
|
||||
} catch (error) {
|
||||
console.error("payment ok but error on traitment afterwards : ", error);
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
resultMessage(
|
||||
`Sorry, your transaction could not be processed...<br><br>${error}`,
|
||||
);
|
||||
//resultMessage(`Sorry, your transaction could not be processed...<br><br>${error}`);
|
||||
resultMessage(eval(PLGNTLS_data.paypal_message_failure));
|
||||
actions.redirect(PLGNTLS_data.paypal_redirection_failure);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
// Example function to show a result to the user. Your site's UI library can be used instead.
|
||||
//function resultMessage(message) {
|
||||
export function resultMessage(message) {
|
||||
const buttons = document.querySelector("#paypal-button-container");
|
||||
const container = document.querySelector("#result-message");
|
||||
buttons.style.display = 'none';
|
||||
container.innerHTML = message;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user