How to Integrate a Payment Gateway in a Web App
A plain guide for business owners on how to integrate a payment gateway in a web app: what to decide, how to confirm payments, and what you inherit.
- payment gateway
- web app

Decide these things before anyone writes code
If you are wondering how to integrate a payment gateway in a web app, the code is the smaller part of the job. Most of the risk sits in decisions the owner makes: who holds the money, what documents the gateway needs from you, how an order becomes 'paid', and what security duties you still carry after the gateway takes the card details.
Most guides online are written for developers and are full of code. This one is for the person who will pay for the work and live with the result. You do not need to read code to follow it, but you should be able to ask your developer the right questions.
Start with the basic shape. Your customer pays on a checkout, the gateway processes the payment through the card networks, banks or UPI, and the money is settled to your bank account. In India, the company running this for you is usually a payment aggregator, and the Reserve Bank of India regulates aggregators through a Master Direction, RBI/DPSS/2025-26/141, dated 15 September 2025, which consolidated earlier instruments. You do not have to read all of it, but it explains why the gateway will ask you questions.
Who you are contracting with
RBI's Master Direction says aggregators must work only with merchants they have a contract with. So expect an onboarding process and a signed agreement, not just an account you create in five minutes.
What the gateway will ask of you
Merchants must complete customer due diligence with officially valid documents and PAN, according to secondary summaries of the rules. Confirm the exact wording on the RBI page and with your chosen provider, and keep your business documents ready.
Where the money sits
Non-bank aggregators must hold merchant funds in an escrow account with a scheduled commercial bank, as secondary sources describe it. Check the RBI text if this matters to your finance team.
What it costs
Fees, GST on fees and payout charges differ by provider and by your business type. Read each provider's current pricing page and ask for the terms in writing. We do not quote rates because they change.
Choose between a hosted checkout and a custom one
The main technical choice is how much of the payment screen you build yourself. With a hosted or embedded checkout, the gateway shows the card or UPI fields and handles the sensitive details. With a fully custom form, your own page handles more of that data, and your security burden grows quickly. For most small and mid-sized businesses, we recommend the hosted or embedded option, because it keeps card details away from your own servers.
Be careful with one common belief: that a hosted payment page means PCI DSS does not apply to you. It does apply. PCI DSS v4.0.1 is the active version, and merchants who use a hosted or embedded checkout usually fall under the shortest self-assessment questionnaire, SAQ A. That is lighter, but it is not zero.
The script requirements 6.4.3 and 11.6.1 were removed from SAQ A and replaced by an eligibility criterion. In plain terms, if you embed the provider's payment form in your own page, for example in an iframe, you must confirm that your site is not open to script attacks. A full redirect to the provider's own payment page is different, because this criterion is aimed at merchants who embed the form. Under PCI SSC FAQ 1588, as summarised by secondary sources, the merchant can rely on the provider's confirmation that its embedded solution has that protection. Ask your gateway for that confirmation in writing, and read the FAQ itself on pcisecuritystandards.org, since we only point you to it and cannot judge your exact case.
- Your developer proposes collecting card numbers in your own form and does not mention PCI at all.
- Nobody can tell you which self-assessment questionnaire applies to your setup.
- Your checkout page loads many third-party scripts and nobody keeps a list of them.
- You are told that using a hosted page removes all compliance duties.
The steps of a sensible integration
The order below is the one we would follow for a typical web app. Gateways differ in detail, so treat their own documentation as the final word. We use Razorpay's published docs as the example here because they are clear on the points that matter most.
Create the account and start in test mode Razorpay allows test mode without completing KYC, using test keys. This lets your developer build and test the whole flow while your business verification runs in parallel.
Create the order on your server Your server records the order and the amount first, then asks the gateway to create a matching payment order. Never trust an amount sent from the customer's browser.
Open the checkout in the browser The customer sees the gateway's payment screen, pays, and the browser receives a result. Treat this result as a hint, not as proof.
Verify the payment signature on your server Razorpay says payment signatures should be verified. Your server checks that the response really came from the gateway before it changes anything.
Confirm through webhooks The gateway sends a server to server message when the payment succeeds or fails. This is the source of truth for marking an order paid.
Go live and test with real small payments Switch to live keys once verification is complete, and run a few low value real payments, including a refund, before announcing the checkout.
- Customer places order
- Server creates payment order
- Customer pays on checkout
- Gateway sends webhook
- Server marks order paid
Confirm payment on the server, not in the browser
This is the point most business owners never hear about, and it causes real money problems. A customer can pay and then close the tab, lose signal or press back before your site learns the result. If your system only marks an order paid when the browser reports success, some paid orders will look unpaid, and a determined person may try to fake success.
Razorpay's own documentation says webhooks are the primary method for event notifications, and that API verification should supplement them where a user needs instant confirmation. It also warns that using a callback URL in a standard web integration bypasses the handler function, so the payment status is not confirmed on the client side straight after payment. In short, design for the server to hear from the gateway directly.
Webhooks need care of their own. Razorpay says the webhook secret validates that a webhook came from Razorpay. Your developer should check it on every message. Messages can also arrive twice or late, so the system should handle the same event more than once without, for example, shipping an order twice.
“A paid order should be decided by a message from the gateway to your server, never by a page in the customer's browser.”
Also ask what happens when a webhook fails to arrive. A good setup has a way to look up the payment status through the gateway's API, and a simple daily check that compares your orders with the gateway's records. This is also useful for your accountant.
Questions owners ask, and where to go next
Can I test the integration before my business is verified?
With Razorpay, yes. Its documentation says test mode works without completing KYC, using test keys. Other gateways have their own rules, so check the one you choose.
Does a hosted checkout mean I have no PCI DSS duties?
No. SAQ A still applies. If you embed the provider's payment form, for example in an iframe, you must also meet the criterion about protecting your page from script attacks. A full redirect to the provider's page is different. Ask your gateway for written confirmation about its embedded solution and read the PCI Security Standards Council material.
Will a gateway refuse my business because of RBI rules?
One source we reviewed says no RBI rule lists businesses a gateway must refuse. Gateways still apply their own policies, so ask them directly before you build around one.
How quickly will I receive the money?
Settlement timelines depend on the provider, your account type and your agreement. Sources conflict, so we do not state one. Get it from the provider in writing.
What should I check about refunds and disputes?
Ask each gateway for its current refund and chargeback process and charges before signing. Test a refund in your live trial so you know how it appears in your system.
Do I need a developer for this?
If your web app is custom, someone must write the server side order creation, signature check and webhook handling. That is where mistakes cost money, so we recommend an experienced developer for it.
Before you hire anyone, write down your answers to four questions: which gateway and why, hosted or custom checkout, how an order becomes paid, and who watches failed or duplicate payments. If a developer or agency can answer all four clearly, you are in a good position. If you want a second opinion on a plan or a quote, we are happy to talk it through.
Planning online payments for your web app and want a clear scope before you commit? Tell us what you are building. Talk to us (opens in a new tab)
- payment gateway
- web app
- Razorpay
- PCI DSS
- RBI
- checkout


