Skip to content
Open
Show file tree
Hide file tree
Changes from 6 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
@@ -1,6 +1,7 @@
*** Changelog ***

= 10.1.0 - xxxx-xx-xx =
* Dev - Removes the `_wcstripe_feature_upe` feature flag and the related method from the `WC_Stripe_Feature_Flags` class
* Update - Renames and migrates all Payment Request Buttons settings to Express Checkout
* Dev - Upgrades `@automattic/interpolate-components` to 1.2.1 to remove the `node-fetch` dependency
* Add - Includes a notice to inform merchants about methods that are automatically enabled upon account connection
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 @@ -85,9 +85,11 @@ public static function is_stripe_ece_enabled() {
* This allows the merchant to enable/disable UPE checkout.
*
* @return bool
*
* @deprecated 10.0.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
4 changes: 0 additions & 4 deletions includes/notes/class-wc-stripe-upe-availability-note.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,6 @@ public static function init() {
* - 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 @@ -111,6 +111,7 @@ If you get stuck, you can ask for help in the [Plugin Forum](https://wordpress.o
== Changelog ==

= 10.1.0 - xxxx-xx-xx =
* Dev - Removes the `_wcstripe_feature_upe` feature flag and the related method from the `WC_Stripe_Feature_Flags` class
* Update - Renames and migrates all Payment Request Buttons settings to Express Checkout
* Dev - Upgrades `@automattic/interpolate-components` to 1.2.1 to remove the `node-fetch` dependency
* Add - Includes a notice to inform merchants about methods that are automatically enabled upon account connection
Expand Down
Loading