POST https://gateways.api-97.com/api/v1.php
| Field | Type | Required | Description |
|---|---|---|---|
api_key | string | Yes | Your API-97 API key. |
api_secret | string | Yes | Your API-97 API secret. |
amount | number/string | Yes | Amount in currency units (e.g. 10 or 10.00). |
currency | string | Yes | Use INR. |
customer_name | string | Yes | End-user name. |
customer_email | string | Yes | End-user email. |
redirect_url | string (URL) | Yes | Where to redirect the user after payment. |
relay_url | string (URL) | Strongly Recommended | Important: server-to-server callback (webhook). Without this, gateway dashboard/status may desync. |
user_id | string | No | Optional metadata echoed back in webhook. |
{
"status": "success",
"order_id": "order_RApUx9wvhX41uO",
"public_key": "rzp_test_xxx",
"rzp": { "id": "order_RApUx9wvhX41uO", "amount": 1000, "currency": "INR" }
}
{ "status": "error", "msg": "reason for failure" }
relay_url so final status reaches your server safely.<form method="post" action="/create_order.php"> <input type="number" name="amount" min="1" step="0.01" required /> <input type="text" name="name" placeholder="Full Name" required /> <input type="email" name="email" placeholder="Email" required /> <button type="submit">Pay</button> </form>
<?php
// create_order.php
$apiKey = 'YOUR_API_KEY';
$apiSecret = 'YOUR_API_SECRET';
$amount = number_format((float)($_POST['amount'] ?? 0), 2, '.', '');
$name = $_POST['name'] ?? 'Customer';
$email = $_POST['email'] ?? 'customer@example.com';
$data = [
'api_key' => $apiKey,
'api_secret' => $apiSecret,
'amount' => $amount,
'currency' => 'INR',
'customer_name' => $name,
'customer_email' => $email,
'redirect_url' => 'https://yourdomain.com/status.php',
'relay_url' => 'https://yourdomain.com/webhook.php' // IMPORTANT
];
$ch = curl_init('https://gateways.api-97.com/api/v1.php');
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$res = curl_exec($ch);
curl_close($ch);
$out = json_decode($res, true);
if(!isset($out['status']) || $out['status']!=='success'){ die('Create order failed'); }
// Use $out['public_key'] and ($out['rzp']['id'] or $out['order_id'])
// to open Razorpay checkout on a follow-up page.
?>
<!-- open_checkout.html -->
<script src="https://checkout.razorpay.com/v1/checkout.js"></script>
<script>
// values from your create-order response:
const PUBLIC_KEY = "rzp_test_xxx";
const ORDER_ID = "order_RApUx9wvhX41uO";
const RP_AMOUNT = 1000; // paise
var opts = {
key: PUBLIC_KEY,
order_id: ORDER_ID,
amount: RP_AMOUNT,
currency: "INR",
name: "API-97 Payment",
handler: function(){
// optional client fallback confirm
fetch('/confirm.php', {
method:'POST',
headers:{'Content-Type':'application/x-www-form-urlencoded'},
body: new URLSearchParams({order_id: ORDER_ID, status: 'success'})
}).finally(()=> location.href='/status.php?order_id='+ORDER_ID);
}
};
var rzp = new Razorpay(opts);
rzp.on('payment.failed', function(){
fetch('/confirm.php',{method:'POST',headers:{'Content-Type':'application/x-www-form-urlencoded'},
body:new URLSearchParams({order_id:ORDER_ID,status:'failed'})})
.finally(()=> location.href='/status.php?order_id='+ORDER_ID);
});
rzp.open();
</script>
<?php
// webhook.php — called via relay_url
$payload = json_decode(file_get_contents('php://input'), true);
if(!$payload){ http_response_code(400); exit('bad json'); }
$order = $payload['order_id'] ?? '';
$status = strtolower($payload['status'] ?? ''); // success | failed | created/pending
$amount = $payload['amount'] ?? null; // may be paise (integer)
file_put_contents(__DIR__.'/webhook_log.txt', date('c').' '.json_encode($payload).PHP_EOL, FILE_APPEND);
echo 'OK';
?>
use Illuminate\Http\Request;
use GuzzleHttp\Client;
public function create(Request $request){
$data = [
'api_key' => env('API97_KEY'),
'api_secret' => env('API97_SECRET'),
'amount' => number_format((float)$request->input('amount', 10), 2, '.', ''),
'currency' => 'INR',
'customer_name' => auth()->user()->name,
'customer_email' => auth()->user()->email,
'redirect_url' => url('/status'),
'relay_url' => url('/api97/webhook') // IMPORTANT
];
$out = json_decode((new Client)->post('https://project.api-97.com/api/v1.php',[
'form_params' => $data
])->getBody(), true);
// pass $out to a blade view which opens Razorpay
return view('pay.open', ['out' => $out]);
}
<!-- resources/views/pay/open.blade.php -->
<script src="https://checkout.razorpay.com/v1/checkout.js"></script>
<script>
const PUBLIC_KEY = "{{ $out['public_key'] ?? '' }}";
const ORDER_ID = "{{ $out['rzp']['id'] ?? ($out['order_id'] ?? '') }}";
const RP_AMOUNT = {{ $out['rzp']['amount'] ?? 0 }};
var opts={ key:PUBLIC_KEY, order_id:ORDER_ID, amount:RP_AMOUNT, currency:"INR",
name:"API-97 Payment", handler:function(){ window.location='{{ url('/status') }}?order_id='+ORDER_ID; } };
(new Razorpay(opts)).open();
</script>
// routes/web.php
Route::post('/api97/webhook', function (Illuminate\Http\Request $r) {
\Log::info('API97 webhook', $r->all());
return response('OK');
});
const axios = require('axios'), qs = require('qs'), express = require('express');
const app = express(); app.use(express.urlencoded({extended:true}));
app.post('/create-order', async (req, res) => {
const d = {
api_key: process.env.API97_KEY,
api_secret: process.env.API97_SECRET,
amount: Number(req.body.amount || 10).toFixed(2),
currency: 'INR',
customer_name: req.body.name,
customer_email: req.body.email,
redirect_url: 'https://yourdomain.com/status',
relay_url: 'https://yourdomain.com/webhook' // IMPORTANT
};
const out = (await axios.post('https://project.api-97.com/api/v1.php', qs.stringify(d))).data;
res.json(out); // send to client or render a page to open Razorpay
});
app.post('/webhook', express.json(), (req, res) => {
console.log('API97 webhook:', req.body);
res.send('OK');
});
<script src="https://checkout.razorpay.com/v1/checkout.js"></script>
<script>
// after you fetch server /create-order:
const PUBLIC_KEY = data.public_key;
const ORDER_ID = (data.rzp && data.rzp.id) || data.order_id;
const RP_AMOUNT = (data.rzp && data.rzp.amount) || 0;
(new Razorpay({key:PUBLIC_KEY,order_id:ORDER_ID,amount:RP_AMOUNT,currency:"INR"})).open();
</script>
import requests
data = {
"api_key":"YOUR_API_KEY", "api_secret":"YOUR_API_SECRET",
"amount":"10.00", "currency":"INR",
"customer_name":"User", "customer_email":"u@example.com",
"redirect_url":"https://yourdomain.com/status",
"relay_url":"https://yourdomain.com/webhook" # IMPORTANT
}
out = requests.post("https://gateways.api-97.com/api/v1.php", data=data).json()
# Use out["public_key"] + (out["rzp"]["id"] or out["order_id"]) to open Razorpay
from flask import Flask, request
app = Flask(__name__)
@app.post("/webhook")
def api97_webhook():
data = request.get_json()
print("API97 webhook:", data) # order_id, status, amount...
return "OK", 200
fetch('https://gateways.api-97.com/api/v1.php', {
method: 'POST',
headers: {'Content-Type':'application/x-www-form-urlencoded'},
body: new URLSearchParams({
api_key:'YOUR_API_KEY', api_secret:'YOUR_API_SECRET',
amount:'10.00', currency:'INR',
customer_name:'User', customer_email:'u@example.com',
redirect_url:'https://yourdomain.com/status',
relay_url:'https://yourdomain.com/webhook'
})
}).then(r => r.json()).then(d => {
// Open Razorpay
const s=document.createElement('script');
s.src='https://checkout.razorpay.com/v1/checkout.js';
s.onload=()=> new Razorpay({key:d.public_key,order_id:(d.rzp&&d.rzp.id)||d.order_id,amount:(d.rzp&&d.rzp.amount)||0,currency:'INR'}).open();
document.head.appendChild(s);
});
/api/v1.php with required params. 2) Open Razorpay using public_key + rzp.id. 3) Keep a fallback client confirm. 4) Always set relay_url. 5) Redirect to your redirect_url.