Verify every
webhook.
Each delivery is a POST with a JSON body and a GaisPay-Signature header: a timestamp t and v1 = HMAC-SHA256 of "t.raw_body" with your whsec_ secret.
POST /webhooks/gaispay HTTP/1.1
Content-Type: application/json
User-Agent: GaisPay-Webhook/1
GaisPay-Signature: t=1795289461,v1=5257a869e7ec…
X-Event: invoice.paid
X-Delivery-Id: 418
{"event":"invoice.paid","created_at":1795289461,"data":{…}}What every delivery carries.
| Header | Meaning |
|---|---|
GaisPay-Signature | t=<unix>,v1=<hex hmac> — also sent as X-Signature for older integrations |
X-Event | Event name, e.g. invoice.paid |
X-Delivery-Id | Unique per delivery — use it to de-duplicate |
User-Agent | GaisPay-Webhook/1 |
Copy, paste, verify.
Always compute the HMAC over the raw request body, before any JSON parsing.
import express from "express";
import crypto from "node:crypto";
const app = express();
const SECRET = process.env.GAISPAY_WEBHOOK_SECRET; // whsec_…
app.post("/webhooks/gaispay", express.raw({ type: "application/json" }), (req, res) => {
const sig = Object.fromEntries((req.get("GaisPay-Signature") || "").split(",").map((p) => p.split("=")));
const expected = crypto.createHmac("sha256", SECRET).update(`${sig.t}.${req.body}`).digest("hex");
const valid = sig.v1 && sig.v1.length === expected.length &&
crypto.timingSafeEqual(Buffer.from(sig.v1), Buffer.from(expected));
if (!valid || Math.abs(Date.now() / 1000 - Number(sig.t)) > 300) return res.sendStatus(400);
const event = JSON.parse(req.body);
if (event.event === "invoice.paid") {
// Fulfil event.data.order_id once — store req.get("X-Delivery-Id")
}
res.sendStatus(200);
});<?php
$secret = getenv("GAISPAY_WEBHOOK_SECRET"); // whsec_…
$body = file_get_contents("php://input");
$header = $_SERVER["HTTP_GAISPAY_SIGNATURE"] ?? "";
parse_str(str_replace(",", "&", $header), $sig);
$expected = hash_hmac("sha256", ($sig["t"] ?? "") . "." . $body, $secret);
if (!hash_equals($expected, $sig["v1"] ?? "") || abs(time() - (int)($sig["t"] ?? 0)) > 300) {
http_response_code(400);
exit;
}
$event = json_decode($body, true);
if ($event["event"] === "invoice.paid") {
// Fulfil $event["data"]["order_id"] once
}
http_response_code(200);import hmac, hashlib, os, time
from flask import Flask, request, abort
app = Flask(__name__)
SECRET = os.environ["GAISPAY_WEBHOOK_SECRET"].encode() # whsec_…
@app.post("/webhooks/gaispay")
def gaispay():
body = request.get_data()
sig = dict(p.split("=", 1) for p in request.headers.get("GaisPay-Signature", "").split(",") if "=" in p)
expected = hmac.new(SECRET, f"{sig.get('t')}.".encode() + body, hashlib.sha256).hexdigest()
if not hmac.compare_digest(expected, sig.get("v1", "")) or abs(time.time() - int(sig.get("t", 0))) > 300:
abort(400)
event = request.get_json()
if event["event"] == "invoice.paid":
pass # fulfil event["data"]["order_id"] once
return "", 200How retries work.
10-second timeout
Answer quickly; do heavy work in a background job.
2xx means delivered
Any other status or a timeout is a failure.
10 attempts
Retries start after about 1 minute and the wait doubles each time, up to 6 hours apart.
Order is not guaranteed
Use the status inside the payload, not arrival order.
Public endpoints only
Private and local network addresses are refused.
Visible in the dashboard
Each delivery and its last error appear on the payment.

