From 32153981a84208d74c82a705f29c6b0ede3795da Mon Sep 17 00:00:00 2001 From: mattallan Date: Thu, 5 Sep 2024 13:55:46 +1000 Subject: [PATCH 1/3] Lock the order before creating and confirm both payment and setup intents --- .../payment-methods/class-wc-stripe-upe-payment-gateway.php | 4 +++- 1 file changed, 3 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 130a8f450..f0bda040f 100644 --- a/includes/payment-methods/class-wc-stripe-upe-payment-gateway.php +++ b/includes/payment-methods/class-wc-stripe-upe-payment-gateway.php @@ -795,11 +795,13 @@ private function process_payment_with_deferred_intent( int $order_id ) { $this->update_saved_payment_method( $payment_method_id, $order ); } + // Lock the order before we create and confirm the payment/setup intents to prevent Stripe sending the success webhook before this request is completed. + $this->lock_order_payment( $order ); + if ( $payment_needed ) { // Throw an exception if the minimum order amount isn't met. $this->validate_minimum_order_amount( $order ); - $this->lock_order_payment( $order ); // Create a payment intent, or update an existing one associated with the order. $payment_intent = $this->process_payment_intent_for_order( $order, $payment_information ); } else { From a118ef1eb89112b7c0c0ce1b6b4028530229cc24 Mon Sep 17 00:00:00 2001 From: mattallan Date: Thu, 5 Sep 2024 14:15:35 +1000 Subject: [PATCH 2/3] Add changelog entry --- changelog.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/changelog.txt b/changelog.txt index 9941fa871..0aed62b84 100644 --- a/changelog.txt +++ b/changelog.txt @@ -26,6 +26,7 @@ * 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 - Address Klarna availability based on correct presentment currency rules. +* Fix - Prevent duplicate order notes and emails being sent when purchasing subscription products with no initial payment. = 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. From 689a4def986e8b24ea93fd7d8582f444f82f911d Mon Sep 17 00:00:00 2001 From: mattallan Date: Fri, 6 Sep 2024 10:49:22 +1000 Subject: [PATCH 3/3] Add changelog to readme.txt --- readme.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/readme.txt b/readme.txt index d2462ef5c..a6b23f605 100644 --- a/readme.txt +++ b/readme.txt @@ -155,5 +155,6 @@ If you get stuck, you can ask for help in the Plugin Forum. * Fix - Ensure payment tokens are detached from Stripe when a user is deleted, regardless of if the admin user has a Stripe account. * 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. [See changelog for all versions](https://raw.githubusercontent.com/woocommerce/woocommerce-gateway-stripe/trunk/changelog.txt).