# Webhooks

## Setup your URL

Navigate to your shop and click on the cogwheel bottom left.\
Click on the developer tab.\
Type your "Webhook URL" and click setup.

## Automatic Retrying

We will continue to send webhook messages until we receive a 200 ok from the endpoint you've setup.\
Because of that we do recommend that you setup a check for duplicate transactions.

Each retry will be exponentially delayed depending on how many time the message failed, so we don't spam your servers.

## Verify Signature

In each request we add a "RDG\_WH\_SIGNATURE" variable. You can use your secret key (found in the developers tab), to verify the request is from us.

```php
<?php

define('SECRET_KEY', '123test');

$request= json_decode(file_get_contents("php://input"), true);

if (!check_signature($request)) {
    header("Status: 401 Unauthorized");
    exit;
}

function check_signature($request) {
    return $signature === hash_hmac(
        'sha256', 
        $request['order']['transaction_id'] . $request['status'],
        SECRET_KEY
    );
}
```

## Payment Statuses

| Name                | Description                                                              |
| ------------------- | ------------------------------------------------------------------------ |
| completed           | The payment is fully completed.                                          |
| waiting for payment | The order is currently waiting for the customer to pay.                  |
| refunded            | The order was refunded.                                                  |
| disputed            | The order has an open dispute.                                           |
| dispute canceled    | The dispute was canceled / won, it will also change to completed status. |
| reversed            | The dispute was lost, the money has been returned to the customer.       |

{% hint style="info" %}
To see the payload the different statuses will send in the webhook, go to the next step below.
{% endhint %}
