mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-05 08:59:14 +08:00
Throw user friendly error message if it exist in the response
This commit is contained in:
parent
95d8ee9fff
commit
150d29c0b4
1 changed files with 11 additions and 4 deletions
|
@ -97,8 +97,15 @@ class Orders {
|
|||
|
||||
$status_code = (int) wp_remote_retrieve_response_code( $response );
|
||||
if ( ! in_array( $status_code, array( 200, 201 ), true ) ) {
|
||||
$body = json_decode( $response['body'] );
|
||||
|
||||
$message = $body->details[0]->description ?? '';
|
||||
if ( $message ) {
|
||||
throw new RuntimeException( $message );
|
||||
}
|
||||
|
||||
throw new PayPalApiException(
|
||||
json_decode( $response['body'] ),
|
||||
$body,
|
||||
$status_code
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue