# 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 %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs-shop.rexdigital.group/getting-started/webhooks.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
