Webhooks
Webhooks notify your application in real-time when events occur in PaymentKit. Use webhooks to trigger business logic, sync data, and keep your systems up to date.
How webhooks work
When events occur (like a payment succeeding or subscription being created), PaymentKit sends an HTTP POST request to your configured endpoint with details about the event.
Setting up webhooks
Dashboard
API
- Navigate to Developers > Webhooks
- Click Add Endpoint
- Enter your endpoint URL (must be HTTPS)
- Select the events you want to receive
- Copy your signing secret for verification
Webhook payload
Webhooks are delivered as JSON with a Stripe-compatible format:
The data.object field contains the full entity state at the time of the event. The example above is simplified; actual payloads include all entity fields. Amount fields use atomic units (e.g., cents for USD) with the _atom suffix. The previous_attributes field contains the previous state for update events, showing fields that changed.
Webhook headers
Each webhook request includes headers for verification and debugging:
Verifying signatures
Always verify webhook signatures to ensure requests are from PaymentKit. The signature is an HMAC-SHA256 hash of the raw request body using your endpoint’s signing secret.
Node.js
Python
Always use the raw request body for signature verification, not a parsed/serialized version. JSON serialization can change formatting and break verification.
Event types
Payment events
Checkout session events
Payment intent events
Subscription events
Invoice events
Customer events
Customer discount events
Coupon events
Price events
Product events
Refund events
Retry behavior
If your endpoint returns a server error (5xx status), times out, or is unreachable, PaymentKit automatically retries delivery:
Client errors (4xx status codes) are treated as permanent failures and will not be retried. Ensure your endpoint returns a 2xx status for successful receipt.
After 5 failed attempts, the delivery is marked as permanently failed. You can manually retry from the dashboard.
Respond to webhooks quickly (within 30 seconds) with a 2xx status. Process event data asynchronously to avoid timeouts.
Best practices
Return a 2xx response immediately, then process the event asynchronously.
Use the event ID to deduplicate. Webhooks may be retried on failure, potentially delivering the same event multiple times.
Always verify webhook signatures in production to prevent spoofing.
Webhook endpoints must use HTTPS. PaymentKit rejects HTTP URLs.
Testing webhooks
You can use tools like ngrok to expose your local development server for webhook testing. This allows you to receive real webhook events during development.
Monitoring deliveries
Track webhook delivery status in the dashboard under Events:
- delivered - Successfully received (2xx response)
- pending - Scheduled for initial delivery
- delivering - Currently being delivered
- failed - Delivery failed (will retry if attempts remain, or permanent failure if retries exhausted)
View delivery details including attempt count, response status, error messages, and retry timing.