mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-08-31 06:52:50 +08:00
♻️ Make the final server-side approval conditional
With 3DS the final approval should only fire when the 3DS process was successful. Note that we still need to implement a check to confirm the verification via API
This commit is contained in:
parent
7b579bfc9b
commit
3e2a1f347f
1 changed files with 16 additions and 11 deletions
|
@ -857,6 +857,7 @@ class GooglepayButton extends PaymentButton {
|
|||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Initiates payer action and handles the 3DS contingency.
|
||||
*
|
||||
|
@ -865,14 +866,13 @@ class GooglepayButton extends PaymentButton {
|
|||
const initiatePayerAction = async ( orderID ) => {
|
||||
this.log( 'initiatePayerAction', orderID );
|
||||
|
||||
this.log(
|
||||
'==== Confirm Payment Completed Payer Action Required ====='
|
||||
);
|
||||
await widgetBuilder.paypal
|
||||
.Googlepay()
|
||||
.initiatePayerAction( { orderId: orderID } );
|
||||
|
||||
this.log( '===== Payer Action Completed =====' );
|
||||
// TODO: We need to make a server-side request to check if the 3DS process was successful.
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -947,14 +947,19 @@ class GooglepayButton extends PaymentButton {
|
|||
if ( ! isApprovedByPayPal ) {
|
||||
result = paymentError( 'TRANSACTION FAILED' );
|
||||
} else {
|
||||
/**
|
||||
* This payment requires a 3DS verification before we can process the order.
|
||||
*/
|
||||
if ( isApprovedByPayPal === 'action_required' ) {
|
||||
await initiatePayerAction( orderId );
|
||||
}
|
||||
let success = false;
|
||||
|
||||
const success = await approveOrderServerSide( orderId );
|
||||
// This payment requires a 3DS verification before we can process the order.
|
||||
if ( isApprovedByPayPal === 'action_required' ) {
|
||||
const approved = await initiatePayerAction( orderId );
|
||||
|
||||
// Only approve on server-side when 3DS was successful.
|
||||
if ( approved ) {
|
||||
success = await approveOrderServerSide( orderId );
|
||||
}
|
||||
} else {
|
||||
success = await approveOrderServerSide( orderId );
|
||||
}
|
||||
|
||||
if ( success ) {
|
||||
result = paymentResponse( 'SUCCESS' );
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue