For the complete documentation index, see llms.txt. This page is also available as Markdown.

Handle Webhook

This guide shows how to receive, validate, and process webhook events using your prefered language

Requirements

  • An HTTPS endpoint that accepts POST

  • PHP, Python, NodeJS, Java...


Secure & Handle Webhook

When your server receives a webhook, you should verify the signature before processing it. This ensures the request really comes from the platform and not from someone else.


Example payload (short)

Here is an example of the data you will receive, it contains all the necessary data related to the payment: user identifiers, basket contents, price, payment ID...

{
  "mode": "live",
  "event": "payment.success",
  "created_at": "2025-09-04T13:45:44-04:00",
  "request_id": "51b97ba5891ec220e8b64385a00c3826",
  "webhook_id": "458",
  "store_id": "7541",
  "data": {
    "id": 71134,
    "transaction_id": "68B9D0471D02A",
    "gateway": "paypal",
    "amount": { "total_paid": 12, "currency": "EUR" },
    "user": { "email": "user@example.com", "discord_id": "123", "username": "Player" },
    "basket": [{ "id": 183, "name": "VIP Rank", "price": 10, "quantity": 1 }],
    "actions": { "...": "..." }
  }
}

Create an endpoint

Create a file in your chosen language and start a server that listens for POST requests using the following examples:

How it works

  • Read the body → the raw JSON payload sent by the platform.

  • Get headersX-Pay-Timestamp and X-Pay-Signature (provided in every request).

  • Check freshness → reject if older than 5 minutes.

  • Recalculate signatureHMAC-SHA256(timestamp.body, secret).

  • Compare signatures → use hash_equals to prevent timing attacks.

  • Process event → decode JSON and handle it (e.g., update DB).

How it works

  • Raw body is required — don’t use express.json() directly, otherwise the signature check will fail.

  • Check timestamp (X-Pay-Timestamp) — reject if older than 5 minutes.

  • Recalculate signature: HMAC-SHA256(timestamp.body, secret) with the base64-decoded secret.

  • Compare with X-Pay-Signature using crypto.timingSafeEqual for safety.

  • Process the event (decode JSON and apply business logic).

How it works

  1. Read the body → the raw JSON payload sent by Tip4Serv.

  2. Get headersX-Pay-Timestamp and X-Pay-Signature (sent with every request).

  3. Check freshness → reject if the webhook is older than 5 minutes.

  4. Recalculate signatureHMAC-SHA256(timestamp.body, secret) using your Base64-decoded secret.

  5. Compare signatures → use hmac.compare_digest to avoid timing attacks.

  6. Process event → decode JSON and handle it (e.g., update your database).

How it works

  • Read the body@RequestBody String body contains the raw JSON payload.

  • Get headersX-Pay-Timestamp and X-Pay-Signature are extracted with @RequestHeader.

  • Check freshness → reject if the timestamp is more than 5 minutes old.

  • Recalculate signature → compute HMAC-SHA256(timestamp.body, secret) with your Base64-decoded secret.

  • Compare signatures → ensure expected == signature before processing.

  • Process event → parse JSON with Jackson (ObjectMapper) and act on the event.

Tips & best practices

  • Respond fast (under a few seconds). Offload heavy work to a queue/worker.

  • Treat optional fields defensively: not every user identifier or custom_fields will be present.

  • Log the raw payload (with privacy in mind) to help debugging.

Last updated