Prerequisites
Before you begin:- A Razorpay account. Sign up at dashboard.razorpay.com/signup.
- API Keys (Key ID and Key Secret) generated from your Razorpay Dashboard under Settings → API Keys.
- A server-side environment capable of making HTTP requests (Node.js, Python, PHP, etc.).
Payment flow
The integration follows three steps:- Your server creates an order and returns the order ID to the client.
- The client opens the Razorpay checkout modal using the order ID.
- After payment, your server verifies the signature to confirm authenticity.
Integration steps
1
Create an order (server-side)
Before showing checkout to the customer, create an order on your server using the Razorpay Node.js SDK (or any server-side SDK). The Return
amount is in the smallest currency unit — for USD, that means cents; for INR, paise.server.js
order.id to your frontend. You will pass this into the checkout options.2
Add the Checkout script and open it
Load the Razorpay Checkout script on your page, then configure and open the modal when the customer clicks the payment button. Pass the The
order_id returned from your server.checkout.html
handler function receives razorpay_payment_id, razorpay_order_id, and razorpay_signature. Send all three to your server for verification.3
Verify the payment signature (server-side)
After the customer completes payment, Razorpay returns a signature. Verify it on your server by recomputing the HMAC-SHA256 hash using your Key Secret. Never skip this step — it is what proves the payment is authentic.If
verify.js
verifyPayment returns true, the payment is genuine and you can fulfil the order. If it returns false, treat the payment as invalid.Best practices
- Always verify signatures server-side. Client-side verification can be tampered with. Signature verification on your server is the only reliable way to confirm a payment.
- Never expose your Key Secret in client-side code. The Key ID is safe to include in frontend JavaScript; the Key Secret must stay on your server only.
- Use Test mode during development. Your Dashboard provides separate test API keys. Switch to Live keys only when you are ready to accept real payments.