API ReferenceIntegrationsKnowledge Base

Orders

Razorpay enables you to create orders and link them to payments. Order creation is an important step as it helps you associate every payment with an order, thus preventing multiple payments.

Orders and payments go hand-in-hand. Once a payment is captured, the order is marked paid. Learn about:

Orders API#

Orders APIs are used to create, update and retrieve details of Orders. Also, you can retrieve details of payments made towards these Orders.

Upgrade your Orders API Integration:
The payment_capture parameter, earlier passed for automatic capture of payments, is being deprecated and hence no longer required. For automatically capturing the payments, visit our payment capture settings page.

Integrations:
Looking to integrate your website, ecommerce store or mobile app with Razorpay Payment Gateway? Visit our Introduction to Razorpay page to find the right integration method for you.

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

You can also collect payments without a website or app, using Razorpay products, such as Payment Links, Payment Pages, Subscription Links, Invoices and Smart Collect.

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) as a path parameter.
    • For example, the Fetch Order by ID API requires you to add the order_id as a path parameter.
    • These 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.

Order Entity#

The Order entity consists of the following fields:

id
string The unique identifier of the Order.
amount
integer The amount for which the Order was created, in currency subunits. For example, for an amount of ₹295, enter 29500.
amount_paid
integer The amount paid against the Order.
amount_due
integer The amount pending against the Order.
currency
string The currency associated with the Order's amount. Refer the list of supported currencies.
receipt
string Receipt number that corresponds to this Order. Can have a maximum length of 40 characters.
status
string The status of the Order. Possible values:
  • created: When you create an order it is in the created state. It stays in this state till a payment is attempted on it.
  • attempted: An order moves from created to attempted state when a payment is first attempted on it. It remains in the attempted state till one payment associated with that order is captured.
  • paid: After the successful capture of the payment, the order moves to the paid state. No further payment requests are permitted once the order moves to the paid state. The order stays in the paid state even if the payment associated with the order is refunded.
attempts
integer The number of payment attempts, successful and failed, that have been made against this Order.
notes
json object Key-value pair that can be used to store additional information about the entity. Maximum 15 key-value pairs, 256 characters (maximum) each. For example, "note_key": "Beam me up Scotty”.
created_at
integer Indicates the Unix timestamp when this Order was created.

Create an Order#

The following endpoint creates an Order:

/orders

Request Parameters#

Following are the parameters to be sent in the request body:

amount mandatory
integer The amount for which the Order was created, in currency subunits. For example, for an amount of ₹295, enter 29500. Payment can only be made for this amount against the Order.
currency mandatory
string ISO code for the currency in which you want to accept the payment. Refer to the list of supported currencies.
receipt optional
string Receipt number that corresponds to this Order, set for your internal reference. Can have a maximum length of 40 characters.
notes optional
json object Key-value pair that can be used to store additional information about the entity. Maximum 15 key-value pairs, 256 characters (maximum) each. For example, "note_key": "Beam me up Scotty”.

Fetch Orders#

The following endpoint retrieves the details of all Orders created by you.

/orders

In this example, count and skip query parameters have been used. You can invoke this API without these query parameters as well.

Query Parameters#

authorized
boolean Possible values:
  • 1 - Retrieves Orders for which payments have been authorized. Payment and Order states differ. Learn more about payment states.
  • 0 - Retrieves Orders for which payments have not been authorized.
receipt
string Retrieves the Orders that contain the provided value for receipt.
from
integer Timestamp (in Unix format) from when the Orders should be fetched.
to
integer Timestamp (in Unix format) up till when Orders are to be fetched.
count
integer The number of orders to be fetched. The default value is 10. The maximum value is 100. This can be used for pagination, in combination with skip.
skip
integer The number of orders to be skipped. The default value is 0. This can be used for pagination, in combination with count.
expand[]
array Used to retrieve additional information about the payment. Using this parameter will cause a sub-entity to be added to the response.

Supported values are:
  • payments: Returns a collection of all payments made for each order.
  • payments.card: Returns the card details of each payment made for each order.
  • transfers: Returns a collection of transfers created for each order.
    For more information about creating transfers using Orders, refer to the Transfers section of the Route API documentation.
  • virtual_account: Returns the virtual account details created for each order.
    For more information about creating Virtual Accounts, refer to the Smart Collect API documentation.

Examples#

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

expand[]=payments
Used to expand the payments made for an order.
expand[]=payments.card
Used to expand the details of the card used for making the payment for each order.

Fetch an Order with Id#

The following endpoint retrieves the details of a particular Order.

/orders/:id

Path Parameter#

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

Fetch Payments for an Order#

You can retrieve all the payments made for an Order. The response contains all the payments, either authorized or failed, for that Order.

/orders/:id/payments

Path Parameter#

id mandatory
string Unique identifier of the Order for which the payments should be retrieved.

Update the Order#

You can modify an existing Order to update the Notes field only. Notes can be used to record additional information about the Order. A key-value store, the notes field can have a maximum of 15 key-value pairs, each of 256 characters (maximum).

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

To modify the notes field in a particular Order, construct the API request as follows:

/orders/:id/

Request Parameter#

notes mandatory
json object Notes of the entity to be modified. Learn more about notes in the API documentation.

Path Parameter#

id mandatory
string Unique identifier of the Order in which the Notes field must be updated.

Products API#

You can now store additional information on the products that customers add to their cart while shopping on your website or app, using the Products API.

The Products API is based on the Orders API and uses the same endpoint. Along with the existing Orders parameters, you must use the products array to pass additional, domain-specific product information such as type, price, and so on.

Products Entity#

The parameters of the product entity depend on the product type. Currently, the only supported type is mutual_fund.

Type: Mutual Funds#

Businesses operating in the Mutual Funds sector can use the products array to send additional details on the mutual fund schemes their customers have invested in, in a single order.

products

array The products added by the customer to their cart.

type
string The type of product. Currently, the only supported value is mutual_fund.
plan if type=mutual_fund
string The name of the mutual fund plan selected by the customer. For example, GD.
folio if type=mutual_fund
string Unique identifier of the customer's account with the mutual fund. For example, 9104927822.
amount if type=mutual_fund
string The amount paid by the customer for the plan. For example, 1400.
option if type=mutual_fund
string Mutual fund plan option. For example, G.
scheme if type=mutual_fund
string Type of mutual fund scheme. For example, LT.
receipt if type=mutual_fund
string Unique reference number. For example, 77407

Usage#

The following endpoint creates an Order with the transaction details and the domain-specific product details.

/orders

Other Product Types#

Businesses operating in various sectors can use the products array to send additional details on the products purchased by their customers, in a single order.

Note:
Currently, mutual_funds is the only product type. If you would like us to add support for other types, please get in touch with our Support team.

×