File "create-order.php"
Full path: /home/eshuaesb/public_html/www.mhawaterpark.com/bookticket/create-order.php
File
size: 0.87 KB (887 B bytes)
MIME-type: text/x-php
Charset: utf-8
Download Open Edit Advanced Editor Back
<?php
ini_set('display_errors', 1);
error_reporting(E_ALL);
// Use the manual path to Razorpay SDK
require('razorpay/Razorpay.php'); // Replace with correct relative path
use Razorpay\Api\Api;
$keyId = 'rzp_test_4clm2oRR0AjqFE'; // Replace with your test key
$keySecret = 'rzp_test_4clm2oRR0AjqFE';
header('Content-Type: application/json');
try {
if (!isset($_POST['amount']) || !is_numeric($_POST['amount'])) {
echo json_encode(['error' => 'Invalid amount']);
exit;
}
$amount = $_POST['amount'] * 100;
$api = new Api($keyId, $keySecret);
$order = $api->order->create([
'receipt' => 'rcpt_' . time(),
'amount' => $amount,
'currency' => 'INR'
]);
echo json_encode(['order_id' => $order['id']]);
} catch (Exception $e) {
echo json_encode(['error' => $e->getMessage()]);
}