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. 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 via the payment.failed webhook.Path Parameters
Path Parameters
id mandatory
: string The unique identifier of the payment to be retrieved. For example, pay_1Aa00000000002.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 retrieves tokens linked to a customer.GET /customers/:id/tokens
Path Parameters
Path Parameters
id mandatory
: string The unique identifier of the customer for whom tokens are to be retrieved. For example, cust_1Aa00000000002.2.3. Delete Tokens
The following endpoint deletes a token.DELETE /customers/:customer_id/tokens/:token_id
Path Parameters
Path Parameters
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.2.4. Cancel Token
The following endpoint initiates cancellation of the mandate from NPCI.PUT /customers/:customer_id/tokens/:token_id/cancel
Path Parameters
Path Parameters
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 cancelled. For example, token_1Aa00000000001.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.
invalid_request_timing
invalid_request_timing
- Description: The cancellation request was received outside the allowed cancellation window or for an unsupported mandate type.
- Next Steps: Please ensure the cancel request is sent within the valid cancellation window and that the mandate type supports this operation. Retry after verifying mandate details.