Add feature flag for AppSwitch

This commit is contained in:
Himad M 2025-07-15 10:49:12 -04:00
parent 2c59a006f5
commit 4acdda7cd8
No known key found for this signature in database
GPG key ID: 5FC769E9888A7B98
5 changed files with 22 additions and 0 deletions

View file

@ -401,6 +401,7 @@ export const PayPalComponent = ( {
const shouldEnableAppSwitch = () => {
// AppSwitch should only be enabled in Pay Now flows with server side shipping callback.
return (
config.scriptData.appswitch.enabled &&
! config.scriptData.final_review_enabled &&
config.scriptData.server_side_shipping_callback.enabled
);

View file

@ -252,6 +252,7 @@ class Renderer {
shouldEnableAppSwitch = () => {
// AppSwitch should only be enabled in Pay Now flows with server side shipping callback.
return (
this.defaultSettings.appswitch.enabled &&
! this.defaultSettings.final_review_enabled &&
this.defaultSettings.server_side_shipping_callback.enabled
);

View file

@ -169,6 +169,7 @@ return array(
$container->get( 'woocommerce.logger.woocommerce' ),
$container->get( 'button.handle-shipping-in-paypal' ),
$container->get( 'wcgateway.server-side-shipping-callback-enabled' ),
$container->get( 'wcgateway.appswitch-enabled' ),
$container->get( 'button.helper.disabled-funding-sources' ),
$container->get( 'wcgateway.configuration.card-configuration' ),
$container->get( 'api.helper.partner-attribution' ),

View file

@ -259,6 +259,11 @@ class SmartButton implements SmartButtonInterface {
*/
private bool $server_side_shipping_callback_enabled;
/**
* Whether the AppSwitch is enabled (feature flag).
*/
private bool $appswitch_enabled;
/**
* Whether the final review is enabled in blocks settings.
*/
@ -291,6 +296,7 @@ class SmartButton implements SmartButtonInterface {
* @param LoggerInterface $logger The logger.
* @param bool $should_handle_shipping_in_paypal Whether the shipping should be handled in PayPal.
* @param bool $server_side_shipping_callback_enabled Whether the server-side shipping callback is enabled (feature flag).
* @param bool $appswitch_enabled Whether the AppSwitch is enabled (feature flag).
* @param DisabledFundingSources $disabled_funding_sources List of funding sources to be disabled.
* @param CardPaymentsConfiguration $dcc_configuration The DCC Gateway Configuration.
* @param PartnerAttribution $partner_attribution The PayPal Partner Attribution Helper.
@ -321,6 +327,7 @@ class SmartButton implements SmartButtonInterface {
LoggerInterface $logger,
bool $should_handle_shipping_in_paypal,
bool $server_side_shipping_callback_enabled,
bool $appswitch_enabled,
DisabledFundingSources $disabled_funding_sources,
CardPaymentsConfiguration $dcc_configuration,
PartnerAttribution $partner_attribution,
@ -350,6 +357,7 @@ class SmartButton implements SmartButtonInterface {
$this->payment_tokens_endpoint = $payment_tokens_endpoint;
$this->should_handle_shipping_in_paypal = $should_handle_shipping_in_paypal;
$this->server_side_shipping_callback_enabled = $server_side_shipping_callback_enabled;
$this->appswitch_enabled = $appswitch_enabled;
$this->disabled_funding_sources = $disabled_funding_sources;
$this->dcc_configuration = $dcc_configuration;
$this->partner_attribution = $partner_attribution;
@ -1365,6 +1373,9 @@ document.querySelector("#payment").before(document.querySelector(".ppcp-messages
'server_side_shipping_callback' => array(
'enabled' => $this->server_side_shipping_callback_enabled,
),
'appswitch' => array(
'enabled' => $this->appswitch_enabled,
),
'needShipping' => $this->need_shipping(),
'vaultingEnabled' => $this->settings->has( 'vault_enabled' ) && $this->settings->get( 'vault_enabled' ),
'productType' => null,

View file

@ -2265,4 +2265,12 @@ return array(
getenv( 'PCP_SERVER_SIDE_SHIPPING_CALLBACK_ENABLED' ) === '1'
);
},
'wcgateway.appswitch-enabled' => static function( ContainerInterface $container ) : bool {
return apply_filters(
// phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores
'woocommerce.feature-flags.woocommerce_paypal_payments.appswitch_enabled',
getenv( 'PCP_APPSWITCH_ENABLED' ) === '1'
);
},
);