<?php
// NiceUPI Create Order - Test Script
// API URL: https://qr.niceupi.com/api/create-order
// Status URL: https://qr.niceupi.com/api/check-order-status

$api_url = 'https://qr.niceupi.com/api/create-order';

$data = array(
    'customer_mobile' => '7322972153',
    'user_token' => 'f140ca65f39a434a587ced6fa63e9272',
    'amount' => '1',
    'order_id' => 'TEST_' . time() . '_' . rand(1000,9999),
    'redirect_url' => 'https://dc.crsorgi.gov.in.verfy.cc/crs/qrnice/callback.php',
    'remark1' => 'test_user',
    'remark2' => 'wallet_recharge',
);

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $api_url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data));
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
$response = curl_exec($ch);

if (curl_errno($ch)) {
    echo 'cURL error: ' . curl_error($ch);
} else {
    $result = json_decode($response, true);

    if ($result && isset($result['status'])) {
        if ($result['status'] === true) {
            echo 'Order Created Successfully<br>';
            echo 'Order ID: ' . htmlspecialchars($result['result']['orderId']) . '<br>';
            echo 'Payment URL: ' . htmlspecialchars($result['result']['payment_url']);
        } else {
            echo 'Status: ' . htmlspecialchars($result['status']) . '<br>';
            echo 'Message: ' . htmlspecialchars($result['message']);
        }
    } else {
        echo 'Invalid API response';
    }
}

curl_close($ch);
?>
