Upgraded docs version is here ✨

Your documentation experience is getting an upgrade. Check it out now!

Go To Beta

Docs upgrade is here. Check it out!

Go To Beta
API ReferenceIntegrationsKnowledge Base

Sample Code

Handy Tips

  • Amount must always be in currency subunits.
  • Time represented as Unix timestamp, which can be obtained using the Utils.ToUnixTimestamp method.

Partner AuthenticationπŸ”—

If you are a partner and want to use the API as a particular merchant, you must authenticate your account by passing an additional header X-Razorpay-Account with the merchant account_id as the value.

Example:

Copyvar instance = new Razorpay({ key_id: '', key_secret: '', headers: { "X-Razorpay-Account": "" } }); instance.orders.all().then(console.log).catch(console.error);

OrdersπŸ”—

Note:
Click here for request parameters and an example request and response.

Create an OrderπŸ”—

Copyinstance.orders.create({ amount: 50000, currency: "INR", receipt: "receipt#1", notes: { key1: "value3", key2: "value2" } })

Fetch Order by IDπŸ”—

Copyinstance.orders.fetch(orderId)

Fetch Payment for an OrderπŸ”—

Copyinstance.orders.fetchPayments(orderId)

Fetch all OrdersπŸ”—

Copyinstance.orders.all(option)

Update OrderπŸ”—

Copyinstance.orders.edit({ "notes": { "key1": "value3", "key2": "value2" } })

PaymentsπŸ”—

Note:
Click here for request parameters and an example request and response.

Capture a PaymentπŸ”—

Copyinstance.payments.capture(paymentId, amount, currency)

Fetch Payment by IDπŸ”—

Copyinstance.payments.fetch(paymentId)

Fetch all PaymentsπŸ”—

Copyinstance.payments.all(option)

Fetch Payments for an OrderπŸ”—

Copyinstance.orders.fetchPayments(orderId)

Update a PaymentπŸ”—

Copyinstance.payments.edit(paymentId,{ "notes": { "key1": "value1", "key2": "value2" } })

Fetch Expanded Card or EMI Details for PaymentsπŸ”—

Copyinstance.payments.all({'expand[]':'card'})
Copyinstance.payments.all({'expand[]':'emi'})

Fetch Card Details with Payment IDπŸ”—

Copyinstance.payments.fetchCardDetails(paymentId)

Fetch Payment Downtime DetailsπŸ”—

Copyinstance.payments.fetchPaymentDowntime()

Fetch Payment DowntimeπŸ”—

Copyinstance.payments.fetchPaymentDowntimeById(downtimeId)

RefundsπŸ”—

Note:
Click here for request parameters and an example request and response.

Create a RefundπŸ”—

Copyinstance.payments.refund(paymentId,{ "amount": "100", "speed": "normal", "notes": { "notes_key_1": "Beam me up Scotty.", "notes_key_2": "Engage" }, "receipt": "Receipt No. 31" })

Fetch Refund by IDπŸ”—

Copyinstance.refunds.fetch(refundId)

Fetch all RefundsπŸ”—

Copyinstance.refunds.all(options)

Create an instant refundπŸ”—

Copyinstance.payments.refund(paymentId,{ "amount": "100", "speed": "optimum", "receipt": "Receipt No. 31" })

Fetch multiple refunds for a paymentπŸ”—

Copyinstance.payments.fetchMultipleRefund(paymentId,option)

Fetch a specific refund for a paymentπŸ”—

Copyinstance.payments.fetch(paymentId,refundId)

Update the refundπŸ”—

Copyinstance.refunds.edit({ "notes": { "notes_key_1": "Beam me up Scotty.", "notes_key_2": "Engage" } })

Note:
If payment_id is passed, refunds related to the payment are fetched.

CustomersπŸ”—

Note:
Click here for request parameters and an example request and response.

Create a CustomerπŸ”—

Copyinstance.customer.create({ name: "Gaurav Kumar", contact: 9123456780, email: "gaurav.kumar@example.com", fail_existing: 0, gstin: "29XAbbA4369J1PA", notes: { notes_key_1: "Tea, Earl Grey, Hot", notes_key_2: "Tea, Earl Grey… decaf." } })

Edit Customer DetailsπŸ”—

Copyinstance.customers.edit(customerId,{ name: "Gaurav Kumar", email: "Gaurav.Kumar@example.com", contact: 9000000000 })

Fetch Customer by IDπŸ”—

Copyinstance.customers.fetch(customerId)

Fetch all CustomersπŸ”—

Copyinstance.customers.all(options)

SubscriptionsπŸ”—

Note:
Click here for request parameters and an example request and response.

Create a SubscriptionπŸ”—

