From a3d4a3e04fbaac0074bbf591c88155b9ea389d54 Mon Sep 17 00:00:00 2001
From: Philipp Stracker
Date: Tue, 10 Sep 2024 19:42:20 +0200
Subject: [PATCH] =?UTF-8?q?=F0=9F=A5=85=20Add=20generic=20error=20handling?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
modules/ppcp-axo/src/Gateway/AxoGateway.php | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/modules/ppcp-axo/src/Gateway/AxoGateway.php b/modules/ppcp-axo/src/Gateway/AxoGateway.php
index ffa2ce0a0..59cfd7742 100644
--- a/modules/ppcp-axo/src/Gateway/AxoGateway.php
+++ b/modules/ppcp-axo/src/Gateway/AxoGateway.php
@@ -10,6 +10,7 @@ declare(strict_types=1);
namespace WooCommerce\PayPalCommerce\Axo\Gateway;
use Psr\Log\LoggerInterface;
+use Exception;
use WC_Order;
use WC_Payment_Gateway;
use WooCommerce\PayPalCommerce\ApiClient\Endpoint\OrderEndpoint;
@@ -27,6 +28,7 @@ use WooCommerce\PayPalCommerce\WcGateway\Processor\OrderMetaTrait;
use WooCommerce\PayPalCommerce\WcGateway\Processor\OrderProcessor;
use WooCommerce\PayPalCommerce\WcGateway\Settings\SettingsRenderer;
use WooCommerce\PayPalCommerce\WcGateway\Gateway\ProcessPaymentTrait;
+use WooCommerce\PayPalCommerce\WcGateway\Exception\GatewayGenericException;
use WooCommerce\PayPalCommerce\Session\SessionHandler;
/**
@@ -230,6 +232,13 @@ class AxoGateway extends WC_Payment_Gateway {
public function process_payment( $order_id ) {
$wc_order = wc_get_order( $order_id );
+ if ( ! is_a( $wc_order, WC_Order::class ) ) {
+ return $this->handle_payment_failure(
+ null,
+ new GatewayGenericException( new Exception( 'WC order was not found.' ) )
+ );
+ }
+
// phpcs:ignore WordPress.Security.NonceVerification.Missing
$fastlane_member = wc_clean( wp_unslash( $_POST['fastlane_member'] ?? '' ) );
if ( $fastlane_member ) {