# Webhook {#webhook}

Webhook wysyła zdarzenie GAMEMONITORING do Twojego systemu po akcji na platformie. To zwykłe żądanie `POST` z body JSON, dzięki któremu strona, panel lub usługa gry może reagować automatycznie.

Jeśli konfigurujesz nagrody za głosy, najpierw podłącz Webhook według tej instrukcji, a potem użyj osobnego scenariusza: [Nagrody za głosy](https://gamemonitoring.pl/developers/docs/webhook/vote#flow).

## Podłączenie {#connect}

Ta konfiguracja łączy projekt GAMEMONITORING z handlerem i daje token podpisu do weryfikacji przychodzących żądań.

1. Otwórz [Moje projekty](https://gamemonitoring.pl/projects/my), utwórz projekt albo wybierz istniejący, a następnie przejdź do ustawień Webhook.
2. Utwórz publiczny endpoint HTTPS, który przyjmuje `POST` z `Content-Type: application/json` i nie przekierowuje żądań.
3. W ustawieniach Webhook wpisz pełny URL handlera, na przykład `https://panel.example.com/gamemonitoring-webhook`, i zapisz go.
4. Skopiuj token podpisu z tego samego bloku i wpisz go w skrypcie handlera.
5. W handlerze sprawdź `signature`, obsłuż potrzebne `event_type` i zwróć udaną odpowiedź `2xx` dopiero po przetworzeniu zdarzenia.

Do lokalnego testowania możesz uruchomić handler na swoim komputerze i wystawić go przez publiczny URL HTTPS. Użyj [ngrok](https://ngrok.com) albo innej usługi tunelowania, a wygenerowany publiczny URL wpisz w ustawieniach Webhook.

Po konfiguracji wyślij testowy Webhook z interfejsu i sprawdź status dostawy. Dla przykładowego URL serwer musi przyjmować `POST` na `/gamemonitoring-webhook`.

Jeśli test się nie uda, zacznij od odpowiedzi handlera: `401` oznacza błąd podpisu, `403` albo strona weryfikacyjna HTML zwykle wskazuje WAF lub bot protection, a timeout oznacza, że URL jest niedostępny z internetu albo odpowiada za wolno.

## Wymagania handlera {#handler-requirements}

- URL musi być dostępny z internetu. Lokalne adresy, sieci prywatne i URL z loginem lub hasłem nie są odpowiednie.
- HTTPS jest zalecany dla produkcji. HTTP jest obsługiwany, ale słabiej chroni dane w transmisji.
- Handler musi przyjmować metodę `POST` i body JSON bez przekierowań.
- Zwracaj `2xx` dopiero po przetworzeniu zdarzenia przez Twój system. Zwykle wystarczy `204 No Content`.
- Jeśli zdarzenia nie da się bezpiecznie przetworzyć, zwróć kod błędu. `3xx`, `4xx`, `5xx`, timeout i błąd połączenia są traktowane jako nieudana dostawa.
- Jeśli używasz firewalla, bot protection lub allowlist, dodaj [adresy IP GAMEMONITORING](https://gamemonitoring.pl/developers/docs/ips) do wyjątków.
- Nie zwracaj w treści odpowiedzi tokenów, stack trace, błędów SQL ani innych szczegółów wewnętrznych. Odpowiedź handlera jest widoczna w interfejsie, więc tekst błędu musi być bezpieczny i zrozumiały.

## Dane zdarzenia {#event-data}

Każdy Webhook przychodzi z body JSON i podstawowymi polami:

- `event_type` — jakie zdarzenie trzeba obsłużyć.
- `event_id` — unikalny ID zdarzenia. Użyj go razem z `event_type` do idempotencji i ochrony przed ponowną dostawą.
- `is_test` — oznacza testową dostawę z interfejsu.
- `signature` — podpis body zdarzenia.

**Przykład zdarzenia Webhook**

```json
{
  "event_id": "9824cabb-2203-437e-9b6c-aba43dde3e4b",
  "event_type": "example.event",
  "is_test": false,
  "signature": "0ac4c97a5d934599dbd78985c4bcbb6926e77b4809d2be56333b1b25f638f064"
}
```

Jak czytać przykład: `event_type` pokazuje, jakie zdarzenie trzeba obsłużyć; `event_id` jest potrzebne do idempotencji przed zmianą stanu; `is_test: true` oznacza techniczne sprawdzenie dostawy; `signature` nie jest daną biznesową i służy tylko do uwierzytelnienia żądania.

Logika przetwarzania zależy od `event_type`. Dla `server.vote` i `project.vote` użyj osobnego scenariusza: [Nagrody za głosy](https://gamemonitoring.pl/developers/docs/webhook/vote#flow).

Jeśli `is_test` ma wartość `true`, sprawdź podpis i zwróć `2xx`, ale nie zmieniaj salda, nie wydawaj przedmiotów i nie uruchamiaj operacji produkcyjnych.

## Przykład odpowiedzi handlera {#response-example}

Każde przychodzące zdarzenie zakończ jednym jasnym wynikiem:

- `204 No Content` — podpis jest poprawny, a zdarzenie zostało przetworzone albo bezpiecznie pominięte. Tę samą odpowiedź zwracaj dla testowej dostawy i dla zdarzenia już przetworzonego.
- `400 Bad Request` — brakuje wymaganych pól. To oznacza błąd handlera albo nieoczekiwane body żądania; nie uruchamiaj logiki biznesowej.
- `401 Unauthorized` — podpis jest nieprawidłowy. Nie wykonuj żądań API, nie zmieniaj bazy i nie wydawaj nagród.
- `500 Internal Server Error` — baza, kolejka lub wewnętrzny system jest tymczasowo niedostępny. Dostawa pozostanie nieudana i można ją ponowić po usunięciu przyczyny.

Przykład: jeśli handler odebrał zdarzenie, sprawdził podpis, zapisał `event_type` + `event_id` i przetworzył zdarzenie, może zwrócić `204`. Jeśli baza jest niedostępna i zdarzenia nie da się zapisać, lepiej zwrócić `500`, żeby dostawa nie została za wcześnie oznaczona jako udana.

## Weryfikacja podpisu {#signature}

Podpis znajduje się w polu `signature`. Sprawdzaj go przed logiką biznesową, żądaniami API i zmianami w bazie.

Do weryfikacji weź wszystkie pola body poza `signature`, posortuj klucze alfabetycznie i zbuduj ciąg `key=value` połączony przez `&`. Wartości boolean zapisuj jako `true` albo `false`.

**Ciąg do podpisu**

```text
event_id=9824cabb-2203-437e-9b6c-aba43dde3e4b&event_type=example.event&is_test=false
```

Dla przykładu powyżej ciąg podpisu buduje się tylko z `event_id`, `event_type` i `is_test`. Następnie oblicz `HMAC-SHA256` tokenem podpisu z ustawień Webhook i porównaj wynik z `signature` z żądania.

Gotowe podpisy w przykładach są policzone dla tokena demonstracyjnego `paste-webhook-token-here`. W swoim handlerze użyj tokena z ustawień Webhook.

W handlerze:

- zbuduj ciąg do podpisu z posortowanych kluczy;
- oblicz `HMAC-SHA256` tokenem podpisu;
- porównaj wynik z `signature` funkcją o stałym czasie porównania: `hash_equals` w PHP, `timingSafeEqual` w Node.js albo `compare_digest` w Pythonie;
- zwróć `401`, jeśli podpis jest nieprawidłowy.

## Krok 1. Podstawowy handler {#minimal-handler}

Zacznij od handlera, który przyjmuje dowolny Webhook: czyta JSON, sprawdza `signature`, obsługuje testową dostawę, sprawdza podstawowe pola i zwraca `204`. Na tym etapie handler tylko potwierdza, że dostawa jest przyjmowana poprawnie. Logikę konkretnego zdarzenia dodaj po tym, gdy ten podstawowy przepływ działa.

### PHP

```php
<?php
// Replace this token with the signing token from your GAMEMONITORING webhook settings.
$secret = 'paste-webhook-token-here';

// Read and decode the JSON body sent by GAMEMONITORING.
$event = json_decode(file_get_contents('php://input'), true) ?: [];

// Test deliveries are signed too. Normalize the boolean value to the lowercase
// string used by GAMEMONITORING when the signature is calculated.
$isTest = ($event['is_test'] ?? false) === true;
$signingData = array_replace($event, ['is_test' => $isTest ? 'true' : 'false']);

// Build the exact signing string: all body fields except signature,
// sorted by key and joined as key=value pairs with &.
$fields = array_values(array_filter(array_keys($event), fn($field) => $field !== 'signature'));
sort($fields, SORT_STRING);

// Calculate HMAC-SHA256 with the webhook token from your settings.
$signing = implode('&', array_map(fn($field) => $field . '=' . (string) ($signingData[$field] ?? ''), $fields));
$expected = hash_hmac('sha256', $signing, $secret);
$actual = (string) ($event['signature'] ?? '');

// Reject the request before doing any work when the signature is invalid.
if (!hash_equals($expected, $actual)) {
    http_response_code(401);
    exit;
}

// Test deliveries must not change balance, inventory, roles, or production data.
if ($isTest) {
    http_response_code(204);
    exit;
}

// Real deliveries must include an event type and a stable event id.
$eventType = (string) ($event['event_type'] ?? '');
$eventId = (string) ($event['event_id'] ?? '');

if ($eventType === '' || $eventId === '') {
    http_response_code(400);
    exit;
}

// At this point the webhook is trusted. Add event-specific logic here.
syslog(LOG_INFO, 'Accepted webhook event ' . $eventType . ' #' . $eventId);

// 204 tells GAMEMONITORING that the delivery was accepted successfully.
http_response_code(204);
```

### JavaScript

```javascript
const crypto = require('node:crypto')
const express = require('express')

const app = express()
// Replace this token with the signing token from your GAMEMONITORING webhook settings.
const secret = 'paste-webhook-token-here'

// GAMEMONITORING sends JSON with Content-Type: application/json.
app.use(express.json())

function isValidSignature(event) {
  // Build the exact signing string: all body fields except signature,
  // sorted by key and joined as key=value pairs with &.
  const fields = Object.keys(event).filter((field) => field !== 'signature').sort()
  const signing = fields.map((field) => field + '=' + String(event[field] ?? '')).join('&')

  // Calculate HMAC-SHA256 with the webhook token from your settings.
  const expected = crypto.createHmac('sha256', secret).update(signing).digest('hex')
  const actual = String(event.signature || '')

  // timingSafeEqual requires buffers with the same length.
  const expectedBuffer = Buffer.from(expected)
  const actualBuffer = Buffer.from(actual)

  return expectedBuffer.length === actualBuffer.length && crypto.timingSafeEqual(expectedBuffer, actualBuffer)
}

app.post('/gamemonitoring-webhook', (req, res) => {
  // Read the webhook payload parsed by express.json().
  const event = req.body || {}

  // Reject the request before doing any work when the signature is invalid.
  if (!isValidSignature(event)) {
    return res.sendStatus(401)
  }

  // Test deliveries must not change balance, inventory, roles, or production data.
  if (event.is_test === true) {
    return res.sendStatus(204)
  }

  // Real deliveries must include an event type and a stable event id.
  const eventType = String(event.event_type || '')
  const eventId = String(event.event_id || '')

  if (!eventType || !eventId) {
    return res.sendStatus(400)
  }

  // At this point the webhook is trusted. Add event-specific logic here.
  console.log('Accepted webhook event ' + eventType + ' #' + eventId)

  // 204 tells GAMEMONITORING that the delivery was accepted successfully.
  return res.sendStatus(204)
})

app.listen(3000)
```

### Python

```python
import hashlib
import hmac

from flask import Flask, abort, request

app = Flask(__name__)
# Replace this token with the signing token from your GAMEMONITORING webhook settings.
secret = b'paste-webhook-token-here'

def stringify(value):
    # GAMEMONITORING signs booleans as lowercase true/false strings.
    if isinstance(value, bool):
        return 'true' if value else 'false'

    return '' if value is None else str(value)

def is_valid_signature(event):
    # Build the exact signing string: all body fields except signature,
    # sorted by key and joined as key=value pairs with &.
    fields = sorted(field for field in event.keys() if field != 'signature')
    signing = '&'.join(f'{field}={stringify(event.get(field))}' for field in fields)

    # Calculate HMAC-SHA256 with the webhook token from your settings.
    expected = hmac.new(secret, signing.encode(), hashlib.sha256).hexdigest()
    actual = str(event.get('signature') or '')

    return hmac.compare_digest(expected, actual)

@app.post('/gamemonitoring-webhook')
def gamemonitoring_webhook():
    # Read and decode the JSON body sent by GAMEMONITORING.
    event = request.get_json(silent=True) or {}

    # Reject the request before doing any work when the signature is invalid.
    if not is_valid_signature(event):
        abort(401)

    # Test deliveries must not change balance, inventory, roles, or production data.
    if event.get('is_test') is True:
        return '', 204

    # Real deliveries must include an event type and a stable event id.
    event_type = str(event.get('event_type') or '')
    event_id = str(event.get('event_id') or '')

    if not event_type or not event_id:
        abort(400)

    # At this point the webhook is trusted. Add event-specific logic here.
    app.logger.info('Accepted webhook event %s #%s', event_type, event_id)

    # 204 tells GAMEMONITORING that the delivery was accepted successfully.
    return '', 204
```

## Krok 2. Dodaj deduplikację {#deduplication}

Webhook używa modelu at-least-once: to samo zdarzenie może przyjść więcej niż raz. Zanim handler zmieni stan Twojego systemu, zadbaj o idempotentność tej operacji po `event_type` + `event_id`.

Najpierw utwórz tabelę, która zapisuje parę `event_type` i `event_id` z unikalnym kluczem. Jeśli rekord już istnieje, zdarzenie było już przetworzone.

**Tabela przetworzonych zdarzeń Webhook**

```sql
CREATE TABLE gamemonitoring_webhooks (
  event_type varchar(64) NOT NULL,
  event_id varchar(100) NOT NULL,
  created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (event_type, event_id)
);
```

Następnie rozszerz podstawowy handler: po sprawdzeniu podpisu i podstawowych pól zapisz `event_type` + `event_id`, a zmiany stanu wykonuj w tej samej transakcji.

### PHP

```php
<?php
// Replace this token with the signing token from your GAMEMONITORING webhook settings.
$secret = 'paste-webhook-token-here';

// Read and decode the JSON body sent by GAMEMONITORING.
$event = json_decode(file_get_contents('php://input'), true) ?: [];

// Test deliveries are signed too. Normalize the boolean value to the lowercase
// string used by GAMEMONITORING when the signature is calculated.
$isTest = ($event['is_test'] ?? false) === true;
$signingData = array_replace($event, ['is_test' => $isTest ? 'true' : 'false']);

// Build the exact signing string: all body fields except signature,
// sorted by key and joined as key=value pairs with &.
$fields = array_values(array_filter(array_keys($event), fn($field) => $field !== 'signature'));
sort($fields, SORT_STRING);

// Calculate HMAC-SHA256 with the webhook token from your settings.
$signing = implode('&', array_map(fn($field) => $field . '=' . (string) ($signingData[$field] ?? ''), $fields));
$expected = hash_hmac('sha256', $signing, $secret);
$actual = (string) ($event['signature'] ?? '');

// Reject the request before doing any work when the signature is invalid.
if (!hash_equals($expected, $actual)) {
    http_response_code(401);
    exit;
}

// Test deliveries must not change balance, inventory, roles, or production data.
if ($isTest) {
    http_response_code(204);
    exit;
}

// Real deliveries must include an event type and a stable event id.
$eventType = (string) ($event['event_type'] ?? '');
$eventId = (string) ($event['event_id'] ?? '');

if ($eventType === '' || $eventId === '') {
    http_response_code(400);
    exit;
}

// At this point the webhook is trusted. Deduplicate it before event-specific logic.
$pdo = null;

try {
    // Add your local database connection for deduplication and event-specific work.
    $pdo = new PDO('mysql:host=127.0.0.1;dbname=game;charset=utf8mb4', 'game', 'password', [
        PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
    ]);

    // Keep deduplication and the real state change in one transaction.
    // If any step fails, return 500 so the delivery can be retried.
    $pdo->beginTransaction();

    // Store the event once. This requires the table to have a unique key on
    // (event_type, event_id). Duplicate deliveries affect zero rows.
    $deduplicate = $pdo->prepare('INSERT IGNORE INTO gamemonitoring_webhooks (event_type, event_id) VALUES (?, ?)');
    $deduplicate->execute([$eventType, $eventId]);

    // The event was already processed earlier. Return success without changing
    // state again, because duplicate delivery is expected.
    if ($deduplicate->rowCount() === 0) {
        $pdo->commit();
        http_response_code(204);
        exit;
    }

    // Add event-specific database changes here. Keep them after the
    // deduplication insert and inside this same transaction.

    // Commit only after deduplication and event-specific work both succeed.
    $pdo->commit();

    // Log only newly processed real events after the transaction succeeds.
    syslog(LOG_INFO, 'Accepted webhook event ' . $eventType . ' #' . $eventId);

    http_response_code(204);
} catch (Throwable $error) {
    // Roll back partial database work so the event can be retried safely.
    if ($pdo instanceof PDO && $pdo->inTransaction()) {
        $pdo->rollBack();
    }

    // 500 keeps the delivery failed instead of marking unfinished work as done.
    http_response_code(500);
}
```

### JavaScript

```javascript
const crypto = require('node:crypto')
const express = require('express')
const mysql = require('mysql2/promise')

const app = express()
// Replace this token with the signing token from your GAMEMONITORING webhook settings.
const secret = 'paste-webhook-token-here'

// Add your local database connection for deduplication and event-specific work.
const db = mysql.createPool({
  database: 'game',
  host: '127.0.0.1',
  password: 'password',
  user: 'game',
})

// GAMEMONITORING sends JSON with Content-Type: application/json.
app.use(express.json())

function isValidSignature(event) {
  // Build the exact signing string: all body fields except signature,
  // sorted by key and joined as key=value pairs with &.
  const fields = Object.keys(event).filter((field) => field !== 'signature').sort()
  const signing = fields.map((field) => field + '=' + String(event[field] ?? '')).join('&')

  // Calculate HMAC-SHA256 with the webhook token from your settings.
  const expected = crypto.createHmac('sha256', secret).update(signing).digest('hex')
  const actual = String(event.signature || '')

  // timingSafeEqual requires buffers with the same length.
  const expectedBuffer = Buffer.from(expected)
  const actualBuffer = Buffer.from(actual)

  return expectedBuffer.length === actualBuffer.length && crypto.timingSafeEqual(expectedBuffer, actualBuffer)
}

app.post('/gamemonitoring-webhook', async (req, res) => {
  // Read the webhook payload parsed by express.json().
  const event = req.body || {}

  // Reject the request before doing any work when the signature is invalid.
  if (!isValidSignature(event)) {
    return res.sendStatus(401)
  }

  // Test deliveries must not change balance, inventory, roles, or production data.
  if (event.is_test === true) {
    return res.sendStatus(204)
  }

  // Real deliveries must include an event type and a stable event id.
  const eventType = String(event.event_type || '')
  const eventId = String(event.event_id || '')

  if (!eventType || !eventId) {
    return res.sendStatus(400)
  }

  // At this point the webhook is trusted. Deduplicate it before event-specific logic.
  let connection

  try {
    connection = await db.getConnection()

    // Keep deduplication and the real state change in one transaction.
    // If any step fails, return 500 so the delivery can be retried.
    await connection.beginTransaction()

    // Store the event once. This requires the table to have a unique key on
    // (event_type, event_id). Duplicate deliveries affect zero rows.
    const [deduplicate] = await connection.execute(
      'INSERT IGNORE INTO gamemonitoring_webhooks (event_type, event_id) VALUES (?, ?)',
      [eventType, eventId],
    )

    // The event was already processed earlier. Return success without changing
    // state again, because duplicate delivery is expected.
    if (deduplicate.affectedRows === 0) {
      await connection.commit()
      return res.sendStatus(204)
    }

    // Add event-specific database changes here. Keep them after the
    // deduplication insert and inside this same transaction.

    // Commit only after deduplication and event-specific work both succeed.
    await connection.commit()

    // Log only newly processed real events after the transaction succeeds.
    console.log('Accepted webhook event ' + eventType + ' #' + eventId)

    return res.sendStatus(204)
  } catch (error) {
    // Roll back partial database work so the event can be retried safely.
    if (connection) {
      await connection.rollback()
    }

    // 500 keeps the delivery failed instead of marking unfinished work as done.
    return res.sendStatus(500)
  } finally {
    // Return the connection to the pool.
    if (connection) {
      connection.release()
    }
  }
})

app.listen(3000)
```

### Python

```python
import hashlib
import hmac

import pymysql
from flask import Flask, abort, request

app = Flask(__name__)
# Replace this token with the signing token from your GAMEMONITORING webhook settings.
secret = b'paste-webhook-token-here'

# Add your local database connection for deduplication and event-specific work.
db_config = {
    'database': 'game',
    'host': '127.0.0.1',
    'password': 'password',
    'user': 'game',
}

def stringify(value):
    # GAMEMONITORING signs booleans as lowercase true/false strings.
    if isinstance(value, bool):
        return 'true' if value else 'false'

    return '' if value is None else str(value)

def is_valid_signature(event):
    # Build the exact signing string: all body fields except signature,
    # sorted by key and joined as key=value pairs with &.
    fields = sorted(field for field in event.keys() if field != 'signature')
    signing = '&'.join(f'{field}={stringify(event.get(field))}' for field in fields)

    # Calculate HMAC-SHA256 with the webhook token from your settings.
    expected = hmac.new(secret, signing.encode(), hashlib.sha256).hexdigest()
    actual = str(event.get('signature') or '')

    return hmac.compare_digest(expected, actual)

@app.post('/gamemonitoring-webhook')
def gamemonitoring_webhook():
    # Read and decode the JSON body sent by GAMEMONITORING.
    event = request.get_json(silent=True) or {}

    # Reject the request before doing any work when the signature is invalid.
    if not is_valid_signature(event):
        abort(401)

    # Test deliveries must not change balance, inventory, roles, or production data.
    if event.get('is_test') is True:
        return '', 204

    # Real deliveries must include an event type and a stable event id.
    event_type = str(event.get('event_type') or '')
    event_id = str(event.get('event_id') or '')

    if not event_type or not event_id:
        abort(400)

    # At this point the webhook is trusted. Deduplicate it before event-specific logic.
    connection = None

    try:
        connection = pymysql.connect(**db_config)
        connection.begin()

        # Keep deduplication and the real state change in one transaction.
        # If any step fails, return 500 so the delivery can be retried.
        with connection.cursor() as cursor:
            # Store the event once. This requires the table to have a unique key
            # on (event_type, event_id). Duplicate deliveries affect zero rows.
            cursor.execute(
                'INSERT IGNORE INTO gamemonitoring_webhooks (event_type, event_id) VALUES (%s, %s)',
                (event_type, event_id),
            )

            # The event was already processed earlier. Return success without
            # changing state again, because duplicate delivery is expected.
            if cursor.rowcount == 0:
                connection.commit()
                return '', 204

            # Add event-specific database changes here. Keep them after the
            # deduplication insert and inside this same transaction.

        # Commit only after deduplication and event-specific work both succeed.
        connection.commit()

        # Log only newly processed real events after the transaction succeeds.
        app.logger.info('Accepted webhook event %s #%s', event_type, event_id)

        return '', 204
    except Exception:
        # Roll back partial database work so the event can be retried safely.
        if connection:
            connection.rollback()

        # 500 keeps the delivery failed instead of marking unfinished work as done.
        abort(500)
    finally:
        # Close the database connection.
        if connection:
            connection.close()
```

Nie używaj nicku, ID użytkownika ani ID serwera jako klucza deduplikacji: jeden użytkownik może wywołać różne zdarzenia albo później powtórzyć dozwoloną akcję. Kluczem musi być `event_type` + `event_id`.

Przykład: handler zmienił stan Twojego systemu, ale połączenie zerwało się przed otrzymaniem przez GAMEMONITORING `204`. Później dostawa zostaje ponowiona i to samo zdarzenie przychodzi jeszcze raz. Handler musi znaleźć zapisane `event_type` + `event_id`, pominąć ponowną zmianę stanu i zwrócić `204`.

Jeśli handler tymczasowo nie może przetworzyć zdarzenia, zwróć odpowiedź z błędem. Po usunięciu przyczyny dostawę można ponowić z interfejsu, jeśli ponowienie jest dostępne dla tego zdarzenia.

## Testy i ponowna wysyłka {#tests-resend}

Dostawa testowa (`is_test: true`) sprawdza URL, podpis i odpowiedź HTTP handlera. Handler musi przejść tę samą ścieżkę przetwarzania: odczytać JSON, sprawdzić `signature`, rozpoznać `is_test` i zwrócić udaną odpowiedź `2xx`.

Zdarzenie testowe nie powinno zmieniać salda, ekwipunku, ról, subskrypcji ani innych danych produkcyjnych. Do testu wystarczą techniczny log i odpowiedź `204`.

Jeśli dostawa zakończy się błędem, interfejs pokazuje status, kod HTTP i odpowiedź handlera. Po naprawieniu przyczyny nieudaną dostawę można wysłać ponownie, jeśli ponowienie jest dostępne dla tego zdarzenia.
