From 9a75c569fb99692e7b3f87ebcf0a94be7ad313e5 Mon Sep 17 00:00:00 2001 From: Mayisha <33387139+Mayisha@users.noreply.github.com> Date: Thu, 5 Dec 2024 13:00:35 +0600 Subject: [PATCH] Fix call to a member function get_token() on null (#3626) * call process_payment function when retrying a payment * add changelog --- changelog.txt | 1 + .../class-wc-stripe-upe-payment-gateway.php | 8 ++++---- readme.txt | 1 + 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/changelog.txt b/changelog.txt index 1b1475c01..b09c86132 100644 --- a/changelog.txt +++ b/changelog.txt @@ -14,6 +14,7 @@ * Fix - Return 'is_live' as true in account summary response when test mode is disabled in gateway settings and charge is enabled in Stripe account. * Fix - Prevents notices being displayed on WordPress 6.7 due to loading translations too early (only shown on stores with WP_DEBUG enabled). * Fix - Prevent showing the shipping options on express checkout modal for virtual product variations. +* Fix - Do not assume payment is using a saved card when retrying a failed payment. * Tweak - Update links to plugin documentation and Stripe documentation. = 8.9.0 - 2024-11-14 = 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 2657568cd..88f7b8cfc 100644 --- a/includes/payment-methods/class-wc-stripe-upe-payment-gateway.php +++ b/includes/payment-methods/class-wc-stripe-upe-payment-gateway.php @@ -1415,7 +1415,7 @@ public function save_payment_method_to_order( $order, $payment_method ) { /** * Retries the payment process once an error occured. * - * @param object $intent The Payment Intent response from the Stripe API. + * @param object $response The response from the Stripe API. * @param WC_Order $order An order that is being paid for. * @param bool $retry A flag that indicates whether another retry should be attempted. * @param bool $force_save_source Force save the payment source. @@ -1424,7 +1424,7 @@ public function save_payment_method_to_order( $order, $payment_method ) { * @throws WC_Stripe_Exception If the payment is not accepted. * @return array|void */ - public function retry_after_error( $intent, $order, $retry, $force_save_source = false, $previous_error = false, $use_order_source = false ) { + public function retry_after_error( $response, $order, $retry, $force_save_source = false, $previous_error = false, $use_order_source = false ) { if ( ! $retry ) { $localized_message = __( 'Sorry, we are unable to process your payment at this time. Please retry later.', 'woocommerce-gateway-stripe' ); $order->add_order_note( $localized_message ); @@ -1433,13 +1433,13 @@ public function retry_after_error( $intent, $order, $retry, $force_save_source = // Don't do anymore retries after this. if ( 5 <= $this->retry_interval ) { - return $this->process_payment_with_saved_payment_method( $order->get_id(), false ); + return $this->process_payment( $order->get_id(), false, $force_save_source, $response->error, $previous_error ); } sleep( $this->retry_interval ); $this->retry_interval++; - return $this->process_payment_with_saved_payment_method( $order->get_id(), true ); + return $this->process_payment( $order->get_id(), true, $force_save_source, $response->error, $previous_error ); } /** diff --git a/readme.txt b/readme.txt index 650a7f599..3207e25fa 100644 --- a/readme.txt +++ b/readme.txt @@ -124,6 +124,7 @@ If you get stuck, you can ask for help in the [Plugin Forum](https://wordpress.o * Fix - Return 'is_live' as true in account summary response when test mode is disabled in gateway settings and charge is enabled in Stripe account. * Fix - Prevents notices being displayed on WordPress 6.7 due to loading translations too early (only shown on stores with WP_DEBUG enabled). * Fix - Prevent showing the shipping options on express checkout modal for virtual product variations. +* Fix - Do not assume payment is using a saved card when retrying a failed payment. * Tweak - Update links to plugin documentation and Stripe documentation. [See changelog for all versions](https://raw.githubusercontent.com/woocommerce/woocommerce-gateway-stripe/trunk/changelog.txt).