[Fix] Fix undefined array key 0 when checking $retry_errors in process_payment method.

This commit is contained in:
Fitim Vata 2023-05-15 12:14:05 +02:00
parent 7e481e6d1e
commit ca2b76f18f

View file

@ -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];