Available in🇮🇳 India
Once you capture a payment, Razorpay returns a razorpay_payment_id that can be used to fetch the token_id. This is a manual process and can be done using either APIs or Webhooks. This token_id is used to create and charge subsequent payments.
Handy TipsYou can also search for the Token on your Dashboard.
2.1. What is a Token?
A recurring token represents the mandate that the customer sets up on their card. Razorpay generates atoken_id when the customer completes the authorisation transaction and links it to the customer_id. You use this token_id every time you create a subsequent payment.
The recurring token is different from the card token, which the card network generates when the card is tokenised as required by RBI guidelines.
2.2. Token States
As the authorisation transaction moves through its states, the token generated for the mandate also changes state.
Only tokens in the
confirmed state can be used to create subsequent payments.
2.3. Fetch Token by Payment id
Token Sharing for Partner Auth ModelIf you are a Razorpay Partner, who wants to use this API via Partner Auth, you must ensure the following:
- Add the basic auth with partner credentials (client_id and client_secret).
- Add the
account_idof the sub-merchant usingX-Razorpay-Accountin the header. For example, -H “X-Razorpay-Account: acc_KBrJAIEqre5ucn”
Request
GET /payments/:id
Response
Handy TipsYou can also retrieve the
token_id from the payment.authorized webhook.Response Parameters
Response Parameters
The payment amount represented in smallest unit of the currency passed. For example,
amount = 100 translates to 100 subunits, that is ₹1.The currency in which the payment is made. Refer to the list of international currencies that we support.
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.
The payment method used for making the payment. Possible values:
cardnetbankingwalletemiupi
Indicates if the payment is captured. Possible values:
true: Payment has been captured.false: Payment has not been captured.
Description of the error that occurred during payment. For example,
Payment processing failed because of incorrect OTP.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.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 fetches tokens linked to a customer.GET /customers/:id/tokens
Response
Response Parameters
Response Parameters
Card usage restriction. Possible values:
true: Supports international transactions.false: International transactions are not supported.
Whether the OTP function is enabled or not. Possible values:
true: The OTP function is enabled.false: The OTP function is not enabled.
Whether the recurring for this payment method is enabled or not. Possible Values:
true: Recurring is enabled.false: Recurring is not enabled.
This represents whether recurring is enabled for this token. Possible values:
true: Recurring is enabled.false: Recurring is not enabled.
This represents the status of the recurring transaction. Possible values:
initiatedconfirmedrejectedcancelledpaused
The unique identifier issued by the payment gateway during customer registration. This can be Gateway Reference Number or Gateway Token.
2.5. Fetch a Token by Token ID and Customer ID
The following endpoint fetches a particular token linked to a customer.GET /customers/:customer_id/tokens/:token_id
Response
Response Parameters
Response Parameters
Card usage restriction. Possible values:
true: Supports international transactions.false: International transactions are not supported.
Whether the OTP function is enabled or not. Possible values:
true: The OTP function is enabled.false: The OTP function is not enabled.
Whether the recurring for this payment method is enabled or not. Possible Values:
true: Recurring is enabled.false: Recurring is not enabled.
This represents whether recurring is enabled for this token. Possible values:
true: Recurring is enabled.false: Recurring is not enabled.
This represents the status of the recurring transaction. Possible values:
initiatedconfirmedrejectedcancelledpaused
The unique identifier issued by the payment gateway during customer registration. This can be Gateway Reference Number or Gateway Token.
2.6. Delete Tokens
The following endpoint deletes a token.DELETE /customers/:customer_id/tokens/:token_id
2.7. Error Scenarios
If a token request fails, the API response carries an error object withcode, description, source, step and reason. Use the reason to decide the next action. For the Cards Recurring error reasons, see Error Codes.