API ReferenceIntegrationsKnowledge Base

Payment Links

The APIs explained here allow you to create and fetch single or multiple payment links based on the payment ID. You can send notifications and also cancel the payment links using these APIs. These operations can also be performed on the Dashboard.

Note:
Payment Link is a solution on our existing Invoices system. Therefore, a few attributes in the entity response will not be of any use in the case of Payment Links.

Payment Link Entity#

The payment entity returned by Razorpay is as shown on the right. It is returned in JSON form by the API (or in the object form if using language SDKs).

type

string Determines the type of Invoice. Pass link as the value, as it represents Payment Link.

currency

string Defaults to INR. We support more than 90 currencies.

description

string A brief description of the Payment Link.

customer_id

string You can pass the customer_id in this field, if you are using Customers API. If not, you can pass the customer object described in the below fields.

customer

Customer details

[name]

string The customer's name.

[email]

string The email address of the customer.

[contact]

string The contact number of the customer.

[billing_address]

Billing address of the customer

[line1]
string
[line2]
string
[city]
string
[zipcode]
string
[state]
string
[country]
string
line_items

Description of the line items

[item_id]
string If you are using Items API, you may use an existing item as a template for line items of invoice. You can still override other details such as name, description by passing these along with item_id. Item will not be updated.Note:
You can only use items of type invoice while creating an invoice.
[name]
string Is required without Item ID.
[description]
string
[amount]
integer Is required without item ID.
[currency]
integer This needs to be passed if an item_id is not being passed. Defaults to INR. Click here for a list of supported currencies.
[quantity]
integer. Defaults to 1
[expire_by]
integer
sms_status

boolean Indicates whether the SMS has been sent to the customer. Possible values are pending and sent.

email_notify

boolean Indicates whether the email has been sent to the customer. Possible values are pending and sent.

notes

object Any custom notes you might want to add to the link can be entered here. Refer Notes section of the API Reference Guide to learn more.

Create Payment Link#

This endpoint helps to create a new Payment Link.

/invoices

Request Parameters#

Following table lists the attributes and their explanations, which are sent in request body:

type mandatory

string in: link/ecod/invoice Must send type=link.

amount mandatory

integer Amount must be in the smallest unit of the currency.

description mandatory

string A brief description of the Payment Link.

customer_id optional

string You can pass the customer_id in this field, if you are using Customers API. If not, you can pass the customer object described in the below fields.

customer

Customer details

[name] optional
string The customer's name.
[email] optional
string The email address of the customer.
[contact] optional
string The contact number of the customer.
view_less optional

boolean Defaults to 1. When set to 1 it collapses the Payment Link's description.

currency optional

string Defaults to INR. We support international currencies.

receipt optional

string Must be a unique number for each Payment Link.

expire_by optional

epoch/integer If specified, Payment Link will expire at the specified time.

sms_notify optional

boolean Defines who handles the SMS notification. If 0 it is handled by you. If 1, it is handled by Razorpay.

email_notify optional

boolean Defines who handles the Email notification. If 0 it is handled by you. If 1, it is handled by Razorpay.

notes optional

object Any custom notes you might want to add to the link can be entered here. Refer Notes section of the API Reference Guide to learn more.

partial_payment optional

string Used to enable partial payments. Defaults to 0.

Note:
Once you have created the payment link, the response from Razorpay API includes a field called short_url. This url can be shared with the customer by any other means as well, for making the payment.

Fetch Payment Link#

You can fetch a specific Payment Link using:

Also, you can fetch all the Payment Links created till date.

By ID#

You can fetch payment link with given ID using the following endpoint.

/invoices/:id

Path Parameter#

id mandatory
string Unique identifier of the Payment Link.

By Payment_id, Receipt and Customer_id#

You can fetch payment links using these query parameters.

Query Parameters#

payment_id
Since the payment has been received, the relevant Payment ID can be used.
receipt
The unique receipt number entered while creating the Payment Link.
customer_id
If the customer is registered, their unique Customer ID can be used.

Fetch Multiple Payment Links#

You can fetch multiple payment links using this endpoint:

/invoices

Send or Resend Notifications#

You can send or resend notifications with the short url to customer via email and SMS, using following endpoint:

/invoices/:id/notify_by/:medium

Path Parameters#

id mandatory
string The unique identifier of the Payment Link that should be resent.
medium mandatory
string: The medium through which the Payment Link must be resent. Allowed values are sms and email.

Update Payment Link#

The endpoint to update the Payment Link is:

/invoices/:id

Path Parameter#

id mandatory
string The unique identifier of the Payment Link that needs to be updated.

Request Parameters#

You can update the following fields of an existing Payment Link using the Patch API:

partial_payment optional
boolean Set this to true to receive partial payments on the link.
receipt optional
string Add a unique receipt number to an existing link.
expire_by optional
integer Specify a UNIX timestamp for the expiry of the link.

Cancel Payment Link#

You can cancel a Payment Link with given ID using the following endpoint:

/invoices/:id/cancel

Path Parameter#

id mandatory
string The unique identifier of the Payment Link.

Note:
This method can only be called on a Payment Link that is in issued state.

Error Format#

Given on the side is the API response format in case of errors such as form validation error, bad request errors, etc.