Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure 3ds contingency uses SCA_ALWAYS instead of 3D_SECURE (521) #464

Merged
merged 9 commits into from
Feb 7, 2022
4 changes: 2 additions & 2 deletions modules/ppcp-wc-gateway/services.php
Original file line number Diff line number Diff line change
Expand Up @@ -1914,12 +1914,12 @@ static function ( ContainerInterface $container ): AuthorizeOrderActionNotice {
),
'class' => array(),
'input_class' => array( 'wc-enhanced-select' ),
'default' => $container->get( 'api.shop.is-psd2-country' ) ? '3D_SECURE' : 'NO_3D_SECURE',
'default' => $container->get( 'api.shop.is-psd2-country' ) ? 'SCA_WHEN_REQUIRED' : 'NO_3D_SECURE',
'desc_tip' => true,
'options' => array(
'NO_3D_SECURE' => __( 'No 3D Secure (transaction will be denied if 3D Secure is required)', 'woocommerce-paypal-payments' ),
'SCA_WHEN_REQUIRED' => __( '3D Secure when required', 'woocommerce-paypal-payments' ),
'3D_SECURE' => __( 'Always trigger 3D Secure', 'woocommerce-paypal-payments' ),
'SCA_ALWAYS' => __( 'Always trigger 3D Secure', 'woocommerce-paypal-payments' ),
),
'screens' => array(
State::STATE_ONBOARDED,
Expand Down
2 changes: 1 addition & 1 deletion modules/ppcp-wc-gateway/src/Settings/SettingsListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
use WooCommerce\PayPalCommerce\ApiClient\Exception\RuntimeException;
use WooCommerce\PayPalCommerce\ApiClient\Helper\Cache;
use WooCommerce\PayPalCommerce\Onboarding\State;
use WooCommerce\PayPalCommerce\WcGateway\Gateway\CreditCardGateway;
use WooCommerce\PayPalCommerce\WcGateway\Gateway\PayPalGateway;
use WooCommerce\PayPalCommerce\Webhooks\WebhookRegistrar;
use WooCommerce\PayPalCommerce\WcGateway\Exception\NotFoundException;

/**
* Class SettingsListener
Expand Down
13 changes: 13 additions & 0 deletions modules/ppcp-wc-gateway/src/WCGatewayModule.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,19 @@ static function () use ( $c ) {
$endpoint->handle_request();
}
);

add_action(
'woocommerce_paypal_payments_gateway_migrate',
static function () use ( $c ) {
$settings = $c->get( 'wcgateway.settings' );
Copy link
Contributor

@AlexP11223 AlexP11223 Feb 3, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would add a type hint here to help psalm and IDE.

assert( $settings instanceof Settings );

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done! :)

assert( $settings instanceof Settings );

if ( $settings->get( '3d_secure_contingency' ) === '3D_SECURE' ) {
$settings->set( '3d_secure_contingency', 'SCA_ALWAYS' );
$settings->persist();
}
}
);
}

/**
Expand Down