#Razorpay APIs

Number of APIs: 196

Razorpay is an Indian payments solution provider that allows businesses to accept, process and disburse payments with its product suite. Razorpay APIs are completely RESTful and all our responses are returned in JSON.

API Authentication

All Razorpay APIs are authenticated using Basic Auth . Basic auth requires the following:

  • [YOUR KEY ID]
  • [YOUR KEY SECRET]

Basic auth expects an Authorization header for each request in the Basic base64token format. Here, base64token is a base64 encoded string of YOUR KEY ID:YOUR KEY SECRET.

Watch Out!

The Authorization header value should strictly adhere to the format mentioned above. Invalid formats will result in authentication failures. Few examples of invalid headers are:

  • BASIC base64token
  • basic base64token
  • Basic "base64token"
  • Basic $base64token

Generate API Key

You can use Razorpay APIs in two modes, Test and Live. The API key is different for each mode.

To generate the API keys: 1. Log into the Razorpay Dashboard . 2. Select the mode (Test or Live) for which you want to generate the API key.
- Test Mode: The test mode is a simulation mode that you can use to test your integration flow. Your customers will not be able to make payments in this mode.
- Live Mode: When your integration is complete, in the Dashboard, switch to the live mode and generate live mode API keys. Replace test mode keys with live mode keys in the integration to accept payments from customers. 3. Navigate to Settings → API Keys → Generate Key to generate key for the selected mode.

Errors

All successful responses are returned with HTTP Status code 204. In case of failure, API returns a JSON error response with the parameters that contain the failure reason.

Understanding Error Response

The error response contains code , description , field , source , step , and reason parameters to understand and troubleshoot the error.

Let us take an example where a merchant tries to add new allowed payer accounts when the overall limit is exceeded.

json: Sample Error Response { "error": { "code": "BAD_REQUEST_ERROR", "description": "Authentication failed due to incorrect otp", "field": null, "source": "customer", "step": "payment_authentication", "reason": "invalid_otp", "metadata": { "payment_id": "pay_EDNBKIP31Y4jl8", "order_id": "order_DBJKIP31Y4jl8" } } }

Response Parameters

error

: object The error object.

code

: string Type of the error.

description

: string Description of the error.

field

: string Name of the parameter in the API request that caused the error.

source

: string The point of failure in the specific operation (payment in this case). For example, customer, business

step

: string The stage where the transaction failure occurred. The stages can vary depending on the payment method used to complete the transaction.

reason

: string The exact error reason. It can be handled programmatically.

metadata

: object Contains additional information about the request.


`payment_id`
: `string` Unique identifier of the payment.

`order_id`
: `string` Unique identifier of the order associated with the payment.



Know more about Error Codes .

  1. Customers APIs - Create a Customer POST https://api.razorpay.com/v1/customers

  2. Customers APIs - Fetch all Customers GET https://api.razorpay.com/v1/customers

  3. Customers APIs - Fetch Customer by ID GET https://api.razorpay.com/v1/customers/{cust_id}

  4. Customers APIs - Edit a Customer PUT https://api.razorpay.com/v1/customers/{cust_id}

  5. Orders APIs - Create an Order POST https://api.razorpay.com/v1/orders

  6. Orders APIs - Fetch Orders (With Expanded Card Payments) GET https://api.razorpay.com/v1/orders?expand[]=payments.card

  7. Orders APIs - Fetch Orders by ID GET https://api.razorpay.com/v1/orders/{order_id}

  8. Orders APIs - Fetch Payments by Order GET https://api.razorpay.com/v1/orders/{order_id}/payments

  9. Orders APIs - Update Order PATCH https://api.razorpay.com/v1/orders/{order_id}

  10. Payments APIs-Payment Downtime API - Fetch Payment Downtime Details GET https://api.razorpay.com/v1/payments/downtimes