From 10a07837c2752871658bf595bdd27f425138ef03 Mon Sep 17 00:00:00 2001 From: James Allan Date: Tue, 10 Sep 2024 17:48:04 +1000 Subject: [PATCH 1/7] Add an admin notice for SEPA subscriptions migrations after disabling legacy checkout (#3422) * Display an admin notice to inform users of the SEPA migration after disabling legacy checkout * Get any status * The next action should never be more than 3 hours so remove the else case * Add changelog entries * Display the notice for up to 3 days to limit the scope of the notice queries * Stop showing the notice after all subscriptions have been migrated * If admin re-enable legacy checkout and then later disable legacy checkout, we should make sure to reattempt the migrations * Update includes/migrations/class-wc-stripe-subscriptions-repairer-legacy-sepa-tokens.php Co-authored-by: Matt Allan * Schedule jobs to run in 1 minute rather than 1 hour * Update notice to no longer include next update time case * Treat in-progress actions as $is_still_scheduling_jobs * Remove duplicated Paged param * Schedule individual SEPA updates to run in 2 minutes * Add a tool to enable users to restart the migration if needed * Replace "migrate" with "update" * Move variable around for slight performance improvement * Add changelog entry for new tool * Update includes/migrations/class-wc-stripe-subscriptions-repairer-legacy-sepa-tokens.php Co-authored-by: Matt Allan --------- Co-authored-by: Matt Allan --- changelog.txt | 2 + ...ass-wc-rest-stripe-settings-controller.php | 6 + ...scriptions-repairer-legacy-sepa-tokens.php | 225 +++++++++++++++++- readme.txt | 2 + 4 files changed, 234 insertions(+), 1 deletion(-) diff --git a/changelog.txt b/changelog.txt index beba4b5d0..37a078c86 100644 --- a/changelog.txt +++ b/changelog.txt @@ -29,6 +29,8 @@ * Fix - Address Klarna availability based on correct presentment currency rules. * Fix - Use correct ISO country code of United Kingdom in supported country and currency list of AliPay and WeChat. * Fix - Prevent duplicate order notes and emails being sent when purchasing subscription products with no initial payment. +* Add - Display an admin notice on the WooCommerce > Subscriptions screen for tracking the progress of SEPA subscriptions migrations after the legacy checkout is disabled. +* Add - Introduce a new tool on the WooCommerce > Status > Tools screen to restart the legacy SEPA subscriptions update. = 8.6.1 - 2024-08-09 = * Tweak - Improves the wording of the invalid Stripe keys errors, instructing merchants to click the "Configure connection" button instead of manually setting the keys. diff --git a/includes/admin/class-wc-rest-stripe-settings-controller.php b/includes/admin/class-wc-rest-stripe-settings-controller.php index 75ff2882f..2272c3b8c 100644 --- a/includes/admin/class-wc-rest-stripe-settings-controller.php +++ b/includes/admin/class-wc-rest-stripe-settings-controller.php @@ -455,6 +455,12 @@ private function update_is_upe_enabled( WP_REST_Request $request ) { } $settings = WC_Stripe_Helper::get_stripe_settings(); + + // If the new UPE is enabled, we need to remove the flag to ensure legacy SEPA tokens are updated flag. + if ( $is_upe_enabled && ! WC_Stripe_Feature_Flags::is_upe_checkout_enabled() ) { + delete_option( 'woocommerce_stripe_subscriptions_legacy_sepa_tokens_updated' ); + } + $settings[ WC_Stripe_Feature_Flags::UPE_CHECKOUT_FEATURE_ATTRIBUTE_NAME ] = $is_upe_enabled ? 'yes' : 'disabled'; WC_Stripe_Helper::update_main_stripe_settings( $settings ); diff --git a/includes/migrations/class-wc-stripe-subscriptions-repairer-legacy-sepa-tokens.php b/includes/migrations/class-wc-stripe-subscriptions-repairer-legacy-sepa-tokens.php index 763342a55..b5aa70c38 100644 --- a/includes/migrations/class-wc-stripe-subscriptions-repairer-legacy-sepa-tokens.php +++ b/includes/migrations/class-wc-stripe-subscriptions-repairer-legacy-sepa-tokens.php @@ -12,6 +12,20 @@ */ class WC_Stripe_Subscriptions_Repairer_Legacy_SEPA_Tokens extends WCS_Background_Repairer { + /** + * The transient key used to store the progress of the repair. + * + * @var string + */ + private $action_progress_transient = 'wc_stripe_legacy_sepa_tokens_repair_progress'; + + /** + * The transient key used to store whether we should display the notice to the user. + * + * @var string + */ + private $display_notice_transient = 'wc_stripe_legacy_sepa_tokens_repair_notice'; + /** * Constructor * @@ -26,6 +40,10 @@ public function __construct( WC_Logger_Interface $logger ) { // Repair subscriptions prior to renewal as a backstop. Hooked onto 0 to run before the actual renewal. add_action( 'woocommerce_scheduled_subscription_payment', [ $this, 'maybe_migrate_before_renewal' ], 0 ); + + add_action( 'admin_notices', [ $this, 'display_admin_notice' ] ); + + add_filter( 'woocommerce_debug_tools', [ $this, 'add_debug_tool' ] ); } /** @@ -48,6 +66,9 @@ public function maybe_update() { // This will be handled in the scheduled action. $this->schedule_repair(); + // Display the admin notice to inform the user that the repair is in progress. Limited to 3 days. + set_transient( $this->display_notice_transient, 'yes', 3 * DAY_IN_SECONDS ); + // Prevent the repair from being scheduled again. update_option( 'woocommerce_stripe_subscriptions_legacy_sepa_tokens_updated', 'yes' ); } @@ -67,11 +88,32 @@ public function repair_item( $subscription_id ) { $token_updater->maybe_update_subscription_legacy_payment_method( $subscription_id ); $this->log( sprintf( 'Successful migration of subscription #%1$d.', $subscription_id ) ); + + delete_transient( $this->action_progress_transient ); } catch ( \Exception $e ) { $this->log( $e->getMessage() ); } } + /** + * Schedules an individual action to migrate a subscription. + * + * Overrides the parent class function to make two changes: + * 1. Don't schedule an action if one already exists. + * 2. Schedules the migration to happen in two minutes instead of in one hour. + * 3. Delete the transient which stores the progress of the repair. + * + * @param int $item The ID of the subscription to migrate. + */ + protected function update_item( $item ) { + if ( ! as_next_scheduled_action( $this->repair_hook, [ 'repair_object' => $item ] ) ) { + as_schedule_single_action( gmdate( 'U' ) + ( 2 * MINUTE_IN_SECONDS ), $this->repair_hook, [ 'repair_object' => $item ] ); + } + + unset( $this->items_to_repair[ $item ] ); + delete_transient( $this->action_progress_transient ); + } + /** * Gets the batch of subscriptions using the Legacy SEPA payment method to be updated. * @@ -85,7 +127,6 @@ protected function get_items_to_repair( $page ) { 'return' => 'ids', 'type' => 'shop_subscription', 'posts_per_page' => 20, - 'paged' => $page, 'status' => 'any', 'paged' => $page, 'payment_method' => WC_Gateway_Stripe_Sepa::ID, @@ -140,4 +181,186 @@ public function maybe_migrate_before_renewal( $subscription_id ) { $token_updater->maybe_update_subscription_source( $subscription ); } } + + /** + * Displays an admin notice to inform the user that the repair is in progress. + * + * This notice is displayed on the Subscriptions list table page and includes information about the progress of the repair. + * What % of the repair is complete, or when the next scheduled action is expected to run. + */ + public function display_admin_notice() { + + if ( ! class_exists( 'WC_Subscriptions' ) || ! WC_Stripe_Feature_Flags::is_upe_checkout_enabled() ) { + return; + } + + // Only display this on the subscriptions list table page. + if ( ! $this->is_admin_subscriptions_list_table_screen() ) { + return; + } + + // The notice is only displayed for up to 3 days after disabling the setting. + $display_notice = get_transient( $this->display_notice_transient ) === 'yes'; + + if ( ! $display_notice ) { + return; + } + + // If there are no subscriptions to be migrated, remove the transient so we don't show the notice. + // Don't return early so we can show the notice at least once. + if ( ! $this->has_legacy_sepa_subscriptions() ) { + delete_transient( $this->display_notice_transient ); + } + + $action_progress = $this->get_scheduled_action_counts(); + + if ( ! $action_progress ) { + return; + } + + // If we're still in the process of scheduling jobs, show a note to the user. + if ( (bool) as_next_scheduled_action( $this->scheduled_hook ) ) { + // translators: %1$s: tag, %2$s: tag, %3$s: tag. %4$s: tag. + $progress = sprintf( __( '%1$sProgress: %2$s %3$sWe are still identifying all subscriptions that require updating.%4$s', 'woocommerce-gateway-stripe' ), '', '', '', '' ); + } else { + // All scheduled actions have run, so we're done. + if ( 0 === absint( $action_progress['pending'] ) ) { + // Remove the transient to prevent the notice from showing again. + delete_transient( $this->display_notice_transient ); + } + + // Calculate the percentage of completed actions. + $total_action_count = $action_progress['pending'] + $action_progress['complete']; + $compete_percentage = $total_action_count ? floor( ( $action_progress['complete'] / $total_action_count ) * 100 ) : 0; + + // translators: %1$s: tag, %2$s: tag, %3$s: percentage complete. + $progress = sprintf( __( '%1$sProgress: %2$s %3$s%% complete', 'woocommerce-gateway-stripe' ), '', '', $compete_percentage ); + } + + // Note: We're using a Subscriptions class to generate the admin notice, however, it's safe to use given the context of this class. + $notice = new WCS_Admin_Notice( 'notice notice-warning is-dismissible' ); + $notice->set_html_content( + '

' . esc_html__( 'SEPA subscription update in progress', 'woocommerce-gateway-stripe' ) . '

' . + '

' . __( "We are currently updating customer subscriptions that use the legacy Stripe SEPA Direct Debit payment method. During this update, you may notice that some subscriptions appear as manual renewals. Don't worry—renewals will continue to process as normal. Please be aware this process may take some time.", 'woocommerce-gateway-stripe' ) . '

' . + '

' . $progress . '

' + ); + + $notice->display(); + } + + /** + * Checks if the current screen is the subscriptions list table. + * + * @return bool True if the current screen is the subscriptions list table, false otherwise. + */ + private function is_admin_subscriptions_list_table_screen() { + if ( ! is_admin() || ! function_exists( 'get_current_screen' ) ) { + return false; + } + + $screen = get_current_screen(); + + if ( ! is_object( $screen ) ) { + return false; + } + + // Check if we are on the subscriptions list table page in a HPOS or WP_Post context. + return in_array( $screen->id, [ 'woocommerce_page_wc-orders--shop_subscription', 'edit-shop_subscription' ], true ); + } + + /** + * Fetches the number of pending and completed migration scheduled actions. + * + * @return array|bool The counts of pending and completed actions. False if the Action Scheduler store is not available. + */ + private function get_scheduled_action_counts() { + $action_counts = get_transient( $this->action_progress_transient ); + + // If the transient is not set, calculate the action counts. + if ( false === $action_counts ) { + $store = ActionScheduler::store(); + + if ( ! $store ) { + return false; + } + + $action_counts = [ + 'pending' => (int) $store->query_actions( + [ + 'hook' => $this->repair_hook, + 'status' => ActionScheduler_Store::STATUS_PENDING, + ], + 'count' + ), + 'complete' => (int) $store->query_actions( + [ + 'hook' => $this->repair_hook, + 'status' => ActionScheduler_Store::STATUS_COMPLETE, + ], + 'count' + ), + ]; + + set_transient( $this->action_progress_transient, $action_counts, 10 * MINUTE_IN_SECONDS ); + } + + return $action_counts; + } + + /** + * Registers the repair tool for the Legacy SEPA token migration. + * + * @param array $tools The existing repair tools. + * + * @return array The updated repair tools. + */ + public function add_debug_tool( $tools ) { + // We don't need to show the tool if the WooCommerce Subscriptions extension isn't active or the UPE checkout isn't enabled + if ( ! class_exists( 'WC_Subscriptions' ) || ! WC_Stripe_Feature_Flags::is_upe_checkout_enabled() ) { + return $tools; + } + + // Don't show the tool if the repair is already in progress or there are no subscriptions to migrate. + if ( (bool) as_next_scheduled_action( $this->scheduled_hook ) || (bool) as_next_scheduled_action( $this->repair_hook ) || ! $this->has_legacy_sepa_subscriptions() ) { + return $tools; + } + + $tools['stripe_legacy_sepa_tokens'] = [ + 'name' => __( 'Stripe Legacy SEPA Token Update', 'woocommerce-gateway-stripe' ), + 'desc' => __( 'This will restart the legacy Stripe SEPA update process.', 'woocommerce-gateway-stripe' ), + 'button' => __( 'Restart SEPA token update', 'woocommerce-gateway-stripe' ), + 'callback' => [ $this, 'restart_update' ], + ]; + + return $tools; + } + + /** + * Checks if there are subscriptions using the Legacy SEPA payment method. + * + * @return bool True if there are subscriptions using the Legacy SEPA payment method, false otherwise. + */ + private function has_legacy_sepa_subscriptions() { + $subscriptions = wc_get_orders( + [ + 'return' => 'ids', + 'type' => 'shop_subscription', + 'status' => 'any', + 'posts_per_page' => 1, + 'payment_method' => WC_Gateway_Stripe_Sepa::ID, + ] + ); + + return ! empty( $subscriptions ); + } + + /** + * Restarts the legacy token update process. + */ + public function restart_update() { + // Clear the option to allow the update to be scheduled again. + delete_option( 'woocommerce_stripe_subscriptions_legacy_sepa_tokens_updated' ); + + $this->maybe_update(); + } } diff --git a/readme.txt b/readme.txt index a17f5b53c..d72a11280 100644 --- a/readme.txt +++ b/readme.txt @@ -157,5 +157,7 @@ If you get stuck, you can ask for help in the Plugin Forum. * Fix - Address Klarna availability based on correct presentment currency rules. * Fix - Use correct ISO country code of United Kingdom in supported country and currency list of AliPay and WeChat. * Fix - Prevent duplicate order notes and emails being sent when purchasing subscription products with no initial payment. +* Add - Display an admin notice on the WooCommerce > Subscriptions screen for tracking the progress of SEPA subscriptions migrations after the legacy checkout is disabled. +* Add - Introduce a new tool on the WooCommerce > Status > Tools screen to restart the legacy SEPA subscriptions update. [See changelog for all versions](https://raw.githubusercontent.com/woocommerce/woocommerce-gateway-stripe/trunk/changelog.txt). From 4758d8c6bbdcf9e5b0efd4a43379833761015089 Mon Sep 17 00:00:00 2001 From: Diego Curbelo Date: Fri, 13 Sep 2024 15:18:03 -0300 Subject: [PATCH 2/7] Remove Stripe keys from the DB when uninstalling the plugin (#3385) * Update the options list to remove * Remove webhook data when uninstalling * Disable the gateway before removing the plugin --- changelog.txt | 1 + readme.txt | 1 + uninstall.php | 122 ++++++++++++++++++++++++++++++++++++++++---------- 3 files changed, 101 insertions(+), 23 deletions(-) diff --git a/changelog.txt b/changelog.txt index 37a078c86..2d1481439 100644 --- a/changelog.txt +++ b/changelog.txt @@ -26,6 +26,7 @@ * Update - Specify the JS Stripe API version as 2024-06-20. * Tweak - Use order ID from 'get_order_number' in stripe intent metadata. * Fix - Ensure payment tokens are detached from Stripe when a user is deleted, regardless of if the admin user has a Stripe account. +* Fix - Remove the Stripe OAuth Keys when uninstalling the plugin. * Fix - Address Klarna availability based on correct presentment currency rules. * Fix - Use correct ISO country code of United Kingdom in supported country and currency list of AliPay and WeChat. * Fix - Prevent duplicate order notes and emails being sent when purchasing subscription products with no initial payment. diff --git a/readme.txt b/readme.txt index d72a11280..b386e53c2 100644 --- a/readme.txt +++ b/readme.txt @@ -154,6 +154,7 @@ If you get stuck, you can ask for help in the Plugin Forum. * Update - Specify the JS Stripe API version as 2024-06-20. * Tweak - Use order ID from 'get_order_number' in stripe intent metadata. * Fix - Ensure payment tokens are detached from Stripe when a user is deleted, regardless of if the admin user has a Stripe account. +* Fix - Remove the Stripe OAuth Keys when uninstalling the plugin. * Fix - Address Klarna availability based on correct presentment currency rules. * Fix - Use correct ISO country code of United Kingdom in supported country and currency list of AliPay and WeChat. * Fix - Prevent duplicate order notes and emails being sent when purchasing subscription products with no initial payment. diff --git a/uninstall.php b/uninstall.php index 71a22240e..49409e678 100644 --- a/uninstall.php +++ b/uninstall.php @@ -1,44 +1,120 @@ Date: Tue, 10 Sep 2024 00:04:51 +0600 Subject: [PATCH 3/7] Fix undefined check of global variable (#3387) * get data from wcSettings on block checkout if 'wc_stripe_upe_params' is not loaded yet --- changelog.txt | 3 +++ client/stripe-utils/utils.js | 33 +++++++++++++++++++++++---------- readme.txt | 3 +++ 3 files changed, 29 insertions(+), 10 deletions(-) diff --git a/changelog.txt b/changelog.txt index 2d1481439..4739f74ca 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,5 +1,8 @@ *** Changelog *** += 8.8.0 - xxxx-xx-xx = +* Fix - Resolve an error for checkout block where 'wc_stripe_upe_params' is undefined due to the script registering the variable not being loaded yet. + = 8.7.0 - xxxx-xx-xx = * Fix - Prevent duplicate failed-order emails from being sent. * Fix - Support custom name and description for Afterpay. diff --git a/client/stripe-utils/utils.js b/client/stripe-utils/utils.js index 736778ab0..6eea1b78b 100644 --- a/client/stripe-utils/utils.js +++ b/client/stripe-utils/utils.js @@ -1,4 +1,4 @@ -/* global wc_stripe_upe_params */ +/* global wc_stripe_upe_params, wc */ import { dispatch } from '@wordpress/data'; import { __ } from '@wordpress/i18n'; import { getAppearance } from '../styles/upe'; @@ -21,13 +21,24 @@ import { * @return {StripeServerData} Stripe server data. */ const getStripeServerData = () => { - // Classic checkout. + let data = null; + // eslint-disable-next-line camelcase - if ( ! wc_stripe_upe_params ) { + if ( typeof wc_stripe_upe_params !== 'undefined' ) { + data = wc_stripe_upe_params; // eslint-disable-line camelcase + } else if ( + typeof wc === 'object' && + typeof wc.wcSettings !== 'undefined' + ) { + // 'getSetting' has this data value on block checkout only. + data = wc.wcSettings?.getSetting( 'getSetting' ) || null; + } + + if ( ! data ) { throw new Error( 'Stripe initialization data is not available' ); } - // eslint-disable-next-line camelcase - return wc_stripe_upe_params; + + return data; }; const isNonFriendlyError = ( type ) => @@ -210,8 +221,8 @@ export { getStripeServerData, getErrorMessageForTypeAndCode }; */ export const isLinkEnabled = ( paymentMethodsConfig ) => { return ( - paymentMethodsConfig.link !== undefined && - paymentMethodsConfig.card !== undefined + paymentMethodsConfig?.link !== undefined && + paymentMethodsConfig?.card !== undefined ); }; @@ -505,16 +516,18 @@ export const getPaymentMethodName = ( paymentMethodType ) => { * @return {boolean} Whether the payment method is restricted to selected billing country. **/ export const isPaymentMethodRestrictedToLocation = ( upeElement ) => { - const paymentMethodsConfig = getStripeServerData()?.paymentMethodsConfig; + const paymentMethodsConfig = + getStripeServerData()?.paymentMethodsConfig || {}; const paymentMethodType = upeElement.dataset.paymentMethodType; - return !! paymentMethodsConfig[ paymentMethodType ].countries.length; + return !! paymentMethodsConfig[ paymentMethodType ]?.countries.length; }; /** * @param {Object} upeElement The selector of the DOM element of particular payment method to mount the UPE element to. **/ export const togglePaymentMethodForCountry = ( upeElement ) => { - const paymentMethodsConfig = getStripeServerData()?.paymentMethodsConfig; + const paymentMethodsConfig = + getStripeServerData()?.paymentMethodsConfig || {}; const paymentMethodType = upeElement.dataset.paymentMethodType; const supportedCountries = paymentMethodsConfig[ paymentMethodType ].countries; diff --git a/readme.txt b/readme.txt index b386e53c2..7942b7e78 100644 --- a/readme.txt +++ b/readme.txt @@ -128,6 +128,9 @@ If you get stuck, you can ask for help in the Plugin Forum. == Changelog == += 8.8.0 - xxxx-xx-xx = +* Fix - Resolve an error for checkout block where 'wc_stripe_upe_params' is undefined due to the script registering the variable not being loaded yet. + = 8.7.0 - xxxx-xx-xx = * Fix - Prevent duplicate failed-order emails from being sent. * Fix - Support custom name and description for Afterpay. From b58b118b1ad2e0da516a5a45aaf133e9e7ca2ed4 Mon Sep 17 00:00:00 2001 From: Diego Curbelo Date: Fri, 13 Sep 2024 16:37:12 -0300 Subject: [PATCH 4/7] Update changelog and readme --- changelog.txt | 6 ++---- readme.txt | 6 ++---- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/changelog.txt b/changelog.txt index 4739f74ca..d923b2c48 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,8 +1,5 @@ *** Changelog *** -= 8.8.0 - xxxx-xx-xx = -* Fix - Resolve an error for checkout block where 'wc_stripe_upe_params' is undefined due to the script registering the variable not being loaded yet. - = 8.7.0 - xxxx-xx-xx = * Fix - Prevent duplicate failed-order emails from being sent. * Fix - Support custom name and description for Afterpay. @@ -29,12 +26,13 @@ * Update - Specify the JS Stripe API version as 2024-06-20. * Tweak - Use order ID from 'get_order_number' in stripe intent metadata. * Fix - Ensure payment tokens are detached from Stripe when a user is deleted, regardless of if the admin user has a Stripe account. -* Fix - Remove the Stripe OAuth Keys when uninstalling the plugin. * Fix - Address Klarna availability based on correct presentment currency rules. * Fix - Use correct ISO country code of United Kingdom in supported country and currency list of AliPay and WeChat. * Fix - Prevent duplicate order notes and emails being sent when purchasing subscription products with no initial payment. * Add - Display an admin notice on the WooCommerce > Subscriptions screen for tracking the progress of SEPA subscriptions migrations after the legacy checkout is disabled. * Add - Introduce a new tool on the WooCommerce > Status > Tools screen to restart the legacy SEPA subscriptions update. +* Fix - Remove the Stripe OAuth Keys when uninstalling the plugin. +* Fix - Resolve an error for checkout block where 'wc_stripe_upe_params' is undefined due to the script registering the variable not being loaded yet. = 8.6.1 - 2024-08-09 = * Tweak - Improves the wording of the invalid Stripe keys errors, instructing merchants to click the "Configure connection" button instead of manually setting the keys. diff --git a/readme.txt b/readme.txt index 7942b7e78..14caf0848 100644 --- a/readme.txt +++ b/readme.txt @@ -128,9 +128,6 @@ If you get stuck, you can ask for help in the Plugin Forum. == Changelog == -= 8.8.0 - xxxx-xx-xx = -* Fix - Resolve an error for checkout block where 'wc_stripe_upe_params' is undefined due to the script registering the variable not being loaded yet. - = 8.7.0 - xxxx-xx-xx = * Fix - Prevent duplicate failed-order emails from being sent. * Fix - Support custom name and description for Afterpay. @@ -157,11 +154,12 @@ If you get stuck, you can ask for help in the Plugin Forum. * Update - Specify the JS Stripe API version as 2024-06-20. * Tweak - Use order ID from 'get_order_number' in stripe intent metadata. * Fix - Ensure payment tokens are detached from Stripe when a user is deleted, regardless of if the admin user has a Stripe account. -* Fix - Remove the Stripe OAuth Keys when uninstalling the plugin. * Fix - Address Klarna availability based on correct presentment currency rules. * Fix - Use correct ISO country code of United Kingdom in supported country and currency list of AliPay and WeChat. * Fix - Prevent duplicate order notes and emails being sent when purchasing subscription products with no initial payment. * Add - Display an admin notice on the WooCommerce > Subscriptions screen for tracking the progress of SEPA subscriptions migrations after the legacy checkout is disabled. * Add - Introduce a new tool on the WooCommerce > Status > Tools screen to restart the legacy SEPA subscriptions update. +* Fix - Remove the Stripe OAuth Keys when uninstalling the plugin. +* Fix - Resolve an error for checkout block where 'wc_stripe_upe_params' is undefined due to the script registering the variable not being loaded yet. [See changelog for all versions](https://raw.githubusercontent.com/woocommerce/woocommerce-gateway-stripe/trunk/changelog.txt). From 95cbb1b6e4751c9b8af1ec3638ca31cdfaba7532 Mon Sep 17 00:00:00 2001 From: Diego Curbelo Date: Fri, 13 Sep 2024 16:40:32 -0300 Subject: [PATCH 5/7] Bump WC tested up to version --- woocommerce-gateway-stripe.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/woocommerce-gateway-stripe.php b/woocommerce-gateway-stripe.php index 2ce2cee14..e677efeb5 100644 --- a/woocommerce-gateway-stripe.php +++ b/woocommerce-gateway-stripe.php @@ -10,7 +10,7 @@ * Requires at least: 6.4 * Tested up to: 6.6 * WC requires at least: 8.9 - * WC tested up to: 9.1 + * WC tested up to: 9.3 * Text Domain: woocommerce-gateway-stripe * Domain Path: /languages */ From ac0a45cb3bff23670f4ef39204f57c1595f664bd Mon Sep 17 00:00:00 2001 From: Wesley Rosa Date: Mon, 16 Sep 2024 16:25:20 -0300 Subject: [PATCH 6/7] UPE banner for APM enabled merchants (#3433) * UPE banner for APM enabled merchants * Fix payment method list override * Changelog and readme entries * Changing the dummy text for the new banner * Adding specific unit tests * Updating promotional surface with the final copy * Fix minor typo --- changelog.txt | 1 + .../promotional-banner-section.test.js | 21 ++++++ .../promotional-banner-section.js | 73 ++++++++++++++++++- readme.txt | 1 + 4 files changed, 93 insertions(+), 3 deletions(-) diff --git a/changelog.txt b/changelog.txt index d923b2c48..46df8fed1 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,6 +1,7 @@ *** Changelog *** = 8.7.0 - xxxx-xx-xx = +* Add - Introduces a new promotional surface to encourage merchants with the legacy checkout experience and APMs enabled to use the new checkout experience. * Fix - Prevent duplicate failed-order emails from being sent. * Fix - Support custom name and description for Afterpay. * Fix - Link APM charge IDs in Order Details page to their Stripe dashboard payments page. diff --git a/client/settings/payment-settings/__tests__/promotional-banner-section.test.js b/client/settings/payment-settings/__tests__/promotional-banner-section.test.js index 841d36731..cd15ff6d3 100644 --- a/client/settings/payment-settings/__tests__/promotional-banner-section.test.js +++ b/client/settings/payment-settings/__tests__/promotional-banner-section.test.js @@ -3,6 +3,7 @@ import React from 'react'; import { screen, render } from '@testing-library/react'; import userEvent from '@testing-library/user-event'; import PromotionalBannerSection from '../promotional-banner-section'; +import { useEnabledPaymentMethodIds } from 'wcstripe/data'; jest.mock( '@wordpress/data' ); @@ -10,6 +11,11 @@ jest.mock( 'wcstripe/data/account', () => ( { useAccount: jest.fn(), } ) ); +jest.mock( 'wcstripe/data', () => ( { + useEnabledPaymentMethodIds: jest.fn().mockReturnValue( [ [ 'card' ] ] ), + useTestMode: jest.fn().mockReturnValue( [ false ] ), +} ) ); + const noticesDispatch = { createErrorNotice: jest.fn(), createSuccessNotice: jest.fn(), @@ -68,4 +74,19 @@ describe( 'PromotionalBanner', () => { screen.queryByTestId( 're-connect-account-banner' ) ).toBeInTheDocument(); } ); + + it( 'Display the APM version of the new checkout experience promotional surface when any APM is enabled', () => { + useEnabledPaymentMethodIds.mockReturnValue( [ [ 'card', 'ideal' ] ] ); + + render( + + ); + + expect( + screen.queryByTestId( 'new-checkout-apms-banner' ) + ).toBeInTheDocument(); + } ); } ); diff --git a/client/settings/payment-settings/promotional-banner-section.js b/client/settings/payment-settings/promotional-banner-section.js index e01c6fdef..1a793c0c6 100644 --- a/client/settings/payment-settings/promotional-banner-section.js +++ b/client/settings/payment-settings/promotional-banner-section.js @@ -1,14 +1,15 @@ import { __ } from '@wordpress/i18n'; import { useDispatch } from '@wordpress/data'; import { React } from 'react'; -import { Card, Button } from '@wordpress/components'; +import { Card, Button, ExternalLink } from '@wordpress/components'; import styled from '@emotion/styled'; +import interpolateComponents from 'interpolate-components'; import CardBody from '../card-body'; import bannerIllustration from './banner-illustration.svg'; import bannerIllustrationReConnect from './banner-illustration-re-connect.svg'; import Pill from 'wcstripe/components/pill'; import { recordEvent } from 'wcstripe/tracking'; -import { useTestMode } from 'wcstripe/data'; +import { useEnabledPaymentMethodIds, useTestMode } from 'wcstripe/data'; const NewPill = styled( Pill )` border-color: #674399; @@ -66,6 +67,9 @@ const PromotionalBannerSection = ( { 'core/notices' ); const [ isTestModeEnabled ] = useTestMode(); + const [ enabledPaymentMethodIds ] = useEnabledPaymentMethodIds(); + const hasAPMEnabled = + enabledPaymentMethodIds.filter( ( e ) => e !== 'card' ).length > 0; const handleButtonClick = () => { const callback = async () => { @@ -159,6 +163,65 @@ const PromotionalBannerSection = ( { ); + const NewCheckoutExperienceAPMsBanner = () => ( + + + + + { __( 'New', 'woocommerce-gateway-stripe' ) } + +

+ { __( + 'Enable the new Stripe checkout to continue accepting non-card payments', + 'woocommerce-gateway-stripe' + ) } +

+

+ { interpolateComponents( { + mixedString: __( + 'Stripe will end support for non-card payment methods in the {{StripeLegacyLink}}legacy checkout on October 29, 2024{{/StripeLegacyLink}}. To continue accepting non-card payments, you must enable the new checkout experience or remove non-card payment methods from your checkout to avoid payment disruptions.', + 'woocommerce-gateway-stripe' + ), + components: { + StripeLegacyLink: ( + + ), + }, + } ) } +

+
+ + + +
+ + + { __( + 'Enable the new checkout', + 'woocommerce-gateway-stripe' + ) } + + + { __( 'Dismiss', 'woocommerce-gateway-stripe' ) } + + +
+ ); + const NewCheckoutExperienceBanner = () => ( @@ -215,7 +278,11 @@ const PromotionalBannerSection = ( { if ( isConnectedViaOAuth === false ) { BannerContent = ; } else if ( ! isUpeEnabled ) { - BannerContent = ; + if ( hasAPMEnabled ) { + BannerContent = ; + } else { + BannerContent = ; + } } return ( diff --git a/readme.txt b/readme.txt index 14caf0848..31f289dd7 100644 --- a/readme.txt +++ b/readme.txt @@ -129,6 +129,7 @@ If you get stuck, you can ask for help in the Plugin Forum. == Changelog == = 8.7.0 - xxxx-xx-xx = +* Add - Introduces a new promotional surface to encourage merchants with the legacy checkout experience and APMs enabled to use the new checkout experience. * Fix - Prevent duplicate failed-order emails from being sent. * Fix - Support custom name and description for Afterpay. * Fix - Link APM charge IDs in Order Details page to their Stripe dashboard payments page. From cd54ee8a33e53d35cc1f0d21fcfae53a6cd80080 Mon Sep 17 00:00:00 2001 From: Wesley Rosa Date: Mon, 16 Sep 2024 17:46:33 -0300 Subject: [PATCH 7/7] woorelease: Product version bump update --- changelog.txt | 2 +- package-lock.json | 2 +- package.json | 2 +- readme.txt | 4 ++-- woocommerce-gateway-stripe.php | 4 ++-- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/changelog.txt b/changelog.txt index 46df8fed1..f81254b54 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,6 +1,6 @@ *** Changelog *** -= 8.7.0 - xxxx-xx-xx = += 8.7.0 - 2024-09-16 = * Add - Introduces a new promotional surface to encourage merchants with the legacy checkout experience and APMs enabled to use the new checkout experience. * Fix - Prevent duplicate failed-order emails from being sent. * Fix - Support custom name and description for Afterpay. diff --git a/package-lock.json b/package-lock.json index d8061ef35..ee1482c3e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "woocommerce-gateway-stripe", - "version": "8.6.1", + "version": "8.7.0", "lockfileVersion": 2, "requires": true, "packages": { diff --git a/package.json b/package.json index 270ca44a5..0ebe59200 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "woocommerce-gateway-stripe", "title": "WooCommerce Gateway Stripe", - "version": "8.6.1", + "version": "8.7.0", "license": "GPL-3.0", "homepage": "http://wordpress.org/plugins/woocommerce-gateway-stripe/", "repository": { diff --git a/readme.txt b/readme.txt index 31f289dd7..ae82454bc 100644 --- a/readme.txt +++ b/readme.txt @@ -4,7 +4,7 @@ Tags: credit card, stripe, apple pay, payment request, google pay, sepa, bancont Requires at least: 6.4 Tested up to: 6.6 Requires PHP: 7.4 -Stable tag: 8.6.1 +Stable tag: 8.7.0 License: GPLv3 License URI: https://www.gnu.org/licenses/gpl-3.0.html Attributions: thorsten-stripe @@ -128,7 +128,7 @@ If you get stuck, you can ask for help in the Plugin Forum. == Changelog == -= 8.7.0 - xxxx-xx-xx = += 8.7.0 - 2024-09-16 = * Add - Introduces a new promotional surface to encourage merchants with the legacy checkout experience and APMs enabled to use the new checkout experience. * Fix - Prevent duplicate failed-order emails from being sent. * Fix - Support custom name and description for Afterpay. diff --git a/woocommerce-gateway-stripe.php b/woocommerce-gateway-stripe.php index e677efeb5..9c9e5cdf8 100644 --- a/woocommerce-gateway-stripe.php +++ b/woocommerce-gateway-stripe.php @@ -5,7 +5,7 @@ * Description: Take credit card payments on your store using Stripe. * Author: WooCommerce * Author URI: https://woocommerce.com/ - * Version: 8.6.1 + * Version: 8.7.0 * Requires Plugins: woocommerce * Requires at least: 6.4 * Tested up to: 6.6 @@ -22,7 +22,7 @@ /** * Required minimums and constants */ -define( 'WC_STRIPE_VERSION', '8.6.1' ); // WRCS: DEFINED_VERSION. +define( 'WC_STRIPE_VERSION', '8.7.0' ); // WRCS: DEFINED_VERSION. define( 'WC_STRIPE_MIN_PHP_VER', '7.3.0' ); define( 'WC_STRIPE_MIN_WC_VER', '7.4' ); define( 'WC_STRIPE_FUTURE_MIN_WC_VER', '7.5' );