Testing online payments safely: how test mode works (Razorpay as an example)
Use Razorpay's documented test-mode behavior to plan payment success, failure and retry checks without real customer payment data.
Before real customers pay on your site or app, you need to prove the payment flow works. Payment providers offer a test mode for this. Razorpay's documentation (https://razorpay.com/docs/payments/payments/test-card-details/) is a clear example. Other providers work on similar ideas but have their own rules, so read yours.
What Razorpay's documentation says about test mode
- Test cards work in test mode only.
- Test mode shows a mock bank page with Success and Failure options to imitate the live payment experience.
- No real money is deducted when you use test API keys; it is a simulated transaction.
- Using test cards in live mode gives an error such as "card issuer is invalid" or "invalid card input".
- In the test checkout, any random CVV and any future expiry date are accepted; on the sample payment page, a random OTP of 4 to 10 digits makes the payment succeed, while one below 4 digits makes it fail.
- The page lists test cards by network for Indian payments and separate cards that simulate specific error conditions, where you choose failure on the mock page to see the right error.
Check the page for the current card list rather than copying numbers from an article.
What to test
| Scenario | What you want to see |
|---|---|
| Successful payment | Order confirmed, receipt created, stock reduced once |
| Failed payment | Clear unpaid/failed state; no paid fulfillment, even if an order record already exists |
| Timeout or slow bank | No duplicate order if the customer retries |
| Customer closes the page mid-payment | The order status ends in a clear state after the provider notifies you |
| Refund | Amount and status match |
The scenarios and expected results are our checklist. Use the provider's error-simulation cards for the failure rows.
Rules for safe testing
- Use test keys and test cards only in test environments. Never use a real customer's card or order data to test.
- Keep test and live keys separate, stored outside the code repository, and make it impossible for the test app to use live keys.
- Switch to live mode deliberately, with a checklist: live keys, webhook URLs, success and failure pages. Check your provider's terms and your own policies before any live transaction; this article gives no advice on real-money test payments.
- Confirm results on the server. The browser saying "paid" is not proof; check with the provider's server-side confirmation.
Limits
This article does not cover fees, settlement times, compliance or legal duties. Those depend on your provider and your country. The test-mode behaviours above are Razorpay's as documented on the page we read.
By Omnistu.