# Refunds

This feature allows you to refund a single collection. You can refund transactions made via Bank Transfers and Cards for NGN and GHS currencies.<br>

{% hint style="info" %}
*We now support REFUNDS for Mobile Money transactions.*
{% endhint %}

### To Initiate Refunds for a transaction:

| Authorization | Set value to Bearer SECRET\_KEY |
| ------------- | ------------------------------- |
| Content-type  | Set value to `application/json` |

{% hint style="info" %}
The secret key can be gotten from the 'Settings' page on your Startbutton dashboard.
{% endhint %}

Post a request to the URL below, where the base URL is determined by the environment you are in.

<details>

<summary>BaseUrl</summary>

Sandbox/PROD : <https://api.startbutton.tech&#x20>;

</details>

{% tabs %}
{% tab title="Endpoint" %}
POST - `{{baseurl}}/transaction/refunds`
{% endtab %}
{% endtabs %}

You can initiate refunds for all your collection transactions made via `bank_transfer` or `transfer`

| Param                | Required? | Description                                                                                                                                                                                                         |
| -------------------- | --------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| transactionReference | Yes       | <p>This is the original transaction reference of the transaction you wish to refund. <br><br>This can be gotten from your collection Tab under the "<em>Transaction Ref</em>" column.</p>                           |
| reason               | optional  | This is to provide a reason for the refund.                                                                                                                                                                         |
| amount               | Yes       | <p>This is the amount you'd like to refund.<br><br>Note: Refunds can be partially or fully initiated. </p><p>This means that for a NGN2000 transaction, you can refund the whole sum or part of the entire sum.</p> |

{% hint style="info" %}
amount should be in fractional unit.
{% endhint %}

#### Sample code:

{% tabs %}
{% tab title="Required parameters" %}

```
{
  "transactionReference": "79xxxxxxxxx",
  "amount": 500
}
```

{% endtab %}

{% tab title="Optional parameters" %}

```
{
  "transactionReference": "79xxxxxxxxx",
  "reason":"Test refund",
  "amount": 500
}
```

{% endtab %}
{% endtabs %}

{% hint style="info" %}

1. The amount is not required to be in fractional units.
2. The original transaction reference can be obtained from the dashboard transaction detail or the Webhook notification.
3. Your available balance must be sufficient to cater to the refund being initiated.
4. A fee is attached to any processed refund.
   {% endhint %}

#### Sample responses:

{% tabs %}
{% tab title="Success" %}

```
{
    "success": true,
    "message": "Refund initiated successfully!"
}
```

{% endtab %}

{% tab title="Bank not found" %}

```
{
    "success": false,
    "message": {
        "reason": "Bank account to send refund not found!",
        "type": "BANK_ACCOUNT"
    },
    "data": 400
}
```

{% endtab %}

{% tab title="Refund amount error" %}

```
{
    "success": false,
    "message": "Refund amount is greater than the transaction amount!",
    "data": 400
}
```

{% endtab %}

{% tab title="Insufficient available bal" %}

```
{
    "success": false,
    "message": "User has insufficient balance.",
    "data": 400
}
```

{% endtab %}
{% endtabs %}

{% hint style="info" %}
When a refund is processed, you receive an email- informing you if the refund was `successful`or`failed`.
{% endhint %}
