Skip to content

Commit 9cd5240

Browse files
authored
Don't update canceled order to on-hold in the dispute created event (#3672)
* Don't update canceled order to on-hold in the dispute created event * Changelog and readme entries * Specific unit test
1 parent 9691ad8 commit 9cd5240

File tree

4 files changed

+15
-3
lines changed

4 files changed

+15
-3
lines changed

changelog.txt

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

33
= 9.1.0 - xxxx-xx-xx =
4+
* Fix - Don't update canceled order status to on-hold when a dispute is opened.
45
* Fix - Correctly sets the dispute opened note when a dispute does not require any further action.
56
* Add - Display Multibanco payment instruction details in Order Received page and Order Confirmation email.
67
* Tweak - Add the transaction limit information to the Afterpay/Clearpay method when listing payment methods.

includes/class-wc-stripe-webhook-handler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,7 @@ public function process_webhook_dispute( $notification ) {
356356
$message = __( 'A dispute was created for this order.', 'woocommerce-gateway-stripe' );
357357
}
358358

359-
if ( ! $order->get_meta( '_stripe_status_final', false ) ) {
359+
if ( ! $order->has_status( 'cancelled' ) && ! $order->get_meta( '_stripe_status_final', false ) ) {
360360
$order->update_status( 'on-hold', $message );
361361
} else {
362362
$order->add_order_note( $message );

readme.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ If you get stuck, you can ask for help in the [Plugin Forum](https://wordpress.o
111111
== Changelog ==
112112

113113
= 9.1.0 - xxxx-xx-xx =
114+
* Fix - Don't update canceled order status to on-hold when a dispute is opened.
114115
* Fix - Correctly sets the dispute opened note when a dispute does not require any further action.
115116
* Add - Display Multibanco payment instruction details in Order Received page and Order Confirmation email.
116117
* Tweak - Add the transaction limit information to the Afterpay/Clearpay method when listing payment methods.

tests/phpunit/test-wc-stripe-webhook-handler.php

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -306,11 +306,11 @@ public function provide_test_process_webhook_charge_failed() {
306306
* @return void
307307
* @dataProvider provide_test_process_webhook_dispute
308308
*/
309-
public function test_process_webhook_dispute( $order_status_final, $dispute_status, $expected_status, $expected_note ) {
309+
public function test_process_webhook_dispute( $order_status, $order_status_final, $dispute_status, $expected_status, $expected_note ) {
310310
$charge_id = 'ch_fQpkNKxmUrZ8t4CT7EHGS3Rg';
311311

312312
$order = WC_Helper_Order::create_order();
313-
$order->set_status( 'processing' );
313+
$order->set_status( $order_status );
314314
$order->set_transaction_id( $charge_id );
315315
if ( $order_status_final ) {
316316
$order->update_meta_data( '_stripe_status_final', true );
@@ -351,18 +351,28 @@ public function test_process_webhook_dispute( $order_status_final, $dispute_stat
351351
public function provide_test_process_webhook_dispute() {
352352
return [
353353
'response needed, order status not final' => [
354+
'order status' => 'processing',
354355
'order status final' => false,
355356
'dispute status' => 'needs_response',
356357
'expected status' => 'on-hold',
357358
'expected note' => '/A dispute was created for this order. Response is needed./',
358359
],
360+
'response needed, order status not final, status is cancelled' => [
361+
'order status' => 'cancelled',
362+
'order status final' => false,
363+
'dispute status' => 'needs_response',
364+
'expected status' => 'cancelled',
365+
'expected note' => '/A dispute was created for this order. Response is needed./',
366+
],
359367
'response needed, order status final' => [
368+
'order status' => 'processing',
360369
'order status final' => true,
361370
'dispute status' => 'needs_response',
362371
'expected status' => 'processing',
363372
'expected note' => '/A dispute was created for this order. Response is needed./',
364373
],
365374
'response not needed, order status not final' => [
375+
'order status' => 'processing',
366376
'order status final' => false,
367377
'dispute status' => 'lost',
368378
'expected status' => 'on-hold',

0 commit comments

Comments
 (0)