Move ensure 3ds contingency logic to woocommerce_paypal_payments_gateway_migrate action

This commit is contained in:
dinamiko 2022-02-03 16:23:23 +01:00
parent d12a9d3547
commit 53b017ae31
2 changed files with 11 additions and 20 deletions

View file

@ -208,25 +208,6 @@ class SettingsListener {
exit;
}
/**
* Ensure 3DS contingency use `SCA_ALWAYS` instead of `3D_SECURE`.
*
* @return void
* @throws NotFoundException When a setting was not found.
*/
public function listen_for_3d_secure_contingency(): void {
if ( ! $this->is_valid_site_request() || $this->settings->get( '3d_secure_contingency' ) !== '3D_SECURE' ) {
return;
}
$this->settings->set( '3d_secure_contingency', 'SCA_ALWAYS' );
$this->settings->persist();
$redirect_url = admin_url( 'admin.php?page=wc-settings&tab=checkout&section=ppcp-gateway' );
wp_safe_redirect( $redirect_url, 302 );
exit;
}
/**
* Listens to the request.
*

View file

@ -132,6 +132,17 @@ class WCGatewayModule implements ModuleInterface {
$endpoint->handle_request();
}
);
add_action(
'woocommerce_paypal_payments_gateway_migrate',
static function () use ( $c ) {
$settings = $c->get( 'wcgateway.settings' );
if ( $settings->get( '3d_secure_contingency' ) === '3D_SECURE' ) {
$settings->set( '3d_secure_contingency', 'SCA_ALWAYS' );
$settings->persist();
}
}
);
}
/**
@ -183,7 +194,6 @@ class WCGatewayModule implements ModuleInterface {
*/
$listener->listen_for_merchant_id();
$listener->listen_for_vaulting_enabled();
$listener->listen_for_3d_secure_contingency();
}
);