From ba07030dacf27c6dc0bef84c76243c58e3fd85e1 Mon Sep 17 00:00:00 2001 From: dinamiko Date: Wed, 11 Aug 2021 15:01:23 +0200 Subject: [PATCH] Update order status to failed when instrument is declined --- .../src/Gateway/class-processpaymenttrait.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/modules/ppcp-wc-gateway/src/Gateway/class-processpaymenttrait.php b/modules/ppcp-wc-gateway/src/Gateway/class-processpaymenttrait.php index 53efac516..dea673169 100644 --- a/modules/ppcp-wc-gateway/src/Gateway/class-processpaymenttrait.php +++ b/modules/ppcp-wc-gateway/src/Gateway/class-processpaymenttrait.php @@ -141,6 +141,11 @@ trait ProcessPaymentTrait { } } catch ( PayPalApiException $error ) { if ( $error->has_detail( 'INSTRUMENT_DECLINED' ) ) { + $wc_order->update_status( + 'failed', + __( 'Instrument declined.', 'woocommerce-paypal-payments' ) + ); + $this->session_handler->increment_insufficient_funding_tries(); $host = $this->config->has( 'sandbox_on' ) && $this->config->get( 'sandbox_on' ) ? 'https://www.sandbox.paypal.com/' : 'https://www.paypal.com/';