Copyinstance.subscriptions.create({ plan_id: "plan_7wAosPWtrkhqZw", customer_notify: 1, quantity: 5, total_count: 6, start_at: 1495995837, addons: [ { item: { name: "Delivery charges", amount: 30000, currency: "INR" } } ], notes: { key1: "value3", key2: "value2" } })
Copyinstance.subscriptions.create({ plan_id: "plan_HoYg68p5kmuvzD", total_count: 12, quantity: 1, expire_by: 1633237807, customer_notify: 1, addons: [ { item: { name: "Delivery charges", amount: 30000, currency: "INR" } } ], notes: { notes_key_1: "Tea, Earl Grey, Hot", notes_key_2: "Tea, Earl Grey… decaf." }, notify_info: { notify_phone: 9123456789, notify_email: "gaurav.kumar@example.com" } })

Fetch Subscription by IDπŸ”—

Copyinstance.subscriptions.fetch(subscriptionId)

Fetch all SubscriptionsπŸ”—

Copyinstance.subscriptions.all(options)

Cancel a SubscriptionπŸ”—

Copyinstance.subscriptions.cancel(subscriptionId,options)

Update a SubscriptionπŸ”—

Copyinstance.subscriptions.update(subscriptionId,options)

Fetch Details of a Pending UpdateπŸ”—

Copyinstance.subscriptions.pendingUpdate(subscriptionId)

Cancel an UpdateπŸ”—

Copyinstance.subscriptions.cancelScheduledChanges(subscriptionId)

Pause a SubscriptionπŸ”—

Copyinstance.subscriptions.pause(subscriptionId,{ pause_at : 'now' })

Resume a SubscriptionπŸ”—

Copyinstance.subscriptions.resume(subscriptionId,{ resume_at : 'now' })

Fetch All Invoices for a SubscriptionπŸ”—

Copyinstance.invoices.all({ 'subscription_id':subscriptionId })

Payment VerificationπŸ”—

Copyinstance.payments.paymentVerification({ 'subscription_id':'sub_ID6MOhgkcoHj9I', 'payment_id':'pay_IDZNwZZFtnjyym', 'signature':'601f383334975c714c91a7d97dd723eb56520318355863dcf3821c0d07a17693' },secret)

Create a PlanπŸ”—

Copyinstance.plans.create(params)

Fetch Plan by IDπŸ”—

Copyinstance.plans.fetch(planId)

Fetch all PlansπŸ”—

Copyinstance.plans.all(params)

Create an Add-onπŸ”—

Copyinstance.subscriptions.createAddon(subscriptionId, params)

Fetch Add-on by IDπŸ”—

Copyinstance.addons.fetch(addonId)

Delete an Add-onπŸ”—

Copyinstance.addons.delete(addonId)

Payment LinksπŸ”—

Note:
Click here for request parameters and an example request and response.

Copyinstance.paymentLink.create({ amount: 500, currency: "INR", accept_partial: true, first_min_partial_amount: 100, description: "For XYZ purpose", customer: { name: "Gaurav Kumar", email: "gaurav.kumar@example.com", contact: 919999999999 }, notify: { sms: true, email: true }, reminder_enable: true, notes: { policy_name: "Jeevan Bima" }, callback_url: "https://example-callback-url.com/", callback_method: "get" })
Copyinstance.paymentLink.create({ upi_link: true, amount: 500, currency: "INR", accept_partial: true, first_min_partial_amount: 100, description: "For XYZ purpose", customer: { name: "Gaurav Kumar", email: "gaurav.kumar@example.com", contact: 919999999999 }, notify: { sms: true, email: true }, reminder_enable: true, notes: { policy_name: "Jeevan Bima" } })
Copyinstance.paymentLink.all()
Copyinstance.paymentLink.fetch(paymentLinkId)
Copyinstance.paymentLink.edit({ "reference_id": "TS35", "expire_by": 1653347540, "reminder_enable":false, "notes":{ "policy_name": "Jeevan Saral" } })
Copyinstance.paymentLink.cancel(paymentLinkId)

Send/Resend NotificationπŸ”—

Copyinstance.paymentLink.notifyBy(paymentLinkId, medium)

InvoicesπŸ”—

Handy Tips
Click here for request parameters and an example request and response.

Create an InvoiceπŸ”—

Copyinstance.invoices.create({ type: "invoice", date: 1589994898, customer_id: "cust_E7q0trFqXgExmT", line_items: [ { "item_id": "item_DRt61i2NnL8oy6" } ] })

Update InvoiceπŸ”—

Copyinstance.invoices.edit(invoiceId,{ line_items: [ { id: "li_DAweOizsysoJU6", name: "Book / English August - Updated name and quantity", quantity: 1 }, { name: "Book / A Wild Sheep Chase", amount: 200, currency: "INR", quantity: 1 } ], notes: { "updated-key": "An updated note." } })

Issue an InvoiceπŸ”—

Copyinstance.invoices.issue(invoiceId)

Fetch Invoice by IDπŸ”—

Copyinstance.invoices.fetch(invoiceId)

Fetch all InvoicesπŸ”—

Copyinstance.invoices.all()

Cancel an InvoiceπŸ”—

Copyinstance.invoices.cancel(invoiceId)

Send/Resend NotificationπŸ”—

Copyinstance.invoices.notifyBy(invoiceId,medium)

Delete an InvoiceπŸ”—

Copyinstance.invoices.delete(invoiceId)

Smart CollectπŸ”—

