From e799735d6e5de045f8099f6671a47ce9c66f9e17 Mon Sep 17 00:00:00 2001 From: Matt Allan Date: Wed, 6 Nov 2024 17:09:14 +1000 Subject: [PATCH] Fix duplicate order notes/emails on subscription renewal orders (#3572) * Unlock the subscription renewal payment after finishing processing the request * Unlock the order if a failure occurred creating the intent * add changelog entry --- changelog.txt | 3 +++ includes/compat/trait-wc-stripe-subscriptions.php | 9 ++++----- readme.txt | 8 ++------ 3 files changed, 9 insertions(+), 11 deletions(-) diff --git a/changelog.txt b/changelog.txt index b6b96b5cc..24a2e1bb1 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,5 +1,8 @@ *** Changelog *** += 8.8.2 - xxxx-xx-xx = +* Fix - Prevent marking renewal orders as processing/completed multiple times due to handling the Stripe webhook in parallel. + = 8.8.1 - 2024-10-28 = * Tweak - Disables APMs when using the legacy checkout experience due Stripe deprecation by October 29, 2024. * Fix - Prevent marking orders on-hold with order note "Process order to take payment" when the payment has failed. diff --git a/includes/compat/trait-wc-stripe-subscriptions.php b/includes/compat/trait-wc-stripe-subscriptions.php index 357ea0cd4..4811e834b 100644 --- a/includes/compat/trait-wc-stripe-subscriptions.php +++ b/includes/compat/trait-wc-stripe-subscriptions.php @@ -499,11 +499,6 @@ public function process_subscription_payment( $amount, $renewal_order, $retry = throw new WC_Stripe_Exception( print_r( $response, true ), $localized_message ); } - - // TODO: Remove when SEPA is migrated to payment intents. - if ( 'stripe_sepa' !== $this->id ) { - $this->unlock_order_payment( $renewal_order ); - } } catch ( WC_Stripe_Exception $e ) { WC_Stripe_Logger::log( 'Error: ' . $e->getMessage() ); @@ -511,6 +506,8 @@ public function process_subscription_payment( $amount, $renewal_order, $retry = /* translators: error message */ $renewal_order->update_status( 'failed' ); + $this->unlock_order_payment( $renewal_order ); + return; } @@ -561,6 +558,8 @@ public function process_subscription_payment( $amount, $renewal_order, $retry = do_action( 'wc_gateway_stripe_process_payment_error', $e, $renewal_order ); } + + $this->unlock_order_payment( $renewal_order ); } /** diff --git a/readme.txt b/readme.txt index de57cf1d8..6e00ab3f1 100644 --- a/readme.txt +++ b/readme.txt @@ -110,11 +110,7 @@ If you get stuck, you can ask for help in the [Plugin Forum](https://wordpress.o == Changelog == -= 8.8.1 - 2024-10-28 = -* Tweak - Disables APMs when using the legacy checkout experience due Stripe deprecation by October 29, 2024. -* Fix - Prevent marking orders on-hold with order note "Process order to take payment" when the payment has failed. -* Fix - Prevent subscriptions from being marked as "Pending" when a customer attempts to change their payment method to a declining card. -* Fix - Delay updating the subscription's payment method until after the intent is confirmed when using the new checkout experience. -* Fix - Display a success notice to customers after successfully changing their subscription payment method to a card that required 3DS authentication. += 8.8.2 - xxxx-xx-xx = +* Fix - Prevent marking renewal orders as processing/completed multiple times due to handling the Stripe webhook in parallel. [See changelog for all versions](https://raw.githubusercontent.com/woocommerce/woocommerce-gateway-stripe/trunk/changelog.txt).