Enable Fastlane by default for compatible setups

This commit is contained in:
Daniel Dudzic 2025-03-10 23:57:08 +01:00
parent 6078ec3f59
commit d7314a3ebc
No known key found for this signature in database
GPG key ID: 31B40D33E3465483
3 changed files with 160 additions and 38 deletions

View file

@ -9,11 +9,13 @@ declare( strict_types = 1 );
namespace WooCommerce\PayPalCommerce\Settings;
use Mollie\Api\Resources\Payment;
use WC_Payment_Gateway;
use WooCommerce\PayPalCommerce\ApiClient\Endpoint\PartnersEndpoint;
use WooCommerce\PayPalCommerce\ApiClient\Exception\PayPalApiException;
use WooCommerce\PayPalCommerce\ApiClient\Helper\DccApplies;
use WooCommerce\PayPalCommerce\Applepay\Assets\AppleProductStatus;
use WooCommerce\PayPalCommerce\Axo\Gateway\AxoGateway;
use WooCommerce\PayPalCommerce\Googlepay\Helper\ApmProductStatus;
use WooCommerce\PayPalCommerce\LocalAlternativePaymentMethods\BancontactGateway;
use WooCommerce\PayPalCommerce\LocalAlternativePaymentMethods\BlikGateway;
@ -43,6 +45,8 @@ use WooCommerce\PayPalCommerce\Settings\Service\SettingsDataManager;
use WooCommerce\PayPalCommerce\Settings\DTO\ConfigurationFlagsDTO;
use WooCommerce\PayPalCommerce\Settings\Enum\ProductChoicesEnum;
use WooCommerce\PayPalCommerce\Settings\Data\GeneralSettings;
use WooCommerce\PayPalCommerce\Settings\Data\PaymentSettings;
use WooCommerce\PayPalCommerce\Axo\Helper\CompatibilityChecker;
/**
* Class SettingsModule
@ -578,6 +582,24 @@ class SettingsModule implements ServiceModule, ExecutableModule {
}
);
// Enable Fastlane after onboarding if the store is compatible.
add_action(
'woocommerce_paypal_payments_apply_default_configuration',
static function () use ( $container ) {
$compatibility_checker = $container->get( 'axo.helpers.compatibility-checker' );
assert( $compatibility_checker instanceof CompatibilityChecker );
$payment_settings = $container->get( 'settings.data.payment' );
assert( $payment_settings instanceof PaymentSettings );
if ( $compatibility_checker->is_fastlane_compatible() ) {
$payment_settings->toggle_method_state( AxoGateway::ID, true );
}
$payment_settings->save();
}
);
// Redirect payment method links in the WC Payment Gateway to the new UI Payment Methods tab.
$gateway_redirect_service = $container->get( 'settings.service.gateway-redirect' );
assert( $gateway_redirect_service instanceof GatewayRedirectService );