API ReferenceIntegrationsKnowledge Base

Payments

You can accept payments from your customers by integrating your website or app with Razorpay Payment Gateway or using Razorpay products such as Payment Links, Payment Pages, Subscription Links, Invoices and Smart Collect.

If you want to directly integrate with our APIs, reach out to our Support team with your requirements.

This section contains the details of the Payment APIs that are used to capture payments, fetch details of payments made by customers and add notes to existing payments.

Postman Collection#

We have a Postman collection to make the integration quicker and easier. Click the Download Postman Collection button below to get started.

Instructions to use the Postman Collection#

  • All Razorpay APIs are authorized using Basic Authorization.
    • Generate API Keys from the Dashboard .
    • Add your API Keys in Postman. Selected the required API → Auth → Type = Basic Auth → Username = <Your_Key_ID>; Password = <Your_Key_secret>
  • Some APIs in the collection require data specific to your account such as order_id(Order ID) and pay_id (Payment ID) as a path parameter.
    • For example, the Fetch Payments based on Orders API requires you to add the order_id as a path parameter.
    • Such parameters are enclosed in {} in the collection. For example, {order_id}.
    • The API throws an error if these are incorrect or do not exist in your system.

Payment Entity#

For ease of understanding, the response for each request is shown on the right panel. The responses can be formatted in JSON.

The various parameters are explained below:

id
string Unique identifier of the payment.
entity
string Indicates the type of entity.
amount
string The payment amount represented in smallest unit of the currency passed. For example, amount = 100 translates to 100 paise, that is ₹1 (default currency is INR).
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:
-created
-authorized
-captured
-refunded
-failed
base_amount
string The converted payment amount that will be used to calculate fees and settlements. Represented in smallest unit of the base_currency. This attribute is currently only present if the currency is non-INR.
base_currency
string The conversion currency that will be used to calculate fees and settlements. This currently defaults to INR, and is present only if the currency is non-INR.
method
string The payment method used for making the payment. Possible values:
-card
-netbanking
-wallet
- emi
-upi
order_id
string Order ID, if provided. Read Orders API to learn more.
description `
string Description of the payment, if any.
international
boolean Indicates whether the payment is done via an international card or a domestic one.
refund_status
string The refund status of the payment. Possible values include:
- null
- partial
- full.
amount_refunded
integer The amount refunded in smallest unit of the currency passed.
For example, if amount_refunded = 100, here 100 stands for 100 paise, which is equal to ₹1. INR is the default currency.
captured
boolean Indicates if the payment has been captured.
email
string Customer email address used for the payment.
contact
string Customer contact number used for the payment.
fee
integer Fee (including GST) charged by Razorpay.
tax
integer GST charged for the payment.
error_code
string Code for the error that occurred during payment. For example, BAD_GATEWAY_ERROR.
error_description
string Description of the error that occurred during payment.
notes
json object Contains user-defined fields, stored for reference purposes.
created_at
integer Timestamp, in UNIX format, on which the payment was created.

Capture a Payment#

Once the payment is authorized by the customer's bank, you must verify if the authorized amount deducted from the customer's account is the same as the amount paid by the customer on your website or app.

You can configure automatic capture of payments on the Razorpay Dashboard.

To change the status of the payment from authorized to captured, send the following request:

/payments/:id/capture

Path Parameter#

id mandatory
string Unique identifier of the payment to be captured.

Request Parameters#

amount mandatory
string The amount to be captured (should be equal to the authorized amount, in the smallest unit of the chosen currency).
currency mandatory
string ISO code of the currency in which the payment was made. Refer to the list of supported currencies.

After the capture, the funds are transferred to your account in T+2 days in case of domestic transaction. For international transactions, the time taken is T+7 business days. The amount sent in the capture request must come from a verified source and be the amount that you are expecting to receive.

Recommendation:
While creating a capture request, in the amount field enter only the amount associated with the Order that is stored in your database.

Note:
Attempting to capture a payment whose status is not authorized will produce an error.

Fetch a Payment#

The following endpoint is used for retrieving a specific payment object using its id.

/payments/:id

Path Parameter#

id mandatory
string Unique identifier of the payment to be retrieved.

Query Parameters#

expand[] optional
array Used to retrieve additional information about the payment, specifically the method used to make the payment. Using this parameter will cause a sub-entity to be added to the response.

Supported values are:
  • card - Expanded card details, applicable for card and EMI payments.
  • emi - Expanded EMI plan details, applicable for EMI payments.
  • offers - Expanded Offer details, applicable when an offer was applied to a payment.

Examples#

The expand[] parameter on the Payments endpoint returns expandable fields in the response:

expand[]=card
Used to expand the card details when the payment method is emi.
expand[]=emi
Used to expand the EMI plan details when the payment method is emi.

Expanded Offers#

expand[]=offers
Used to expand the Offers applied to a payment, wherever applicable.

Fetch Multiple Payments#

The following endpoint is used for retrieving all the payments.

/payments

Query Parameters#

from
integer Timestamp, in seconds, from when payments are to be fetched.
to
integer Timestamp, in seconds, till when payments are to be fetched.
count
integer Number of payments to be fetched.
Default value is 10. Maximum value is 100. This can be used for pagination, in combination with the skip parameter.
skip
integer Number of records to be skipped while fetching the payments.
expand[]
array Used to retrieve additional information about the payment, specifically the method used to make the payment. Using this parameter will cause a sub-entity to be added to the response.

Supported values are:
-card - Expanded card details, usable for card and EMI payments.
-emi - Expanded EMI plan details, usable for EMI payments.

Note:
By default, only last 10 are returned. You can use the count and skip parameters to retrieve the specific number of records that you need.

Example#

The usage of the expand[] parameter in retrieving the card or the EMI plan details of the payments is shown in the example, displayed on the right.

Request #1 is for retrieving the expanded card details of the payments, in which the payment method is card or emi. Request #2 is for retrieving the expanded EMI plan details of the payments, in which the payment method is emi.

Fetch Payments based on Orders#

The following endpoint retrieves payments corresponding to an Order:

/orders/:id/payments

Path Parameter#

id mandatory
string Unique identifier of the order you want to fetch payment details for.

Fetch the Card Details for a Payment#

You can retrieve the details of the card that has been used to make a payment using the following endpoint.

/payments/:id/card

Path Parameter#

id mandatory
string Unique identifier of the payment you want to retrieve card details for.

Response Entities#

id
string Unique identifier of the card used for the payment.
entity
string The value for this attribute will always be card.
name
string Name of the card holder.
last4
string The last 4 digits of the card number.
network
string The card network. Possible values:
  • American Express
  • Diners Club
  • Maestro
  • MasterCard
  • RuPay
  • Unknown
  • Visa
type
string The card type. Possible values:
  • credit
  • debit
  • prepaid
  • unknown
issuer
string The card issuer. 4-character code denoting the issuing bank

This attribute will not be set for the card that has been issued by a foreign bank.
international
boolean This attribute will be set to true if the card has been issued by a foreign bank.
emi
boolean This attribute is set to true if the card can be used for EMI payment method.

Update the Payment#

You can modify an existing payment to update the Notes field only. Notes can be used to record additional information about the payment. You can add up to 15 key-value pairs with each value of the key not exceeding 256 characters.

Using the PATCH operation, you can replace the entire notes object for the entity.

Request Parameters#

To modify the Notes field in a particular payment, construct the API request as follows:

/payments/:id/
id mandatory
string Unique identifier of the payment for which the Notes field must be updated.
notes mandatory
json object Contains user-defined fields, stored for reference purposes. Refer to the Notes section of API documentation.
×