atch (RuntimeException $e) { if (strpos($e->getMessage(), 'declined') !== \false || strpos($e->getMessage(), 'PAYMENT_DENIED') !== \false || strpos($e->getMessage(), 'INSTRUMENT_DECLINED') !== \false || strpos($e->getMessage(), 'Payment provider declined') !== \false) { throw new Exception(__('Your payment was declined after 3D Secure verification. Please try a different payment method or contact your bank.', 'woocommerce-paypal-payments')); } throw $e; } } /** * Get user-friendly error message for 3DS failures. * * @param Exception $exception The exception. * @return string */ private function get_3ds_error_message(Exception $exception): string { $error_message = $exception->getMessage(); if (strpos($error_message, '3D Secure') !== \false) { return $error_message; } if (strpos($error_message, 'declined') !== \false) { return __('Your payment was declined after 3D Secure verification. Please try a different payment method or contact your bank.', 'woocommerce-paypal-payments'); } return __('There was an error processing your payment. Please try again or contact support.', 'woocommerce-paypal-payments'); } /** * Gets the appropriate payment gateway for the given payment method. * * @param string $payment_method The payment method ID. * @return \WC_Payment_Gateway|null */ private function get_payment_gateway(string $payment_method) { // For regular PayPal payments, use the injected gateway. if ($payment_method === $this->gateway->id) { return $this->gateway; } // For other payment methods (like AXO), get from WooCommerce. $available_gateways = WC()->payment_gateways->get_available_payment_gateways(); if (isset($available_gateways[$payment_method])) { return $available_gateways[$payment_method]; } // Returning with an approved order puts the checkout in continuation mode, // where DisableGateways offers PayPal alone - so the gateway that sent the // buyer to PayPal is missing from the list above on the way back. $registered_gateways = WC()->payment_gateways->payment_gateways(); return $registered_gateways[$payment_method] ?? null; } }