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.
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.1. 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.Path Parameter
Path Parameter
id mandatory
: string The unique identifier of the payment to be retrieved. For example, pay_1Aa00000000002.Response Parameters
Response Parameters
id
: string Unique identifier of the payment.entity
: string Indicates the type of entity. Here, it is payment.amount
: integer The payment amount represented in smallest unit of the currency passed. For example, amount = 100 translates to 100 subunits, that is ₹1.currency
: string The currency in which the payment is made. Refer to the list of international currencies that we support.status
: string The status of the payment. Possible values:createdauthorizedcapturedrefundedfailed
order_id
: string The unique identifier of the order.invoice_id
: string The unique identifier of the invoice.international
: 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.
method
: string The payment method used for making the payment. Possible values:cardnetbankingwalletemiupi
amount_refunded
: integer The amount refunded in smallest unit of the currency passed.refund_status
: string The refund status of the payment. Possible values:nullpartialfull
captured
: boolean Indicates if the payment is captured. Possible values:true: Payment has been captured.false: Payment has not been captured.
description
: string Description of the payment, if any.email
: string Customer email address used for the payment.contact
: integer Customer contact number used for the payment.customer_id
: string The unique identifier of the customer.token_id
: string The unique identifier of the token.notes
: json object Contains user-defined fields, stored for reference purposes.fee
: integer Fee (including GST) charged by Razorpay.tax
: integer GST charged for the payment.error_code
: string Error that occurred during payment. For example, BAD_REQUEST_ERROR.error_description
: string Description of the error that occurred during payment. For example, Payment processing failed because of incorrect OTP.error_source
: string The point of failure. For example, customer.error_step
: 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.error_reason
: string The exact error reason. For example, incorrect_otp.created_at
: integer Timestamp, in UNIX format, on which the payment was created.2.2. 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
Path Parameter
Path Parameter
id mandatory
: string The unique identifier of the customer for whom tokens are to be retrieved. For example, cust_1Aa00000000002.Response Parameters
Response Parameters
entity
: string The entity being created. Here, it is a collection.count
: integer The number of tokens to be fetched.items
: object Details related to token such as token id and bank information.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
Path Parameters
Path Parameters
customer_id mandatory
: string The unique identifier of the customer for whom tokens are to be retrieved. For example, cust_IjsVsJ7d27hxOs.token_id mandatory
: string The unique identifier of the token that should be retrieved. For example, token_J0BgMu8YDVusZa.Response Parameters
Response Parameters
entity
: string The entity being created. Here, it is a collection.count
: integer The number of tokens to be fetched.items
: object Details related to token such as token id and bank information.2.3. Delete Tokens
The following endpoint deletes a token.DELETE /customers/:customer_id/tokens/:token_id
Path Parameter
Path Parameter
customer_id mandatory
: string The unique identifier of the customer with whom the token is linked. For example, cust_1Aa00000000002.token_id mandatory
: string The unique identifier of the token that is to be deleted. For example, token_1Aa00000000001.Response Parameter
Response Parameter
deleted
: boolean Indicates whether the token is deleted. Possible values:true: The token is deleted successfully.false: The token was not deleted.