Webhook guide

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.

HTTP request
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":{…}}
Headers

What every delivery carries.

HeaderMeaning
GaisPay-Signaturet=<unix>,v1=<hex hmac> — also sent as X-Signature for older integrations
X-EventEvent name, e.g. invoice.paid
X-Delivery-IdUnique per delivery — use it to de-duplicate
User-AgentGaisPay-Webhook/1
Code

Copy, paste, verify.

Always compute the HMAC over the raw request body, before any JSON parsing.

Node.js
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);
});
Delivery rules

How retries work.

01

10-second timeout

Answer quickly; do heavy work in a background job.

02

2xx means delivered

Any other status or a timeout is a failure.

03

10 attempts

Retries start after about 1 minute and the wait doubles each time, up to 6 hours apart.

04

Order is not guaranteed

Use the status inside the payload, not arrival order.

05

Public endpoints only

Private and local network addresses are refused.

06

Visible in the dashboard

Each delivery and its last error appear on the payment.

More for developers