AI Folks
  • Courses
  • Web Of AI
  • Pricing
  • Enterprise
Log in
PreviousWebhooks: know who paidNextSelling products with Shopify

Vibe Coder · Unit 18: Email, Payments and Commerce · Lesson 4 of 5

Payments in India with Razorpay

If your customers are in India they expect UPI and local methods. Razorpay follows the same pattern as Stripe with different names: order, checkout, signature.

Read the short notes and pictures.Do everything inside a blue frame.

Pay the way your customers pay

A checkout that only takes international cards loses most Indian customers at the last step. People there pay by UPI, and also by cards, net banking and wallets, and they expect prices in rupees. Razorpay is a payment gateway built around those methods. Its docs list availability in India, Malaysia, Singapore and the United States.

One provider or two

Many products with customers in India and abroad use Razorpay for India and Stripe elsewhere, choosing by the customer’s country. Start with the one where your first customers are. Check each provider’s current rules on which businesses and countries it supports before you build.

The flow

  1. 1

    Create an order on your server

    With the amount, the currency and your own reference. Razorpay returns an order id.

  2. 2

    Open checkout on your page

    Pass the order id and your public key. Razorpay shows the payment methods.

  3. 3

    The customer pays

    On Razorpay’s checkout.

  4. 4

    Three values come back

    razorpay_payment_id, razorpay_order_id and razorpay_signature.

  5. 5

    Verify the signature on your server

    Before giving the customer anything.

  6. 6

    Confirm the payment status

    And set up webhooks, so you also hear about payments when the browser has closed.

A golden weave, hand-drawn. A table of the three values that come back: payment id, order id and signature.
Three values return after a successful payment.

The amount

The amount is given in the currency’s smallest unit, not in rupees. An amount of 49900 in INR is 499 rupees. Getting this wrong by a factor of a hundred is the classic first mistake, and test mode is where you want to make it.

Verifying the signature

Razorpay’s documentation describes the check precisely: make an HMAC SHA256 digest of the order id, a vertical bar, and the payment id, using your key secret. If your digest equals the signature that came back, the payment is authentic. Use the order id you stored on your server, not the one the browser sends back.

What your server computes

expected = HMAC_SHA256(
    order_id + "|" + razorpay_payment_id,
    key_secret
)

What it decides

if expected == razorpay_signature:
    mark the order as paid
else:
    reject it
You do not need to write this by hand. Razorpay’s server libraries include a verification function, and your coding agent will use it if you ask for "Razorpay signature verification on the server".
A golden weave, hand-drawn. A table comparing the three steps in Stripe and in Razorpay.
The pattern is the same as Stripe’s.

Test mode and going live

Test mode keys

Razorpay gives you Test Mode API keys. A mock bank page with Success and Failure buttons simulates payments; no money moves.

Live mode

Replace the test keys with Live Mode keys only after testing, and after completing Razorpay’s account verification.

Go-live checklist

Razorpay’s own list: switch keys, configure payment capture, set up webhooks.

No-code options

Razorpay also offers plugins for store platforms such as Shopify and WooCommerce.

The key secret stays on the server

The key id is public and goes in the page. The key secret signs and verifies. It must never appear in browser code, in a builder’s front-end file or in a repository.

ActivityYour turnWrite it yourself first, then compare.

A test payment of "499" charges 4 rupees and 99 paise. What happened and what is the fix?

ActivityBuild stepA product that can charge

Add a second way to pay, or decide not to

Decide whether your customers need Razorpay. If they do, add it in test mode: create an order on the server, open checkout, verify the signature, and update the user. If not, write down why and what would change your mind.

Done when

Whichever you chose, note it in your README under "Payments".

Keep these

  • Indian customers expect UPI and local methods.
  • Order on the server, checkout on their page, verify the signature.
  • Amounts are in the smallest currency unit.
Previous lessonWebhooks: know who paidNext lessonSelling products with Shopify