Skip to main content

Webhook signing

Anyone who knows your callback URL can send it a fake “payment succeeded” message. Signing lets your server reject those. Add the domain your callback URLs are on in the console, and PalPluss signs every callback it sends to that domain. Signatures use the Standard Webhooks format, the same scheme used by Svix and Resend.
Signing changes nothing else. The body, callbackUrl and retries work exactly as before. Callbacks to URLs on domains you haven’t added are still sent, unsigned.

How to apply it

1

Add your domain in the console

Open Webhooks → Add domain and enter the host of your callback URL. Copy the whsec_… secret.
2

Store the secret on your server

Put it in an environment variable, for example PALPLUSS_WEBHOOK_SECRET. Never put it in code or a browser app.
3

Keep your requests as they are

Nothing changes in how you call PalPluss. Keep sending the same callbackUrl. When it’s on your domain, the callback is signed.
4

Verify every callback

Check the three webhook-* headers against the raw body with the code below. Reject the callback with 400 if the check fails.
5

Test, then enforce

Use Send test webhook, log failed checks for a while, then start rejecting them.
Which callbacks are signed: every callback PalPluss sends to a URL on your domain, for STK Push (including payments made through payment links), B2C payouts and wallet top-ups, with live and test keys.

1. Add your domain

In the console, open Webhooks → Add domain and enter the host of your callback URL: You can paste a full URL; only its host is kept. IP addresses and localhost can’t be added. You can sign up to 10 domains. To add another once you reach the limit, remove one you no longer use. A *. entry covers all of a domain’s subdomains and counts as one. You get a signing secret that starts with whsec_. Store it on your server, for example as PALPLUSS_WEBHOOK_SECRET. You can show it again in the console at any time. Signing covers callbacks from every API key on your account, in live and test mode.

2. What a signed callback looks like

Three headers are added: The signature is a base64 HMAC-SHA256 of {webhook-id}.{webhook-timestamp}.{raw body}. The key is the base64-decoded part of your secret after whsec_.

3. Verify it

Verify against the raw request body, exactly as received. Parsing the JSON and re-serialising it can change the bytes and break the signature.

Express: keep the raw body

In Laravel, read the raw body with $request->getContent(). In Django, use request.body.
Signature libraries for the Standard Webhooks format work too, because the scheme is the same. The code above has no dependencies.

4. Send a test webhook

Under Webhooks, choose Send test webhook on a domain and enter an https URL on it. PalPluss sends a signed webhook.test event:
The console shows the status code your server returned. Return a 2xx when the signature checks out and 400 when it doesn’t. Test webhooks are only sent to public https addresses.

Rotate the secret

If the secret leaks, choose Rotate secret. A new secret is created straight away. For the next 24 hours, callbacks carry signatures from both the new and the old secret, so you can update your server without missing any. After that, only the new secret is used.

Turning signing on safely

  1. Add the domain and deploy your verification code, but only log failures at first.
  2. Watch a few real callbacks pass.
  3. Then reject unsigned or invalid callbacks with 400.
If you remove a domain, callbacks to it are sent unsigned again. A server that requires signatures will then reject them.

Still do this

A valid signature proves the callback came from PalPluss. Keep the other good habits from Webhooks: use transaction.id (or webhook-id) to ignore duplicates, respond with 2xx quickly, and re-fetch GET /transactions/{id} before fulfilling high-value orders.