Available in🇮🇳 India
Once you capture a payment, Razorpay Checkout returns a razorpay_payment_id. You can use this id to fetch the token_id, which is used to create and charge subsequent payments.
You can retrieve the token_id using the Dashboard or the APIs given below.
2.1 What is a Token?
A token is a unique identifier that represents a registered UPI Autopay mandate between a customer and your business. When a customer approves a mandate through their UPI app during the Initiate Mandate Registration step, Razorpay generates atoken_id and associates it with the customer’s customer_id.
The token stores the mandate’s configuration, including the maximum debit amount, frequency and expiry date. You use this token_id every time you want to charge the customer a subsequent payment. A single customer can have multiple tokens for different mandates, for example, one for a monthly subscription and another for a quarterly insurance premium.
Handy Tips
- Each token is tied to a specific payment method and customer. A token created via UPI cannot be used for card-based recurring payments and vice versa.
- Tokens have a lifecycle with defined states. Always check the token state before attempting a subsequent debit. Know more in the Token States section below.
2.2 Token States
A UPI Autopay token (mandate) transitions through the following states during its lifecycle. Ensure your integration handles all of these states to avoid unexpected failures.2.3. Fetch Token by Payment ID
The following endpoint fetches thetoken_id using a payment_id.
GET /payments/:id
Handy TipsYou can also retrieve the
token_id against the payment_id from the payment.authorized webhook.Path Parameter
string
required
The unique identifier of the payment to be retrieved. For example,
pay_1Aa00000000002.Response Parameters
Response Parameters
Response Parameters
string
Unique identifier of the payment.
string
Indicates the type of entity.
integer
The payment amount in currency subunits. For example, for an amount of ₹1 enter 100.
string
The currency in which the payment is made. Refer to the list of international currencies that we support.
string
The status of the payment. Possible values:
createdauthorizedcapturedrefundedfailed
string
Unique identifier of the invoice associated with this payment. It is
null when the registration is done using the API-based setup.boolean
Indicates whether the payment is done via an international card or a domestic one. Possible values:
true: Payment made using international card.false: Payment not made using international card.
string
The payment method used for making the payment. Possible values:
cardnetbankingwalletemiupipaylater
integer
The amount refunded in currency subunits. For example, if
amount_refunded = 100, it is equal to ₹1.string
The refund status of the payment. Possible values:
nullpartialfull
boolean
Indicates if the payment is captured. Possible values:
true: Payment has been captured.false: Payment has not been captured.
string
Description of the payment, if any.
string
The unique identifier of the card used by the customer to make the payment.
string
The 4-character bank code which the customer’s account is associated with. For example,
UTIB for Axis Bank.string
The name of the wallet used by the customer to make the payment. For example,
payzapp.string
The customer’s VPA (Virtual Payment Address) or UPI id used to make the payment. For example,
gauravkumar@exampleupi.string
Customer email address used for the payment.
string
Customer contact number used for the payment.
string
Unique identifier of the customer associated with this payment.
string
Unique identifier of the token associated with this payment. Use it to create subsequent payments.
object
Contains user-defined fields, stored for reference purposes.
integer
Fee (including GST) charged by Razorpay.
integer
GST charged for the payment.
string
Error that occurred during payment. For example,
BAD_REQUEST_ERROR.string
Description of the error that occurred during payment. For example,
Payment processing failed because of incorrect OTP.string
The point of failure. For example,
customer.string
The stage where the transaction failure occurred. The stages can vary depending on the payment method used to complete the transaction. For example,
payment_authentication.string
The exact error reason. For example,
incorrect_otp.object
An object containing unique reference numbers for the payment. For debit payments, it contains the
rrn and upi_transaction_id.string
The payment provider used to process the payment. For example,
Razorpay. It is returned when Optimizer is enabled for your account.integer
Timestamp, in UNIX format, on which the payment was created.
object
Details of the UPI payment received. Only applicable if
method is upi.string
A unique bank reference number provided by the banking partner for the payment. It is
null for the authorisation payment.string
Unique UPI transaction id for the payment. Returned for debit payments.
string
The customer’s VPA (Virtual Payment Address) or UPI id used to make the payment. For example,
success@razorpay.2.4. Fetch Tokens by Customer ID
A customer can have multiple tokens and these tokens can be used to create subsequent payments for multiple products or services. The following endpoint retrieves tokens linked to a customer.GET /customers/:id/tokens
Response
Handy TipsThe
recurring_details.status field in the response indicates the current token state. Use this to check if the token is confirmed (active), paused, cancelled or in any other state before attempting a subsequent debit.Path Parameter
string
required
The unique identifier of the customer for whom tokens are to be retrieved. For example,
cust_1Aa00000000002.2.5. Fetch Token by Token ID and Customer ID
Use this API to fetch token details usingtoken_id and customer_id as path parameters.
GET /v1/customers/:customer_id/tokens/:token_id
Response Parameters
Response Parameters
string
The unique identifier of the token. For example,
token_FHfAzGzREc1ug6.string
The name of the entity. Here, it is
token.string
The token value used to identify the mandate.
string
The bank associated with the token. Returns
null for UPI tokens.string
The wallet associated with the token. Returns
null for UPI tokens.string
The payment method associated with the token. Here, it is
upi.object
Details of the customer’s UPI VPA linked to the token.
string
The username part of the customer’s UPI ID.
string
The handle (bank or PSP) part of the customer’s UPI ID. For example,
upi.string
The account holder’s name as registered with the bank. Returns
null if not available.boolean
Indicates whether the token is enabled for recurring payments. Possible values:
true, false.object
Details of the recurring mandate associated with the token.
string
The status of the recurring mandate. For example,
confirmed.string
The reason for mandate failure, if applicable. Returns
null if there is no failure.string
The authentication type used. Returns
null if not applicable.string
The mandate reference number. Returns
null if not yet assigned.integer
Unix timestamp at which the token was last used. Returns
null if unused.integer
Unix timestamp at which the token was created.
integer
Unix timestamp at which the mandate validity begins.
boolean
Indicates whether Dynamic Currency Conversion (DCC) is enabled.
integer
The maximum amount that can be debited per transaction, in currency subunits.
integer
Unix timestamp at which the token expires.
2.6. Cancel Token
You can cancel tokens that are in theinitiated, confirmed or paused state. You can also retry a cancellation for a token that is in the cancellation_initiated state. Razorpay does not perform any additional validation checks before forwarding the cancellation request to NPCI.
The interim cancellation_initiated status is returned when the cancellation request is acknowledged but a successful callback from the downstream partners is not yet received. When the gateway returns a callback confirming the cancellation, the status updates to cancelled and the token.cancelled webhook is triggered. Wait for the token.cancelled webhook before suspending or terminating subscription services, or applying any late payment fees to customers. Use the following endpoint to cancel a token. This initiates the cancellation of the mandate from NPCI.
PUT /customers/:customer_id/tokens/:token_id/cancel
Path Parameters
Path Parameters
Error Response Parameters
Error Response Parameters
Given below is a list of possible errors you may face while cancelling a token.
token_not_recurring
token_not_recurring
- Description: The token provided is not a recurring/autopay token and is not eligible for cancellation via this API.
- Next Steps: Please ensure you are passing a valid UPI Autopay recurring token. Non-recurring tokens cannot be cancelled using this API.
invalid_mandate_state
invalid_mandate_state
- Description: The UPI mandate linked to this token is not in a cancellable state. The mandate may already be revoked or failed.
- Next Steps: Please check the current status of the mandate before attempting cancellation. Cancellation is only allowed when the mandate is in confirmed or active state.
token_customer_mismatch
token_customer_mismatch
- Description: The token provided does not belong to the authenticated customer. Cross-customer token access is not permitted.
- Next Steps: Please verify that the
token_idbelongs to the customer in context and retry with the correct token.
token_merchant_mismatch
token_merchant_mismatch
- Description: The token provided was not created under your merchant account. Cross-merchant token access is not permitted.
- Next Steps: Please ensure you are using tokens created under your own merchant account and retry with the correct
token_id.
concurrent_request_in_progress
concurrent_request_in_progress
- Description: A cancellation or update operation is already in progress for this token. Simultaneous requests on the same token are not allowed.
- Next Steps: Please wait at least 60 seconds before retrying the cancellation request. Avoid sending duplicate or parallel cancel requests for the same token.
2.7. Delete Tokens
Deleting a token removes it from Razorpay’s database. The deleted token will not appear on the Dashboard or when all tokens are fetched. However, it does not cancel the mandate. If you wish to delete the mandate with Razorpay, you must first cancel it using the Cancel Token API. The following endpoint deletes a token.DELETE /customers/:customer_id/tokens/:token_id
Response
Path Parameters
Path Parameters
Response Parameters
Response Parameters
boolean
Indicates whether the token is deleted. Possible values:
true: The token is deleted successfully.false: The token was not deleted.