Create a refund for payment.

The response of refund initiation is similar to that of order status API Response with the addition of refund block.
The fields and description in refund block is given below

unique_request_idThe unique request id that is passed during refund initiation
statusThe status of the refund initiated. Initial status will always be PENDING
sent_to_gatewayThe flag denotes if the refund was initiated to gateway. The initial status is always false, as refunds are queued at juspay for a max of 15minutes.
refund_typeThe type of refund. Values can be STANDARD, INSTANT
refund_sourceThe name of gateway
refThe refund id provided by the PG
initiated_byThe source of initiation.
idThe reference id provided by PG, if not available then its mapped to unique request id.
error_messageThe error message provided by the PG
error_codeThe error code provided by the PG
createdThe timestamp of refund creation
amountThe refund amount passed in the request

Refund API failure with response code

ConditionResponseResponse code
Duplicate unique_request_id{
"status_id": -1,
"status": "ERROR",
"error_message": "A refund call was already completed with this unique_request_id for the order.",
"error_code": ""
Refund amount greater than refundable{
"status_id": -1,
"status": "ERROR",
"error_message": "Refund amount exceeds the refundable amount.",
"error_code": "invalid.amount.exceeded"
Amount/unique_request_id not passed{
"status": "Bad Request",
"error_message": "Mandatory fields are missing",
"error_code": "Mandatory fields are missing"
Refund Amount is 0{
"status_id": -1,
"status": "ERROR",
"error_message": "Amount is invalid.",
"error_code": "invalid amount"
Invalid Order id{ “status_id”: 40, “status”: “NOT_FOUND”, “order_id”: “TEST1r32766” }400
Unsuccessful order{
"status_id": -1,
"status": "ERROR",
"error_message": "Cannot process unsuccessful order.",
"error_code": "invalid.order.not_successful"
Invalid Authentication{
"status": "error",
"error_code": "access_denied"
Click Try It! to start a request and see the response here!