Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
* Fix - Ensure Amazon Pay, Apple Pay, and Google Pay display settings are managed correctly
* Dev - Add logging with DNS resolution diagnostics for URL validation issues when calling Stripe API
* Fix - Allow payment methods to be disabled when they are not available
* Dev - Removes the `_wcstripe_feature_upe` feature flag and the related method from the `WC_Stripe_Feature_Flags` class
* Dev - Fixes some incorrect subscriptions support implementations for payment methods

= 10.1.0 - 2025-11-11 =
Expand Down
49 changes: 12 additions & 37 deletions includes/admin/stripe-settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -291,44 +291,19 @@
]
);

if ( WC_Stripe_Feature_Flags::is_upe_preview_enabled() ) {
// in the new settings, "checkout" is going to be enabled by default (if it is a new WCStripe installation).
$stripe_settings['express_checkout_button_locations']['default'][] = 'checkout';
// in the new settings, "checkout" is going to be enabled by default (if it is a new WCStripe installation).
$stripe_settings['express_checkout_button_locations']['default'][] = 'checkout';

// no longer needed in the new settings.
unset( $stripe_settings['express_checkout_button_branded_type'] );
unset( $stripe_settings['express_checkout_button_height'] );
unset( $stripe_settings['express_checkout_button_label'] );
// injecting some of the new options.
$stripe_settings['express_checkout_button_type']['options']['default'] = __( 'Only icon', 'woocommerce-gateway-stripe' );
$stripe_settings['express_checkout_button_type']['options']['book'] = __( 'Book', 'woocommerce-gateway-stripe' );
// no longer valid options.
unset( $stripe_settings['express_checkout_button_type']['options']['branded'] );
unset( $stripe_settings['express_checkout_button_type']['options']['custom'] );
} else {
unset( $stripe_settings['express_checkout_button_size'] );
}

if ( WC_Stripe_Feature_Flags::is_upe_preview_enabled() ) {
$upe_settings = [
WC_Stripe_Feature_Flags::UPE_CHECKOUT_FEATURE_ATTRIBUTE_NAME => [
'title' => __( 'New checkout experience', 'woocommerce-gateway-stripe' ),
'label' => sprintf(
/* translators: 1) br tag 2) Stripe anchor tag 3) Apple anchor tag 4) Stripe dashboard opening anchor tag 5) Stripe dashboard closing anchor tag */
__( 'Try the new payment experience (Early access) %1$sGet early access to a new, smarter payment experience on checkout and let us know what you think by %2$s. We recommend this feature for experienced merchants as the functionality is currently limited. %3$s', 'woocommerce-gateway-stripe' ),
'<br />',
'<a href="https://woocommerce.survey.fm/woocommerce-stripe-upe-opt-out-survey" target="_blank">submitting your feedback</a>',
'<a href="https://woocommerce.com/document/stripe/admin-experience/new-checkout-experience/" target="_blank">Learn more</a>'
),
'type' => 'checkbox',
'description' => __( 'New checkout experience allows you to manage all payment methods on one screen and display them to customers based on their currency and location.', 'woocommerce-gateway-stripe' ),
'default' => 'no',
'desc_tip' => true,
],
];
// Insert UPE options below the 'logging' setting.
$stripe_settings = array_merge( $stripe_settings, $upe_settings );
}
// no longer needed in the new settings.
unset( $stripe_settings['express_checkout_button_branded_type'] );
unset( $stripe_settings['express_checkout_button_height'] );
unset( $stripe_settings['express_checkout_button_label'] );
// injecting some of the new options.
$stripe_settings['express_checkout_button_type']['options']['default'] = __( 'Only icon', 'woocommerce-gateway-stripe' );
$stripe_settings['express_checkout_button_type']['options']['book'] = __( 'Book', 'woocommerce-gateway-stripe' );
// no longer valid options.
unset( $stripe_settings['express_checkout_button_type']['options']['branded'] );
unset( $stripe_settings['express_checkout_button_type']['options']['custom'] );

