From a83af94b88e8a82efa5d1c1a7efe87690f6f91e3 Mon Sep 17 00:00:00 2001 From: Kirill Braslavsky Date: Mon, 15 Mar 2021 19:49:10 +0200 Subject: [PATCH] avoid redundant exception throwing --- .../src/Endpoint/class-createorderendpoint.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/modules/ppcp-button/src/Endpoint/class-createorderendpoint.php b/modules/ppcp-button/src/Endpoint/class-createorderendpoint.php index 53d5465dd..9dd79512a 100644 --- a/modules/ppcp-button/src/Endpoint/class-createorderendpoint.php +++ b/modules/ppcp-button/src/Endpoint/class-createorderendpoint.php @@ -245,12 +245,16 @@ class CreateOrderEndpoint implements EndpointInterface { * Returns the PaymentMethod object for the order. * * @return PaymentMethod - * @throws \WooCommerce\PayPalCommerce\WcGateway\Exception\NotFoundException In case a setting would not be found. */ private function payment_method() : PaymentMethod { - $payee_preferred = $this->settings->has( 'payee_preferred' ) && $this->settings->get( 'payee_preferred' ) ? - PaymentMethod::PAYEE_PREFERRED_IMMEDIATE_PAYMENT_REQUIRED - : PaymentMethod::PAYEE_PREFERRED_UNRESTRICTED; + try { + $payee_preferred = $this->settings->has( 'payee_preferred' ) && $this->settings->get( 'payee_preferred' ) ? + PaymentMethod::PAYEE_PREFERRED_IMMEDIATE_PAYMENT_REQUIRED + : PaymentMethod::PAYEE_PREFERRED_UNRESTRICTED; + } catch (NotFoundException $exception){ + $payee_preferred = PaymentMethod::PAYEE_PREFERRED_UNRESTRICTED; + } + $payment_method = new PaymentMethod( $payee_preferred ); return $payment_method; }