AM GATEWAY API

Accept UPI payments in websites, apps and Telegram bots β€” verified automatically, money straight to your UPI ID.

⚑ Instant responsesπŸ€– Telegram-readyπŸ” HMAC webhooksπŸ§ͺ Test mode
Quick start

Accept UPI in your app or Telegram bot

Three calls. Create an order, show the QR / payment link, wait until the status is PAID. Payments go straight to your own UPI ID β€” the gateway only verifies them.

  1. Connect FamPay in your dashboard. Your API key is created automatically.
  2. Create an order β†’ you get pay_url, qr_image_url and the exact amount.
  3. Check the status every 3–5 seconds (or receive a webhook) β†’ deliver when PAID.
Base URLhttps://famgateway.vipsite.in/api/v1
AI-ready

One prompt for the whole integration

Paste this into ChatGPT, Claude, Gemini or any coding assistant (or hand it to your developer). It contains everything: every endpoint, field, status, webhook signature rule and the expired-card handling β€” your assistant can build the full integration from it.

7,270 characters Β· uses a placeholder, never your real key
Read the prompt

Authentication

Send your key with every request. Use whichever your platform supports β€” all three work the same:

MethodExampleBest for
HeaderX-API-Key: YOUR_API_KEYServers, Python / Node / PHP bots
BearerAuthorization: Bearer YOUR_API_KEYHTTP libraries with auth helpers
URL parameter?api_key=YOUR_API_KEYBot builders that can only do a simple GET (TeleBotHost etc.)
Keep the key on your server / bot only. Never put it in a website's JavaScript or send it to users. Live keys start with amg_live_ (older gram_ keys still work), test keys with amg_test_.

Create order POST / GET

https://famgateway.vipsite.in/api/v1/orders/create

ParameterRequiredDescription
amountyesRupees, e.g. 99 or 99.50. Must be within your min/max limits.
client_refnoYour own reference (invoice / Telegram user ID). Letters, numbers, - _ . : #, max 80.
Idempotency-Key headerrecommendedSame key again = the same order is returned (no duplicates if your bot retries).
curl -X POST https://famgateway.vipsite.in/api/v1/orders/create \
  -H "X-API-Key: YOUR_API_KEY" \
  -H "Idempotency-Key: INV-1001" \
  -d amount=99 -d client_ref=INV-1001
https://famgateway.vipsite.in/api/v1/orders/create?api_key=YOUR_API_KEY&amount=99&client_ref=TG12345
<?php
$ch = curl_init('https://famgateway.vipsite.in/api/v1/orders/create');
curl_setopt_array($ch, [
  CURLOPT_POST => true, CURLOPT_RETURNTRANSFER => true, CURLOPT_TIMEOUT => 15,
  CURLOPT_HTTPHEADER => ['X-API-Key: YOUR_API_KEY', 'Idempotency-Key: INV-1001'],
  CURLOPT_POSTFIELDS => ['amount' => 99, 'client_ref' => 'INV-1001'],
]);
$res = json_decode(curl_exec($ch), true);
if (($res['status'] ?? '') === 'success') {
    header('Location: ' . $res['data']['pay_url']);   // or show $res['data']['qr_image_url']
}
import requests
r = requests.post('https://famgateway.vipsite.in/api/v1/orders/create',
    headers={'X-API-Key': 'YOUR_API_KEY', 'Idempotency-Key': 'INV-1001'},
    data={'amount': 99, 'client_ref': 'INV-1001'}, timeout=15)
order = r.json()['data']
print(order['order_id'], order['amount'], order['pay_url'])
const r = await fetch('https://famgateway.vipsite.in/api/v1/orders/create', {
  method: 'POST',
  headers: { 'X-API-Key': 'YOUR_API_KEY', 'Idempotency-Key': 'INV-1001',
             'Content-Type': 'application/json' },
  body: JSON.stringify({ amount: 99, client_ref: 'INV-1001' })
});
const { data } = await r.json();

Response

