From 5cd6708ad7bb8486ed1cea9b667fbaf06206e05c Mon Sep 17 00:00:00 2001 From: David Stone Date: Wed, 1 Apr 2026 11:40:32 -0600 Subject: [PATCH] fix(paypal): capture and log PayPal-Debug-Id response header PayPal support requires the PayPal-Debug-Id header from API responses for debugging. Extract it via wp_remote_retrieve_header() after every REST API call and log it alongside the existing request logging. Also include the debug ID in error log messages and expose it in the WP_Error data array so callers can surface it if needed. Closes #731 Part of #725 --- inc/gateways/class-paypal-rest-gateway.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/inc/gateways/class-paypal-rest-gateway.php b/inc/gateways/class-paypal-rest-gateway.php index 415548b7..10d1e320 100644 --- a/inc/gateways/class-paypal-rest-gateway.php +++ b/inc/gateways/class-paypal-rest-gateway.php @@ -723,13 +723,14 @@ protected function api_request(string $endpoint, array $data = [], string $metho if ($code >= 400) { $error_msg = $body['message'] ?? ($body['error_description'] ?? __('API request failed', 'ultimate-multisite')); - $this->log(sprintf('API Error (%d): %s', $code, wp_json_encode($body)), LogLevel::ERROR); + $this->log(sprintf('API Error (%d): %s [Debug-Id: %s]', $code, wp_json_encode($body), $debug_id ?: 'n/a'), LogLevel::ERROR); return new \WP_Error( 'wu_paypal_api_error', $error_msg, [ - 'status' => $code, - 'response' => $body, + 'status' => $code, + 'response' => $body, + 'debug_id' => $debug_id, ] ); }