mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-06 18:16:38 +08:00
🎨 Minor code improvements
This commit is contained in:
parent
8ce7d6ca99
commit
ed8ae81297
2 changed files with 6 additions and 8 deletions
|
@ -10,16 +10,9 @@ declare( strict_types = 1 );
|
||||||
namespace WooCommerce\PayPalCommerce\Settings\Endpoint;
|
namespace WooCommerce\PayPalCommerce\Settings\Endpoint;
|
||||||
|
|
||||||
use Exception;
|
use Exception;
|
||||||
use stdClass;
|
|
||||||
use RuntimeException;
|
|
||||||
use Psr\Log\LoggerInterface;
|
|
||||||
use WP_REST_Request;
|
use WP_REST_Request;
|
||||||
use WP_REST_Response;
|
use WP_REST_Response;
|
||||||
use WP_REST_Server;
|
use WP_REST_Server;
|
||||||
use WooCommerce\PayPalCommerce\ApiClient\Authentication\PayPalBearer;
|
|
||||||
use WooCommerce\PayPalCommerce\ApiClient\Endpoint\Orders;
|
|
||||||
use WooCommerce\PayPalCommerce\ApiClient\Helper\InMemoryCache;
|
|
||||||
use WooCommerce\PayPalCommerce\Settings\Data\GeneralSettings;
|
|
||||||
use WooCommerce\PayPalCommerce\Settings\Service\AuthenticationManager;
|
use WooCommerce\PayPalCommerce\Settings\Service\AuthenticationManager;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -10,6 +10,7 @@ declare( strict_types = 1 );
|
||||||
namespace WooCommerce\PayPalCommerce\Settings\Service;
|
namespace WooCommerce\PayPalCommerce\Settings\Service;
|
||||||
|
|
||||||
use JsonException;
|
use JsonException;
|
||||||
|
use Throwable;
|
||||||
use Psr\Log\LoggerInterface;
|
use Psr\Log\LoggerInterface;
|
||||||
use WooCommerce\PayPalCommerce\ApiClient\Exception\RuntimeException;
|
use WooCommerce\PayPalCommerce\ApiClient\Exception\RuntimeException;
|
||||||
use WooCommerce\PayPalCommerce\ApiClient\Authentication\PayPalBearer;
|
use WooCommerce\PayPalCommerce\ApiClient\Authentication\PayPalBearer;
|
||||||
|
@ -306,7 +307,11 @@ class AuthenticationManager {
|
||||||
$order_response = $orders->order( $order_id );
|
$order_response = $orders->order( $order_id );
|
||||||
$order_body = json_decode( $order_response['body'], false, 512, JSON_THROW_ON_ERROR );
|
$order_body = json_decode( $order_response['body'], false, 512, JSON_THROW_ON_ERROR );
|
||||||
} catch ( JsonException $exception ) {
|
} catch ( JsonException $exception ) {
|
||||||
|
// Cast JsonException to a RuntimeException.
|
||||||
throw new RuntimeException( 'Could not decode JSON response: ' . $exception->getMessage() );
|
throw new RuntimeException( 'Could not decode JSON response: ' . $exception->getMessage() );
|
||||||
|
} catch ( Throwable $exception ) {
|
||||||
|
// Cast any other Throwable to a RuntimeException.
|
||||||
|
throw new RuntimeException( $exception->getMessage() );
|
||||||
}
|
}
|
||||||
|
|
||||||
$pu = $order_body->purchase_units[0];
|
$pu = $order_body->purchase_units[0];
|
||||||
|
@ -315,7 +320,7 @@ class AuthenticationManager {
|
||||||
if ( ! is_object( $payee ) ) {
|
if ( ! is_object( $payee ) ) {
|
||||||
throw new RuntimeException( 'Payee not found.' );
|
throw new RuntimeException( 'Payee not found.' );
|
||||||
}
|
}
|
||||||
if ( ! isset( $payee->merchant_id ) || ! isset( $payee->email_address ) ) {
|
if ( ! isset( $payee->merchant_id, $payee->email_address ) ) {
|
||||||
throw new RuntimeException( 'Payee info not found.' );
|
throw new RuntimeException( 'Payee info not found.' );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue