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']; } } ?>
Your secure transaction = htmlspecialchars($transactionId) ?> has been created. The car is reserved for you. Please proceed with payment verification.
= $car['year'] ?> Model • = $car['city'] ?>
Reservation expires in: 15:00
Provide your legal documentation and banking details to proceed with this secure purchase.