# Refund

**POST** `https://api.heleket.com/v1/payment/refund`

Refunds are made using the payout API key. The sign header of the request must be generated using your payout API key. [How to get the payout API key](https://doc.heleket.com/methods/payouts/getting-started.md)

## Request

### Body parameters

| Name | Parameter type | Default value | Definition |
| --- | --- | --- | --- |
| address (required) | string |  | The address to which the refund should be made |
| is\_subtract (required) | boolean |  | Whether to take a commission from the merchant's balance or from the refund amount<br>**true** - take the commission from merchant balance<br>**false** - reduce the refundable amount by the commission amount|
| uuid (required) | uuid<br>required\_without: order\_id|  | Invoice uuid |
| order\_id (required) | string<br>min:1<br>max:128<br>alpha\_dash<br>required\_without: uuid|  | Invoice order ID |
| amount | string<br>max:40<br>null| null | Refund amount |

> Invoice is identified by **order\_id** or **uuid**, if you pass both, the account will be identified by uuid

### Request example

```
curl https://api.heleket.com/v1/payment/refund \
-X POST \
-H 'merchant: 8b03432e-385b-4670-8d06-064591096795' \
-H 'sign: fe99035f86fa436181717b302b95bacff1' \
-H 'Content-Type: application/json' \
-d '{
"uuid": "8b03432e-385b-4670-8d06-064591096795",
"address": "TDD97yguPESTpcrJMqU6h2ozZbibv4Vaqm",
"is_subtract": "true"
}'
```

## Response

### Response example

```
{
  "state": 0,
  "result": []
}
```

## Possible errors

### Validation errors

code : 422

example responses:

If the invoice with the uuid or order\_id you provided doesn’t exist:

```
{
    "state": 1,
    "message": "Payment was not found"
}
```

If you will not pass a _uuid_ and _order\_id_, you will receive this message. It means that at least one of the parameters is required.

```
{
	"state": 1,
	"errors": {
		"uuid": ["validation.required_without"],
		"order_id": ["validation.required_without"]
	}
}
```

If payouts are blocked on your merchant, you will receive this error message. This happens, for example, when you change your password and payouts are blocked for 24 hours.

```
{
    "state": 1,
    "message": "You are forbidden"
}
```

If merchant wallet that is connected to an invoice does not exist:

```
{
    "state": 1,
    "message": "Undefined merchant wallet"
}
```

If the invoice is not finalized or not paid.

```
{
    "state": 1,
    "message": "Refunds are made only for completed payments"
}
```

If the amount to be refunded exceeds the amount of the invoice payment:

```
{
    "state": 1,
    "message": "The refund amount should not be more than the amount paid"
}
```

If technical work occurs and the payment is temporarily unavailable, you can receive this error message:

```
{
    "state": 1,
    "message": "Server error"
}
```
