Search Documentation

Search API endpoints, webhooks, tools, and guides

On this page4 sections
Guides

Verifying Webhook Signatures

Verify X-Invoger-Signature (t=...,v1=...) headers using HMAC-SHA256 and timing-safe comparison.

Every webhook HTTP request dispatched by InvogerPOS includes cryptographic signature headers so your server can verify authenticity and prevent replay attacks.

Webhook Request Headers

HeaderFormatDescription
X-Invoger-EventstringEvent name (e.g. invoice.created) or webhook.ping
X-Invoger-DeliveryUUIDUnique delivery ID for idempotent processing
X-Invoger-Timestampunix secondsTimestamp string when the request was signed
X-Invoger-Signaturet=<ts>,v1=<hex>Timestamped HMAC-SHA256 signature of {timestamp}.{rawBody}

Signature Verification Algorithm

InvogerPOS signs the concatenated string ${timestamp}.${rawBody} using HMAC-SHA256 with your subscription's signing secret (whsec_...), formatted as t=${timestamp},v1=${hex}.

Node.js Verification Example

javascript
import crypto from "node:crypto"; export function verifyInvogerWebhook(rawBody, headers, signingSecret) { const sigHeader = headers["x-invoger-signature"] || ""; const parts = Object.fromEntries( sigHeader.split(",").map((kv) => kv.split("=")), ); const timestamp = parts.t || headers["x-invoger-timestamp"]; const receivedV1 = parts.v1; if (!timestamp || !receivedV1) return false; // Reject stale payloads older than 5 minutes const now = Math.floor(Date.now() / 1000); if (Math.abs(now - parseInt(timestamp, 10)) > 300) { return false; } const expected = crypto .createHmac("sha256", signingSecret) .update(`${timestamp}.${rawBody}`) .digest("hex"); return crypto.timingSafeEqual( Buffer.from(receivedV1, "hex"), Buffer.from(expected, "hex"), ); }

Python Verification Example

python
import hmac import hashlib import time def verify_invoger_webhook(raw_body_bytes, signature_header, secret_str): parts = dict(item.split("=", 1) for item in signature_header.split(",") if "=" in item) timestamp = parts.get("t", "") v1_sig = parts.get("v1", "") if not timestamp or not v1_sig or abs(time.time() - int(timestamp)) > 300: return False signed_payload = f"{timestamp}.".encode("utf-8") + raw_body_bytes expected = hmac.new( secret_str.encode("utf-8"), signed_payload, hashlib.sha256, ).hexdigest() return hmac.compare_digest(v1_sig, expected)
POST/api
app.post("/webhooks/invoger", express.raw({ type: "application/json" }), (req, res) => {
  const valid = verifyInvogerWebhook(req.body.toString("utf8"), req.headers, process.env.WEBHOOK_SECRET);
  if (!valid) return res.status(401).send("Invalid signature");
  res.status(200).send("OK");
});
Interactive playground

Response

application/json
{
  "verified": true
}