Use this file to discover all available pages before exploring further.
PayBridgeNP signs every webhook delivery with an HMAC-SHA256 signature. You should always verify this signature before processing an event - otherwise anyone could send fake payment notifications to your endpoint.
The easiest way is PayBridge.webhooks.constructEvent() - it handles signature parsing, HMAC comparison, and replay attack protection (rejects events older than 5 minutes).
import express from "express";import { PayBridge } from "@paybridge-np/sdk";const app = express();// Must use raw body - do NOT use express.json() for this routeapp.post( "/webhooks/paybridge", express.raw({ type: "application/json" }), async (req, res) => { const sig = req.headers["x-paybridge-signature"] as string; const body = req.body.toString(); let event; try { event = await PayBridge.webhooks.constructEvent( body, sig, process.env.PAYBRIDGE_WEBHOOK_SECRET!, ); } catch (err) { console.error("Webhook verification failed:", err.message); return res.status(400).send(`Webhook error: ${err.message}`); } switch (event.type) { case "payment.succeeded": await handleSuccess(event.data); break; case "payment.failed": await handleFailure(event.data); break; } res.json({ received: true }); },);
The HMAC is computed over the raw request body string. If you parse the JSON first (e.g. with express.json() middleware) and then re-serialize it, the string may differ and signature verification will fail.Always read the body as a string before passing it to constructEvent.
customer_address is present when the checkout session or payment link had collectAddress: true. It is null otherwise.livemode is true when the event was generated by a live (sk_live_) key and false for sandbox (sk_test_). Branch on it in your handler to avoid processing a sandbox event as a real payment, especially when the same handler URL serves both modes.
If your endpoint returns a non-2xx status or times out, PayBridgeNP retries with exponential backoff:
Attempt
Delay after previous
1
30 seconds
2
5 minutes
3
30 minutes
4
2 hours
5
8 hours
After 5 failed attempts the delivery is marked as permanently failed. You can see all delivery attempts and their response codes in the Webhooks → delivery log in your dashboard.
Want to sanity-check your HMAC implementation without running any server code? Use the Webhook Debugger - paste your signing secret, the raw request body, and the X-PayBridge-Signature header, and it tells you whether the signature would verify and why.