Skip to main content
Webhooks allow Paystack to send real-time notifications to your server when events occur on your account. This guide shows you how to implement webhook handlers securely.

Overview

Webhooks are essential for:
  • Real-time payment confirmations
  • Automatic order fulfillment
  • Subscription management
  • Transfer status updates
  • Dispute notifications
The SDK handles signature verification, payload parsing, and type-safe event handling automatically.

Setup Webhook Handler

Register event handlers for the events you want to process.
1

Initialize the SDK

2

Register event handlers

3

Create webhook endpoint

Set up an endpoint to receive webhook requests from Paystack.

Framework Integration

Express.js

Use express.raw() middleware for the webhook route to preserve the raw body. This is required for signature verification.

Next.js (App Router)

Hono (Bun/Cloudflare Workers)

Available Events

The SDK provides type-safe handlers for all Paystack webhook events:

Transaction Events

Transfer Events

Virtual Account Events

Subscription Events

Refund Events

Security

The SDK automatically verifies webhook signatures using HMAC SHA-512.

How It Works

  1. Paystack signs each webhook with your secret key
  2. The SDK verifies the signature before processing
  3. Invalid signatures are rejected automatically
Never disable signature verification in production. Always use the raw request body for verification.

Best Practices

  1. Return 200 immediately - Process webhooks asynchronously
  2. Implement idempotency - Handle duplicate webhook deliveries
  3. Log all webhooks - Keep audit trails for debugging
  4. Monitor failures - Set up alerts for webhook errors
  5. Use queues - Process webhooks in background jobs
  6. Verify transactions - Always confirm with API calls when needed
  7. Test thoroughly - Use Paystack’s webhook testing tool
  8. Handle errors gracefully - Don’t let webhook failures break your app

Common Patterns

Asynchronous Processing

Idempotent Webhook Handling

Error Handling with Retries

Complete Order Fulfillment

Testing Webhooks

Test your webhook handlers locally:
Use tools like ngrok to expose your local server for testing with real Paystack webhooks.

Troubleshooting

Webhook Not Received

  1. Check your webhook URL in Paystack Dashboard
  2. Ensure your server is publicly accessible
  3. Verify your server returns 200 OK
  4. Check firewall settings

Signature Verification Failed

  1. Use the raw request body (not parsed JSON)
  2. Verify you’re using the correct secret key
  3. Check for middleware that modifies the body
  4. Ensure the signature header is being read correctly

Duplicate Webhooks

  1. Implement idempotency checks
  2. Use unique references to track processed webhooks
  3. Return 200 OK even for duplicates