Skip to content

Commit e6e094b

Browse files
mattallandiegocurbelo
authored andcommitted
Don't call process_response() inside process_payment_with_deferred_intent() for orders that require action/confirmation (#3520)
* Don't process the latest charge if the payment requires confirmation or further actions * Add changelog entry * Fix 3DS tests now that get_latest_charge_from_intent() isn't run
1 parent 9f683f5 commit e6e094b

File tree

4 files changed

+7
-5
lines changed

4 files changed

+7
-5
lines changed

changelog.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
= 8.8.1 - xxxx-xx-xx =
44
* Tweak - Disables APMs when using the legacy checkout experience due Stripe deprecation by October 29, 2024.
5+
* Fix - Prevent marking orders on-hold with order note "Process order to take payment" when the payment has failed.
56

67
= 8.8.0 - 2024-10-17 =
78
* Fix - Update URL and path constants to support use of symlinked plugin.

includes/payment-methods/class-wc-stripe-upe-payment-gateway.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -885,7 +885,7 @@ private function process_payment_with_deferred_intent( int $order_id ) {
885885
$redirect = $return_url;
886886
}
887887

888-
if ( $payment_needed ) {
888+
if ( $payment_needed && ! in_array( $payment_intent->status, [ 'requires_confirmation', 'requires_action' ], true ) ) {
889889
// Use the last charge within the intent to proceed.
890890
$charge = $this->get_latest_charge_from_intent( $payment_intent );
891891

readme.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,5 +130,6 @@ If you get stuck, you can ask for help in the Plugin Forum.
130130

131131
= 8.8.1 - xxxx-xx-xx =
132132
* Tweak - Disables APMs when using the legacy checkout experience due Stripe deprecation by October 29, 2024.
133+
* Fix - Prevent marking orders on-hold with order note "Process order to take payment" when the payment has failed.
133134

134135
[See changelog for all versions](https://raw.githubusercontent.com/woocommerce/woocommerce-gateway-stripe/trunk/changelog.txt).

tests/phpunit/test-class-wc-stripe-upe-payment-gateway.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -452,7 +452,7 @@ public function test_process_payment_deferred_intent_with_required_action_return
452452

453453
// We only use this when handling mandates.
454454
$this->mock_gateway
455-
->expects( $this->exactly( 2 ) )
455+
->expects( $this->once() )
456456
->method( 'get_latest_charge_from_intent' )
457457
->willReturn( null );
458458

@@ -539,7 +539,7 @@ public function test_process_payment_deferred_intent_with_required_action_for_wa
539539

540540
// We only use this when handling mandates.
541541
$this->mock_gateway
542-
->expects( $saved_token ? $this->never() : ( $free_order ? $this->once() : $this->exactly( 2 ) ) )
542+
->expects( $saved_token ? $this->never() : $this->once() )
543543
->method( 'get_latest_charge_from_intent' )
544544
->willReturn( null );
545545

@@ -1378,7 +1378,7 @@ function( $passed_order ) use ( $order ) {
13781378
'payment_method_details' => $payment_intent_mock,
13791379
];
13801380
$this->mock_gateway
1381-
->expects( $this->exactly( 2 ) )
1381+
->expects( $this->once() )
13821382
->method( 'get_latest_charge_from_intent' )
13831383
->willReturn( $this->array_to_object( $charge ) );
13841384

@@ -1387,7 +1387,7 @@ function( $passed_order ) use ( $order ) {
13871387
$client_secret = $payment_intent_mock->client_secret;
13881388

13891389
$this->assertEquals( 'success', $response['result'] );
1390-
$this->assertEquals( 'processing', $final_order->get_status() );
1390+
$this->assertEquals( 'pending', $final_order->get_status() ); // Order status should be pending until 3DS is completed.
13911391
$this->assertEquals( $payment_intent_id, $final_order->get_meta( '_stripe_intent_id', true ) );
13921392
$this->assertEquals( $customer_id, $final_order->get_meta( '_stripe_customer_id', true ) );
13931393
$this->assertEquals( $payment_method_id, $final_order->get_meta( '_stripe_source_id', true ) );

0 commit comments

Comments
 (0)