Set up your webhook address
1
Prepare an address on your server
You need a web address that starts with
https:// and can receive messages, for example https://yourshop.com/afara-webhook. Ask your developer or website provider if you are not sure.2
Add it in the dashboard
In the merchant portal, click the gear icon, open API Keys, and scroll to Webhooks & Callback. Enter the address in Test Webhook URL for testing, or Webhook URL for real payments.
3
Save
Click Update. Then take a test payment and check that your server receives the message.
Test and live payments use separate addresses, so you can safely try things out without affecting your real shop.
What Afara sends
When a payment succeeds, Afara sends aPOST request to your address with a JSON body that describes the event:
The sample above shows the main fields. The full payload also includes channel, fees, customer and timestamps, and we are confirming the exact field list against the live system.
Check that the message really came from Afara
Every webhook includes a header calledX-Webhook-Signature. It looks like this:
1
Get your secret key
Copy your secret key (it starts with
TSK_ for test or SK_ for live) from Settings > API Keys. Keep it on your server only.2
Read the raw body
Use the request body exactly as it arrived. Do not re-format it first.
3
Calculate the signature
Create an HMAC-SHA256 hash of the raw body using your secret key.
4
Compare
The result, written in lowercase hexadecimal and prefixed with
sha256=, must match the header. If it does not, reject the request.Good habits
- Reply quickly with a success response (HTTP 200) and do slow work afterwards.
- Expect repeats. Make sure handling the same payment twice does not deliver the order twice. Use the transaction reference to spot duplicates.
- Check the amount and reference against your own order before you mark it as paid.