Webhooks

Receive payment events and verify signatures.

Configure endpoints

Add webhook URLs in Dashboard → Settings → Webhooks. Select events and store the signing secret shown once at creation.

Event: payment.success

{
  "type": "payment.success",
  "created_at": "2026-07-11T10:00:00+00:00",
  "data": {
    "transaction_id": "txn_abc",
    "gross_amount": "10000",
    "parent_net_amount": "9200",
    "commission_amount": "500",
    "currency": "KES",
    "customer_phone": "+254712345678"
  }
}

Verify signatures

NezaHub signs the raw request body with HMAC-SHA256. Compare the X-NezaHub-Signature header before processing with construct_event() / constructEvent().

from nezahub import construct_event

event = construct_event(
    request.body,
    request.headers["X-NezaHub-Signature"],
    webhook_secret,
)
if event["type"] == "payment.success":
    txn_id = event["data"]["transaction_id"]