Automattic\WooCommerce\Gateways\PayPal
Request::get_paypal_order_details
Get PayPal order details.
Method of the class: Request{}
No Hooks.
Returns
Array.
Usage
$Request = new Request(); $Request->get_paypal_order_details( $paypal_order_id ): array;
- $paypal_order_id(string) (required)
- The ID of the PayPal order.
Request::get_paypal_order_details() Request::get paypal order details code WC 10.7.0
public function get_paypal_order_details( string $paypal_order_id ): array {
$request_body = array(
'test_mode' => $this->gateway->testmode,
);
$response = $this->send_wpcom_proxy_request( 'GET', self::WPCOM_PROXY_ORDER_ENDPOINT . '/' . $paypal_order_id, $request_body );
if ( is_wp_error( $response ) ) {
throw new Exception( 'PayPal order details request failed: ' . esc_html( $response->get_error_message() ) );
}
$http_code = wp_remote_retrieve_response_code( $response );
$body = wp_remote_retrieve_body( $response );
$response_data = json_decode( $body, true );
if ( 200 !== $http_code ) {
$debug_id = isset( $response_data['debug_id'] ) ? $response_data['debug_id'] : null;
$message = 'PayPal order details request failed. HTTP ' . (int) $http_code . ( $debug_id ? '. Debug ID: ' . $debug_id : '' );
throw new Exception( esc_html( $message ) );
}
return $response_data;
}