uniqid(),
'amount' => $amount,
'currency' => 'INR',
'payment_capture' => 1 // auto capture
];
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://api.razorpay.com/v1/orders',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS => json_encode($orderData),
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json'
),
CURLOPT_USERPWD => $api_key . ":" . $api_secret,
));
$response = curl_exec($curl);
curl_close($curl);
$response = json_decode($response, true);
if (isset($response['id'])) {
$order_id = $response['id'];
$razorpay_amount = $response['amount'];
$data = [
"key" => $api_key,
"amount" => $razorpay_amount,
"name" => $name,
"description" => "Booking Payment",
"image" => "",
"prefill" => [
"name" => $name,
"email" => $email,
"contact" => $phone,
],
"order_id" => $order_id,
];
$json = json_encode($data);
} else {
echo "Error creating order: " . $response['error']['description'];
exit;
}
}
?>
Booking Confirmation