Webhooks
Register an HTTPS endpoint to receive signed events, then verify each delivery's signature before acting on it.
POST
/v1/webhook-endpointsRegister a webhook endpoint
| Parameter | Type | Required | Description |
|---|---|---|---|
| url | string | Yes | — |
| description | string | No | — |
| eventTypes | string[] | No | — |
Request body
json
{
"url": "https://yourshop.com/webhooks/akilipay",
"description": "Premium subscription",
"eventTypes": [
"payment.succeeded",
"payment.failed"
]
}Response
json
{
"status": "ok",
"data": {
"id": "a1b2c3d4-5678-90ab-cdef-1234567890ab",
"url": "https://yourshop.com/webhooks/akilipay",
"eventTypes": [
"payment.succeeded",
"payment.failed"
],
"status": "active",
"secretLastFour": "a1b2",
"secret": "whsec_shown_once_store_it_now"
}
}GET
/v1/webhook-endpointsList webhook endpoints
Response
json
{
"status": "ok",
"data": [
{
"id": "a1b2c3d4-5678-90ab-cdef-1234567890ab",
"url": "https://yourshop.com/webhooks/akilipay",
"eventTypes": [
"payment.succeeded",
"payment.failed"
],
"status": "active",
"secretLastFour": "a1b2"
}
]
}Webhooks & Security
HMAC Signature Verification
AkiliPay signs all webhook payloads with an HMAC-SHA256 signature using your endpoint secret (whsec_...).
Webhook Headers Protocol
x-akilipay-signature:
t=1732014000,v1=5d6e8b...
x-akilipay-event-type:
payment.succeeded
x-akilipay-event-id:
evt_0192830192
Replay Attack Protection
The timestamp t prevents replay attacks. Compare it with the server current time and reject webhooks older than 300 seconds (5 minutes).
Signature Verification Code
Verify Webhook Signature (Node.js)
typescript
import crypto from 'node:crypto';
export function verifyAkiliPayWebhook(header, rawBody, webhookSecret) {
const parts = Object.fromEntries(header.split(',').map(p => p.trim().split('=')));
const timestamp = Number(parts.t);
const signature = parts.v1;
if (Math.abs(Math.floor(Date.now() / 1000) - timestamp) > 300) return false;
const expected = crypto
.createHmac('sha256', webhookSecret)
.update(`${timestamp}.${rawBody}`)
.digest('hex');
return crypto.timingSafeEqual(Buffer.from(signature), Buffer.from(expected));
}Computes HMAC-SHA256 and validates timing-safe equality.