Agent skill
NextPay Webhooks Skill
Receive and verify NextPay (NextAPI) webhooks, delivered via Svix. Use when setting up NextPay webhook handlers, debugging svix-signature verification, or handling events like v2.payment_intent.succeeded, payout_request.processed, payout.failed, and deposit.confirmed.
Install this skill
npx skills add hookdeck/webhook-skills --skill nextpay-webhooks
NextPay's NextAPI is a Philippine payments API for collections (QRPH, cards, payment intents), payouts and platform wallets. It delivers webhooks through Svix, which implements Standard Webhooks. Every delivery is an HTTP POST with a JSON body and three signature headers: svix-id, svix-timestamp, and svix-signature. The body has one of two shapes: v2.* payment events are {"event": ..., "payload": ...}, while payout and platform events are {"type": ..., "data": ...}. Read the name as event.event || event.type.
When to Use This Skill
- How do I receive NextPay webhooks?
- How do I verify NextPay webhook signatures (
svix-signature)? - How do I handle
v2.payment_orintent.succeeded payout_request.processedevents? - How do I react to
payout.failed,deposit.confirmedorlegal_?entity.verification_ status_ changed - Why is my NextPay webhook signature verification failing, or rejecting Hookdeck retries?
Verification (core)
Signed content is {svix-id}.{svix-timestamp}.{raw body}. Svix signs it with HMAC-SHA256 using the base64-decoded secret (the part after whsec_), base64-encodes the result, and sends one or more space-separated v1,<signature> entries. Use the official svix library, which compares in constant time. Read the svix-* headers, and when svix-id is absent fall back to the webhook-* headers (webhook-id, webhook-timestamp, webhook-signature).
import { Webhook } from 'svix'; // svix 2.x is ESM-only
const prefix = req.headers['svix-id'] ? 'svix' : 'webhook';
const id = req.headers[`${prefix}-id`];
const timestamp = req.headers[`${prefix}-timestamp`];
const signature = req.headers[`${prefix}-signature`];
// rawBody: the raw Buffer/string, never re-serialized JSON
new Webhook(process.env.NEXTPAY_WEBHOOK_SECRET).verify(rawBody, {
'svix-id': id, 'svix-timestamp': timestamp, 'svix-signature': signature,
'webhook-id': id, 'webhook-timestamp': timestamp, 'webhook-signature': signature,
}); // throws on a bad signature or a timestamp outside the window
const event = JSON.parse(rawBody.toString('utf8')); // parse only after verify passes
from svix.webhooks import Webhook, WebhookVerificationError
wh = Webhook(os.environ["NEXTPAY_WEBHOOK_SECRET"]) # "whsec_..."
wh.verify(raw_body, {"svix-id": id, "svix-timestamp": ts, "svix-signature": sig,
"webhook-id": id, "webhook-timestamp": ts, "webhook-signature": sig})
For complete handlers with tests, see examples/express/, examples/nextjs/, examples/fastapi/.
The signing secret is per webhook, starts with whsec_, and is returned once as secret in the response to POST /v2/webhooks. Keep the full whsec_... value in NEXTPAY_WEBHOOK_SECRET (NextPay's own guides call the variable NEXTAPI_WEBHOOK_SECRET; the name is your choice). Handlers fail closed: with the variable unset they return 500 instead of accepting anything.
Hookdeck retries and replays hit the 5-minute window
The svix library always enforces a fixed 5-minute timestamp window, and it can't be configured. Hookdeck retries and replays resend the original svix-timestamp, so the library rejects any retry or replay that happens more than 5 minutes after the original delivery. If you verify behind Hookdeck (or replay old events), use the manual verifier in references/verification.md, where the window can be dropped or widened. Deduplicate on svix-id (or the event id) instead of relying on the timestamp.
Common Event Types
16 events are documented (the list may not be exhaustive). The examples handle all of these:
| Event | Body shape | Triggered When |
|---|---|---|
v2.payment_ | event + payload | Payment received and settled |
v2.payment_ | event + payload | A payment intent was cancelled |
v2.payment_ | event + payload | A single-use Funding Method instrument was used |
v2.payment_ | event + payload | An incoming Funding Method payment arrived |
v2.payment_ | event + payload | That incoming payment cleared |
payout_ | type + data | A payout request failed to create |
payout_request.queued | type + data | A payout request is queued for settlement |
payout_ | type + data | A payout request failed to queue |
payout_request.processed | type + data | A payout request is fully processed |
payout.succeeded | type + data | An individual payout was delivered |
payout.failed | type + data | An individual payout failed |
payout.processed | type + data | An individual payout finished processing |
payout.processing_failed | type + data | An individual payout failed during processing |
deposit.confirmed | type + data | An inbound deposit was confirmed on an account |
direct_transfer.received | type + data | An account received a direct transfer |
legal_ | type + data | A merchant KYC/compliance status changed |
See references/overview.md for the body shapes and delivery rules.
Environment Variables
# Signing secret returned once by POST /v2/webhooks (Svix format, starts with whsec_)
NEXTPAY_WEBHOOK_SECRET=whsec_xxxxx
Local Development
# Start tunnel (no account needed)
npx hookdeck-cli listen 3000 nextpay --path /webhooks/nextpay
Register the tunnel URL with POST /v2/webhooks (an events list selects what you receive), and store the returned secret. See references/setup.md.
Reference Materials
- references/overview.md - NextPay webhook concepts, events, body shapes, delivery rules
- references/setup.md - Register a webhook, get the secret, test locally
- references/verification.md - Svix verification details, header fallback, manual verifier, timestamp window