💡 Document payment workflow

This commit is contained in:
Philipp Stracker 2024-08-20 14:14:30 +02:00
parent 451dc842ed
commit 63b5055903
No known key found for this signature in database
2 changed files with 21 additions and 4 deletions

View file

@ -587,6 +587,14 @@ class GooglepayButton extends PaymentButton {
return 'APPROVED' === confirmOrderResponse?.status;
};
/**
* This approval mainly confirms that the orderID is valid.
*
* It's still needed because this handler redirects to the checkout page if the server-side
* approval was successful.
*
* @param {string} orderID
*/
const approveOrderServerSide = async ( orderID ) => {
let isApproved = true;
@ -625,6 +633,7 @@ class GooglepayButton extends PaymentButton {
return;
}
// This must be the last step in the process, as it initiates a redirect.
const success = await approveOrderServerSide( id );
if ( success ) {