From 2c8a56f2d21e2659401b9d68e60e7e093db0fe9f Mon Sep 17 00:00:00 2001 From: Alfredo Sumaran Date: Wed, 22 Jan 2025 07:20:35 -0500 Subject: [PATCH] Add Bacs LPM feature flag (#3754) --- .../admin/class-wc-stripe-settings-controller.php | 1 + includes/class-wc-stripe-feature-flags.php | 13 ++++++++++++- .../class-wc-stripe-upe-payment-gateway.php | 3 +++ 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/includes/admin/class-wc-stripe-settings-controller.php b/includes/admin/class-wc-stripe-settings-controller.php index 61815f96b..96f494080 100644 --- a/includes/admin/class-wc-stripe-settings-controller.php +++ b/includes/admin/class-wc-stripe-settings-controller.php @@ -182,6 +182,7 @@ public function admin_scripts( $hook_suffix ) { 'i18n_out_of_sync' => $message, 'is_upe_checkout_enabled' => WC_Stripe_Feature_Flags::is_upe_checkout_enabled(), 'is_ach_enabled' => WC_Stripe_Feature_Flags::is_ach_lpm_enabled(), + 'is_bacs_enabled' => WC_Stripe_Feature_Flags::is_bacs_lpm_enabled(), 'stripe_oauth_url' => $oauth_url, 'stripe_test_oauth_url' => $test_oauth_url, 'show_customization_notice' => get_option( 'wc_stripe_show_customization_notice', 'yes' ) === 'yes' ? true : false, diff --git a/includes/class-wc-stripe-feature-flags.php b/includes/class-wc-stripe-feature-flags.php index 05d50f7fb..032ebd3bd 100644 --- a/includes/class-wc-stripe-feature-flags.php +++ b/includes/class-wc-stripe-feature-flags.php @@ -7,7 +7,8 @@ class WC_Stripe_Feature_Flags { const UPE_CHECKOUT_FEATURE_ATTRIBUTE_NAME = 'upe_checkout_experience_enabled'; const ECE_FEATURE_FLAG_NAME = '_wcstripe_feature_ece'; - const LPM_ACH_FEATURE_FLAG_NAME = '_wcstripe_feature_lpm_ach'; + const LPM_ACH_FEATURE_FLAG_NAME = '_wcstripe_feature_lpm_ach'; + const LPM_BACS_FEATURE_FLAG_NAME = '_wcstripe_feature_lpm_bacs'; /** * Checks whether ACH LPM (Local Payment Method) feature flag is enabled. @@ -19,6 +20,16 @@ public static function is_ach_lpm_enabled() { return 'yes' === get_option( self::LPM_ACH_FEATURE_FLAG_NAME, 'no' ); } + /** + * Checks whether Bacs LPM (Local Payment Method) feature flag is enabled. + * Alows the merchant to enable/disable Bacs payment method. + * + * @return bool + */ + public static function is_bacs_lpm_enabled(): bool { + return 'yes' === get_option( self::LPM_BACS_FEATURE_FLAG_NAME, 'no' ); + } + /** * Checks whether Stripe ECE (Express Checkout Element) feature flag is enabled. * Express checkout buttons are rendered with either ECE or PRB depending on this feature flag. diff --git a/includes/payment-methods/class-wc-stripe-upe-payment-gateway.php b/includes/payment-methods/class-wc-stripe-upe-payment-gateway.php index 01ffd084a..c494fef35 100644 --- a/includes/payment-methods/class-wc-stripe-upe-payment-gateway.php +++ b/includes/payment-methods/class-wc-stripe-upe-payment-gateway.php @@ -416,6 +416,9 @@ public function javascript_params() { // ACH LPM Feature flag. $stripe_params['is_ach_enabled'] = WC_Stripe_Feature_Flags::is_ach_lpm_enabled(); + // Bacs LPM Feature flag. + $stripe_params['is_bacs_enabled'] = WC_Stripe_Feature_Flags::is_bacs_lpm_enabled(); + $cart_total = ( WC()->cart ? WC()->cart->get_total( '' ) : 0 ); $currency = get_woocommerce_currency();