# Webhook

1. All `collection` and `disbursement` transactions notification updates will be sent as **`POST`** to the URL set as the `webhook url` under your merchant account API tokens.<br>
2. Only, `https` URLs can be set or notified.<br>
3. You will need to acknowledge receipt of the notification by responding with the HTTP status code **`200`**. Otherwise, we might keep calling your webhook URL at an interval of 10 minutes for 2 days.<br>
4. To ensure that the notification data sent to your `webhook URL` comes from our servers, set a `webhook hash` under the `Api Tokens`.<br>
5. We will include a header called, `webhook-hash` in the request sent to the `webhook URL`. e.g **webhook-hash: WH-\*\*\*"**

{% hint style="info" %}
You should verify the `webhook-hash` we sent matches what was set under your merchant account before giving service to your customer
{% endhint %}

#### **Responding to webhooks**

We will stop sending notification to your webhook URL if it responds with the following “HTTP status codes” below;

| Code  | Description             |
| ----- | ----------------------- |
| `200` | - OK                    |
| `400` | - Bad Request           |
| `401` | - Unauthorised          |
| `403` | - Forbidden             |
| `422` | - Unprocessable entity. |

**Rejecting webhook notification**

In a scenario where the transaction cannot be processed respond with HTTP codes below;

| Code  | Description                                                                                                                                      |
| ----- | ------------------------------------------------------------------------------------------------------------------------------------------------ |
| `400` | <p>- Bad Request.<br>- e.g when there’s a missing parameter</p>                                                                                  |
| `422` | <p>- Unprocessable entity.<br>- e.g when the request is fine but you cannot complete it because the amount does not match what you expected.</p> |

{% hint style="danger" %}
**KEYNOTE**

Always verify the, **`amount`** to make sure it matches what is meant to be **`paid`** before giving service to the customer.
{% endhint %}

```javascript
{
    "id": "383737927636356536773773",
    "request_amount": 0.4,
    "request_currency": "USD",
    "account_amount": 1462.53,
    "account_currency": "UGX",
    "transaction_fee": 42.23,
    "total_credit": 1420.30,
    "customer_charged": false,
    "merchant_reference": "88736jh-kkas87-mmn736-9n873ms-6636h",
    "paytota_reference": "PT-KMSSD-30000",
    "transaction_status": "COMPLETED",
    "transaction_type": "collection",
    "message": "Transaction Completed Successfully",
    "account_number": "Optional - 256777111222",
    "account_name": "Optional",
    "institution_name": "Optional - MTN Mobile Money Uganda"
}
```
