From c439e4ec5b3a03e7dcbf245ee0342638691dc20e Mon Sep 17 00:00:00 2001 From: Arthur Moreira Date: Fri, 2 Feb 2024 10:52:41 +0100 Subject: [PATCH] Change order state to failed when receive the order declined webhook --- src/Mondu/Mondu/Controllers/WebhooksController.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/Mondu/Mondu/Controllers/WebhooksController.php b/src/Mondu/Mondu/Controllers/WebhooksController.php index e9cf7b9..c32c8c5 100644 --- a/src/Mondu/Mondu/Controllers/WebhooksController.php +++ b/src/Mondu/Mondu/Controllers/WebhooksController.php @@ -164,6 +164,12 @@ private function handle_declined( $params ) { return $this->return_not_found(); } + $order->add_order_note( esc_html( sprintf( __( 'Mondu order is on declined state.', 'mondu' ) ) ), false ); + + if ( $order->get_status() == 'on-hold' ) { + $order->update_status('wc-failed', __('Failed', 'woocommerce')); + } + return $this->return_success(); }