{
  "status": "success",
  "request_id": "req_7f3a…",
  "data": {
    "order_id": "AMG4EB00B3C1A2F",
    "amount": "99.03",
    "mode": "live",
    "pay_url": "https://famgateway.vipsite.in/pay.php?o=AMG4EB00B3C1A2F",
    "upi_link": "upi://pay?pa=you@fam&am=99.03&…",
    "qr_image_url": "https://api.qrserver.com/v1/create-qr-code/?…",
    "valid_seconds": 300,
    "expires_at": "2026-11-01T18:57:00+05:30"
  }
}
Always show data.amount (e.g. β‚Ή99.03), not the amount you asked for. A few paise are added so every open order is unique β€” that is how payments are matched automatically.
FieldUse it for
pay_urlHosted checkout page with QR, timer and live status. Best for Telegram buttons and websites.
qr_image_urlReady PNG of the QR β€” send it as a photo in Telegram (sendPhoto).
upi_linkDraw your own QR. (Telegram buttons cannot open upi:// links β€” use pay_url.)

Check status GET

https://famgateway.vipsite.in/api/v1/orders/status/{order_id}

curl https://famgateway.vipsite.in/api/v1/orders/status/AMG4EB00B3C1A2F -H "X-API-Key: YOUR_API_KEY"
https://famgateway.vipsite.in/api/v1/orders/status/AMG4EB00B3C1A2F?api_key=YOUR_API_KEY
r = requests.get('https://famgateway.vipsite.in/api/v1/orders/status/' + order_id,
                 headers={'X-API-Key': 'YOUR_API_KEY'}, timeout=10).json()
if r['data']['status'] == 'PAID':
    deliver(order_id)
{
  "status": true,
  "message": "Payment verified successfully",
  "data": {
    "order_id": "AMG4EB00B3C1A2F",
    "status": "PAID",
    "amount": "99.03",
    "utr": "768040076752",
    "txn_id": "FMP1234567890",
    "payer": "RAHUL KUMAR",
    "paid_at": "2026-11-01T18:53:10+05:30"
  }
}
data.statusMeaningWhat to do
PENDINGWaiting for paymentCheck again in 3–5 s
PAIDVerified β€” finalDeliver the product (once)
EXPIREDTime ran outKeep checking for ~3 more minutes (late payments are still matched), then create a new order
REVIEWNeeds a manual checkTell the customer support is checking
FAILEDMarked failed by supportDo not deliver

The status call answers instantly from the database; the gateway checks your FamApp emails in the background. Top-level status is true only for PAID.

Telegram

Telegram bot integration

/buycreate ordersend QR + Pay buttoncheck every 4 sPAID β†’ deliver
  • Send qr_image_url as a photo and put pay_url on a button (Telegram buttons can't open upi://).
  • Use client_ref = Telegram user ID + message ID, and the same value as Idempotency-Key, so a double-tap never makes two orders.
  • Check status every 3–5 s until PAID, or for ~3 min after expiry. Keep a "delivered" list so you deliver once.
  • Prefer webhooks for big bots β€” no polling at all.
import asyncio, aiohttp
from aiogram import Bot, Dispatcher, F
from aiogram.filters import Command
from aiogram.types import Message, CallbackQuery, InlineKeyboardMarkup, InlineKeyboardButton

API = 'https://famgateway.vipsite.in/api/v1'
KEY = 'YOUR_API_KEY'
bot = Bot('BOT_TOKEN')
dp = Dispatcher()
delivered = set()

async def api(method, path, data=None, idem=None):
    headers = {'X-API-Key': KEY}
    if idem: headers['Idempotency-Key'] = idem
    async with aiohttp.ClientSession(timeout=aiohttp.ClientTimeout(total=15)) as s:
        async with s.request(method, API + path, headers=headers, data=data) as r:
            return await r.json(content_type=None)

@dp.message(Command('buy'))
async def buy(m: Message):
    ref = f'tg{m.from_user.id}-{m.message_id}'
    res = await api('POST', '/orders/create', {'amount': 99, 'client_ref': ref}, idem=ref)
    if res.get('status') != 'success':
        return await m.answer('❌ ' + res.get('message', res.get('error', 'Payment error')))
    d = res['data']
    kb = InlineKeyboardMarkup(inline_keyboard=[
        [InlineKeyboardButton(text='πŸ’³ Pay β‚Ή' + d['amount'], url=d['pay_url'])],
        [InlineKeyboardButton(text='πŸ”„ Check payment', callback_data='chk:' + d['order_id'])]])
    await m.answer_photo(d['qr_image_url'], reply_markup=kb,
        caption=f"Pay exactly β‚Ή{d['amount']} (with paise)\nOrder: {d['order_id']}\nValid {d['valid_seconds'] // 60} min")
    asyncio.create_task(watch(m.chat.id, d['order_id'], d['valid_seconds']))

async def deliver(chat_id, data):
    if data['order_id'] in delivered: return
    delivered.add(data['order_id'])
    await bot.send_message(chat_id, f"βœ… Payment received β‚Ή{data['amount']}\nUTR: {data.get('utr') or '-'}")
    # TODO: give the product here

async def watch(chat_id, oid, seconds):
    for _ in range(seconds // 4 + 45):           # + ~3 min grace for late payments
        await asyncio.sleep(4)
        r = await api('GET', f'/orders/status/{oid}')
        st = (r.get('data') or {}).get('status')
        if st == 'PAID': return await deliver(chat_id, r['data'])
        if st in ('FAILED', 'REVIEW'): return await bot.send_message(chat_id, '⚠️ Payment ' + st.lower() + '. Contact support.')
    await bot.send_message(chat_id, 'βŒ› Order expired. Send /buy to try again.')

@dp.callback_query(F.data.startswith('chk:'))
async def check(c: CallbackQuery):
    r = await api('GET', '/orders/status/' + c.data[4:])
    d = r.get('data') or {}
    if d.get('status') == 'PAID': await deliver(c.message.chat.id, d)
    await c.answer('Status: ' + d.get('status', 'unknown'))

asyncio.run(dp.start_polling(bot))
import requests
from telegram import Update, InlineKeyboardButton, InlineKeyboardMarkup
from telegram.ext import ApplicationBuilder, CommandHandler, ContextTypes

API, KEY = 'https://famgateway.vipsite.in/api/v1', 'YOUR_API_KEY'
H = {'X-API-Key': KEY}

async def buy(update: Update, ctx: ContextTypes.DEFAULT_TYPE):
    ref = f'tg{update.effective_user.id}-{update.message.message_id}'
    res = requests.post(API + '/orders/create', headers={**H, 'Idempotency-Key': ref},
                        data={'amount': 99, 'client_ref': ref}, timeout=15).json()
    if res.get('status') != 'success':
        return await update.message.reply_text('❌ ' + res.get('message', 'error'))
    d = res['data']
    await update.message.reply_photo(d['qr_image_url'], caption=f"Pay exactly β‚Ή{d['amount']}\nOrder {d['order_id']}",
        reply_markup=InlineKeyboardMarkup([[InlineKeyboardButton('πŸ’³ Pay now', url=d['pay_url'])]]))
    ctx.job_queue.run_repeating(poll, interval=4, first=4, data={'oid': d['order_id'], 'chat': update.effective_chat.id, 'n': 0})

async def poll(ctx: ContextTypes.DEFAULT_TYPE):
    job = ctx.job; j = job.data; j['n'] += 1
    d = requests.get(API + '/orders/status/' + j['oid'], headers=H, timeout=10).json().get('data', {})
    if d.get('status') == 'PAID':
        job.schedule_removal()
        await ctx.bot.send_message(j['chat'], f"βœ… Paid β‚Ή{d['amount']} Β· UTR {d.get('utr')}")
    elif j['n'] > 120:                      # ~8 minutes
        job.schedule_removal()
        await ctx.bot.send_message(j['chat'], 'βŒ› Order expired. /buy again.')

app = ApplicationBuilder().token('BOT_TOKEN').build()   # pip install "python-telegram-bot[job-queue]"
app.add_handler(CommandHandler('buy', buy))
app.run_polling()
const { Telegraf, Markup } = require('telegraf');
const API = 'https://famgateway.vipsite.in/api/v1', KEY = 'YOUR_API_KEY';
const bot = new Telegraf('BOT_TOKEN');
const delivered = new Set();
const api = async (path, opts = {}) => (await fetch(API + path, {
  ...opts, headers: { 'X-API-Key': KEY, ...(opts.headers || {}) }, signal: AbortSignal.timeout(15000) })).json();

bot.command('buy', async (ctx) => {
  const ref = `tg${ctx.from.id}-${ctx.message.message_id}`;
  const res = await api('/orders/create', { method: 'POST', headers: { 'Idempotency-Key': ref, 'Content-Type': 'application/json' },
    body: JSON.stringify({ amount: 99, client_ref: ref }) });
  if (res.status !== 'success') return ctx.reply('❌ ' + (res.message || res.error));
  const d = res.data;
  await ctx.replyWithPhoto(d.qr_image_url, { caption: `Pay exactly β‚Ή${d.amount}\nOrder ${d.order_id}`,
    ...Markup.inlineKeyboard([[Markup.button.url('πŸ’³ Pay now', d.pay_url)]]) });
  let n = 0;
  const t = setInterval(async () => {
    const r = await api('/orders/status/' + d.order_id).catch(() => null);
    const st = r && r.data && r.data.status;
    if (st === 'PAID' && !delivered.has(d.order_id)) { delivered.add(d.order_id); clearInterval(t); ctx.reply('βœ… Payment received!'); }
    else if (++n > (d.valid_seconds / 4) + 45) { clearInterval(t); ctx.reply('βŒ› Expired. /buy again.'); }
  }, 4000);
});
bot.launch();
<?php
const API = 'https://famgateway.vipsite.in/api/v1';
const KEY = 'YOUR_API_KEY';
function amg(string $path, array $post = null, string $idem = ''): array {
    $ch = curl_init(API . $path);
    $h = ['X-API-Key: ' . KEY]; if ($idem) $h[] = 'Idempotency-Key: ' . $idem;
    curl_setopt_array($ch, [CURLOPT_RETURNTRANSFER => true, CURLOPT_TIMEOUT => 15, CURLOPT_HTTPHEADER => $h]);
    if ($post !== null) { curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, $post); }
    return json_decode((string)curl_exec($ch), true) ?: [];
}
// 1) when user taps Buy
$ref = 'tg' . $userId . '-' . $messageId;
$res = amg('/orders/create', ['amount' => 99, 'client_ref' => $ref], $ref);
$d = $res['data'];
// sendPhoto($chatId, $d['qr_image_url'], caption: "Pay β‚Ή{$d['amount']}", button: $d['pay_url']);
// save $d['order_id'] with the user in your DB

// 2) on "Check payment" button or every few seconds from cron
$st = amg('/orders/status/' . $orderId)['data']['status'] ?? '';
if ($st === 'PAID') { /* deliver once */ }
STEP 1 β€” create the order (HTTP GET):
https://famgateway.vipsite.in/api/v1/orders/create?api_key=YOUR_API_KEY&amount=99&client_ref=USER_ID

Read from the JSON response:
  data.order_id      β†’ save it for this user
  data.amount        β†’ show this exact amount (e.g. 99.03)
  data.qr_image_url  β†’ send as photo
  data.pay_url       β†’ put on an inline URL button "Pay now"

STEP 2 β€” "Check payment" button (HTTP GET):
https://famgateway.vipsite.in/api/v1/orders/status/ORDER_ID?api_key=YOUR_API_KEY

Read data.status:
  PAID     β†’ deliver (remember the order_id so you deliver only once)
  PENDING  β†’ "Not received yet, try again in a few seconds"
  EXPIRED  β†’ still check for 3 min, then ask to create a new order

Tips: use URL-encoding for client_ref, keep the API key only inside the bot code,
and don't create a new order on every button press β€” reuse the saved order_id.

Webhooks

Set a webhook URL in Dashboard β†’ Webhooks. When a payment is verified we POST a signed JSON event within seconds. Your endpoint must be public HTTPS, answer HTTP 2xx within 8 s and must not redirect. Failed deliveries are retried with exponential backoff.

HeaderMeaning
X-AMG-Eventpayment.success, payment.review, payment.failed, payment.expired, webhook.test
X-AMG-Event-IdUnique evt_… β€” store it to ignore duplicates
X-AMG-TimestampUnix time β€” reject if older than 5 minutes (replay protection)
X-AMG-Signaturesha256= HMAC of timestamp + "." + raw body with your webhook secret
<?php
$body = file_get_contents('php://input');
$ts   = $_SERVER['HTTP_X_AMG_TIMESTAMP'] ?? '';
$sig  = $_SERVER['HTTP_X_AMG_SIGNATURE'] ?? '';
$calc = 'sha256=' . hash_hmac('sha256', $ts . '.' . $body, 'YOUR_WEBHOOK_SECRET');
if (!hash_equals($calc, $sig) || abs(time() - (int)$ts) > 300) { http_response_code(401); exit; }
$event = json_decode($body, true);
if ($event['event'] === 'payment.success') {
    $orderId = $event['data']['order_id'];   // deliver once (check $event['id'] not processed before)
}
http_response_code(200);
import hmac, hashlib, time
from flask import Flask, request
app = Flask(__name__)
SECRET = b'YOUR_WEBHOOK_SECRET'

@app.post('/amg-webhook')
def hook():
    ts = request.headers.get('X-AMG-Timestamp', '')
    sig = request.headers.get('X-AMG-Signature', '')
    calc = 'sha256=' + hmac.new(SECRET, ts.encode() + b'.' + request.get_data(), hashlib.sha256).hexdigest()
    if not hmac.compare_digest(calc, sig) or abs(time.time() - int(ts or 0)) > 300:
        return 'bad signature', 401
    ev = request.get_json()
    if ev['event'] == 'payment.success':
        deliver(ev['data']['order_id'])
    return 'ok'
const crypto = require('crypto');
app.post('/amg-webhook', express.raw({ type: 'application/json' }), (req, res) => {
  const ts = req.get('X-AMG-Timestamp'), sig = req.get('X-AMG-Signature') || '';
  const calc = 'sha256=' + crypto.createHmac('sha256', 'YOUR_WEBHOOK_SECRET').update(ts + '.' + req.body).digest('hex');
  if (calc.length !== sig.length || !crypto.timingSafeEqual(Buffer.from(calc), Buffer.from(sig)) || Math.abs(Date.now() / 1000 - ts) > 300)
    return res.status(401).end();
  const ev = JSON.parse(req.body);
  if (ev.event === 'payment.success') deliver(ev.data.order_id);
  res.sendStatus(200);
});
Bots

QR image & logo

qr_image_url is a ready PNG of the payment QR, drawn on the gateway server. It looks exactly like the QR on the hosted checkout page: the QR design you picked in Dashboard β†’ QR & checkout, with a logo in the centre. Send it straight to sendPhoto β€” nothing to download or draw.

Your settingCentre of the QR
You uploaded your own logoYour logo
You never uploaded oneThe AM GATEWAY logo
You pressed Remove logoPlain QR, no logo
create orderqr_image_urlsendPhotocustomer scans
https://api.telegram.org/botBOT_TOKEN/sendPhoto?chat_id=CHAT_ID&photo=URL_ENCODED_qr_image_url&caption=Pay%20exactly%20%E2%82%B999.03
import requests

BOT = 'https://api.telegram.org/botBOT_TOKEN'

def send_qr(chat_id, d):          # d = response['data'] from /orders/create
    return requests.post(BOT + '/sendPhoto', data={
        'chat_id': chat_id,
        'photo': d['qr_image_url'],   # Telegram downloads it itself
        'caption': f"Pay exactly β‚Ή{d['amount']}\nOrder {d['order_id']}",
    }, timeout=15).json()
async function sendQr(chatId, d) {   // d = res.data from /orders/create
  const r = await fetch(`https://api.telegram.org/botBOT_TOKEN/sendPhoto`, {
    method: 'POST', headers: { 'Content-Type': 'application/json' },
    body: JSON.stringify({ chat_id: chatId, photo: d.qr_image_url,
      caption: `Pay exactly β‚Ή${d.amount}\nOrder ${d.order_id}` }) });
  return r.json();
}
<?php
function send_qr(string $botToken, $chatId, array $d): array {   // $d = response['data'] from /orders/create
    $ch = curl_init("https://api.telegram.org/bot$botToken/sendPhoto");
    curl_setopt_array($ch, [CURLOPT_POST => true, CURLOPT_RETURNTRANSFER => true, CURLOPT_TIMEOUT => 15, CURLOPT_POSTFIELDS => [
        'chat_id' => $chatId, 'photo' => $d['qr_image_url'],
        'caption' => "Pay exactly β‚Ή{$d['amount']}\nOrder {$d['order_id']}"]]);
    $r = json_decode((string)curl_exec($ch), true); curl_close($ch);
    return $r ?: [];
}
  • Every order has its own QR (amount and order id are inside) β€” never reuse an old image for a new order.
  • Optional: ?s=300…900 changes the size in pixels (default 640). &dl=1 forces a download.
  • If a bot builder cannot send photos from a URL, fetch qr_image_url yourself and upload the bytes as a file.
  • Changing your logo or design in the dashboard applies to every new QR immediately.

Test mode

Use your amg_test_… key: orders are created with "mode": "test", never matched to real money, and you can mark them paid yourself:

curl -X POST https://famgateway.vipsite.in/api/v1/test/pay/AMG4EB00B3C1A2F -H "X-API-Key: amg_test_…"

This fires your webhook too, so you can test the whole bot flow without paying.

Errors

Errors return JSON with a message (or error) and a request_id β€” quote it to support.

HTTPMeaningFix
400Missing / invalid parameterCheck amount, order_id, client_ref
401Key missing, wrong, revoked, expired, or FamPay not connectedCopy the key again from the dashboard
403Account suspended / endpoint not allowed for this keyContact support
404Order not found (or belongs to another account)Use the order_id from your create response
409Idempotency-Key reused with a different amountUse a new key per order
413Request too largeSend only the documented fields
429Too many requests / daily quotaWait Retry-After seconds; poll every 3–5 s, not faster
503MaintenanceRetry in a minute

Limits & speed

  • Create and status calls answer from the database β€” typically well under 200 ms on normal hosting.
  • Payment verification normally takes 3–10 s after the customer pays (it depends on when FamApp's email arrives).
  • Rate limit: shown in the X-RateLimit-Limit / X-RateLimit-Remaining headers (default 120 requests/min per account).
  • Use HTTPS and a 10–15 s timeout. Retry network errors with the same Idempotency-Key.
  • Public health check: GET https://famgateway.vipsite.in/api/v1/health

FAQ

Why is the amount β‚Ή99.03 instead of β‚Ή99?

Each open order gets a unique amount so the gateway can tell payments apart automatically. Always ask the customer to pay the exact amount shown.

Customer paid but status is still PENDING

Wait up to a minute. If the customer paid a different amount or after the order expired (+3 min grace), it will not match β€” contact support with the UTR.

Can I keep using autoqr.php / autoverify.php?

Yes. Old URLs and old keys keep working with the same response format.

Do you hold my money?

No. Customers pay your own UPI ID directly. The gateway only verifies the payment.