API Test Keys

Refund Payments and Reverse Transfer from a Linked Account

POST
/v1/payments/:id/refund

Click to copy

Use this endpoint to create refunds on a particular payment_id.

  • The amount is deducted from your main account balance when refunding a payment. You can set the reverse_all parameter to 1 in the refund POST request to recover the amount from the Linked Account. This will recover the amount for every transfer made on the payment before processing the refund to the customer.

  • You can automate reversals with the reverse_all parameter in the following refund scenarios:

    • Full refund
    • Partial refund for a payment transferred to a single account.

Watch Out!

For partial refunds on a payment transferred to multiple accounts, the reverse_all parameter cannot be applied since Curlec cannot determine which transfer to reverse partially. You will have to use the transfer reversal API to reverse this payment.

A new reversal entity is created internally and linked for every reversal defined by the transfer_id.

Is this page helpful?

Curl

change language

change language

1
curl -X POST https://api.razorpay.com/v1/payments/pay_JJCqynf4fQS0N1/refund \
2
-u [YOUR_KEY_ID]:[YOUR_KEY_SECRET]
3
-H 'content-type: application/json'
4
-d '{
5
"amount": 100,
6
"reverse_all": 1
7
}'

Success

Failure

1
{
2
"id": "rfnd_JJFNlNXPHY640A",
3
"entity": "refund",
4
"amount": 100,
5
"currency": "MYR",
6
"payment_id": "pay_JJCqynf4fQS0N1",
7
"notes": [],
8
"receipt": null,
9
"acquirer_data": {
10
"arn": null
11
},
12
"created_at": 1649941680,
13
"batch_id": null,
14
"status": "processed",
15
"speed_processed": "normal",
16
"speed_requested": "normal"
17
}
Path Parameters
id

*

string

A unique identifier of the payment that should be refunded.

Request Parameters
amount

*

string

The amount of refund in the smallest unit of currency. For example, for an amount of RM200.35, the value of this field should be 20035.

reverse_all
boolean

Reverses transfer made to a linked account. Possible values:

  • 1: Reverses transfer made to a linked account.
  • 0: Does not reverse transfer made to a linked account.

Response Parameters
id
string

Unique identifier of the refund.

entity
string

Indicates the type of entity. Here, it is refund.

amount
integer

The amount of refund in the smallest unit of currency. For example, for an amount of RM200.35, the value of this field should be 20035.

currency
string

The currency of refund. Currently, only MYR is supported.

payment_id
string

Unique identifier of the payment for which this refund has been requested.

created_at
integer

Timestamp, in Unix, of refund creation.

notes
json object

Set of key-value pairs that can be associated with an entity. These pairs can be useful for storing additional information about the entity. A maximum of 15 key-value pairs, each of 256 characters (maximum), are supported.

receipt
string

Unique identifier that you can use for internal reference.

acquirer_data
array

A dynamic array consisting of a unique reference number that is provided by the banking partner when a refund is processed. This reference number can be used by the customer to track the status of the refund with the bank.

Errors

The api key/secret provided is invalid

Error Status: 4xx

This error occurs when there is a mismatch between the API credentials passed in the API call and the API credentials generated on the dashboard.

Solution

The sum of amount requested for refund is greater than the available amount

Error Status: 400

This error occurs when the total transferred amount exceeds the payment amount.

Solution

The amount must be atleast MYR 1.00

Error Status: 400

This error occurs when the amount is less than the minimum amount. The transaction amount expressed in the currency subunit, such as sen (in MYR) should always be greater than or equal to RM1.

Solution

payment_id is not a valid id

Error Status: 400

This error occurs when you pass an invalid payment_id in the API endpoint.

Solution

Refund Payments and Reverse Transfer from a Linked Account

POST
/v1/payments/:id/refund

Click to copy

Use this endpoint to create refunds on a particular payment_id.

  • The amount is deducted from your main account balance when refunding a payment. You can set the reverse_all parameter to 1 in the refund POST request to recover the amount from the Linked Account. This will recover the amount for every transfer made on the payment before processing the refund to the customer.

  • You can automate reversals with the reverse_all parameter in the following refund scenarios:

    • Full refund
    • Partial refund for a payment transferred to a single account.

Watch Out!

For partial refunds on a payment transferred to multiple accounts, the reverse_all parameter cannot be applied since Curlec cannot determine which transfer to reverse partially. You will have to use the transfer reversal API to reverse this payment.

A new reversal entity is created internally and linked for every reversal defined by the transfer_id.

Is this page helpful?

Path Parameters
id

*

string

A unique identifier of the payment that should be refunded.

Request Parameters
amount

*

string

The amount of refund in the smallest unit of currency. For example, for an amount of RM200.35, the value of this field should be 20035.

reverse_all
boolean

Reverses transfer made to a linked account. Possible values:

  • 1: Reverses transfer made to a linked account.
  • 0: Does not reverse transfer made to a linked account.

Response Parameters
id
string

Unique identifier of the refund.

entity
string

Indicates the type of entity. Here, it is refund.

amount
integer

The amount of refund in the smallest unit of currency. For example, for an amount of RM200.35, the value of this field should be 20035.

currency
string

The currency of refund. Currently, only MYR is supported.

payment_id
string

Unique identifier of the payment for which this refund has been requested.

created_at
integer

Timestamp, in Unix, of refund creation.

notes
json object

Set of key-value pairs that can be associated with an entity. These pairs can be useful for storing additional information about the entity. A maximum of 15 key-value pairs, each of 256 characters (maximum), are supported.

receipt
string

Unique identifier that you can use for internal reference.

acquirer_data
array

A dynamic array consisting of a unique reference number that is provided by the banking partner when a refund is processed. This reference number can be used by the customer to track the status of the refund with the bank.

Errors

The api key/secret provided is invalid

Error Status: 4xx

This error occurs when there is a mismatch between the API credentials passed in the API call and the API credentials generated on the dashboard.

Solution

The sum of amount requested for refund is greater than the available amount

Error Status: 400

This error occurs when the total transferred amount exceeds the payment amount.

Solution

The amount must be atleast MYR 1.00

Error Status: 400

This error occurs when the amount is less than the minimum amount. The transaction amount expressed in the currency subunit, such as sen (in MYR) should always be greater than or equal to RM1.

Solution

payment_id is not a valid id

Error Status: 400

This error occurs when you pass an invalid payment_id in the API endpoint.

Solution

Curl

change language

change language

1
curl -X POST https://api.razorpay.com/v1/payments/pay_JJCqynf4fQS0N1/refund \
2
-u [YOUR_KEY_ID]:[YOUR_KEY_SECRET]
3
-H 'content-type: application/json'
4
-d '{
5
"amount": 100,
6
"reverse_all": 1
7
}'

Success

Failure

1
{
2
"id": "rfnd_JJFNlNXPHY640A",
3
"entity": "refund",
4
"amount": 100,
5
"currency": "MYR",
6
"payment_id": "pay_JJCqynf4fQS0N1",
7
"notes": [],
8
"receipt": null,
9
"acquirer_data": {
10
"arn": null
11
},
12
"created_at": 1649941680,
13
"batch_id": null,
14
"status": "processed",
15
"speed_processed": "normal",
16
"speed_requested": "normal"
17
}