Enable 3DS check for Google Pay

This change finally triggers a `PAYER_ACTION_REQUIRED` status response during checkout.
This commit is contained in:
Philipp Stracker 2025-02-26 18:58:27 +01:00
parent dc90a73f81
commit 021a4b3de7
No known key found for this signature in database

View file

@ -22,6 +22,7 @@ use WooCommerce\PayPalCommerce\Vendor\Inpsyde\Modularity\Module\ModuleClassNameI
use WooCommerce\PayPalCommerce\Vendor\Inpsyde\Modularity\Module\ServiceModule;
use WooCommerce\PayPalCommerce\Vendor\Psr\Container\ContainerInterface;
use WooCommerce\PayPalCommerce\WcGateway\Settings\Settings;
use WooCommerce\PayPalCommerce\WcGateway\Gateway\CreditCardGateway;
/**
* Class GooglepayModule
@ -248,6 +249,42 @@ class GooglepayModule implements ServiceModule, ExtendingModule, ExecutableModul
}
);
add_filter(
'ppcp_create_order_request_body_data',
static function ( array $data, string $payment_method ) use ( $c ) : array {
// TODO (bug): This condition only works when using Google Pay as separate gateway!
// When GooglePay is part of the smart buttons block, this condition fails and will not enable 3DS.
if ( $payment_method !== GooglePayGateway::ID ) {
return $data;
}
$settings = $c->get( 'wcgateway.settings' );
assert( $settings instanceof Settings );
$three_d_secure_contingency =
$settings->has( '3d_secure_contingency' )
? apply_filters( 'woocommerce_paypal_payments_three_d_secure_contingency', $settings->get( '3d_secure_contingency' ) )
: '';
if (
$three_d_secure_contingency === 'SCA_ALWAYS'
|| $three_d_secure_contingency === 'SCA_WHEN_REQUIRED'
) {
$data['payment_source']['google_pay'] = array(
'attributes' => array(
'verification' => array(
'method' => $three_d_secure_contingency,
),
),
);
}
return $data;
},
10,
2
);
return true;
}
}