From 44622b58596750f0f16a02a72996d8f323215070 Mon Sep 17 00:00:00 2001 From: Wesley Rosa Date: Fri, 12 Sep 2025 14:45:27 -0300 Subject: [PATCH 01/21] Showing connection modal when oauth is needed --- includes/admin/class-wc-stripe-settings-controller.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/admin/class-wc-stripe-settings-controller.php b/includes/admin/class-wc-stripe-settings-controller.php index ba3e84e719..438c54df6a 100644 --- a/includes/admin/class-wc-stripe-settings-controller.php +++ b/includes/admin/class-wc-stripe-settings-controller.php @@ -117,7 +117,7 @@ public function admin_options( WC_Stripe_Payment_Gateway $gateway ) { $settings = WC_Stripe_Helper::get_stripe_settings(); $account_data_exists = ( ! empty( $settings['publishable_key'] ) && ! empty( $settings['secret_key'] ) ) || ( ! empty( $settings['test_publishable_key'] ) && ! empty( $settings['test_secret_key'] ) ); - echo $account_data_exists ? '
' : '
'; + echo $account_data_exists && ! $this->needs_oauth_urls() ? '
' : '
'; } /** From 40628fb46bc5111b4b7ff03450b241e6f1bbca1d Mon Sep 17 00:00:00 2001 From: Wesley Rosa Date: Fri, 12 Sep 2025 15:56:32 -0300 Subject: [PATCH 02/21] Adding the info icon --- assets/images/info.svg | 8 ++++ .../admin/class-wc-stripe-admin-notices.php | 37 +++++++++++++++++-- 2 files changed, 41 insertions(+), 4 deletions(-) create mode 100644 assets/images/info.svg diff --git a/assets/images/info.svg b/assets/images/info.svg new file mode 100644 index 0000000000..099b41b68c --- /dev/null +++ b/assets/images/info.svg @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/includes/admin/class-wc-stripe-admin-notices.php b/includes/admin/class-wc-stripe-admin-notices.php index bd77d9498a..947fae576f 100644 --- a/includes/admin/class-wc-stripe-admin-notices.php +++ b/includes/admin/class-wc-stripe-admin-notices.php @@ -41,11 +41,12 @@ public function __construct() { * @since 1.0.0 * @version 4.0.0 */ - public function add_admin_notice( $slug, $class, $message, $dismissible = false ) { + public function add_admin_notice( $slug, $class, $message, $dismissible = false, $icon_img_url = '' ) { $this->notices[ $slug ] = [ - 'class' => $class, - 'message' => $message, - 'dismissible' => $dismissible, + 'class' => $class, + 'message' => $message, + 'dismissible' => $dismissible, + 'icon_img_url' => $icon_img_url, ]; } @@ -81,6 +82,12 @@ public function admin_notices() { + + '; echo wp_kses( $notice['message'], @@ -196,6 +203,7 @@ public function stripe_check_environment() { $show_sca_notice = get_option( 'wc_stripe_show_sca_notice' ); $changed_keys_notice = get_option( 'wc_stripe_show_changed_keys_notice' ); $legacy_deprecation_notice = get_option( 'wc_stripe_show_legacy_deprecation_notice' ); + $oauth_required_notice = get_option( 'wc_stripe_oauth_required' ); $options = WC_Stripe_Helper::get_stripe_settings(); $testmode = WC_Stripe_Mode::is_test(); $test_pub_key = isset( $options['test_publishable_key'] ) ? $options['test_publishable_key'] : ''; @@ -393,6 +401,24 @@ public function stripe_check_environment() { $this->add_admin_notice( 'legacy_deprecation', 'notice notice-warning', $message, true ); } } + + if ( empty( $oauth_required_notice ) ) { + // Show the reconnection notice if the account requires OAuth reconnection. + $has_live_keys = ! empty( $live_pub_key ) && ! empty( $live_secret_key ); + $has_test_keys = ! empty( $test_pub_key ) && ! empty( $test_secret_key ); + $stripe_connect = woocommerce_gateway_stripe()->connect; + + // Check each mode only if it has keys + $needs_live_oauth = $has_live_keys && ! $stripe_connect->is_connected_via_oauth( 'live' ); + $needs_test_oauth = $has_test_keys && ! $stripe_connect->is_connected_via_oauth( 'test' ); + + $oauth_required = $needs_live_oauth || $needs_test_oauth; + if ( true ) { + $icon_img_url = WC_STRIPE_PLUGIN_URL . '/assets/images/info.svg'; + $message = __( 'Please reconnect to continue using Stripe and avoid disruptions on your store.', 'woocommerce-gateway-stripe' ); + $this->add_admin_notice( 'oauth_required', 'notice notice-warning', $message, true, $icon_img_url ); + } + } } } @@ -633,6 +659,9 @@ public function hide_notices() { case 'upe_payment_methods': update_option( 'wc_stripe_show_upe_payment_methods_notice', 'no' ); break; + case 'oauth_required': + update_option( 'wc_stripe_show_oauth_required_notice', 'no' ); + break; case 'subscriptions': update_option( 'wc_stripe_show_subscriptions_notice', 'no' ); break; From f247cb162098233665b9b40c08c8e85be03d9d03 Mon Sep 17 00:00:00 2001 From: Wesley Rosa Date: Fri, 12 Sep 2025 16:25:27 -0300 Subject: [PATCH 03/21] Improving tests PHP docs --- .../admin/class-wc-stripe-admin-notices.php | 2 +- .../Admin/WC_Stripe_Admin_Notices_Test.php | 41 ++++++++++++++++++- 2 files changed, 41 insertions(+), 2 deletions(-) diff --git a/includes/admin/class-wc-stripe-admin-notices.php b/includes/admin/class-wc-stripe-admin-notices.php index 947fae576f..0e25fc22bb 100644 --- a/includes/admin/class-wc-stripe-admin-notices.php +++ b/includes/admin/class-wc-stripe-admin-notices.php @@ -413,7 +413,7 @@ public function stripe_check_environment() { $needs_test_oauth = $has_test_keys && ! $stripe_connect->is_connected_via_oauth( 'test' ); $oauth_required = $needs_live_oauth || $needs_test_oauth; - if ( true ) { + if ( $oauth_required ) { $icon_img_url = WC_STRIPE_PLUGIN_URL . '/assets/images/info.svg'; $message = __( 'Please reconnect to continue using Stripe and avoid disruptions on your store.', 'woocommerce-gateway-stripe' ); $this->add_admin_notice( 'oauth_required', 'notice notice-warning', $message, true, $icon_img_url ); diff --git a/tests/phpunit/Admin/WC_Stripe_Admin_Notices_Test.php b/tests/phpunit/Admin/WC_Stripe_Admin_Notices_Test.php index d9c377152b..c3dcda88f3 100644 --- a/tests/phpunit/Admin/WC_Stripe_Admin_Notices_Test.php +++ b/tests/phpunit/Admin/WC_Stripe_Admin_Notices_Test.php @@ -12,6 +12,9 @@ use WC_Subscriptions; use WooCommerce\Stripe\Tests\WC_Mock_Stripe_API_Unit_Test_Case; +/** + * Tests for the admin notices class. + */ class WC_Stripe_Admin_Notices_Test extends WC_Mock_Stripe_API_Unit_Test_Case { /** * The original value of the HPOS option. @@ -20,6 +23,11 @@ class WC_Stripe_Admin_Notices_Test extends WC_Mock_Stripe_API_Unit_Test_Case { */ private static $original_hpos_value; + /** + * @inheritDoc + * + * @return void + */ public function set_up() { parent::set_up(); require_once WC_STRIPE_PLUGIN_PATH . '/includes/admin/class-wc-stripe-admin-notices.php'; @@ -56,6 +64,11 @@ public static function tear_down_after_class() { update_option( 'woocommerce_custom_orders_table_enabled', self::$original_hpos_value ); } + /** + * Test that no notices are shown when the user is not an admin. + * + * @return void + */ public function test_no_notices_are_shown_when_user_is_not_admin() { WC_Stripe_Helper::update_main_stripe_settings( [ 'enabled' => 'yes' ] ); $notices = new WC_Stripe_Admin_Notices(); @@ -65,6 +78,11 @@ public function test_no_notices_are_shown_when_user_is_not_admin() { $this->assertCount( 0, $notices->notices ); } + /** + * Test that no notices are shown when Stripe is not enabled. + * + * @return void + */ public function test_no_notices_are_shown_when_stripe_is_not_enabled() { wp_set_current_user( $this->factory->user->create( [ 'role' => 'administrator' ] ) ); WC_Stripe_Helper::update_main_stripe_settings( [ 'enabled' => 'no' ] ); @@ -76,13 +94,28 @@ public function test_no_notices_are_shown_when_stripe_is_not_enabled() { } /** + * Test that the correct notices are shown in all scenarios. + * + * @param array $options_to_set Options to set before running the test. + * @param array $expected_notices Notices expected to be shown. + * @param string|false $expected_output Optional. If set, the output is expected to match this regex. + * @param array $query_params Optional. Query parameters to set before running the test. + * @return void + * * @dataProvider options_to_notices_map */ - public function test_correct_stripe_notices_are_shown_in_all_scenarios( $options_to_set, $expected_notices = [], $expected_output = false, $query_params = [] ) { + public function test_correct_stripe_notices_are_shown_in_all_scenarios( + $options_to_set, + array $expected_notices = [], + $expected_output = false, + array $query_params = [] + ) { wp_set_current_user( $this->factory->user->create( [ 'role' => 'administrator' ] ) ); + foreach ( $query_params as $param => $value ) { $_GET[ $param ] = $value; } + foreach ( $options_to_set as $option_name => $option_value ) { update_option( $option_name, $option_value ); } @@ -94,6 +127,7 @@ public function test_correct_stripe_notices_are_shown_in_all_scenarios( $options $notices = new WC_Stripe_Admin_Notices(); ob_start(); $notices->admin_notices(); + // Displaying the style notice results in an early return. if ( ! in_array( 'style', $expected_notices, true ) ) { if ( WC_Stripe_Helper::is_wc_lt( WC_STRIPE_FUTURE_MIN_WC_VER ) ) { @@ -204,6 +238,11 @@ public function test_invalid_keys_notice_is_shown_when_account_data_is_not_valid $this->assertMatchesRegularExpression( '/Your customers cannot use Stripe on checkout/', $notices->notices['keys']['message'] ); } + /** + * Data provider for `test_correct_stripe_notices_are_shown_in_all_scenarios`. + * + * @return array + */ public function options_to_notices_map() { return [ [ From fe6d549403e82f46ec0d9c49f2d407e97679854a Mon Sep 17 00:00:00 2001 From: Wesley Rosa Date: Fri, 12 Sep 2025 16:35:33 -0300 Subject: [PATCH 04/21] Fix tests --- .../Admin/WC_Stripe_Admin_Notices_Test.php | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/tests/phpunit/Admin/WC_Stripe_Admin_Notices_Test.php b/tests/phpunit/Admin/WC_Stripe_Admin_Notices_Test.php index c3dcda88f3..5ad90d70a1 100644 --- a/tests/phpunit/Admin/WC_Stripe_Admin_Notices_Test.php +++ b/tests/phpunit/Admin/WC_Stripe_Admin_Notices_Test.php @@ -4,6 +4,7 @@ use WC_Stripe; use WC_Stripe_Admin_Notices; +use WC_Stripe_Connect; use WC_Stripe_Database_Cache; use WC_Stripe_Feature_Flags; use WC_Stripe_Helper; @@ -23,6 +24,13 @@ class WC_Stripe_Admin_Notices_Test extends WC_Mock_Stripe_API_Unit_Test_Case { */ private static $original_hpos_value; + /** + * The original `WC_Stripe_Connect` instance, to be restored after tests. + * + * @var WC_Stripe_Connect + */ + private WC_Stripe_Connect $stripe_connect_original; + /** * @inheritDoc * @@ -46,6 +54,28 @@ public function set_up() { 'test' => 'test', ] ); + + // overriding the `WC_Stripe_Connect` in woocommerce_gateway_stripe(), + $stripe_connect_mock = $this->createPartialMock( WC_Stripe_Connect::class, [ 'is_connected_via_oauth' ] ); + $stripe_connect_mock + ->expects( $this->any() ) + ->method( 'is_connected_via_oauth' ) + ->willReturn( true ); + + $this->stripe_connect_original = woocommerce_gateway_stripe()->connect; + woocommerce_gateway_stripe()->connect = $stripe_connect_mock; + } + + /** + * @inheritDoc + * + * @return void + */ + public function tear_down() { + parent::tear_down(); + + // Restoring the original `WC_Stripe_Connect` instance. + woocommerce_gateway_stripe()->connect = $this->stripe_connect_original; } /** From 5ee1ff6ffbc43ed58e55f71a3babf25659e2846a Mon Sep 17 00:00:00 2001 From: Wesley Rosa Date: Fri, 12 Sep 2025 16:56:04 -0300 Subject: [PATCH 05/21] Fix tests --- .../Admin/WC_Stripe_Admin_Notices_Test.php | 246 +++++++++++------- 1 file changed, 155 insertions(+), 91 deletions(-) diff --git a/tests/phpunit/Admin/WC_Stripe_Admin_Notices_Test.php b/tests/phpunit/Admin/WC_Stripe_Admin_Notices_Test.php index 5ad90d70a1..87c4ed9c4c 100644 --- a/tests/phpunit/Admin/WC_Stripe_Admin_Notices_Test.php +++ b/tests/phpunit/Admin/WC_Stripe_Admin_Notices_Test.php @@ -56,7 +56,10 @@ public function set_up() { ); // overriding the `WC_Stripe_Connect` in woocommerce_gateway_stripe(), - $stripe_connect_mock = $this->createPartialMock( WC_Stripe_Connect::class, [ 'is_connected_via_oauth' ] ); + $stripe_connect_mock = $this->createPartialMock( + WC_Stripe_Connect::class, + [ 'is_connected_via_oauth' ] + ); $stripe_connect_mock ->expects( $this->any() ) ->method( 'is_connected_via_oauth' ) @@ -127,6 +130,7 @@ public function test_no_notices_are_shown_when_stripe_is_not_enabled() { * Test that the correct notices are shown in all scenarios. * * @param array $options_to_set Options to set before running the test. + * @param bool $is_oauth_connected Optional. Whether the account is connected via OAuth. Default true. * @param array $expected_notices Notices expected to be shown. * @param string|false $expected_output Optional. If set, the output is expected to match this regex. * @param array $query_params Optional. Query parameters to set before running the test. @@ -135,7 +139,8 @@ public function test_no_notices_are_shown_when_stripe_is_not_enabled() { * @dataProvider options_to_notices_map */ public function test_correct_stripe_notices_are_shown_in_all_scenarios( - $options_to_set, + array $options_to_set, + bool $is_oauth_connected = true, array $expected_notices = [], $expected_output = false, array $query_params = [] @@ -154,6 +159,17 @@ public function test_correct_stripe_notices_are_shown_in_all_scenarios( $this->mock_payment_method_configurations( $options_to_set['woocommerce_stripe_settings']['upe_checkout_experience_accepted_payments'] ); } + if ( ! $is_oauth_connected ) { + woocommerce_gateway_stripe()->connect = $this->createPartialMock( + WC_Stripe_Connect::class, + [ 'is_connected_via_oauth' ] + ); + woocommerce_gateway_stripe()->connect + ->expects( $this->any() ) + ->method( 'is_connected_via_oauth' ) + ->willReturn( false ); + } + $notices = new WC_Stripe_Admin_Notices(); ob_start(); $notices->admin_notices(); @@ -173,112 +189,27 @@ public function test_correct_stripe_notices_are_shown_in_all_scenarios( if ( $expected_output ) { $this->assertMatchesRegularExpression( $expected_output, ob_get_contents() ); } + ob_end_clean(); + $this->assertCount( count( $expected_notices ), $notices->notices ); foreach ( $expected_notices as $expected_notice ) { $this->assertArrayHasKey( $expected_notice, $notices->notices ); } } - public function test_currency_notice_is_shown_for_upe_methods() { - add_filter( - 'pre_option__wcstripe_feature_upe', - function () { - return 'yes'; - } - ); - wp_set_current_user( $this->factory->user->create( [ 'role' => 'administrator' ] ) ); - - $this->mock_payment_method_configurations( - [ - WC_Stripe_Payment_Methods::CARD, - WC_Stripe_Payment_Methods::GIROPAY, - WC_Stripe_Payment_Methods::BANCONTACT, - WC_Stripe_Payment_Methods::EPS, - ] - ); - - WC_Stripe_Helper::update_main_stripe_settings( - [ - 'enabled' => 'yes', - 'testmode' => 'yes', - 'test_publishable_key' => 'pk_test_valid_test_key', - 'test_secret_key' => 'sk_test_valid_test_key', - 'upe_checkout_experience_enabled' => 'yes', - 'connection_type' => 'connect', - ] - ); - - update_option( 'wc_stripe_show_style_notice', 'no' ); - update_option( 'home', 'https://...' ); - update_option( 'wc_stripe_show_sca_notice', 'no' ); - - $notices = new WC_Stripe_Admin_Notices(); - ob_start(); - $notices->admin_notices(); - ob_end_clean(); - if ( WC_Stripe_Helper::is_wc_lt( WC_STRIPE_FUTURE_MIN_WC_VER ) ) { - $this->assertCount( 2, $notices->notices ); - $this->assertArrayHasKey( 'wcver', $notices->notices ); - } else { - $this->assertCount( 1, $notices->notices ); - } - $this->assertArrayHasKey( 'upe_payment_methods', $notices->notices ); - } - - public function test_invalid_keys_notice_is_shown_when_account_data_is_not_valid() { - // We need to re-create the mock object to override the mocked 'get_cached_account_data' function. - WC_Stripe::get_instance()->account = $this->getMockBuilder( 'WC_Stripe_Account' ) - ->disableOriginalConstructor() - ->setMethods( - [ - 'get_cached_account_data', - ] - ) - ->getMock(); - WC_Stripe::get_instance()->account->method( 'get_cached_account_data' )->willReturn( null ); - - wp_set_current_user( $this->factory->user->create( [ 'role' => 'administrator' ] ) ); - WC_Stripe_Helper::update_main_stripe_settings( - [ - 'enabled' => 'yes', - 'testmode' => 'no', - 'publishable_key' => 'pk_live_invalid_test_key', - 'secret_key' => 'sk_live_invalid_test_secret', - ] - ); - update_option( 'wc_stripe_show_style_notice', 'no' ); - update_option( 'wc_stripe_show_sca_notice', 'no' ); - update_option( 'wc_stripe_show_legacy_deprecation_notice', 'no' ); - update_option( 'home', 'https://...' ); - - $notices = new WC_Stripe_Admin_Notices(); - ob_start(); - $notices->admin_notices(); - ob_end_clean(); - - if ( WC_Stripe_Helper::is_wc_lt( WC_STRIPE_FUTURE_MIN_WC_VER ) ) { - $this->assertCount( 2, $notices->notices ); - $this->assertArrayHasKey( 'wcver', $notices->notices ); - } else { - $this->assertCount( 1, $notices->notices ); - } - - $this->assertArrayHasKey( 'keys', $notices->notices ); - $this->assertMatchesRegularExpression( '/Your customers cannot use Stripe on checkout/', $notices->notices['keys']['message'] ); - } - /** * Data provider for `test_correct_stripe_notices_are_shown_in_all_scenarios`. * * @return array */ - public function options_to_notices_map() { + public function options_to_notices_map(): array { return [ [ [ 'woocommerce_stripe_settings' => [ 'enabled' => 'yes' ], ], + 'is oauth connected' => true, [ 'style', ], @@ -295,6 +226,7 @@ public function options_to_notices_map() { 'wc_stripe_show_sca_notice' => 'no', 'home' => 'https://...', ], + 'is oauth connected' => true, [ 'mode', ], @@ -311,6 +243,7 @@ public function options_to_notices_map() { 'three_d_secure' => 'yes', ], ], + 'is oauth connected' => true, [ '3ds', 'style', @@ -324,6 +257,7 @@ public function options_to_notices_map() { ], 'wc_stripe_show_3ds_notice' => 'no', ], + 'is oauth connected' => true, [ 'style', ], @@ -341,6 +275,7 @@ public function options_to_notices_map() { 'wc_stripe_show_sca_notice' => 'no', 'home' => 'https://...', ], + 'is oauth connected' => true, [ '3ds', ], @@ -359,6 +294,7 @@ public function options_to_notices_map() { 'wc_stripe_show_sca_notice' => 'no', 'home' => 'https://...', ], + 'is oauth connected' => true, [ 'keys', ], @@ -377,6 +313,7 @@ public function options_to_notices_map() { '_wcstripe_feature_upe_settings' => 'yes', 'home' => 'https://...', ], + 'is oauth connected' => true, [], false, [ @@ -394,6 +331,7 @@ public function options_to_notices_map() { '_wcstripe_feature_upe_settings' => 'yes', 'home' => 'https://...', ], + 'is oauth connected' => true, [ 'keys', ], @@ -415,6 +353,7 @@ public function options_to_notices_map() { 'wc_stripe_show_sca_notice' => 'no', 'home' => 'https://...', ], + 'is oauth connected' => true, [ 'keys', ], @@ -432,6 +371,7 @@ public function options_to_notices_map() { 'wc_stripe_show_sca_notice' => 'no', 'home' => 'https://...', ], + 'is oauth connected' => true, [ 'mode', ], @@ -453,6 +393,7 @@ public function options_to_notices_map() { 'wc_stripe_show_sca_notice' => 'no', 'home' => 'https://...', ], + 'is oauth connected' => true, [ 'keys', ], @@ -482,6 +423,7 @@ public function options_to_notices_map() { 'wc_stripe_show_style_notice' => 'no', 'wc_stripe_show_sca_notice' => 'no', ], + 'is oauth connected' => true, [ 'ssl', ], @@ -497,6 +439,7 @@ public function options_to_notices_map() { 'wc_stripe_show_style_notice' => 'no', 'home' => 'https://...', ], + 'is oauth connected' => true, [ 'sca', ], @@ -511,6 +454,7 @@ public function options_to_notices_map() { 'wc_stripe_show_style_notice' => 'no', 'wc_stripe_show_changed_keys_notice' => 'yes', ], + 'is oauth connected' => true, [ '3ds', 'keys', @@ -529,6 +473,7 @@ public function options_to_notices_map() { 'wc_stripe_show_style_notice' => 'no', 'wc_stripe_show_changed_keys_notice' => 'yes', ], + 'is oauth connected' => true, [ 'keys', 'ssl', @@ -548,6 +493,7 @@ public function options_to_notices_map() { 'wc_stripe_show_style_notice' => 'no', 'wc_stripe_show_changed_keys_notice' => 'yes', ], + 'is oauth connected' => true, [ 'ssl', 'sca', @@ -566,6 +512,7 @@ public function options_to_notices_map() { 'wc_stripe_show_changed_keys_notice' => 'yes', 'home' => 'https://...', ], + 'is oauth connected' => true, [ 'sca', 'changed_keys', @@ -584,6 +531,7 @@ public function options_to_notices_map() { 'home' => 'https://...', 'wc_stripe_show_sca_notice' => 'no', ], + 'is oauth connected' => true, [ 'changed_keys', ], @@ -614,13 +562,129 @@ public function options_to_notices_map() { 'home' => 'https://...', 'wc_stripe_show_sca_notice' => 'no', ], + 'is oauth connected' => true, [ 'upe_payment_methods', ], ], + 'OAuth required notice' => [ + [ + 'woocommerce_stripe_settings' => [ + 'enabled' => 'yes', + 'testmode' => 'no', + 'publishable_key' => 'pk_live_valid_test_key', + 'secret_key' => 'sk_live_valid_test_key', + ], + 'wc_stripe_show_style_notice' => 'no', + 'home' => 'https://...', + 'wc_stripe_show_sca_notice' => 'no', + ], + 'is oauth connected' => false, + [ + 'oauth_required', + ], + ], ]; } + /** + * Test that the currency notice is shown when UPE methods are enabled. + * + * @return void + */ + public function test_currency_notice_is_shown_for_upe_methods() { + add_filter( + 'pre_option__wcstripe_feature_upe', + function () { + return 'yes'; + } + ); + wp_set_current_user( $this->factory->user->create( [ 'role' => 'administrator' ] ) ); + + $this->mock_payment_method_configurations( + [ + WC_Stripe_Payment_Methods::CARD, + WC_Stripe_Payment_Methods::GIROPAY, + WC_Stripe_Payment_Methods::BANCONTACT, + WC_Stripe_Payment_Methods::EPS, + ] + ); + + WC_Stripe_Helper::update_main_stripe_settings( + [ + 'enabled' => 'yes', + 'testmode' => 'yes', + 'test_publishable_key' => 'pk_test_valid_test_key', + 'test_secret_key' => 'sk_test_valid_test_key', + 'upe_checkout_experience_enabled' => 'yes', + 'connection_type' => 'connect', + ] + ); + + update_option( 'wc_stripe_show_style_notice', 'no' ); + update_option( 'home', 'https://...' ); + update_option( 'wc_stripe_show_sca_notice', 'no' ); + + $notices = new WC_Stripe_Admin_Notices(); + ob_start(); + $notices->admin_notices(); + ob_end_clean(); + if ( WC_Stripe_Helper::is_wc_lt( WC_STRIPE_FUTURE_MIN_WC_VER ) ) { + $this->assertCount( 2, $notices->notices ); + $this->assertArrayHasKey( 'wcver', $notices->notices ); + } else { + $this->assertCount( 1, $notices->notices ); + } + $this->assertArrayHasKey( 'upe_payment_methods', $notices->notices ); + } + + /** + * Test that the invalid keys notice is shown when account data is not valid. + * + * @return void + */ + public function test_invalid_keys_notice_is_shown_when_account_data_is_not_valid() { + // We need to re-create the mock object to override the mocked 'get_cached_account_data' function. + WC_Stripe::get_instance()->account = $this->getMockBuilder( 'WC_Stripe_Account' ) + ->disableOriginalConstructor() + ->setMethods( + [ + 'get_cached_account_data', + ] + ) + ->getMock(); + WC_Stripe::get_instance()->account->method( 'get_cached_account_data' )->willReturn( null ); + + wp_set_current_user( $this->factory->user->create( [ 'role' => 'administrator' ] ) ); + WC_Stripe_Helper::update_main_stripe_settings( + [ + 'enabled' => 'yes', + 'testmode' => 'no', + 'publishable_key' => 'pk_live_invalid_test_key', + 'secret_key' => 'sk_live_invalid_test_secret', + ] + ); + update_option( 'wc_stripe_show_style_notice', 'no' ); + update_option( 'wc_stripe_show_sca_notice', 'no' ); + update_option( 'wc_stripe_show_legacy_deprecation_notice', 'no' ); + update_option( 'home', 'https://...' ); + + $notices = new WC_Stripe_Admin_Notices(); + ob_start(); + $notices->admin_notices(); + ob_end_clean(); + + if ( WC_Stripe_Helper::is_wc_lt( WC_STRIPE_FUTURE_MIN_WC_VER ) ) { + $this->assertCount( 2, $notices->notices ); + $this->assertArrayHasKey( 'wcver', $notices->notices ); + } else { + $this->assertCount( 1, $notices->notices ); + } + + $this->assertArrayHasKey( 'keys', $notices->notices ); + $this->assertMatchesRegularExpression( '/Your customers cannot use Stripe on checkout/', $notices->notices['keys']['message'] ); + } + /** * Test for `subscription_check_detachment`. * From fb0f2650d05c1c65c7090927ab9a50171cb2cef2 Mon Sep 17 00:00:00 2001 From: Wesley Rosa Date: Fri, 12 Sep 2025 17:01:38 -0300 Subject: [PATCH 06/21] Changelog and readme entries --- changelog.txt | 1 + readme.txt | 1 + 2 files changed, 2 insertions(+) diff --git a/changelog.txt b/changelog.txt index d804b202ff..38253885c6 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,6 +1,7 @@ *** Changelog *** = 9.10.0 - xxxx-xx-xx = +* Update - Shows the Stripe account connection modal in settings when the merchant did not connect via OAuth along with a new notice * Dev - Fix live reload issue with Webpack 5 * Add - Adds support for the Romanian Leu (RON) currency when paying with Klarna * Update - Reduces the minimum transaction amount for Affirm to 35 USD diff --git a/readme.txt b/readme.txt index d4a7f67c3f..b6e81b2f90 100644 --- a/readme.txt +++ b/readme.txt @@ -111,6 +111,7 @@ If you get stuck, you can ask for help in the [Plugin Forum](https://wordpress.o == Changelog == = 9.10.0 - xxxx-xx-xx = +* Update - Shows the Stripe account connection modal in settings when the merchant did not connect via OAuth along with a new notice * Dev - Fix live reload issue with Webpack 5 * Add - Adds support for the Romanian Leu (RON) currency when paying with Klarna * Update - Reduces the minimum transaction amount for Affirm to 35 USD From 23bffac7ea3a6598d12f718f1c43eecdeb6ca28c Mon Sep 17 00:00:00 2001 From: Wesley Rosa Date: Fri, 19 Sep 2025 17:04:30 -0300 Subject: [PATCH 07/21] Reverting the logic to display the connection modal --- includes/admin/class-wc-stripe-settings-controller.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/admin/class-wc-stripe-settings-controller.php b/includes/admin/class-wc-stripe-settings-controller.php index 438c54df6a..ba3e84e719 100644 --- a/includes/admin/class-wc-stripe-settings-controller.php +++ b/includes/admin/class-wc-stripe-settings-controller.php @@ -117,7 +117,7 @@ public function admin_options( WC_Stripe_Payment_Gateway $gateway ) { $settings = WC_Stripe_Helper::get_stripe_settings(); $account_data_exists = ( ! empty( $settings['publishable_key'] ) && ! empty( $settings['secret_key'] ) ) || ( ! empty( $settings['test_publishable_key'] ) && ! empty( $settings['test_secret_key'] ) ); - echo $account_data_exists && ! $this->needs_oauth_urls() ? '
' : '
'; + echo $account_data_exists ? '
' : '
'; } /** From 4e1f6fc69b07519ddd515fb5613f864172ded9ea Mon Sep 17 00:00:00 2001 From: Wesley Rosa Date: Fri, 19 Sep 2025 17:05:00 -0300 Subject: [PATCH 08/21] Reconnect notice inside the connection status section --- .../__tests__/reconnect-notice.test.js | 15 ++++++++ .../account-details/reconnect-notice.js | 35 +++++++++++++++++++ 2 files changed, 50 insertions(+) create mode 100644 client/settings/account-details/__tests__/reconnect-notice.test.js create mode 100644 client/settings/account-details/reconnect-notice.js diff --git a/client/settings/account-details/__tests__/reconnect-notice.test.js b/client/settings/account-details/__tests__/reconnect-notice.test.js new file mode 100644 index 0000000000..c807f39b8c --- /dev/null +++ b/client/settings/account-details/__tests__/reconnect-notice.test.js @@ -0,0 +1,15 @@ +import { render, screen } from '@testing-library/react'; +import { ReconnectNotice } from 'wcstripe/settings/account-details/reconnect-notice'; + +describe( 'ReconnectNotice', () => { + it( 'renders the reconnect notice', () => { + render( ); + + expect( + screen.getByText( + /reconnect your stripe account using the new authentication flow to avoid disruptions on your store/i + ) + ).toBeInTheDocument(); + expect( screen.getByTestId( 'help' ) ).toBeInTheDocument(); + } ); +} ); diff --git a/client/settings/account-details/reconnect-notice.js b/client/settings/account-details/reconnect-notice.js new file mode 100644 index 0000000000..246fc1dfc0 --- /dev/null +++ b/client/settings/account-details/reconnect-notice.js @@ -0,0 +1,35 @@ +import { info } from '@wordpress/icons'; +import React from 'react'; +import styled from '@emotion/styled'; +import { __ } from '@wordpress/i18n'; +import { Icon } from '@wordpress/components'; + +const NoticeContainer = styled.div` + background-color: #fcf0f1; + width: 100%; + padding: 16px; + margin-bottom: 10px; + + span { + margin-right: 8px; + vertical-align: middle; + + > svg { + fill: #8a2424; + } + } +`; + +export const ReconnectNotice = () => { + return ( + + + + + { __( + 'Reconnect your Stripe account using the new authentication flow to avoid disruptions on your store.', + 'woocommerce-gateway-stripe' + ) } + + ); +}; From 7b2a8894cb8398b3556758a4f3ea1383c19d6811 Mon Sep 17 00:00:00 2001 From: Wesley Rosa Date: Fri, 19 Sep 2025 17:05:25 -0300 Subject: [PATCH 09/21] Implementing the reconnect notice --- client/settings/account-details/index.js | 5 +++++ .../account-details-section.js | 19 +++++++++++++------ 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/client/settings/account-details/index.js b/client/settings/account-details/index.js index 6a051a54da..a48be98359 100644 --- a/client/settings/account-details/index.js +++ b/client/settings/account-details/index.js @@ -8,6 +8,7 @@ import { createInterpolateElement } from '@wordpress/element'; import Tooltip from 'wcstripe/components/tooltip'; import { useAccount } from 'wcstripe/data/account'; import { WebhookDescription } from 'wcstripe/components/webhook-description'; +import { ReconnectNotice } from 'wcstripe/settings/account-details/reconnect-notice'; const AccountDetailsContainer = styled.div` display: flex; @@ -124,6 +125,9 @@ const WebhooksSection = () => { const AccountDetails = () => { const { data } = useAccount(); const isTestModeEnabled = Boolean( data.testmode ); + const oauthConnected = isTestModeEnabled + ? data?.oauth_connections?.test?.connected + : data?.oauth_connections?.live?.connected; const hasAccountError = Object.keys( data.account ?? {} ).length === 0; if ( hasAccountError ) { @@ -151,6 +155,7 @@ const AccountDetails = () => { return ( + { ! oauthConnected && } diff --git a/client/settings/payment-settings/account-details-section.js b/client/settings/payment-settings/account-details-section.js index 9c25bec72a..46cdd8a216 100644 --- a/client/settings/payment-settings/account-details-section.js +++ b/client/settings/payment-settings/account-details-section.js @@ -95,7 +95,9 @@ const AccountSettingsDropdownMenu = ( { const AccountDetailsSection = ( { setModalType, setKeepModalContent } ) => { const [ isTestMode ] = useTestMode(); const { data } = useAccount(); - const isTestModeEnabled = Boolean( data.testmode ); + const oauthConnected = isTestMode + ? data?.oauth_connections?.test?.connected + : data?.oauth_connections?.live?.connected; return ( @@ -110,7 +112,7 @@ const AccountDetailsSection = ( { setModalType, setKeepModalContent } ) => { ) } - { isTestModeEnabled && ( + { isTestMode && ( { __( 'Test Mode', 'woocommerce-gateway-stripe' ) } @@ -135,10 +137,15 @@ const AccountDetailsSection = ( { setModalType, setKeepModalContent } ) => { setModalType( isTestMode ? 'test' : 'live' ) } > - { __( - 'Configure connection', - 'woocommerce-gateway-stripe' - ) } + { oauthConnected + ? __( + 'Configure connection', + 'woocommerce-gateway-stripe' + ) + : __( + 'Reconnect to Stripe', + 'woocommerce-gateway-stripe' + ) } From 1111bb0be6a2a18efe7926d9b00027d4b9e47a6e Mon Sep 17 00:00:00 2001 From: Wesley Rosa Date: Fri, 19 Sep 2025 17:15:53 -0300 Subject: [PATCH 10/21] Unit test --- .../__tests__/account-details-section.test.js | 46 +++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/client/settings/payment-settings/__tests__/account-details-section.test.js b/client/settings/payment-settings/__tests__/account-details-section.test.js index b8fbd45389..a2c9ce9c0c 100644 --- a/client/settings/payment-settings/__tests__/account-details-section.test.js +++ b/client/settings/payment-settings/__tests__/account-details-section.test.js @@ -90,6 +90,10 @@ describe( 'AccountDetailsSection', () => { live: 'example.com', test: 'example.com', }, + oauth_connections: { + live: { connected: true }, + test: { connected: true }, + }, }, } ); useTestMode.mockReturnValue( [ false, jest.fn() ] ); @@ -125,6 +129,10 @@ describe( 'AccountDetailsSection', () => { live: 'example.com', test: 'example.com', }, + oauth_connections: { + live: { connected: true }, + test: { connected: true }, + }, }, } ); useTestMode.mockReturnValue( [ true, jest.fn() ] ); @@ -161,6 +169,10 @@ describe( 'AccountDetailsSection', () => { live: 'example.com', test: 'example.com', }, + oauth_connections: { + live: { connected: true }, + test: { connected: true }, + }, }, } ); useTestMode.mockReturnValue( [ false, jest.fn() ] ); @@ -198,6 +210,10 @@ describe( 'AccountDetailsSection', () => { live: 'example.com', test: 'example.com', }, + oauth_connections: { + live: { connected: true }, + test: { connected: true }, + }, }, } ); mockRefreshAccount.mockClear(); @@ -241,5 +257,35 @@ describe( 'AccountDetailsSection', () => { expect( mockRefreshAccount ).toHaveBeenCalledTimes( 1 ); } ); + + it( 'should change the button text when not oauth connected', () => { + useAccount.mockReturnValue( { + data: { + webhook_url: 'example.com', + account: { + id: 'acct_123', + email: 'test@example.com', + testmode: false, + }, + configured_webhook_urls: { + live: 'example.com', + test: 'example.com', + }, + oauth_connections: { + live: { connected: false }, + test: { connected: false }, + }, + }, + } ); + + render( + + ); + + const editKeysButton = screen.getByRole( 'button', { + name: /Reconnect to Stripe/i, + } ); + expect( editKeysButton ).toBeInTheDocument(); + } ); } ); } ); From 15916c55c1339ecf34442d4481b788df505b2455 Mon Sep 17 00:00:00 2001 From: Wesley Rosa Date: Fri, 19 Sep 2025 18:19:27 -0300 Subject: [PATCH 11/21] Changing the style of the new top notice --- .../admin/class-wc-stripe-admin-notices.php | 47 ++++++++++++------- 1 file changed, 31 insertions(+), 16 deletions(-) diff --git a/includes/admin/class-wc-stripe-admin-notices.php b/includes/admin/class-wc-stripe-admin-notices.php index 0e25fc22bb..ee267e1187 100644 --- a/includes/admin/class-wc-stripe-admin-notices.php +++ b/includes/admin/class-wc-stripe-admin-notices.php @@ -41,12 +41,12 @@ public function __construct() { * @since 1.0.0 * @version 4.0.0 */ - public function add_admin_notice( $slug, $class, $message, $dismissible = false, $icon_img_url = '' ) { + public function add_admin_notice( $slug, $class, $message, $dismissible = false, $actions = [] ) { $this->notices[ $slug ] = [ - 'class' => $class, - 'message' => $message, - 'dismissible' => $dismissible, - 'icon_img_url' => $icon_img_url, + 'class' => $class, + 'message' => $message, + 'dismissible' => $dismissible, + 'actions' => $actions, ]; } @@ -74,7 +74,7 @@ public function admin_notices() { } foreach ( (array) $this->notices as $notice_key => $notice ) { - echo '
'; + echo '
'; if ( $notice['dismissible'] ) { ?> @@ -82,12 +82,6 @@ public function admin_notices() { - - '; echo wp_kses( $notice['message'], @@ -100,7 +94,23 @@ public function admin_notices() { 'br' => [], ] ); - echo '

'; + echo '

'; + + if ( count( $notice['actions'] ) > 0 ) { + foreach ( $notice['actions'] as $action ) { + echo wp_kses( + $action, + [ + 'a' => [ + 'href' => [], + 'style' => [], + ], + ] + ); + } + } + + echo '
'; } } @@ -414,9 +424,14 @@ public function stripe_check_environment() { $oauth_required = $needs_live_oauth || $needs_test_oauth; if ( $oauth_required ) { - $icon_img_url = WC_STRIPE_PLUGIN_URL . '/assets/images/info.svg'; - $message = __( 'Please reconnect to continue using Stripe and avoid disruptions on your store.', 'woocommerce-gateway-stripe' ); - $this->add_admin_notice( 'oauth_required', 'notice notice-warning', $message, true, $icon_img_url ); + $message = __( 'Please reconnect to continue using Stripe and avoid disruptions on your store.', 'woocommerce-gateway-stripe' ); + $link = esc_url( admin_url( 'admin.php?page=wc-settings&tab=checkout§ion=stripe&panel=settings&highlight=account-details' ) ); + $actions = [ + '' + . __( 'Reconnect to Stripe', 'woocommerce-gateway-stripe' ) + . '', + ]; + $this->add_admin_notice( 'oauth_required', 'notice notice-error', $message, true, $actions ); } } } From 260d67567351c3c5d840bca7b2b948151018097f Mon Sep 17 00:00:00 2001 From: Wesley Rosa Date: Fri, 19 Sep 2025 18:21:44 -0300 Subject: [PATCH 12/21] Enabling styles when OC is not enabled --- .../payment-methods/class-wc-stripe-upe-payment-gateway.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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 cd7c568aa0..dad6bcbca1 100644 --- a/includes/payment-methods/class-wc-stripe-upe-payment-gateway.php +++ b/includes/payment-methods/class-wc-stripe-upe-payment-gateway.php @@ -287,7 +287,8 @@ public function __construct() { // Hide action buttons for pending orders if they take a while to be confirmed. add_filter( 'woocommerce_my_account_my_orders_actions', [ $this, 'filter_my_account_my_orders_actions' ], 10, 2 ); - // For the Optimized Checkout, allow the display property in inline styles to hide payment method instructions (see `get_testing_instructions_for_optimized_checkout`). + // Allow the display property in inline styles to hide payment method instructions (see `get_testing_instructions_for_optimized_checkout`) + // And to display notices in the admin pages with stylized action buttons if ( $this->oc_enabled ) { add_filter( 'safe_style_css', From 72f2ed49e409cb3c2341a0fc67c6f073790e1380 Mon Sep 17 00:00:00 2001 From: Wesley Rosa Date: Fri, 19 Sep 2025 18:23:08 -0300 Subject: [PATCH 13/21] Enabling styles when OC is not enabled --- .../class-wc-stripe-upe-payment-gateway.php | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) 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 dad6bcbca1..97cb921ec6 100644 --- a/includes/payment-methods/class-wc-stripe-upe-payment-gateway.php +++ b/includes/payment-methods/class-wc-stripe-upe-payment-gateway.php @@ -289,14 +289,12 @@ public function __construct() { // Allow the display property in inline styles to hide payment method instructions (see `get_testing_instructions_for_optimized_checkout`) // And to display notices in the admin pages with stylized action buttons - if ( $this->oc_enabled ) { - add_filter( - 'safe_style_css', - function ( $styles ) { - return array_merge( $styles, [ 'display' ] ); - } - ); - } + add_filter( + 'safe_style_css', + function ( $styles ) { + return array_merge( $styles, [ 'display' ] ); + } + ); // Add metadata to Stripe intents for easier debugging of BNPL issues. add_filter( 'wc_stripe_intent_metadata', [ $this, 'add_bnpl_debug_metadata' ], 10, 2 ); From 17ad679314276586e33626f52279de86dd5e1d0f Mon Sep 17 00:00:00 2001 From: Wesley Rosa Date: Fri, 19 Sep 2025 18:41:50 -0300 Subject: [PATCH 14/21] Fix tests --- .../account-details/__tests__/account-details.test.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/client/settings/account-details/__tests__/account-details.test.js b/client/settings/account-details/__tests__/account-details.test.js index 12568878e7..c92ad6c8eb 100644 --- a/client/settings/account-details/__tests__/account-details.test.js +++ b/client/settings/account-details/__tests__/account-details.test.js @@ -60,6 +60,10 @@ describe( 'AccountDetails', () => { payouts_enabled: false, charges_enabled: false, }, + testmode: true, + oauth_connections: { + test: { connected: true }, + }, }, } ); render( ); From b72f045037f183740b9964534b9226cbaebcf0ed Mon Sep 17 00:00:00 2001 From: Wesley Rosa Date: Fri, 19 Sep 2025 18:47:22 -0300 Subject: [PATCH 15/21] Unit test --- .../__tests__/account-details.test.js | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/client/settings/account-details/__tests__/account-details.test.js b/client/settings/account-details/__tests__/account-details.test.js index c92ad6c8eb..b3ed91aaed 100644 --- a/client/settings/account-details/__tests__/account-details.test.js +++ b/client/settings/account-details/__tests__/account-details.test.js @@ -93,4 +93,29 @@ describe( 'AccountDetails', () => { screen.queryByText( mockedWarningMessage ) ).toBeInTheDocument(); } ); + + it( 'renders the reconnet notice when not connected via oauth', () => { + useAccount.mockReturnValue( { + data: { + testmode: true, + oauth_connections: { + test: { connected: false }, + }, + account: { + settings: { + payouts: { + schedule: { interval: 'daily', delay_days: 2 }, + }, + }, + payouts_enabled: true, + charges_enabled: true, + }, + }, + } ); + render( ); + + expect( + screen.queryByText( /reconnect your Stripe account/i ) + ).toBeInTheDocument(); + } ); } ); From 064dba5735406699eb52cd28ac61e7a00c004aaa Mon Sep 17 00:00:00 2001 From: Wesley Rosa Date: Fri, 19 Sep 2025 18:47:57 -0300 Subject: [PATCH 16/21] Renaming test file --- .../__tests__/{account-details.test.js => index.test.js} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename client/settings/account-details/__tests__/{account-details.test.js => index.test.js} (100%) diff --git a/client/settings/account-details/__tests__/account-details.test.js b/client/settings/account-details/__tests__/index.test.js similarity index 100% rename from client/settings/account-details/__tests__/account-details.test.js rename to client/settings/account-details/__tests__/index.test.js From b16227d1fb37415c83e2e32f53ed78cc3c295bdf Mon Sep 17 00:00:00 2001 From: Wesley Rosa Date: Tue, 23 Sep 2025 14:17:49 -0300 Subject: [PATCH 17/21] Improve unit test --- client/settings/account-details/__tests__/index.test.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/client/settings/account-details/__tests__/index.test.js b/client/settings/account-details/__tests__/index.test.js index b3ed91aaed..bbc2b45e8e 100644 --- a/client/settings/account-details/__tests__/index.test.js +++ b/client/settings/account-details/__tests__/index.test.js @@ -94,7 +94,7 @@ describe( 'AccountDetails', () => { ).toBeInTheDocument(); } ); - it( 'renders the reconnet notice when not connected via oauth', () => { + it( 'renders the reconnect notice when not connected via oauth', () => { useAccount.mockReturnValue( { data: { testmode: true, @@ -115,7 +115,9 @@ describe( 'AccountDetails', () => { render( ); expect( - screen.queryByText( /reconnect your Stripe account/i ) + screen.queryByText( + 'Reconnect your Stripe account using the new authentication flow to avoid disruptions on your store.' + ) ).toBeInTheDocument(); } ); } ); From b66a54db8b563cfc76cc838ab4a67e8fbb922c58 Mon Sep 17 00:00:00 2001 From: Wesley Rosa Date: Tue, 23 Sep 2025 14:32:04 -0300 Subject: [PATCH 18/21] Making the overflow style change strict to notices with actions + comment --- includes/admin/class-wc-stripe-admin-notices.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/includes/admin/class-wc-stripe-admin-notices.php b/includes/admin/class-wc-stripe-admin-notices.php index ee267e1187..80a6217708 100644 --- a/includes/admin/class-wc-stripe-admin-notices.php +++ b/includes/admin/class-wc-stripe-admin-notices.php @@ -74,7 +74,14 @@ public function admin_notices() { } foreach ( (array) $this->notices as $notice_key => $notice ) { - echo '
'; + $has_actions = count( $notice['actions'] ) > 0; + $div_style = 'position:relative;'; + if ( $has_actions ) { + // If there are actions, we need to make sure the div can contain them. + $div_style .= 'overflow: auto;'; + } + + echo '
'; if ( $notice['dismissible'] ) { ?> @@ -96,7 +103,7 @@ public function admin_notices() { ); echo '

'; - if ( count( $notice['actions'] ) > 0 ) { + if ( $has_actions ) { foreach ( $notice['actions'] as $action ) { echo wp_kses( $action, From 39483773089edae6e49da5fbf42f91d988ec0152 Mon Sep 17 00:00:00 2001 From: Wesley Rosa Date: Tue, 23 Sep 2025 14:40:22 -0300 Subject: [PATCH 19/21] Correctly handling the highlight of account details in the frontend --- .../account-details-section.js | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/client/settings/payment-settings/account-details-section.js b/client/settings/payment-settings/account-details-section.js index 46cdd8a216..0a5b5d39fa 100644 --- a/client/settings/payment-settings/account-details-section.js +++ b/client/settings/payment-settings/account-details-section.js @@ -1,6 +1,7 @@ -import { React, useState } from 'react'; +import { React, useEffect, useRef, useState } from 'react'; import { moreVertical } from '@wordpress/icons'; import styled from '@emotion/styled'; +import { getQuery } from '@woocommerce/navigation'; import CardBody from '../card-body'; import CardFooter from '../card-footer'; import Pill from '../../components/pill'; @@ -93,17 +94,32 @@ const AccountSettingsDropdownMenu = ( { // @todo - remove setModalType as prop const AccountDetailsSection = ( { setModalType, setKeepModalContent } ) => { + const headingRef = useRef( null ); const [ isTestMode ] = useTestMode(); const { data } = useAccount(); const oauthConnected = isTestMode ? data?.oauth_connections?.test?.connected : data?.oauth_connections?.live?.connected; + useEffect( () => { + if ( ! headingRef.current ) { + return; + } + + const { highlight } = getQuery(); + if ( highlight === 'account-details' ) { + headingRef.current.scrollIntoView( { + behavior: 'smooth', + block: 'start', + } ); + } + }, [ headingRef ] ); + return ( -

+

{ data.account?.email ? data.account.email : __( From 0b9e97ba0625d0ecf33eec01e4fc504461525993 Mon Sep 17 00:00:00 2001 From: Wesley Rosa Date: Tue, 23 Sep 2025 17:47:39 -0300 Subject: [PATCH 20/21] Upgrading wordpress/icons package + replacing the notice icon with the caution icon --- .../account-details/reconnect-notice.js | 4 +- package-lock.json | 113 +++++++++--------- package.json | 2 +- 3 files changed, 60 insertions(+), 59 deletions(-) diff --git a/client/settings/account-details/reconnect-notice.js b/client/settings/account-details/reconnect-notice.js index 246fc1dfc0..29273e4499 100644 --- a/client/settings/account-details/reconnect-notice.js +++ b/client/settings/account-details/reconnect-notice.js @@ -1,4 +1,4 @@ -import { info } from '@wordpress/icons'; +import { caution } from '@wordpress/icons'; import React from 'react'; import styled from '@emotion/styled'; import { __ } from '@wordpress/i18n'; @@ -24,7 +24,7 @@ export const ReconnectNotice = () => { return ( - + { __( 'Reconnect your Stripe account using the new authentication flow to avoid disruptions on your store.', diff --git a/package-lock.json b/package-lock.json index 832303ba0c..57a0699f0f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -54,7 +54,7 @@ "@wordpress/eslint-plugin": "^17.13.0", "@wordpress/hooks": "3.2.0", "@wordpress/i18n": "^4.2.1", - "@wordpress/icons": "^5.0.1", + "@wordpress/icons": "10.31.0", "@wordpress/jest-preset-default": "^12.22.0", "@wordpress/notices": "2.13.3", "@wordpress/prettier-config": "^3.15.0", @@ -8435,93 +8435,94 @@ } }, "node_modules/@wordpress/icons": { - "version": "5.0.2", - "resolved": "https://registry.npmjs.org/@wordpress/icons/-/icons-5.0.2.tgz", - "integrity": "sha512-ckogzI/j9c+gqTA9T2zCtUiA7gjZHVWvC6USMCBHzPIVK7njQ9MD5R55vSEueA/qjhhcbcTZgz0yWrXnuE9PZw==", + "version": "10.31.0", + "resolved": "https://registry.npmjs.org/@wordpress/icons/-/icons-10.31.0.tgz", + "integrity": "sha512-Bfwt3SyjqClG6mwY78zhlzVRRW/OIqej09NLOGO0CDtjfrgQqD5HAK8kk2CayQr4hWeKMoFxzPBevMxWumBMPA==", "dev": true, + "license": "GPL-2.0-or-later", "dependencies": { - "@babel/runtime": "^7.13.10", - "@wordpress/element": "^4.0.1", - "@wordpress/primitives": "^3.0.1" + "@babel/runtime": "7.25.7", + "@wordpress/element": "^6.31.0", + "@wordpress/primitives": "^4.31.0" }, "engines": { - "node": ">=12" + "node": ">=18.12.0", + "npm": ">=8.19.2" } }, - "node_modules/@wordpress/icons/node_modules/@types/react-dom": { - "version": "16.9.25", - "resolved": "https://registry.npmjs.org/@types/react-dom/-/react-dom-16.9.25.tgz", - "integrity": "sha512-ZK//eAPhwft9Ul2/Zj+6O11YR6L4JX0J2sVeBC9Ft7x7HFN7xk7yUV/zDxqV6rjvqgl6r8Dq7oQImxtyf/Mzcw==", + "node_modules/@wordpress/icons/node_modules/@types/react": { + "version": "18.3.24", + "resolved": "https://registry.npmjs.org/@types/react/-/react-18.3.24.tgz", + "integrity": "sha512-0dLEBsA1kI3OezMBF8nSsb7Nk19ZnsyE1LLhB8r27KbgU5H4pvuqZLdtE+aUkJVoXgTVuA+iLIwmZ0TuK4tx6A==", "dev": true, - "peerDependencies": { - "@types/react": "^16.0.0" + "license": "MIT", + "dependencies": { + "@types/prop-types": "*", + "csstype": "^3.0.2" } }, "node_modules/@wordpress/icons/node_modules/@wordpress/element": { - "version": "4.0.4", - "resolved": "https://registry.npmjs.org/@wordpress/element/-/element-4.0.4.tgz", - "integrity": "sha512-GbYVSZrHitOmupQCjb7cSlewVigXHorpZUBpvWnkU3rhyh1tF/N9qve3fgg7Q3s2szjtTP+eEutB+4mmkwHQOA==", + "version": "6.31.0", + "resolved": "https://registry.npmjs.org/@wordpress/element/-/element-6.31.0.tgz", + "integrity": "sha512-KOier6Y4b4Y5yEV1GYen81R9gCEOvJT6eVbsc93w2fFEKi2FK/oI7IKzGv9GeJMkoCWvTSX6C/ZYTWk6fCUfeA==", "dev": true, + "license": "GPL-2.0-or-later", "dependencies": { - "@babel/runtime": "^7.16.0", - "@types/react": "^16.9.0", - "@types/react-dom": "^16.9.0", - "@wordpress/escape-html": "^2.2.3", - "lodash": "^4.17.21", - "react": "^17.0.1", - "react-dom": "^17.0.1" + "@babel/runtime": "7.25.7", + "@types/react": "^18.2.79", + "@types/react-dom": "^18.2.25", + "@wordpress/escape-html": "^3.31.0", + "change-case": "^4.1.2", + "is-plain-object": "^5.0.0", + "react": "^18.3.0", + "react-dom": "^18.3.0" }, "engines": { - "node": ">=12" + "node": ">=18.12.0", + "npm": ">=8.19.2" } }, "node_modules/@wordpress/icons/node_modules/@wordpress/escape-html": { - "version": "2.2.3", - "resolved": "https://registry.npmjs.org/@wordpress/escape-html/-/escape-html-2.2.3.tgz", - "integrity": "sha512-nYIwT8WzHfAzjjwHLiwDQWrzn4/gUNr5zud465XQszM2cAItN2wnC26/ovSpPomDGkvjcG0YltgnSqc1T62olA==", + "version": "3.31.0", + "resolved": "https://registry.npmjs.org/@wordpress/escape-html/-/escape-html-3.31.0.tgz", + "integrity": "sha512-9g9qd7Q16PWDeYEa2dU+84d1SvjP4LfS7n7AuXkwl5+F7KfL2nZTmDTHWutw9jVjdDAGmjm1VNIj4ydQk9vaLA==", "dev": true, + "license": "GPL-2.0-or-later", "dependencies": { - "@babel/runtime": "^7.16.0" + "@babel/runtime": "7.25.7" }, "engines": { - "node": ">=12" + "node": ">=18.12.0", + "npm": ">=8.19.2" } }, - "node_modules/@wordpress/icons/node_modules/react": { - "version": "17.0.2", - "resolved": "https://registry.npmjs.org/react/-/react-17.0.2.tgz", - "integrity": "sha512-gnhPt75i/dq/z3/6q/0asP78D0u592D5L1pd7M8P+dck6Fu/jJeL6iVVK23fptSUZj8Vjf++7wXA8UNclGQcbA==", + "node_modules/@wordpress/icons/node_modules/@wordpress/primitives": { + "version": "4.31.0", + "resolved": "https://registry.npmjs.org/@wordpress/primitives/-/primitives-4.31.0.tgz", + "integrity": "sha512-cY4EKYQRqHu9NZuoWchxc/KWiofwGskzxz0oCfgbdkRlfTag8yBjWMayz+fRNaenw0l5pzLyIg3rcNDN8xLezw==", "dev": true, + "license": "GPL-2.0-or-later", "dependencies": { - "loose-envify": "^1.1.0", - "object-assign": "^4.1.1" + "@babel/runtime": "7.25.7", + "@wordpress/element": "^6.31.0", + "clsx": "^2.1.1" }, "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/@wordpress/icons/node_modules/react-dom": { - "version": "17.0.2", - "resolved": "https://registry.npmjs.org/react-dom/-/react-dom-17.0.2.tgz", - "integrity": "sha512-s4h96KtLDUQlsENhMn1ar8t2bEa+q/YAtj8pPPdIjPDGBDIVNsrD9aXNWqspUe6AzKCIG0C1HZZLqLV7qpOBGA==", - "dev": true, - "dependencies": { - "loose-envify": "^1.1.0", - "object-assign": "^4.1.1", - "scheduler": "^0.20.2" + "node": ">=18.12.0", + "npm": ">=8.19.2" }, "peerDependencies": { - "react": "17.0.2" + "react": "^18.0.0" } }, - "node_modules/@wordpress/icons/node_modules/scheduler": { - "version": "0.20.2", - "resolved": "https://registry.npmjs.org/scheduler/-/scheduler-0.20.2.tgz", - "integrity": "sha512-2eWfGgAqqWFGqtdMmcL5zCMK1U8KlXv8SQFGglL3CEtd0aDVDWgeF/YoCmvln55m5zSk3J/20hTaSBeSObsQDQ==", + "node_modules/@wordpress/icons/node_modules/is-plain-object": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/is-plain-object/-/is-plain-object-5.0.0.tgz", + "integrity": "sha512-VRSzKkbMm5jMDoKLbltAkFQ5Qr7VDiTFGXxYFXXowVj387GeGNOCsOH6Msy00SGZ3Fp84b1Naa1psqgcCIEP5Q==", "dev": true, - "dependencies": { - "loose-envify": "^1.1.0", - "object-assign": "^4.1.1" + "license": "MIT", + "engines": { + "node": ">=0.10.0" } }, "node_modules/@wordpress/jest-console": { diff --git a/package.json b/package.json index dcd5903597..3cafd3f805 100644 --- a/package.json +++ b/package.json @@ -44,7 +44,7 @@ "@wordpress/eslint-plugin": "^17.13.0", "@wordpress/hooks": "3.2.0", "@wordpress/i18n": "^4.2.1", - "@wordpress/icons": "^5.0.1", + "@wordpress/icons": "10.31.0", "@wordpress/jest-preset-default": "^12.22.0", "@wordpress/notices": "2.13.3", "@wordpress/prettier-config": "^3.15.0", From 48270ef11e79416dda97072de0d9accb2bcfb7ad Mon Sep 17 00:00:00 2001 From: Wesley Rosa Date: Tue, 23 Sep 2025 17:49:23 -0300 Subject: [PATCH 21/21] Removing the unused icon --- assets/images/info.svg | 8 -------- 1 file changed, 8 deletions(-) delete mode 100644 assets/images/info.svg diff --git a/assets/images/info.svg b/assets/images/info.svg deleted file mode 100644 index 099b41b68c..0000000000 --- a/assets/images/info.svg +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - -