mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-06 13:44:42 +08:00
avoid redundant exception throwing
This commit is contained in:
parent
1076c58002
commit
a83af94b88
1 changed files with 8 additions and 4 deletions
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue