From b0f88b7be2e9faf4b1d6f052aed651355d65dd08 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 29 Oct 2025 21:48:17 +0000 Subject: [PATCH 1/2] Initial plan From 267652204727d1cb07a49a534010e7f018ed7766 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 29 Oct 2025 21:54:00 +0000 Subject: [PATCH 2/2] Add missing capture_log function and $requestId initialization to fix HTTP 500 errors Co-authored-by: iaretechnician <2749183+iaretechnician@users.noreply.github.com> --- modules/billing/api/capture_order.php | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/modules/billing/api/capture_order.php b/modules/billing/api/capture_order.php index accdc34a..010623c7 100644 --- a/modules/billing/api/capture_order.php +++ b/modules/billing/api/capture_order.php @@ -10,6 +10,25 @@ $client_secret = 'EJ216np9cAj9n7KSddez3fLVxGe-zi4oKKKl1YGqPp88XIikr4Qzbxh0XW2as- ini_set('display_errors', '0'); error_reporting(E_ALL); +// Setup comprehensive logging +$logDir = __DIR__ . '/../logs'; +@mkdir($logDir, 0755, true); +$logFile = $logDir . '/paypal_capture_order.log'; +$requestId = uniqid('req_', true); // Unique request identifier for tracking + +function capture_log($label, $data) { + global $logFile, $requestId; + $timestamp = date('Y-m-d H:i:s'); + $entry = "[$timestamp] [$requestId] $label\n"; + if (is_array($data) || is_object($data)) { + $entry .= print_r($data, true); + } else { + $entry .= (string)$data; + } + $entry .= "\n" . str_repeat('-', 80) . "\n"; + @file_put_contents($logFile, $entry, FILE_APPEND | LOCK_EX); +} + header('Content-Type: application/json'); // Read and parse input