diff --git a/modules/ppcp-api-client/src/Endpoint/class-requesttrait.php b/modules/ppcp-api-client/src/Endpoint/class-requesttrait.php index 73dc2df94..e8e00f772 100644 --- a/modules/ppcp-api-client/src/Endpoint/class-requesttrait.php +++ b/modules/ppcp-api-client/src/Endpoint/class-requesttrait.php @@ -43,17 +43,22 @@ trait RequestTrait { if ( isset( $args['method'] ) ) { $this->logger->log( 'info', 'Method: ' . wc_print_r( $args['method'], true ) ); } - if ( isset( $args['headers']['body'] ) ) { - $this->logger->log( 'info', 'Request Body: ' . wc_print_r( $args['headers']['body'], true ) ); + if ( isset( $args['body'] ) ) { + $this->logger->log( 'info', 'Request Body: ' . wc_print_r( $args['body'], true ) ); } - if ( isset( $response['headers']->getAll()['paypal-debug-id'] ) ) { - $this->logger->log( 'info', 'Response Debug ID: ' . wc_print_r( $response['headers']->getAll()['paypal-debug-id'], true ) ); - } - if ( isset( $response['response'] ) ) { - $this->logger->log( 'info', 'Response: ' . wc_print_r( $response['response'], true ) ); - } - if ( isset( $response['body'] ) ) { - $this->logger->log( 'info', 'Response Body: ' . wc_print_r( $response['body'], true ) ); + + if ( ! is_wp_error( $response ) ) { + if ( isset( $response['headers']->getAll()['paypal-debug-id'] ) ) { + $this->logger->log( 'info', 'Response Debug ID: ' . wc_print_r( $response['headers']->getAll()['paypal-debug-id'], true ) ); + } + if ( isset( $response['response'] ) ) { + $this->logger->log( 'info', 'Response: ' . wc_print_r( $response['response'], true ) ); + } + if ( isset( $response['body'] ) ) { + $this->logger->log( 'info', 'Response Body: ' . wc_print_r( $response['body'], true ) ); + } + } else { + $this->logger->log( 'error', 'WP Error: ' . wc_print_r( $response->get_error_code() . ' ' . $response->get_error_message(), true ) ); } return $response;