Skip to content

Verify Paddle webhooks

Verify that a webhook really came from Paddle before acting on it.

Identifier 'paddle'
Import import { verifyPaddle } from 'verihook/paddle'
Headers paddle-signature
Signature HMAC-SHA256 of <ts>:<raw body>, sent as ts=<timestamp>;h1=<hex>.
Replay window 300 seconds (options.tolerance)
result.eventType the body’s event_type, e.g. transaction.completed

The notification destination’s secret key (pdl_ntfset_...): in Paddle, open Developer Tools → Notifications, select the destination and copy its secret key.

Store it in an environment variable (PADDLE_WEBHOOK_SECRET below) and never commit it.

import { verifyPaddle } from 'verihook/paddle';
export async function POST(request: Request) {
const result = await verifyPaddle(request, process.env.PADDLE_WEBHOOK_SECRET!);
if (!result.valid) {
console.warn(result.code, result.reason, result.hint);
return new Response('Invalid signature', { status: 401 });
}
console.log(result.eventType, result.event);
return Response.json({ received: true });
}

request can be a Fetch Request or { headers, body, url? } with the raw body. verifyWebhook('paddle', request, secret) from verihook does the same. Read why the raw body matters if verification fails behind a body parser.

app/api/webhooks/paddle/route.ts
import { createWebhookHandler } from 'verihook/next';
export const POST = createWebhookHandler('paddle', process.env.PADDLE_WEBHOOK_SECRET!, async (payload, result) => {
// Runs only for a valid signature
console.log(result.eventType, result.event);
});

Each adapter responds 401 to an invalid signature, 413 to a body over maxBodySize (2 MB by default) and 200 to a duplicate when you pass a dedupeStore.

  • This covers Paddle Billing. Paddle Classic’s p_signature scheme isn’t supported.

signWebhook from verihook/testing builds a correctly signed Paddle request for your tests:

import { signWebhook } from 'verihook/testing';
import { verifyPaddle } from 'verihook/paddle';
const hook = await signWebhook('paddle', {
secret: 'pdl_ntfset_test_secret',
payload: { id: 'evt_test' },
});
const result = await verifyPaddle(
{ headers: hook.headers, body: hook.body, url: hook.url },
hook.secret,
);
// result.valid === true

From the command line, npx verihook simulate paddle --url http://localhost:3000/webhooks/paddle sends one to your local server.

See Testing your handlers for supertest and Fetch Request examples.

Failed results carry a code and often a hint with the likely cause. See Troubleshooting for each error code.

Paddle’s webhook documentation