0) { try { // Fetch product details $stmt = db()->prepare("SELECT * FROM products WHERE id = ?"); $stmt->execute([$product_id]); $product = $stmt->fetch(PDO::FETCH_ASSOC); // Fetch user details $stmt = db()->prepare("SELECT * FROM users WHERE id = ?"); $stmt->execute([$_SESSION["user_id"]]); $user = $stmt->fetch(PDO::FETCH_ASSOC); } catch (PDOException $e) { error_log("Database error: " . $e->getMessage()); // You might want to show a generic error page here die("Error fetching data. Please try again later."); } } if (!$product || !$user) { // Handle case where product or user is not found die("Product or user not found."); } $api = new Api($razorpay_key_id, $razorpay_key_secret); // Create Razorpay Order $orderData = [ 'receipt' => 'rcptid_' . uniqid(), 'amount' => $product['price'] * 100, // amount in paise 'currency' => 'INR', 'payment_capture' => 1 // auto capture ]; $razorpayOrder = $api->order->create($orderData); $razorpayOrderId = $razorpayOrder['id']; $_SESSION['razorpay_order_id'] = $razorpayOrderId; ?>
Amount: $
Billed to:
Name:
Email: