Accept payments
Webhooks
We send a signed POST request to your server when a payment succeeds or expires. Verify the signature, return 200 quickly, then fulfil the order.
Set up your endpoint
- In the dashboard at dashboard.kepperhq.com, open Webhooks and set a URL for live mode, test mode, or both.
- The URL must be public and use
https. To test locally, use a tunnel such as ngrok or Cloudflare Tunnel. - The first time you set a URL, we show you a signing secret (
whsec_…) once. Store it like a password. If you lose it, rotate it in the dashboard; you'll need your PIN.
Events
| Event | Sent when |
|---|---|
payment.successful | We've confirmed the payment and credited your wallet. Fulfil the order now. |
payment.expired | The payment wasn't completed in time. Cancel or release the order. |
Example payload
{
"id": "evt_6744a1c2e4b0f3a9d1c2b3a5",
"object": "event",
"type": "payment.successful",
"livemode": true,
"createdAt": "2026-11-25T14:12:09.311Z",
"data": {
"id": "pay_6744a1c2e4b0f3a9d1c2b3a4",
"object": "payment",
"reference": "order_1001",
"status": "successful",
"channel": "card",
"amount": 500000,
"fee": 7500,
"netAmount": 492500,
"currency": "NGN",
"customer": { "email": "ada@example.com", "name": "Ada Obi" },
"metadata": { "orderId": "1001" },
"paidAt": "2026-11-25T14:12:08.902Z",
...
}
}data is the full payment object, the same as GET /payments/:id returns.
Verify the signature
Every webhook has a Kepper-Signature header:
Kepper-Signature: t=1764079929,v1=5257a869e7ecebeda32affa62cdca3fa51cad7e77a0e56ff536d0ce8e108d8bd- Split the header on
,to gett(Unix timestamp) andv1(the signature). - Reject the request if
tis more than 5 minutes from your server's clock. This stops replayed requests. - Compute HMAC-SHA256 of
{t}.{raw request body}with your signing secret, as lowercase hex. - Compare it to
v1with a constant-time comparison. If they differ, return400and do nothing.
Use the raw body
Compute the signature over the exact bytes you received. If your framework parses the JSON and you serialise it again, the signature won't match.
Node.js (Express)
server.js
import crypto from "node:crypto";
import express from "express";
const app = express();
const SECRET = process.env.KEPPER_WEBHOOK_SECRET; // whsec_...
// Use the raw body: the signature covers the exact bytes we sent.
app.post("/webhooks/kepper", express.raw({ type: "application/json" }), (req, res) => {
const parts = Object.fromEntries(
(req.get("Kepper-Signature") ?? "").split(",").map((p) => p.split("=", 2))
);
const timestamp = Number(parts.t);
if (!timestamp || Math.abs(Date.now() / 1000 - timestamp) > 300) return res.sendStatus(400);
const expected = crypto
.createHmac("sha256", SECRET)
.update(`${timestamp}.${req.body}`)
.digest();
const received = Buffer.from(parts.v1 ?? "", "hex");
if (received.length !== expected.length || !crypto.timingSafeEqual(received, expected))
return res.sendStatus(400);
const event = JSON.parse(req.body);
// Skip if you've already handled event.id, then fulfil the order.
res.sendStatus(200);
});PHP
webhook.php
<?php
$payload = file_get_contents('php://input');
$header = $_SERVER['HTTP_KEPPER_SIGNATURE'] ?? '';
parse_str(str_replace(',', '&', $header), $parts);
$timestamp = (int) ($parts['t'] ?? 0);
if (abs(time() - $timestamp) > 300) { http_response_code(400); exit; }
$expected = hash_hmac('sha256', $timestamp . '.' . $payload, getenv('KEPPER_WEBHOOK_SECRET'));
if (!hash_equals($expected, $parts['v1'] ?? '')) { http_response_code(400); exit; }
$event = json_decode($payload, true);
// Skip if you've already handled $event['id'], then fulfil the order.
http_response_code(200);Python (Flask)
app.py
import hashlib, hmac, os, time
from flask import Flask, abort, request
app = Flask(__name__)
SECRET = os.environ["KEPPER_WEBHOOK_SECRET"].encode()
@app.post("/webhooks/kepper")
def kepper_webhook():
payload = request.get_data()
header = request.headers.get("Kepper-Signature", "")
parts = dict(p.split("=", 1) for p in header.split(",") if "=" in p)
timestamp = int(parts.get("t", 0))
if abs(time.time() - timestamp) > 300:
abort(400)
expected = hmac.new(SECRET, f"{timestamp}.".encode() + payload, hashlib.sha256).hexdigest()
if not hmac.compare_digest(expected, parts.get("v1", "")):
abort(400)
event = request.get_json()
# Skip if you've already handled event["id"], then fulfil the order.
return "", 200Retries and duplicates
- Return any
2xxwithin 10 seconds. Do slow work, like sending emails, after you respond. - If you don't, we retry after 1 minute, 5 minutes, 30 minutes, 2 hours, 6 hours, 12 hours and 24 hours, for 8 attempts in all.
- We don't follow redirects. Point the URL at the final address.
- The same event can arrive more than once. Store
event.id(also in theKepper-Event-Idheader) and skip events you've already handled. - You can see recent deliveries and resend any event from the dashboard under Webhooks.