Essential Security Practices
Always verify webhooks
Verify the signature on every webhook to ensure it’s from Payviox and hasn’t been tampered with.
Use HTTPS
Always use HTTPS for your webhook endpoint to ensure data is encrypted in transit.
Handle idempotency
Be prepared to receive the same webhook multiple times. Use order_id and session_id to prevent duplicate processing.
Respond quickly
Return 200 OK within 30 seconds. Process webhooks asynchronously if needed.
Webhook Security
Critical: Never process webhooks without verifying the signature. This protects against malicious actors sending fake payment notifications.
Signature Verification
Always verify webhook signatures using HMAC SHA256:Use Timing-Safe Comparison
Always use timing-safe comparison functions:- PHP:
hash_equals() - Node.js:
crypto.timingSafeEqual() - Python:
hmac.compare_digest()
Idempotency Handling
Webhooks may be delivered more than once. Implement idempotency checks:Asynchronous Processing
For optimal performance, process webhooks asynchronously:Responding quickly prevents webhook timeout and retry attempts.
API Token Security
Use environment variables
Use environment variables
Never hardcode API tokens in your code:
Separate test and production tokens
Separate test and production tokens
Use different tokens for different environments:
Rotate tokens regularly
Rotate tokens regularly
Change your API tokens periodically and immediately if compromised.
Never expose tokens client-side
Never expose tokens client-side
For production, use tokens only on your server, never in frontend code.
Error Handling
Implement proper error handling in your integration:Logging and Monitoring
Log all webhooks
Keep detailed logs of all webhook events with timestamps for debugging and audit trails.
Monitor success rates
Track payment success and failure rates to identify issues early.
Set up alerts
Configure alerts for high failure rates or webhook delivery issues.
Review dashboard regularly
Check your Payviox dashboard for payment trends and anomalies.
Testing Checklist
Production Checklist
Common Issues and Solutions
Webhook not receiving notifications
Webhook not receiving notifications
Possible causes:
- Incorrect webhook URL in dashboard
- Firewall blocking Payviox IP addresses
- Server not responding within 30 seconds
- Verify webhook URL in dashboard
- Check server logs for errors
- Ensure endpoint returns 200 OK quickly
Signature verification failing
Signature verification failing
Possible causes:
- Using wrong webhook token
- Modifying request body before verification
- Incorrect HMAC algorithm
- Verify webhook token from dashboard
- Always verify against raw request body
- Use HMAC SHA256 algorithm
Duplicate order processing
Duplicate order processing
Possible causes:
- Not implementing idempotency checks
- Slow response times causing retries
- Implement idempotency using session_id and order_id
- Return 200 OK immediately
- Process asynchronously if needed
Payment session creation fails
Payment session creation fails
Possible causes:
- Invalid API token
- Missing required fields
- Invalid payment method ID
- Verify API token is correct
- Check all required fields are provided
- Ensure payment method exists and is active