<?php
header("Content-Type: application/json");

$key_id     = "rzp_live_3x7JRLXTQ0yNPV";   // Your Razorpay Key ID
$key_secret = "ZJZEo0ijrlmJ6MLNLn7PLDk2";  // Your Razorpay Secret Key

// Amount from Android (₹100 = 10000 paise)
// $amount = $_POST['amount'];
$amount = 100; // For testing purpose, amount is hardcoded to 100 paise (₹1)
if (!$amount) {
    echo json_encode(["error" => "Amount missing"]);
    exit;
}

$data = [
    "amount" => $amount,            // amount in paise
    "currency" => "INR",
    "receipt" => "receipt_" . rand(1000,9999)
];

// Initialize cURL
$ch = curl_init('https://api.razorpay.com/v1/orders');
curl_setopt($ch, CURLOPT_USERPWD, $key_id . ":" . $key_secret);
curl_setopt($ch, CURLOPT_TIMEOUT, 60);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type: application/json']);

$response = curl_exec($ch);
curl_close($ch);

echo $response;
