Webhooks
Real-time notifications with PayOS
Overview
PayOS uses webhooks to notify your application about events that occur within your payment orchestration process. These notifications are delivered via HTTP POST requests to your specified endpoint, allowing you to automate workflows and keep your systems synchronized with payment activities.
Event Types
PayOS sends different types of webhook events. Common event types include:
Getting Started with Webhooks
To integrate webhooks into your application, follow these steps:
- Create a webhook subscription - Configure the HTTPS URL where you want to receive notifications
- Implement signature verification - Verify webhook authenticity using the provided secret
- Process webhooks idempotently - Handle webhook events while avoiding duplicate processing
- Acknowledge receipt - Return HTTP 200 response for successful webhook receipt
Creating a Webhook Subscription
You can create and configure your webhook subscriptions on the Svix dashboard.
- Navigate to the Webhooks section in your Svix dashboard
- Click “Add Endpoint”
- Enter your HTTPS endpoint URL
- Select the events you want to subscribe to
- Save your webhook configuration
If you do not yet have a Svix dashboard URL, contact your PayOS account manager.
💡 Tip: If you don’t have an endpoint ready yet, you can use Svix Play to generate a temporary endpoint for testing.
Securing Webhooks
PayOS uses Svix for secure webhook delivery. Each webhook includes a signature that you should verify before processing:
Manual Webhook Verification
While we recommend using the official Svix libraries for webhook verification, you may need to implement manual verification. Here’s how to verify webhooks manually:
1. Required Headers
Each webhook includes three critical headers:
svix-id
: Unique identifier for the webhook messagesvix-timestamp
: Timestamp in seconds since epochsvix-signature
: Base64 encoded list of signatures (space delimited)
2. Constructing the Signed Content
Concatenate the ID, timestamp, and payload with periods:
⚠️ Important: Use the raw request body. Any modification (even whitespace) will invalidate the signature.
3. Calculating the Signature
Use HMAC-SHA256 to verify the signature:
4. Timestamp Verification
Always verify the timestamp to prevent replay attacks:
Example Implementation
Here’s a complete example combining all verification steps:
🔒 Security Note: Always use constant-time string comparison when comparing signatures to prevent timing attacks.
Best Practices
-
Verify Signatures
- Always verify webhook signatures using your webhook secret
- Reject requests with invalid signatures
-
Handle Events Idempotently
- Store processed webhook IDs to prevent duplicate processing
- Use event IDs for deduplication
-
Implement Proper Error Handling
- Return 2xx status codes for successful receipt
- Return 4xx for invalid requests
- Return 5xx for processing errors
-
Monitor Webhook Health
- Track failed deliveries in the PayOS dashboard
- Set up alerts for repeated failures
Testing Webhooks
For development and testing:
- Use the Svix dashboard to view webhook delivery history
- Test signature verification with sample payloads
- Use tools like Svix Play to inspect webhook content
Webhook Retries
If your endpoint returns a non-200 response code or is unavailable, PayOS will retry the webhook delivery with the following backoff schedule:
- 1st retry: 5 minutes
- 2nd retry: 15 minutes
- 3rd retry: 30 minutes
- 4th retry: 1 hour
- 5th retry: 2 hours
- Final retry: 4 hours
IP Allowlisting
If your infrastructure requires IP allowlisting, you’ll need to whitelist Svix’s IP ranges. The current list can be found in the Svix documentation.
Webhook Security Checklist
✅ Use HTTPS endpoints only
✅ Verify webhook signatures
✅ Store webhook secrets securely
✅ Process events idempotently
✅ Monitor failed deliveries
✅ Implement proper error handling