Why Razorpay
If you're building a SaaS in India, Razorpay is where most founders end up. It handles UPI, net banking, wallets, EMI, and cards in one integration β no other gateway covers the full Indian payment stack as cleanly.
Setting Up Your Account
Sign up at razorpay.com with your business PAN, GST number, and bank account details. Approval takes 1β3 business days. Test mode is fully functional while you wait β build everything in test mode and switch keys when approved.
Create separate Razorpay accounts for products that bill independently. Mixing revenue in one account makes reconciliation painful.
The Basic Payment Flow
Always create the order on your backend first:
// Backend: create order
const order = await razorpay.orders.create({
amount: 49900, // paise
currency: 'INR',
receipt: `order_${userId}_${Date.now()}`
});
// Frontend: open checkout
const rzp = new Razorpay({
key: process.env.RAZORPAY_KEY_ID,
amount: order.amount,
currency: 'INR',
order_id: order.id,
handler: (response) => verifyPayment(response)
});
rzp.open();
Never trust the amount from the frontend. Verify every payment server-side.
Subscriptions
For recurring billing, create a plan then a subscription:
POST /v1/plans
{
"period": "monthly",
"interval": 1,
"item": { "name": "Pro Plan", "amount": 49900, "currency": "INR" }
}
Razorpay subscriptions use e-mandate for auto-debit. First payment needs user action; subsequent ones are automatic after e-mandate setup.
Webhooks β Don't Skip This
Webhooks are how Razorpay tells your backend what happened. Handle these events:
payment.capturedβ payment succeededsubscription.chargedβ renewal succeededsubscription.haltedβ payment failed after retriesrefund.processedβ refund completed
Always verify the webhook signature: