# Refunds

## Create Refund

<mark style="color:green;">`POST`</mark> `https://api.lahza.io/refund`

Initiate a refund on your integration

#### Headers

| Name                                            | Type   | Description                     |
| ----------------------------------------------- | ------ | ------------------------------- |
| authorization<mark style="color:red;">\*</mark> | String | Set value to Bearer SECRET\_KEY |
| content-type<mark style="color:red;">\*</mark>  | String | Set value to application/json   |

#### Request Body

| Name                                          | Type   | Description                                                                                                                                                                                                                                           |
| --------------------------------------------- | ------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| transaction<mark style="color:red;">\*</mark> | String | Transaction reference or id                                                                                                                                                                                                                           |
| amount                                        | String | Amount ( in agora if currency is ILS, qirsh, if currency is JOD, and cents, if currency is USD ) to be refunded to the customer. Amount is optional(defaults to original transaction amount) and cannot be more than the original transaction amount. |
| currency                                      | String | Three-letter ISO currency. Allowed values are: ILS, JOD or USD                                                                                                                                                                                        |
| customer\_note                                | String | Customer reason                                                                                                                                                                                                                                       |
| merchant\_note                                | String | Merchant reason                                                                                                                                                                                                                                       |

{% tabs %}
{% tab title="200: OK " %}

```json
{
  "status": true,
  "message": "Refund has been queued for processing",
  "data": {
    "transaction": {
      "id": 1004723697,
      "domain": "live",
      "reference": "T685312322670591",
      "amount": 10000,
      "paid_at": "2021-08-20T18:34:11.000Z",
      "channel": "card",
      "currency": "ILS",
      "authorization": {
        "exp_month": null,
        "exp_year": null,
        "account_name": null
      },
      "customer": {
        "international_format_phone": null
      },
      "plan": {},
      "subaccount": {
        "currency": null
      },
      "split": {},
      "order_id": null,
      "paidAt": "2021-08-20T18:34:11.000Z",
      "pos_transaction_data": null,
      "source": null,
      "fees_breakdown": null
    },
    "integration": 412829,
    "deducted_amount": 0,
    "channel": null,
    "merchant_note": "Refund for transaction T685312322670591 by test@example.com",
    "customer_note": "Refund for transaction T685312322670591",
    "status": "pending",
    "refunded_by": "test@example.com",
    "expected_at": "2021-12-16T09:21:17.016Z",
    "currency": "ILS",
    "domain": "live",
    "amount": 10000,
    "fully_deducted": false,
    "id": 3018284,
    "createdAt": "2021-12-07T09:21:17.122Z",
    "updatedAt": "2021-12-07T09:21:17.122Z"
  }
}
```

{% endtab %}
{% endtabs %}

## Fetch Refund

<mark style="color:blue;">`GET`</mark> `https://api.lahza.io/refund/:reference`

Get details of a refund on your integration<br>

#### Path Parameters

| Name                                        | Type   | Description                               |
| ------------------------------------------- | ------ | ----------------------------------------- |
| reference<mark style="color:red;">\*</mark> | String | Identifier for transaction to be refunded |

#### Headers

| Name                                            | Type   | Description                     |
| ----------------------------------------------- | ------ | ------------------------------- |
| authorization<mark style="color:red;">\*</mark> | String | Set value to Bearer SECRET\_KEY |

{% tabs %}
{% tab title="200: OK " %}

```json
{
  "status": true,
  "message": "Refund retrieved",
  "data": {
    "transaction": 1641,
    "domain": "live",
    "amount": 500000,
    "deducted_amount": 500000,
    "fully_deducted": true,
    "currency": "ILS",
    "channel": "card",
    "status": "processed",
    "refunded_by": "test@example.com",
    "refunded_at": "2023-11-18T10:54:47.000Z",
    "expected_at": "2023-11-22T21:10:59.000Z",
    "customer_note": "xxx",
    "merchant_note": "xxx",
    "id": 1,
    "createdAt": "2023-09-24T21:10:59.000Z",
    "updatedAt": "2023-11-18T11:59:56.000Z"
  }

```

{% endtab %}
{% endtabs %}

## List Refunds

<mark style="color:blue;">`GET`</mark> `https://api.lahza.io/refund`

List refunds available on your integration.

#### Query Parameters

| Name      | Type    | Description                                                                                          |
| --------- | ------- | ---------------------------------------------------------------------------------------------------- |
| reference | String  | Identifier for transaction to be refunded                                                            |
| currency  | String  | Three-letter ISO currency. Allowed values are: ILS, JOD or USD                                       |
| page      | integer | Specify exactly what refund you want to page. If not specify we use a default value of 1.            |
| perPage   | integer | Specify how many records you want to retrieve per page. If not specify we use a default value of 50. |
| to        | date    | A timestamp at which to stop listing refund e.g. 2016-09-21                                          |
| from      | date    | A timestamp from which to start listing refund e.g. 2016-09-21                                       |

#### Headers

| Name                                            | Type   | Description                     |
| ----------------------------------------------- | ------ | ------------------------------- |
| authorization<mark style="color:red;">\*</mark> | String | Set value to Bearer SECRET\_KEY |

{% tabs %}
{% tab title="200: OK " %}

```json
{
  "status": true,
  "message": "Refunds retrieved",
  "data": [
    {
      "id": 1,
      "domain": "live",
      "transaction": 1641,
      "dispute": 20,
      "amount": 500000,
      "deducted_amount": 500000,
      "currency": "ILS",
      "channel": "card",
      "fully_deducted": 1,
      "refunded_by": "customer@gmail.com",
      "refunded_at": "2023-06-15T16:32:19.000Z",
      "expected_at": "2023-03-28T10:49:57.000Z",
      "customer_note": "xxx",
      "merchant_note": "xxx",
      "created_at": "2023-03-21T10:49:57.000Z",
      "updated_at": "2023-06-21T08:41:37.000Z",
      "status": "processed"
    },
    {
      "id": 2,
      "domain": "test",
      "transaction": 323896,
      "amount": 500000,
      "deducted_amount": null,
      "currency": "ILS",
      "channel": "card",
      "fully_deducted": null,
      "refunded_by": "customer@gmail.com",
      "refunded_at": "2023-03-21T10:50:40.000Z",
      "expected_at": "2023-06-10T14:22:03.000Z",
      "customer_note": "xxx",
      "merchant_note": "xxx",
      "created_at": "2023-03-21T10:50:40.000Z",
      "updated_at": "2023-03-21T10:50:40.000Z",
      "status": "pending"
    }
  ]
}
```

{% endtab %}
{% endtabs %}
