Skip to content
2nd Code — website and app development, Lucknow
Navigation
E-commerce Websites

Razorpay Payment Gateway Integration: A Practical Guide for Business Websites

Nityanand
· Full-stack developer since 2019 · 100+ websites
Published · 8 min read

Short answer: a correct Razorpay integration creates the order on your server, opens Razorpay Checkout in the browser, verifies the payment signature on the server, and also listens to webhooks — so an order is confirmed even if the customer closes the page before returning to your site.

How the flow works

  1. Create an order (server): your backend calls Razorpay's Orders API with the amount and receipt ID.
  2. Open Checkout (browser): the customer pays by UPI, card, net banking or wallet.
  3. Verify signature (server): confirm the payment response really came from Razorpay before marking the order paid.
  4. Webhooks (server): receive payment.captured and related events as the source of truth.
  5. Confirm and notify: update the order, send email/WhatsApp, reduce stock.

Common mistakes we fix

MistakeWhat goes wrongFix
Trusting the browser onlyPaid orders stay "pending" if the tab closesAdd webhooks
No signature checkFake success responses can be submittedVerify HMAC signature server-side
Amount from the browserPrice can be tampered withCalculate the amount on the server
Keys in front-end codeSecret key leakedKeep the secret key only on the server
No idempotencyDuplicate orders on retriesProcess each payment ID once

Fees and settlement

Razorpay charges a percentage per transaction that varies by payment method and plan, and settles to your bank account on a schedule. Always check the current Razorpay pricing before quoting margins.

Wallets, subscriptions and apps

Wallet top-ups, savings-scheme instalments and in-app payments need extra care: clear ledgers, refunds, and — inside Android apps — Google Play's payments policy. We built wallet and scheme flows for Narayan Jewellers and wallet recharges for The Fortune Pathway.

Testing checklist before going live

  1. Successful payment by UPI, card and net banking in test mode.
  2. Failed and cancelled payments leave the order unpaid and clearly marked.
  3. Closing the browser after paying still confirms the order via webhook.
  4. Duplicate webhook deliveries do not create duplicate orders.
  5. Refund flow updates the order and notifies the customer.
  6. Live keys swapped in only after all tests pass.

Need it done?

See our e-commerce development and API integration services.

Frequently asked questions

Can Razorpay be added to an existing PHP website?

Yes. It needs server-side order creation, signature verification and a webhook endpoint added to your code.

Do I need a company to use Razorpay?

Razorpay supports several business types; check their onboarding requirements for your situation.

Sources & references

Sources used in this article
SourceChecked
Razorpay Docs — Standard CheckoutOct 2026
Razorpay Docs — WebhooksOct 2026
Razorpay PricingOct 2026

Prices in this article are approximate. Spotted an error? Email admin@2ndcode.com — see our editorial policy.

WhatsApp
Call Now