Webhooks allow you to receive real-time notifications about events in your Notch Pay account. Instead of polling the API for updates, webhooks push data to your server when events occur.
Respond to webhooks with a 200 status code as quickly as possible, even before processing the event. This prevents Notch Pay from retrying the webhook.Process the event asynchronously if it requires time-consuming operations.
Handle Retries
Notch Pay will retry failed webhook deliveries several times with increasing delays. Make your webhook handler idempotent to avoid processing the same event multiple times.Store the event ID and check if you’ve already processed it before taking action.
Monitor Webhook Health
Regularly check your webhook logs in the Notch Pay dashboard to ensure they’re being delivered correctly.Set up monitoring for your webhook endpoint to detect and alert on failures.
Use HTTPS
Always use HTTPS for your webhook endpoints to ensure the data is encrypted in transit.Use a valid SSL certificate from a trusted certificate authority.
Verify that the webhook is active in your Notch Pay dashboard.
2
Check Event Subscriptions
Make sure you’re subscribed to the event types you expect to receive.
3
Check Server Logs
Check your server logs for any errors or failed webhook deliveries.
4
Verify Endpoint Accessibility
Ensure your endpoint is publicly accessible and responds with a 200 status code.
Invalid Signature Errors
1
Check Secret Key
Verify that you’re using the correct webhook secret.
2
Check Raw Payload
Ensure you’re verifying the signature against the raw request body, not the parsed JSON.
3
Check for Modifications
Make sure the payload isn’t being modified before verification (e.g., by a proxy or middleware).
Duplicate Events
1
Implement Idempotency
Store processed event IDs and check for duplicates before processing.
Copy
// Example with a databaseasync function handleWebhook(event) { // Check if we've already processed this event const existingEvent = await db.events.findOne({ id: event.id }); if (existingEvent) { console.log(`Event ${event.id} already processed, skipping`); return; } // Process the event await processEvent(event); // Store the event ID to prevent duplicate processing await db.events.insertOne({ id: event.id, processed_at: new Date() });}
2
Use Database Constraints
Use unique constraints in your database to prevent duplicate event processing.