Payment Gateway API Integration in India: A Developer's Guide to Razorpay, Stripe, and UPI
ചുരുക്കം (Malayalam TL;DR): ഇന്ത്യൻ SaaS products-ന് payment gateway architecture: Razorpay (domestic INR, UPI, UPI AutoPay subscriptions) + Stripe (international USD/EUR) — ഇതാണ് dual-gateway approach. Webhook handling-ൽ idempotency നിർബന്ധം: payment_id database-ൽ check ചെയ്ത് duplicate processing തടയണം. GST invoicing: B2B customers-ന് GSTIN, HSN/SAC code, IGST/CGST/SGST breakdown — Zoho Books ഉപയോഗിക്കാം. UPI AutoPay ₹15,000 limit-ന് കീഴിലുള്ള SaaS subscriptions-ന് ഏറ്റവും effective billing method.
Indian developers building products for the domestic market need two gateway integrations, not one: Razorpay for UPI, net banking, and INR card payments with T+2 settlement, and Stripe for international currency checkout. Attempting to handle both markets with a single gateway consistently produces either poor UPI coverage or slow INR payouts — the dual-gateway architecture is the practical solution most Indian SaaS products arrive at eventually.
India's Payment Landscape in 2026
A Kozhikode SaaS startup spent three weeks integrating their payment system. They chose Stripe because international developer tutorials all used it. Then they discovered Stripe's INR settlement takes seven business days, they couldn't natively offer UPI (which roughly 70% of their Indian users preferred), and their Indian bank account integration worked better with Razorpay's API. They rebuilt — Razorpay for domestic, Stripe for international customers. That rebuild cost them three additional weeks and a delayed launch.
Understanding why requires understanding the Indian payment landscape. UPI handles over 13 billion transactions per month as of 2026, dominating consumer-to-business payments across price points. The NPCI's UPI infrastructure is deeply embedded in Indian consumer behaviour — many Indian users have no linked card but actively transact via UPI on Google Pay, PhonePe, or their bank app. Any Indian consumer-facing product that does not support UPI checkout is turning away a significant portion of its potential users.
Cards (credit and debit) remain important for higher-value transactions and for users who prefer rewards programmes. Net banking is declining in usage but still relevant for large-value B2B transfers and among older enterprise users. BNPL (Buy Now Pay Later) services — Simpl, LazyPay, ZestMoney — are growing in consumer checkout, particularly for ₹500-5,000 purchase sizes. For B2B: NEFT and RTGS for high-value transfers, UPI AutoPay for recurring subscription billing.
International payments require a separate consideration. Stripe handles 135+ currencies with excellent developer tooling and subscription billing. But for Indian businesses collecting international payments, foreign currency accounts and FEMA compliance are additional requirements — a topic addressed in the dual-gateway section below.
Gateway-by-Gateway Comparison for Indian Developers
Razorpay
Razorpay is the dominant payment gateway for Indian businesses across startup, SME, and enterprise segments. Its API coverage is comprehensive: UPI (collect and intent flows), UPI AutoPay for subscription billing, cards, net banking, wallets (Paytm, Mobikwik), BNPL partners (Simpl, LazyPay), QR code payments, and payment links. Settlement timeline is T+2 for most methods — two business days from transaction to bank account.
The Razorpay dashboard provides solid analytics, webhook configuration, and test mode for development. API documentation quality is good, with well-maintained SDKs for Node.js, Python, PHP, Java, and .NET. Transaction fee: 2% per transaction with no monthly platform fee. At scale, custom enterprise pricing is available.
Razorpay Subscriptions (UPI AutoPay and card recurring mandates) is the recommended path for Indian SaaS subscription billing — covered in detail in the UPI AutoPay section below. For international payments, Razorpay is limited — it can accept USD and EUR via payment links but does not provide a full international checkout experience with multi-currency settlement.
Stripe
Stripe's developer experience is exceptional. Beautifully designed checkout UI (Stripe Checkout), robust subscription billing with proration, trial periods, and upgrade/downgrade logic (Stripe Billing), and support for 135+ currencies make it the best choice for Indian products targeting international customers. The Stripe.js frontend library and webhooks documentation set a high standard that other gateways have not yet matched.
India-specific limitations: Stripe's INR settlement takes 7 business days, versus Razorpay's T+2. Stripe supports UPI via Stripe Checkout in India, but the UPI integration is less robust than Razorpay's — edge cases around UPI intent flow and VPA validation are handled better by Razorpay. Fees for Indian processing: 2.9% + ₹25 per successful charge (India pricing may vary with volume).
For Kerala IT companies building products sold to UK, US, EU, or UAE customers: Stripe is the right choice for international-currency checkout. The Stripe Billing subscription engine handles complex SaaS pricing models (seat-based, usage-based, hybrid) more elegantly than Razorpay Subscriptions.
PayU
PayU has strong market presence in India, particularly among enterprise clients and in the Karnataka/Tamil Nadu/Maharashtra startup ecosystems. Its API design is older and less developer-friendly than Razorpay's — error handling and documentation are less polished. PayU is a solid choice for enterprise sales cycles where the client has an existing PayU relationship, or for government-sector projects where PayU has established procurement relationships. Not recommended for greenfield consumer or SaaS products where developer experience matters.
Cashfree Payments
Cashfree stands out for its payout capabilities — paying out to bank accounts and UPI IDs rather than collecting from customers. For marketplace platforms (gig economy, freelance platforms, e-commerce marketplaces distributing to sellers), Cashfree's Payouts API is superior to Razorpay for disbursement-heavy applications. Also offers competitive UPI AutoPay and standard collection APIs. Worth evaluating if your application has significant payout volume alongside collection.
CCAvenue
CCAvenue is India's oldest gateway with the largest legacy enterprise client base. Integration complexity is higher than modern alternatives. Not recommended for new product development — its main relevance is in government tendering systems and traditional e-commerce players with long-standing CCAvenue relationships. If you inherit a project using CCAvenue, migrating to Razorpay at the next major version upgrade is generally worthwhile.
The Dual-Gateway Architecture
For Kerala SaaS products serving both Indian and international markets, the recommended architecture is:
- Razorpay as the default checkout for all INR transactions — UPI, Indian cards, net banking, wallets, BNPL
- Stripe for international currency checkout — USD, GBP, EUR, AED — displayed when users select international payment methods or when the billing address is outside India
Implementation approach: on your checkout page, detect the user's country preference (from their profile, billing address, or browser locale). Indian users land on the Razorpay checkout flow. International users land on Stripe Checkout. Both flows write to the same orders/transactions table in your database, with a gateway_provider column distinguishing the source.
For subscription products: Razorpay Subscriptions with UPI AutoPay for Indian subscribers, Stripe Billing for international subscribers. This dual-subscription model requires your subscription management logic to handle both plan sources — use a unified billing abstraction layer in your backend that normalises events from both gateways into consistent subscription state.
Foreign currency receipt for Indian companies requires an AD (Authorised Dealer) Category-1 bank account and FEMA compliance for remittance reporting. Stripe India routes international payments through this mechanism. Ensure your CA is aware of your international payment volumes for accurate FEMA reporting.
Webhook Handling Done Correctly
Webhook handling is the most frequently botched part of payment integrations, and the consequences — double-processing subscriptions, missed payment confirmations, incorrect order fulfilment — are serious. Both Razorpay and Stripe send webhooks for payment lifecycle events: payment.captured, payment.failed, subscription.charged, subscription.cancelled, and others.
Three requirements must be met for production-safe webhook handling:
1. Validate webhook signatures. Both Razorpay and Stripe sign their webhook payloads with HMAC-SHA256 using your webhook secret. Always verify this signature before processing. For Razorpay: compute HMAC-SHA256 of razorpay_order_id + "|" + razorpay_payment_id using your webhook secret and compare to the provided razorpay_signature. For Stripe: use stripe.webhooks.constructEvent() which handles signature verification internally. Never process unsigned or incorrectly signed webhook payloads.
2. Return 200 OK immediately. Your webhook endpoint must respond with HTTP 200 within 3-5 seconds. If Razorpay or Stripe does not receive a 200 response, they retry the same event — typically up to 10 attempts over 24-48 hours. Any database queries, email sends, PDF generation, or external API calls after webhook receipt should be queued as background jobs (BullMQ, Celery, Sidekiq) and processed asynchronously. Your webhook handler's only job is to validate the signature, enqueue the work, and return 200.
3. Make webhook handlers idempotent. Because webhooks are retried, your handler must be safe to call multiple times with the same event. The standard implementation: maintain a processed_payment_events table with a unique index on payment_id. Before processing, attempt to insert the payment_id — if the insert succeeds, process the event; if it fails with a unique constraint violation, the event was already processed, return 200 without reprocessing. This insert and the subsequent business logic update should be wrapped in a single database transaction to prevent partial processing on server crash.
This three-part pattern eliminates the majority of payment processing bugs in Indian applications. The most common failure modes — duplicate subscription charges, double order fulfillment, and silent payment failures — all trace back to missing one of these three requirements.
GST Invoice Generation Requirements
Indian businesses (GST-registered) must issue GST-compliant tax invoices for all B2B payments from Indian entities, and for B2C payments above ₹2,00,000 (or as required by the recipient). This is a legal compliance requirement, not optional.
A GST-compliant invoice requires:
- Your GSTIN (GST Identification Number)
- Invoice number (sequential, unique within a financial year)
- Invoice date
- Buyer's GSTIN (for B2B transactions — required for the buyer to claim input tax credit)
- Buyer's legal name and billing address with state code
- HSN code (for goods) or SAC code (for services) — software services typically use SAC 998314 or 998313
- Taxable value (pre-GST amount)
- GST breakdown: IGST (for interstate), or CGST + SGST (for intrastate)
- Total invoice amount (taxable + GST)
For Kerala SaaS products: if both your company and the customer are in Kerala, apply CGST (9%) + SGST (9%) for 18% total. If the customer is in any other Indian state, apply IGST (18%). International invoices (export of services) are zero-rated for GST with LUT (Letter of Undertaking) filing — consult your CA for the LUT process.
Automate GST invoice generation by integrating with an accounting platform. Zoho Books (₹749/month) integrates with Razorpay and Stripe through native connectors — payment events automatically trigger invoice creation with the correct GST calculation based on the customer's state. Vyapar is an alternative with lower cost for businesses needing simpler invoicing. Building a custom invoicing system is generally not worth the compliance maintenance burden — use an established platform.
UPI AutoPay for SaaS Subscription Billing
UPI AutoPay, available through Razorpay Subscriptions, is now the preferred subscription billing mechanism for Indian SaaS products targeting the domestic market. The customer authorises a recurring debit mandate via their UPI app — the setup process takes under 60 seconds with any major UPI app (Google Pay, PhonePe, BHIM).
Key parameters: individual debit transactions must be ₹15,000 or below without additional authentication. For annual plans above ₹15,000, split billing into monthly debits or use card recurring mandates instead. The failed payment rate for UPI AutoPay is significantly lower than standing instructions on savings bank accounts — UPI AutoPay debits directly from the user's payment-enabled account rather than depending on the bank's standing instruction processing.
For Indian SaaS developers building subscription products, I cover the full implementation — Razorpay Subscriptions setup, dunning logic for failed payments, upgrade/downgrade proration, and GST invoice automation — as part of my custom software development service. For Kerala SaaS founders still evaluating whether to build versus buy subscription infrastructure, the comparison in building a SaaS product from Kerala covers this decision.
Frequently Asked Questions
Should a Kerala SaaS startup use Razorpay or Stripe as their primary payment gateway?
For a Kerala SaaS startup with primarily Indian customers, Razorpay should be the primary gateway. Razorpay supports the full spectrum of Indian payment methods including UPI, UPI AutoPay for subscriptions, net banking, and all major card networks with better settlement timing than Stripe for INR transactions. For startups with significant international customer bases (UK, US, UAE), a dual-gateway setup is recommended: Razorpay handles INR checkout, Stripe handles international currency transactions. Stripe's developer experience and subscription billing tooling are superior for complex SaaS billing scenarios, but its UPI support and INR settlement timeline make it unsuitable as a sole gateway for India-focused products. Most Kerala SaaS products that have scaled internationally use this dual-gateway architecture.
How do you prevent duplicate payment processing in webhook handlers for Indian payment gateways?
Preventing duplicate processing in Indian payment gateway webhooks requires idempotency at the database level. The standard approach: when a webhook arrives for a payment event (e.g., payment.captured), first check your database if this payment_id has already been processed. If yes, return 200 OK without re-processing. If no, process the payment update and store the payment_id in your processed_events table in the same database transaction. Both Razorpay and Stripe send the same webhook event multiple times if they don't receive a 200 response within 10-20 seconds — your handler must respond immediately (within 3-5 seconds) and do any heavy processing asynchronously in a background job. This pattern also handles the edge case where your server crashes mid-processing — the gateway retries, your idempotency check catches it.
What are the TDS deduction requirements for payment gateway transactions in India?
TDS (Tax Deducted at Source) applies to payment gateway transactions in specific circumstances under Indian tax law. Section 194O of Income Tax Act requires TDS deduction at 1% when an e-commerce operator (marketplace platforms, not SaaS payment processors) makes payments to Indian seller participants above ₹5 lakhs annually. This applies to marketplaces like Amazon India, Flipkart, or homegrown Kerala marketplaces — not to SaaS companies collecting subscriptions from their own customers. For SaaS companies, payment gateway fees paid to Razorpay/Stripe are subject to TDS at 2% under Section 194J (professional/technical service fees) if the annual fee exceeds ₹30,000 and the paying company is a company/firm liable for tax audit. Consult a CA for your specific business structure, as the applicability depends on entity type and transaction nature.