Create Refund API


Create a Refund

The following endpoint creates an Refund:

/refunds

Request parameters

Following are the parameters to be sent in the request body:

Fieldis required?DescriptionExample
ref_idmandatorystring The refund reference id"ref_reference_123"
customer_idmandatorystring The customer id"cust_0912jas123"
payment_idmandatorystring The payment it that what to make a refund"pay_ttqs62k99s"
amountmandatorystringThe refund amount requested
notesoptionalstring The refund note"rejected product"

Example

curl -X POST \
  https://api.durianpay.id/v1/refunds \
  -H 'authorization: [Base64({Your_Server_Key}:)]' \
  -H 'content-type: application/json' \
  -d '{
    "ref_id": "abc",
    "customer_id": "cus_tZwN2O3tl04389",
    "payment_id": "pay_IsL5nOCW4M2790",
    "amount": "1500",
    "notes": "rejected product"
}'

Response Code : 200

Here is an example of success response

{
  "data": {
    "id": "rfn_qfrsL0tlnT0308",
    "ref_id": "reference_1",
    "amount": "20000.00",
    "refund_type": "partial",
    "status": "approved",
    "created_at": "2021-07-20T10:43:42.201587Z",
    "updated_at": "2021-07-20T10:43:42.401256Z",
    "approved_at": "2021-07-20T10:43:42.401256Z",
    "source": "api",
    "customer_id": "cus_9eGU1Iwxeb8004",
    "customer_name": "joe",
    "customer_email": "jade@sfs.com",
    "customer_phone": ""
  }
}

Error Response Code : 400

Here is an example error response for invalid request

{
    "error": "error reading request body",
    "error_code": "DPAY_INTERNAL_ERROR",
}

Error Response Code : 401

Here is an example error response for unauthorized access

{
    "error": "invalid Authorization header in request",
    "error_code": "DPAY_UNAUTHORIZED_ACCESS"
}

Error Response Code : 403

Here is an example error response for invalid request

{
    "error": "refund amount exceed",
    "error_code": "DPAY_REFUND_AMOUNT_EXCEEDED"
}

Error Response Code : 500

Here is an example error response for internal server error

{
    "error": "error creating refund",
    "error_code": "DPAY_INTERNAL_ERROR"
}