What is Razorpay for Magento?
Short answer
Razorpay for Magento is the official razorpay/magento payment module that connects Razorpay, one of the main Indian payment gateways, to Magento 2. It gives your checkout UPI (Google Pay, PhonePe, BHIM and other UPI apps), Indian cards including RuPay, netbanking, wallets and EMI. Card saving follows the RBI tokenisation rules, so card numbers never land in your Magento database. For a store whose buyers pay in INR, this is usually the first payment method I set up.
- Composer-install the official Razorpay module 01
- Register and clear caches 02
- Paste API keys from the Razorpay dashboard 03
- Customer pays via UPI, card, EMI, wallet, or netbanking 04
- Webhooks fire on capture, failure, and refund 05
Watch for this Storing raw card data in Magento
Five steps from composer install to live UPI checkout
This is the order I follow when I add Razorpay to a Magento 2 store, from composer install to the first webhook.
-
01
Composer-install the official Razorpay module
From the Magento project root I run
composer require razorpay/magento. This is the package Razorpay itself publishes on Packagist. I avoid forks and copies from random GitHub repos, because payment code needs the vendor’s security and compliance updates, and you only get those on the official package. -
02
Register and clear caches
Next comes
bin/magento setup:upgradeto register the module, thenbin/magento cache:flush. On production I run it through the normal deploy:setup:di:compileandsetup:static-content:deployas well, because the checkout JS for the payment method is a static asset and will not show up without a fresh deploy. -
03
Paste API keys from the Razorpay dashboard
In
dashboard.razorpay.comunder Settings → API Keys, generate a Key ID and Key Secret. I always start with test mode keys and switch to live keys only after KYC is approved and a test order has gone through. In Magento admin the keys go in Stores → Configuration → Sales → Payment Methods → Razorpay. There I set the payment action (I normally use Authorize and Capture) and enable the method. If you run more than one website, set the keys at website scope. -
04
Customer pays via UPI, card, EMI, wallet, or netbanking
When the shopper places the order, the Razorpay checkout window opens on top of the Magento checkout. They pick UPI, a card, EMI, a wallet or netbanking, and complete payment inside Razorpay’s window. Card details go to Razorpay, not to Magento, and saved cards are stored as RBI-compliant tokens. Once Razorpay confirms the payment, the module updates the Magento order.
-
05
Webhooks fire on capture, failure, and refund
Webhooks cover the cases where the shopper closes the browser before returning to your store. In the Razorpay dashboard I add the webhook URL from the module settings (Razorpay’s Magento docs give it as
https://your-store.com/razorpay/payment/webhook) and subscribe to events such aspayment.authorizedandorder.paid. The module checks the HMAC-SHA256 signature with the webhook secret before it touches an order. Always set that secret. Without it, anyone could post a fake event to that URL.
Four scenarios where Razorpay is the obvious answer
These are the four situations where I reach for Razorpay on a Magento project.
-
D2C / B2C stores selling to Indian customers
If your store charges in INR and ships inside India, your buyers will expect UPI. Many of them pay with nothing else. Razorpay gives you UPI, RuPay cards and netbanking in one module, so you do not need a separate integration for each. On Indian D2C stores I work on, this is the default gateway unless the business already has a contract with another Indian provider.
-
Cross-border stores accepting INR
Some stores outside India also sell to Indian buyers in INR. With a foreign gateway those buyers are often stuck with an international card payment and the fees their bank adds on top. A domestic gateway lets them pay with UPI or a local card instead. Razorpay onboarding needs KYC for your business, so check eligibility for your company before you plan the build around it.
-
B2B Magento with Indian Net-30 invoicing
B2B stores that invoice Indian distributors on credit terms still need a way to collect when the invoice is due. The Magento module handles checkout payments, and Razorpay Payment Links or invoices can cover the offline balance. RazorpayX handles outgoing payouts such as vendor payments and refunds. Those are separate Razorpay products, so I treat them as a separate piece of work from the Magento module.
-
Subscriptions and recurring auto-debit in India
The RBI e-mandate rules ended simple card-on-file recurring charges in India. Recurring payments now need a registered mandate, such as UPI AutoPay or a card mandate, and Razorpay Subscriptions supports both. A Magento subscription module does not talk to Razorpay Subscriptions on its own, so expect custom integration work between the two. Plan that before you promise auto-renewal to customers.
Three Razorpay misconfigs that wreck a Magento store
Every Razorpay-related Magento outage I've been called in to debug came from one of these three mistakes. Audit your config and dashboard for them today.
-
Storing raw card data in Magento
Under the RBI 2022 tokenisation mandate it is illegal for any Indian merchant or PSP to store raw card numbers, expiry dates, or CVVs, only the card-issuer and the card-network may. Every recurring / saved-card flow must use a Razorpay vault token (a network-scope token returned by Razorpay’s tokenise API). Never persist
card.number,card.cvv, orcard.expiryinto the Magento DB, log files, or third-party tools, the RBI fines for non-compliance start at INR 1 crore per breach. -
Skipping the Magic Checkout upgrade
India’s Cash-on-Delivery (COD) order rate sits at 60-70% by default, and COD orders have a Return-to-Origin (RTO) rate of 25-35%, which destroys margins after reverse logistics. Razorpay Magic Checkout is a single-tap UPI / card prompt that converts roughly 30% of would-be COD orders into prepaid orders at checkout. Skipping the Magic Checkout integration costs typical D2C stores ~12% revenue from RTO losses alone. The Magento module supports Magic Checkout out of the box, just enable it in admin config.
-
Leaving webhook signing disabled
By default Razorpay webhooks are unsigned, any client that can POST to your
/razorpay/webhookendpoint can fake apayment.capturedevent and mark unpaid orders as paid. In the Razorpay dashboard → Settings → Webhooks, set a strong webhook secret, then in Magento admin paste the same secret into the Razorpay payment-method config. The module verifies the HMAC-SHA256 signature on every incoming webhook and rejects unsigned or mismatched calls.
Razorpay for Magento: frequently asked questions
-
Razorpay vs Stripe for India: which one wins?
Razorpay, every time, if your customer is paying from India. Stripe does not process UPI natively, charges 4.3% + INR 3 on international cards (vs Razorpay's ~2% domestic), and routes through a foreign acquiring bank that triggers RBI cross-border-payment FX checks on every charge. Razorpay holds an RBI Payment Aggregator licence, processes UPI at 0% MDR (until the RBI changes the rule), and settles directly to your INR current account in T+1 days. Use Stripe for non-Indian markets, Razorpay for India. Many Magento stores wire both modules side by side and route by billing country. -
What is UPI and why does my store need it?
UPI (Unified Payments Interface) is India's real-time inter-bank instant-payment rail, launched by NPCI in 2016 and now processing more than 11 billion transactions per month (2024 NPCI data). Roughly 60% of Indian D2C checkout volume is now UPI: customers tap a Google Pay / PhonePe / Paytm UPI / BHIM intent at checkout, approve the debit on their phone, and the funds land in your account in under 5 seconds. A Magento store without UPI loses roughly half its Indian conversions before the payment screen even loads. Razorpay's Magento module supports UPI intent (mobile) and UPI collect (desktop QR-code) out of the box. -
How does RBI tokenisation work?
Under the RBI 2022 mandate, no merchant, payment aggregator, or gateway may store raw card data (PAN, expiry, CVV): only the card-issuer and the card-network. For saved cards, Razorpay calls Visa / Mastercard / RuPay's network tokenisation APIs and stores a network-scope token (a 16-digit reference unique to your merchant + that card) in place of the real PAN. When the customer pays again, Razorpay sends the token + cryptogram to the issuer, which detokenises and authorises. From your Magento side, you store only the token reference and the last-4 digits: no raw card data ever lands in your DB or logs. The module handles all of this transparently. -
Razorpay Magic Checkout: is it worth the integration cost?
Yes, for any D2C / B2C store with more than 100 orders a month. Magic Checkout is a one-tap UPI / card / wallet prompt that converts roughly 30% of would-be COD (cash-on-delivery) orders into prepaid orders. Indian COD orders have a Return-to-Origin (RTO) rate of 25-35%, costing INR 80-150 per failed delivery in reverse logistics; prepaid orders RTO at under 5%. On a 1,000-order-per-month store with 65% COD, Magic Checkout saves roughly INR 50,000-80,000 per month in RTO losses alone. The Razorpay Magento module enables Magic Checkout via a single admin toggle once Magic is provisioned on your Razorpay dashboard. -
Does Razorpay work with Hyvä themes?
Yes. The official razorpay/magento module version 5.x added native Hyvä Themes compatibility: the popup widget is replaced with an inline Alpine.js + Tailwind component that renders on the Hyvä checkout without pulling in Knockout JS or RequireJS. If you are on an older 4.x module, upgrade with composer require razorpay/magento:^5.0 then run setup:upgrade. The Hyvä compatibility module by Hyvä-Themes/magento2-razorpay is also available as a fallback for stores that cannot upgrade past 4.x. Either way, Razorpay is one of the better-supported payment methods in the Hyvä ecosystem. -
What is Razorpay Affordability / EMI / Pay-Later?
Razorpay Affordability bundles three credit-on-checkout products. EMI on cards: customer pays via a Visa / Mastercard / RuPay credit card and converts the transaction to a 3 / 6 / 9 / 12-month EMI at the card-issuer's rate (~13-18% APR). Cardless EMI: no card required, Razorpay underwrites the customer through Bajaj Finserv / ZestMoney / EarlySalary / IDFC First Bank and grants a 3-12 month EMI at ~14-18% APR. Pay-Later: 0% interest 30-day deferred payment via Simpl / LazyPay / Mobikwik ZIP. All three appear at the Razorpay checkout when the cart value exceeds the minimum threshold (typically INR 3,000+) and are enabled with one admin-config toggle on the Magento module.
Want a Razorpay audit on your Magento store?
Send your storefront URL: I will run a Razorpay integration audit (module version, webhook signing, tokenisation, Magic Checkout, Hyvä compatibility) and reply with a written tuning plan, fixed-price quote, and earliest start date. 24-business-hour turnaround.