return apply_filters(
'wc_stripe_settings',
Expand Down
4 changes: 3 additions & 1 deletion includes/class-wc-stripe-feature-flags.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,11 @@ public static function is_stripe_ece_enabled() {
* This allows the merchant to enable/disable UPE checkout.
*
* @return bool
*
* @deprecated 10.1.0 UPE is always enabled. This method will be removed in a future release.
*/
public static function is_upe_preview_enabled() {
return 'yes' === self::get_option_with_default( '_wcstripe_feature_upe' );
return true;
}

/**
Expand Down
40 changes: 15 additions & 25 deletions includes/class-wc-stripe.php
Original file line number Diff line number Diff line change
Expand Up @@ -540,9 +540,6 @@ function ( $method ) {
*/
public function filter_gateway_order_admin( $sections ) {
unset( $sections['stripe'] );
if ( WC_Stripe_Feature_Flags::is_upe_preview_enabled() ) {
unset( $sections['stripe_upe'] );
}
unset( $sections['stripe_bancontact'] );
unset( $sections['stripe_sofort'] );
unset( $sections['stripe_giropay'] );
Expand All @@ -553,10 +550,9 @@ public function filter_gateway_order_admin( $sections ) {
unset( $sections['stripe_sepa'] );
unset( $sections['stripe_multibanco'] );

$sections['stripe'] = 'Stripe';
if ( WC_Stripe_Feature_Flags::is_upe_preview_enabled() ) {
$sections['stripe_upe'] = 'Stripe checkout experience';
}
$sections['stripe'] = 'Stripe';
$sections['stripe_upe'] = 'Stripe checkout experience';

$sections['stripe_bancontact'] = __( 'Stripe Bancontact', 'woocommerce-gateway-stripe' );
$sections['stripe_sofort'] = __( 'Stripe Sofort', 'woocommerce-gateway-stripe' );
$sections['stripe_giropay'] = __( 'Stripe giropay', 'woocommerce-gateway-stripe' );
Expand Down Expand Up @@ -591,10 +587,6 @@ public function gateway_settings_update( $settings, $old_settings ) {
// Note that we need to run these checks before we call toggle_upe() below.
$this->maybe_reset_stripe_in_memory_key( $settings, $old_settings );

if ( ! WC_Stripe_Feature_Flags::is_upe_preview_enabled() ) {
return $settings;
}

return $this->toggle_upe( $settings, $old_settings );
}

Expand Down Expand Up @@ -790,24 +782,22 @@ public function register_routes() {
$oauth_connect->register_routes();
$stripe_account_controller->register_routes();

if ( WC_Stripe_Feature_Flags::is_upe_preview_enabled() ) {
require_once WC_STRIPE_PLUGIN_PATH . '/includes/admin/class-wc-rest-stripe-settings-controller.php';
require_once WC_STRIPE_PLUGIN_PATH . '/includes/admin/class-wc-stripe-rest-upe-flag-toggle-controller.php';
require_once WC_STRIPE_PLUGIN_PATH . '/includes/admin/class-wc-rest-stripe-account-keys-controller.php';
require_once WC_STRIPE_PLUGIN_PATH . '/includes/admin/class-wc-stripe-rest-oc-setting-toggle-controller.php';
require_once WC_STRIPE_PLUGIN_PATH . '/includes/admin/class-wc-rest-stripe-settings-controller.php';
require_once WC_STRIPE_PLUGIN_PATH . '/includes/admin/class-wc-stripe-rest-upe-flag-toggle-controller.php';
require_once WC_STRIPE_PLUGIN_PATH . '/includes/admin/class-wc-rest-stripe-account-keys-controller.php';
require_once WC_STRIPE_PLUGIN_PATH . '/includes/admin/class-wc-stripe-rest-oc-setting-toggle-controller.php';

$upe_flag_toggle_controller = new WC_Stripe_REST_UPE_Flag_Toggle_Controller();
$upe_flag_toggle_controller->register_routes();
$upe_flag_toggle_controller = new WC_Stripe_REST_UPE_Flag_Toggle_Controller();
$upe_flag_toggle_controller->register_routes();

$settings_controller = new WC_REST_Stripe_Settings_Controller( $this->get_main_stripe_gateway() );
$settings_controller->register_routes();
$settings_controller = new WC_REST_Stripe_Settings_Controller( $this->get_main_stripe_gateway() );
$settings_controller->register_routes();

$stripe_account_keys_controller = new WC_REST_Stripe_Account_Keys_Controller( $this->account );
$stripe_account_keys_controller->register_routes();
$stripe_account_keys_controller = new WC_REST_Stripe_Account_Keys_Controller( $this->account );
$stripe_account_keys_controller->register_routes();

$oc_setting_toggle_controller = new WC_Stripe_REST_OC_Setting_Toggle_Controller( $this->get_main_stripe_gateway() );
$oc_setting_toggle_controller->register_routes();
}
$oc_setting_toggle_controller = new WC_Stripe_REST_OC_Setting_Toggle_Controller( $this->get_main_stripe_gateway() );
$oc_setting_toggle_controller->register_routes();
}

/**
Expand Down
5 changes: 0 additions & 5 deletions includes/notes/class-wc-stripe-upe-availability-note.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,15 +73,10 @@ private static function get_note_class() {
public static function init() {
/**
* No need to display the admin inbox note when
* - UPE preview is disabled
* - UPE is already enabled
* - UPE has been manually disabled
* - Stripe is not enabled
*/
if ( ! WC_Stripe_Feature_Flags::is_upe_preview_enabled() ) {
return;
}

if ( WC_Stripe_Feature_Flags::is_upe_checkout_enabled() ) {
return;
}
Expand Down
46 changes: 9 additions & 37 deletions includes/payment-methods/class-wc-stripe-payment-request.php
Original file line number Diff line number Diff line change
Expand Up @@ -283,10 +283,6 @@ public function get_button_theme() {
* @return string
*/
public function get_button_height() {
if ( ! WC_Stripe_Feature_Flags::is_upe_preview_enabled() ) {
return isset( $this->stripe_settings['payment_request_button_height'] ) ? str_replace( 'px', '', $this->stripe_settings['payment_request_button_height'] ) : '64';
}

$height = isset( $this->stripe_settings['payment_request_button_size'] ) ? $this->stripe_settings['payment_request_button_size'] : 'default';
if ( 'small' === $height ) {
return '40';
Expand Down Expand Up @@ -330,12 +326,7 @@ public function get_button_branded_type() {
* @return boolean
*/
public function is_custom_button() {
// no longer a valid option
if ( WC_Stripe_Feature_Flags::is_upe_preview_enabled() ) {
return false;
}

return 'custom' === $this->get_button_type();
return false;
}

/**
Expand All @@ -357,12 +348,7 @@ public function custom_button_selector() {
* @return string
*/
public function get_button_label() {
// no longer a valid option
if ( WC_Stripe_Feature_Flags::is_upe_preview_enabled() ) {
return '';
}

return isset( $this->stripe_settings['payment_request_button_label'] ) ? $this->stripe_settings['payment_request_button_label'] : 'Buy now';
return '';
}

/**
Expand Down Expand Up @@ -1824,32 +1810,18 @@ public function get_button_settings() {
// it would be DRYer to use `array_merge`,
// but I thought that this approach might be more straightforward to clean up when we remove the feature flag code.
$button_type = $this->get_button_type();
if ( WC_Stripe_Feature_Flags::is_upe_preview_enabled() ) {
return [
'type' => $button_type,
'theme' => $this->get_button_theme(),
'height' => $this->get_button_height(),
// Default format is en_US.
'locale' => apply_filters( 'wc_stripe_payment_request_button_locale', substr( get_locale(), 0, 2 ) ),
'branded_type' => 'default' === $button_type ? 'short' : 'long',
// these values are no longer applicable - all the JS relying on them can be removed.
'css_selector' => '',
'label' => '',
'is_custom' => false,
'is_branded' => false,
];
}

return [
'type' => $button_type,
'theme' => $this->get_button_theme(),
'height' => $this->get_button_height(),
'locale' => apply_filters( 'wc_stripe_payment_request_button_locale', substr( get_locale(), 0, 2 ) ),
// Default format is en_US.
'is_custom' => $this->is_custom_button(),
'is_branded' => $this->is_branded_button(),
'css_selector' => $this->custom_button_selector(),
'branded_type' => $this->get_button_branded_type(),
'locale' => apply_filters( 'wc_stripe_payment_request_button_locale', substr( get_locale(), 0, 2 ) ),
'branded_type' => 'default' === $button_type ? 'short' : 'long',
// these values are no longer applicable - all the JS relying on them can be removed.
'css_selector' => '',
'label' => '',
'is_custom' => false,
'is_branded' => false,
];
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ public function __construct() {
$this->statement_descriptor = ! empty( $main_settings['statement_descriptor'] ) ? $main_settings['statement_descriptor'] : '';

// When feature flags are enabled, title shows the count of enabled payment methods in settings page only.
if ( WC_Stripe_Feature_Flags::is_upe_checkout_enabled() && WC_Stripe_Feature_Flags::is_upe_preview_enabled() && isset( $_GET['page'] ) && 'wc-settings' === $_GET['page'] && isset( $_GET['tab'] ) && 'checkout' === $_GET['tab'] ) {
if ( WC_Stripe_Feature_Flags::is_upe_checkout_enabled() && isset( $_GET['page'] ) && 'wc-settings' === $_GET['page'] && isset( $_GET['tab'] ) && 'checkout' === $_GET['tab'] ) {
$enabled_payment_methods_count = count( $enabled_payment_methods );
$this->title = $enabled_payment_methods_count ?
/* translators: $1. Count of enabled payment methods. */
Expand Down
1 change: 1 addition & 0 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ If you get stuck, you can ask for help in the [Plugin Forum](https://wordpress.o
* Fix - Ensure Amazon Pay, Apple Pay, and Google Pay display settings are managed correctly
* Dev - Add logging with DNS resolution diagnostics for URL validation issues when calling Stripe API
* Fix - Allow payment methods to be disabled when they are not available
* Dev - Removes the `_wcstripe_feature_upe` feature flag and the related method from the `WC_Stripe_Feature_Flags` class
* Dev - Fixes some incorrect subscriptions support implementations for payment methods

[See changelog for full details across versions](https://raw.githubusercontent.com/woocommerce/woocommerce-gateway-stripe/trunk/changelog.txt).
16 changes: 0 additions & 16 deletions tests/phpunit/WC_Stripe_Helper_Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -799,22 +799,6 @@ public function statement_descriptor_sanitation_provider() {
];
}

public function test_turning_on_upe_with_no_stripe_legacy_payment_methods_enabled_will_not_turn_on_the_upe_gateway_and_default_to_card_and_link() {
$this->upe_helper->enable_upe_feature_flag();

$stripe_settings = WC_Stripe_Helper::get_stripe_settings();
$this->assertEquals( 'no', $stripe_settings['enabled'] );
$this->assertEquals( 'no', $stripe_settings['upe_checkout_experience_enabled'] );

$stripe_settings['upe_checkout_experience_enabled'] = 'yes';
WC_Stripe_Helper::update_main_stripe_settings( $stripe_settings );

$stripe_settings = WC_Stripe_Helper::get_stripe_settings();
// Because no Stripe LPM's were enabled when UPE was enabled, the Stripe gateway is not enabled yet.
$this->assertEquals( 'no', $stripe_settings['enabled'] );
$this->assertEquals( 'yes', $stripe_settings['upe_checkout_experience_enabled'] );
}

public function test_turning_on_upe_enables_the_correct_upe_methods_based_on_which_legacy_payment_methods_were_enabled() {
update_option( 'woocommerce_currency', 'EUR' );
$this->upe_helper->enable_upe_feature_flag();
Expand Down
Loading