How do webhooks work and how do I verify the signature?

Many API transactions, such as recharges, bill payments and payouts, do not finish instantly. A webhook is a message our server sends to your server when something happens, typically when a transaction reaches its final status. Instead of asking us repeatedly "is it done yet?", your system is told as soon as it is. This article explains how to set up webhooks and, importantly, how to verify that each one really came from us.

Setting up your webhook URL

  1. Create an endpoint on your server that accepts POST requests, for example https://shop.pepploweb.com/webhooks/pepplo.
  2. Sign in to your client area, open the API section and go to Webhooks.
  3. Enter your URL and save. A webhook secret is shown. Store it securely on your server, like your API key.
  4. Use the test button to send a sample event and confirm your endpoint receives it.

The URL must use HTTPS with a valid certificate and be reachable from the internet. Local addresses and self-signed certificates will not work.

What a webhook looks like

POST /webhooks/pepplo
Content-Type: application/json
X-Signature: 5f1c...e92a
X-Timestamp: 1796300000

{ "event": "transaction.updated", "data": { "txn_id": "PW9F2A71",
  "reference_id": "ORD10045", "service": "recharge", "status": "success" } }

Verifying the signature

Anyone who knows your webhook URL could send fake requests to it, for example pretending a payout succeeded. The signature proves the message came from us and was not changed. We create it by calculating an HMAC-SHA256 hash of the timestamp and the raw request body using your webhook secret. You repeat the calculation and compare.

$payload   = file_get_contents('php://input');
$timestamp = $_SERVER['HTTP_X_TIMESTAMP'] ?? '';
$received  = $_SERVER['HTTP_X_SIGNATURE'] ?? '';
$expected  = hash_hmac('sha256', $timestamp . '.' . $payload, getenv('PEPPLO_WEBHOOK_SECRET'));

if (!hash_equals($expected, $received) || abs(time() - (int)$timestamp) > 300) {
    http_response_code(401);
    exit;
}

Key points:

  • Use the raw body exactly as received, before any JSON decoding or re-formatting.
  • Compare using a constant-time function such as hash_equals.
  • Reject old timestamps to stop someone replaying a captured webhook.

Responding to a webhook

Return an HTTP 200 response quickly, ideally within a few seconds. If your processing is heavy, save the event and process it in a background job. If we do not receive a 2xx response, we retry the webhook several times over a period, so temporary problems on your side do not lose events.

Processing events safely

  • Idempotency: because of retries, you may receive the same event more than once. Check whether you have already applied this status for this transaction before acting.
  • Order: events can arrive out of order. Never let a "pending" event overwrite a final "success" or "failed" status.
  • Confirm when in doubt: for high-value actions, you can call the status check API to confirm before releasing goods or money.
  • Log: store each event with the time received, with sensitive fields masked.

Firewalls and security plugins

Some security plugins and web application firewalls block incoming POST requests without cookies or with unusual headers. If webhooks are not arriving, check that your endpoint is excluded from CSRF protection and allowed by any firewall rules.

The examples in this article are simplified to show the flow. Field names, endpoint paths and response formats can differ by service, so always follow the current reference in our API documentation.

More help

See our troubleshooting article on webhooks not being received, the full event list in the API documentation, or open a ticket with your webhook URL and an example transaction ID.

Was this article helpful?

Still stuck? Open a support ticket and our team will help.


Related articles

← Back

Chat with us
Hi! Send us a message and we will reply here as soon as we can.
Security check image
Chat with us