Merge pull request #2792 from woocommerce/PCP-3884-conditionally-add-local-apms

Add local APM gateways only if PayPal gateway is enabled (3884)
This commit is contained in:
Emili Castells 2024-11-19 09:57:11 +01:00 committed by GitHub
commit 45f7b4fa97
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -47,7 +47,7 @@ class LocalAlternativePaymentMethodsModule implements ServiceModule, ExtendingMo
$settings = $c->get( 'wcgateway.settings' );
assert( $settings instanceof Settings );
if ( ! $settings->has( 'allow_local_apm_gateways' ) || $settings->get( 'allow_local_apm_gateways' ) !== true ) {
if ( ! self::should_add_local_apm_gateways( $settings ) ) {
return true;
}
@ -210,4 +210,17 @@ class LocalAlternativePaymentMethodsModule implements ServiceModule, ExtendingMo
return false;
}
/**
* Check if the local APMs should be added to the available payment gateways.
*
* @param Settings $settings PayPal gateway settings.
* @return bool
*/
private function should_add_local_apm_gateways( Settings $settings ): bool {
return $settings->has( 'enabled' )
&& $settings->get( 'enabled' ) === true
&& $settings->has( 'allow_local_apm_gateways' )
&& $settings->get( 'allow_local_apm_gateways' ) === true;
}
}