reserve($id, $userId); if (!$reservation['success']) { $_SESSION['error'] = $reservation['message']; header('Location: car_detail.php?id=' . $id); exit; } $car = $carRepo->find($id); // Fetch main image manually since find() doesn't JOIN images (standard repository pattern) $stmt = db()->prepare("SELECT image_path FROM car_images WHERE car_id = ? AND is_main = 1"); $stmt->execute([$id]); $mainImage = $stmt->fetch(); $car['image_path'] = $mainImage ? $mainImage['image_path'] : 'assets/images/placeholder-car.jpg'; $costs = $purchaseService->calculateFees($car['price']); $success = false; $error = ''; $transactionId = ''; if ($_SERVER['REQUEST_METHOD'] === 'POST') { $buyerData = [ 'name' => $_POST['buyer_name'] ?? '', 'phone' => $_POST['buyer_phone'] ?? '', 'email' => $_SESSION['user_email'] ?? '', 'bank_id' => $_POST['bank_id'] ?? '', 'personal_info' => $_POST['personal_info'] ?? '', 'payment_method' => $_POST['payment_method'] ?? 'bank_transfer' ]; $result = $controller->checkout($id, $userId, $buyerData); if ($result['success']) { $success = true; $transactionId = $result['transaction_id']; } else { $error = $result['message']; } } ?>
🚀

Purchase Initiated!

Your secure transaction has been created. The car is reserved for you. Please proceed with payment verification.

Enterprise Checkout

Model •

Car Price $
Marketplace Fee (calculateFees($car['price'])['fee'] / $car['price'] * 100 ?>%) $
Tax (calculateFees($car['price'])['tax'] / $car['price'] * 100 ?>%) $
Total Payable $

Reservation expires in: 15:00

ESCROW PROTECTION ACTIVE Transaction ID: Securely Generated

Buyer Verification

Provide your legal documentation and banking details to proceed with this secure purchase.

This reference will be verified with the Afghan banking systems.

ENTERPRISE ESCROW SYSTEM: Your payment will be held securely in Escrow. Funds are only released to the seller once you confirm receipt of the vehicle and the admin verifies all documentation.

CANCEL