How to Generate Dynamic FamPay UPI QR Code with Order ID & Amount (2026)
Dynamic UPI QR codes are the gold standard for checkout experiences in India. Instead of making customers manually copy your UPI ID and type the exact amount, a dynamic QR code pre-fills everything automatically. In this guide, we'll explain how to generate dynamic FamPay (FamApp) UPI QR codes with real-time automated verification using FamGateway.
Learn how to create dynamic UPI QR codes for your FamPay account with automated verification, locked payable amounts, and instant webhook notifications.
- UPI Specification: Standard NPCI URI schema (
upi://pay?pa=...&am=...&tr=...). - Amount Locking: Customer cannot modify the amount; pre-filled directly into UPI PIN screen.
- Verification Speed: Auto-verified via server IMAP within 3–5 seconds of scan completion.
- API Endpoint:
POST /api/create-orderwithX-Api-Keyheader returns dynamic QR URL, hosted checkout, and deep links.
1. Static QR Codes vs Dynamic Auto-Verified QR Codes
Here is why static printed or screenshot QR codes fail in automated web sales compared to dynamic FamGateway QRs:
| Feature Parameter | FamGateway Dynamic QR | Static App Profile QR |
|---|---|---|
| Amount Entry | Locked automatically in app | Manual typing (Dispute prone) |
| Order ID Tagging | Embedded in UPI tr & tn |
None (Manual matching needed) |
| Verification Confirmation | 3–5 Seconds Automated Webhook | Manual screenshot verification |
| Session Expiry (TTL) | 5-Minute Security Window | Permanent (Prone to old receipts) |
2. Why Static QR Codes Hurt Your Sales
If you're displaying a static QR code (like the standard profile QR inside your FamPay app), you are introducing multiple points of friction:
- Amount Entry Errors: Customers frequently type the wrong amount (e.g. ₹499 instead of ₹500), causing payment disputes.
- No Order Link: You cannot match which customer paid for which order without manually requesting transaction IDs and UTR numbers.
- No Real-time Confirmation: Your customer has to wait until you check your app notifications and manually approve their order.
How a Dynamic UPI QR Code Works Under the Hood
Under the NPCI UPI specification, a dynamic QR code is simply a formatted URI string containing specific parameters:
upi://pay?pa=yourvpa@fam&pn=YourBusinessName&am=499.00&tr=ORDER12345&tn=ORDER12345&cu=INR
Key UPI String Parameters:
pa(Payee Address): Your FamPay UPI VPA (e.g.,username@fam).pn(Payee Name): The name displayed to the customer on their UPI app screen.am(Amount): The exact payable amount formatted to two decimal places.tr(Transaction Reference): Your unique internal Order ID.tn(Transaction Note): Your order reference or note (FamGateway embeds the clean Order ID with zero spaces to ensure bank switches don't strip notes).cu(Currency): Must always beINR.
Generating Dynamic FamPay QRs with FamGateway API
While constructing a raw UPI string is easy, verifying whether the customer actually completed the payment is the difficult part. FamGateway automates both generation and instant verification.
1. Create an Order via API
Generate a dynamic QR order session using our simple REST endpoint or the official Python & PHP SDKs:
// Method A: Standard PHP Canonical POST /api/create-order
$apiKey = 'YOUR_FAMGATEWAY_API_KEY';
$payload = json_encode([
'amount' => 199.00,
'customer_name' => 'Rohan Sharma',
'redirect_url' => 'https://example.com/thank-you'
]);
$ch = curl_init('https://famgateway.in/api/create-order');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => $payload,
CURLOPT_HTTPHEADER => [
'Content-Type: application/json',
'X-Api-Key: ' . $apiKey
]
]);
$response = curl_exec($ch);
curl_close($ch);
$result = json_decode($response, true)['data'];
// Access dynamic QR URL, Hosted Checkout, and UPI Intent
$qrImageUrl = $result['qr_url'];
$checkoutUrl = $result['checkout_url'];
$upiIntent = $result['upi_intent'];
Or generate it in 3 lines using the official Python SDK (pip install famgateway):
from famgateway import FamGateway
# Initialize with your API key
fg = FamGateway(api_key="YOUR_FAMGATEWAY_API_KEY")
# Generate dynamic UPI QR order
order = fg.create_order(amount=199.00, customer_name="Rohan Sharma")
print("Dynamic QR Image URL:", order.qr_url)
print("Hosted Mobile Checkout:", order.checkout_url)
print("UPI Deep Link Intent:", order.upi_intent)
2. Display the QR on Your Custom Checkout
You can embed order.qr_url directly as an image on your web page or Discord bot, or redirect mobile buyers straight to order.checkout_url for an instant checkout experience with real-time verification polling.
3. Automatic Webhook Verification
When the customer authorizes payment in their UPI app, FamGateway parses the transaction receipt within 3 to 5 seconds and notifies your webhook listener with cryptographic HMAC-SHA256 signature verification:
// Sample Webhook Handler (webhook.php)
$apiKey = 'YOUR_FAMGATEWAY_API_KEY';
$rawPayload = file_get_contents('php://input');
$signature = $_SERVER['HTTP_X_FAMGATEWAY_SIGNATURE'] ?? '';
// Verify HMAC-SHA256 signature
if (!hash_equals(hash_hmac('sha256', $rawPayload, $apiKey), $signature)) {
http_response_code(401);
die(json_encode(['error' => 'Invalid signature']));
}
$payload = json_decode($rawPayload, true);
if (($payload['status'] ?? '') === 'success') {
$orderId = $payload['order_id'];
$amount = $payload['amount'];
$utr = $payload['utr'];
// Unlock digital product or activate membership in your database
activateUserOrder($orderId, $utr, $amount);
http_response_code(200);
echo json_encode(['status' => 'acknowledged']);
}
Zero-Collision Handling with Bank UTR Idempotency
What if two customers purchase a ₹250 product at the exact same second? FamGateway uses Bank UTR Idempotency Locking combined with atomic database row locks (SELECT ... FOR UPDATE) and strict timestamp filtering. This guarantees 100% collision-free payment attribution for exact clean amounts without requiring decimal increments.
Conclusion
Automated dynamic UPI QR codes transform your checkout into a professional, modern payment experience. With FamGateway, setting up dynamic FamPay QR codes takes less than 5 minutes and costs 0% in transaction fees.
Related Developer Guides & Resources
How to Integrate FamPay UPI Payment Gateway in SMM Panels (Rental, Perfect Panel & SmartPanel)
Step-by-step developer guide to integrating FamPay UPI payment gateway in SMM panels (Rental, Perfect Panel...
How to Accept UPI Payments on WooCommerce Without GST or Current Account (2026 Guide)
Complete tutorial on accepting automated UPI payments on WooCommerce without GST or a commercial current ac...
How to Accept Automated UPI Payments in Telegram Bots (Python & Node.js Guide)
Step-by-step tutorial on accepting automated UPI payments in Telegram shop bots using Python (FastAPI) and ...