From ca2b76f18f401a6b08b771ccc8b9448c9f4a0961 Mon Sep 17 00:00:00 2001 From: Fitim Vata Date: Mon, 15 May 2023 12:14:05 +0200 Subject: [PATCH] [Fix] Fix undefined array key 0 when checking $retry_errors in process_payment method. --- .../ppcp-wc-gateway/src/Gateway/PayPalGateway.php | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/modules/ppcp-wc-gateway/src/Gateway/PayPalGateway.php b/modules/ppcp-wc-gateway/src/Gateway/PayPalGateway.php index 0e71fa812..06722c6aa 100644 --- a/modules/ppcp-wc-gateway/src/Gateway/PayPalGateway.php +++ b/modules/ppcp-wc-gateway/src/Gateway/PayPalGateway.php @@ -486,12 +486,15 @@ class PayPalGateway extends \WC_Payment_Gateway { 'INSTRUMENT_DECLINED' => __( 'Instrument declined.', 'woocommerce-paypal-payments' ), 'PAYER_ACTION_REQUIRED' => __( 'Payer action required, possibly overcharge.', 'woocommerce-paypal-payments' ), ); - $retry_errors = array_filter( - array_keys( $retry_keys_messages ), - function ( string $key ) use ( $error ): bool { - return $error->has_detail( $key ); - } + $retry_errors = array_values( + array_filter( + array_keys( $retry_keys_messages ), + function ( string $key ) use ( $error ): bool { + return $error->has_detail( $key ); + } + ) ); + if ( $retry_errors ) { $retry_error_key = $retry_errors[0];