Available in🇮🇳 India
Use test mode to check your UPI Autopay integration before you go live. Test mode simulates the responses from NPCI and the customer’s bank, so you can register mandates, run auto-debits and handle failures without moving real money or using a UPI app.
Test Mode Coverage
Test mode covers mandate registration, auto-debits and token management. A few live mode behaviours depend on real time windows or on actions the customer takes in their UPI app, and test mode does not simulate these. Read this section first so you know which parts of your integration you need to verify in live mode. The following can be tested in test mode:Before You Begin
- Generate your test mode API keys from the Dashboard. Keys that start with
rzp_test_send all requests to test mode. You do not need to enable any separate flag. - Use the same APIs and request formats you use in live mode. Only the API keys change.
- Pass every amount in paise, as you do in live mode. For example, send
201for ₹2.01 and100for ₹1. - Configure a webhook URL in your test mode Dashboard to receive test events.
100 (₹1) for a successful payment.
Test Mandate Registration
Registration creates the mandate and the token that you use for later debits. In test mode, the simulator approves or declines the registration on its own, so you do not need to open a UPI app or enter a UPI PIN.Register a Mandate Successfully
- Create a customer, or use an existing customer ID.
- Create an order with
methodset toupiand thetokendetails:max_amount,expire_atandfrequency. Setamountto100. - Create the registration payment with
recurringset to1using the UPI intent flow. - Check that the payment moves to
capturedand that a token is created in theconfirmedstate. Save the token ID for auto-debits.
Curl
How the Intent Flow Behaves in Test Mode
The response contains an intent link, as it does in live mode. You do not need to open it. The simulator completes the registration and sends the callback and webhooks. To test a failed registration, use one of the amounts in Registration Failures.Test Auto-Debits
After a mandate is registered, you can charge the customer using the saved token. Before every debit, the customer must receive a pre-debit notification. Razorpay supports two ways of handling this.Coupled and Decoupled Flows
Both flows are available in test mode. Use the flow your account is configured for in live mode. Know more about the
notification object in the Create an Order to Charge the Customer API.
Run a Successful Debit
- Create an order for the debit amount. Use
100, or any amount below the mandate’smax_amountthat is not reserved for a failure. - In the decoupled flow, pass the
notificationobject with thetoken_idin this order to send the pre-debit notification. - Create the recurring payment with the
tokenID andrecurringset to1. - Check that the payment moves to
capturedand that you receive thepayment.capturedandorder.paidwebhooks.
Debit Rejections
These rejections come from the same checks that run in live mode.Debit Failures
To test a failed debit, use one of the amounts in Auto-Debit Failures. Make sure the mandate’smax_amount is higher than the amount you choose.
Simulate Failures
Set the payment amount to one of the amounts below to trigger a failure. The same amounts trigger failures for one-time UPI payments in test mode. The error details returned for an amount depend on whether the payment is a mandate registration or an auto-debit, so each has its own table. Amounts are in paise. For example,201 is ₹2.01. For auto-debits, make sure the mandate’s max_amount is higher than the amount you choose.
Registration Failures
Use these amounts for the registration order and payment. The payment moves tofailed and no token is created.
Auto-Debit Failures
Use these amounts for the debit order and the recurring payment. The payment moves tofailed and the token stays active.
Test Token Management
Tokens created in test mode behave the same way as live tokens for the actions below.Cancel a Token
You can cancel a token in test mode when itsrecurring_details.status is confirmed.
- Send a
PUTrequest to/v1/customers/:customer_id/tokens/:token_id/cancel. The request does not need a body. - Check that the API returns HTTP
200with the statuscancellation_initiated. - Fetch the token. The cancellation is not instant. Within about 45 seconds,
recurring_details.statuschanges tocancelled.
Curl
Response
Webhooks in Test Mode
Test mode sends the same webhooks as live mode, to the URL in your test mode Dashboard.Handy TipsA webhook can be delivered more than once. Use the event ID to process each event only once. This applies in live mode as well.
Move to Live Mode
Before you switch to live keys, check the following:- Registration succeeds through every flow you offer, and your system stores the token ID.
- Your system handles each failure scenario you expect, including failed registrations and failed debits.
- Your debit amount checks match the mandate’s
max_amountandexpire_at. - Your webhook handler processes each event once, even when it is delivered more than once.
- You have planned for the behaviours listed under Available in Live Mode Only, in particular the 24-hour gap before a debit, the
createdstate, automatic retries and customer actions such as pause and revoke.
Related Information
- About UPI Autopay: How mandates, tokens and debits work.
- Integrate Recurring Payments Using UPI: The live mode integration steps.
- Test UPI ID Details: Test amounts for one-time payments.