$token, 'payerId' => $payerId ]; // Make API call to capture payment $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, 'https://' . $_SERVER['HTTP_HOST'] . '/api/capture-paypal-order.php'); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($captureData)); curl_setopt($ch, CURLOPT_HTTPHEADER, [ 'Content-Type: application/json', 'Accept: application/json' ]); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_TIMEOUT, 30); $response = curl_exec($ch); $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE); $curlError = curl_error($ch); curl_close($ch); if ($curlError) { throw new Exception('cURL Error: ' . $curlError); } if ($httpCode !== 200) { throw new Exception('API Error: HTTP ' . $httpCode); } $result = json_decode($response, true); if (!$result) { throw new Exception('Invalid API response'); } if (isset($result['error'])) { throw new Exception('API Error: ' . $result['error']); } if (isset($result['success']) && $result['success']) { $isSuccess = true; $orderId = $result['order_id'] ?? null; $transactionId = $result['transaction_id'] ?? null; $amount = $result['amount'] ?? null; $currency = $result['currency'] ?? null; $message = 'Payment captured successfully! Your order has been processed.'; // Log successful capture error_log('Payment captured successfully - Order ID: ' . $orderId . ', Transaction ID: ' . $transactionId); } else { throw new Exception('Payment capture failed'); } } catch (Exception $e) { error_log('Payment capture error: ' . $e->getMessage()); $isSuccess = false; $message = 'Payment processing failed: ' . $e->getMessage(); } ?> <?php echo $isSuccess ? 'Payment Successful' : 'Payment Error'; ?> - AIUHD

Order Details

Order ID:

Transaction ID:

Amount:

Status: Completed

Return to Home View Products Try Again