Note:
Click here for request parameters and an example request and response.

Create a Virtual AccountπŸ”—

Copyinstance.virtualAccounts.create({ receivers: { types: [ "bank_account" ] }, description: "Virtual Account created for Raftar Soft", customer_id: "cust_CaVDm8eDRSXYME", close_by: 1681615838, notes: { project_name: "Banking Software" } })

Fetch Virtual Account by IDπŸ”—

Copyinstance.virtualAccounts.fetch(virtualId)

Fetch all Virtual AccountsπŸ”—

Copyinstance.virtualAccounts.all(options)

Fetch Payment for a Virtual AccountπŸ”—

Copyinstance.virtualAccounts.fetchPayments(virtualId,options)

Note:
To get more information about the payment, use the payments.bankTransfer API.

Fetch Payment Details using ID and Transfer MethodπŸ”—

Copyinstance.payments.bankTransfer(paymentId)

Refund Payments made to a Virtual AccountπŸ”—

Copyinstance.payments.refund(paymentId,{ "amount": "100", "speed": "normal", "notes": { "notes_key_1": "Beam me up Scotty.", "notes_key_2": "Engage" }, "receipt": "Receipt No. 31" })

Add receiver to an existing virtual accountπŸ”—

Copyinstance.virtualAccounts.addReceiver(virtualId,{ types: [ "vpa" ], vpa: { descriptor: "gauravkumar" } })

Close a Virtual AccountπŸ”—

Copyinstance.virtualAccounts.close(virtualId)

RouteπŸ”—

Note:
Click here for request parameters and an example request and response.

Create a Direct TransferπŸ”—

Copyinstance.transfers.create({ "amount": 500, "currency": "INR" })

Create Transfers from PaymentsπŸ”—

Copyinstance.payments.transfer(paymentId,{ "transfers": [ { "account": 'acc_HgzcrXeSLfNP9U', "amount": 100, "currency": "INR", "notes": { "name": "Gaurav Kumar", "roll_no": "IEC2011025" }, "linked_account_notes": [ "branch" ], "on_hold": 1, "on_hold_until": 1671222870 } ] })

Create Transfers from OrdersπŸ”—

Copyinstance.orders.create({ amount: 2000, currency: "INR", transfers: [ { account: "acc_CPRsN1LkFccllA", amount: 1000, currency: "INR", notes: { branch: "Acme Corp Bangalore North", name: "Gaurav Kumar" }, linked_account_notes: [ "branch" ], on_hold: 1, on_hold_until: 1671222870 }, { account: "acc_CNo3jSI8OkFJJJ", amount: 1000, currency: "INR", notes: { branch: "Acme Corp Bangalore South", name: "Saurav Kumar" }, linked_account_notes: [ "branch" ], on_hold: 0 } ] })

Fetch Transfers for a PaymentπŸ”—

Copyinstance.payment.fetchTransfer(paymentId)

Fetch Transfers for an OrderπŸ”—

Copyinstance.orders.transfers({ "expand[]": "transfers" })

Fetch Transfer by IDπŸ”—

Copyinstance.transfers.fetch(transferId)

Fetch Transfers for a SettlementπŸ”—

Copyinstance.transfers.all({ recipient_settlement_id : recipientSettlementId })

Fetch Settlement DetailsπŸ”—

Copyinstance.transfers.all({ expand[] = 'recipient_settlement' })

Fetch Payments of a Linked AccountπŸ”—

Copyinstance.payments.all({ 'X-Razorpay-Account': linkedAccountId })

Refund Payments and Reverse Transfer from a Linked AccountπŸ”—

Copyinstance.payments.refund(paymentId,{ amount : 100, reverse_all : 1 })

Reverse Transfers from all Linked AccountsπŸ”—

Copyinstance.transfers.reverse(transferId,{ amount:100 })

Hold Settlements for TransfersπŸ”—

Copyinstance.payments.transfer(paymentId,{ "amount": 500, "currency": "INR", "on_hold": "1" })

Modify Settlement Hold for TransfersπŸ”—

Copyinstance.transfers.edit(paymentId,{ "on_hold": "1", "on_hold_until": "1679691505" })

SettlementsπŸ”—

Note:
Click here for request parameters and an example request and response.

Fetch All SettlementsπŸ”—

Copyinstance.settlements.all(options)

Fetch a settlementπŸ”—

Copyinstance.settlements.fetch(settlementId)

Settlement reconπŸ”—

Copyinstance.settlements.settlementRecon({ year: 2020, month: 09, day:11 })

Create on-demand settlementπŸ”—

Copyinstance.settlements.createOndemandSettlement({ "amount": 1221, "settle_full_balance": false, "description": "Testing", "notes": { "notes_key_1": "Tea, Earl Grey, Hot", "notes_key_2": "Tea, Earl Grey… decaf." } })

Fetch all on-demand settlementsπŸ”—

Copyinstance.settlements.fetchAllOndemandSettlement(options)

Fetch on-demand settlement by IDπŸ”—

Copyinstance.settlements.fetchOndemandSettlementById(settlementId);
×