API ReferenceIntegrationsKnowledge Base

2. Fetch and Manage Tokens

Once you capture a payment, Razorpay Checkout 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. Learn about about Tokens.

Note:
You can also search for the Token on your Dashboard. Learn how to search for a Token on the Dashboard.

2.1 Fetch Payment ID using Order ID.#

Once the registration link is sent, you need to wait for the customer to make the payment. You can check if a payment is made and the status of the payment using our APIs.

You can use the below endpoint to fetch the payment_id using an order_id.

/orders/:id/payments

Path Parameter#

id
string The unique identifier linked to the order that was created when you created the registration link. For example, order_1Aa00000000001.

2.2. Fetch Token by Payment ID#

Use the below endpoint to fetch the token_id using a payment_id.

/payments/:id

Note:
You can also retrieve the token_id via the payment.authorized webhook.

Path Parameter#

id mandatory
string The unique identifier of the payment to be retrieved. For example, pay_1Aa00000000002.

2.3. Fetch Tokens by Customer ID#

Use the below endpoint to fetch all tokens linked to a customer.

A customer can have multiple tokens tied to them. These tokens can be used to create subsequent payments for multiple products or services.

/customers/:id/tokens

Path Parameters#

id mandatory
string The unique identifier of the customer for whom tokens are to be retrieved. For example, cust_1Aa00000000002.

2.4. Delete Tokens#

Use the below endpoint to delete a token. You get a 200 OK response if the token is deleted successfully.

/customers/:customer_id/tokens/:token_id

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.
×