Webhooks
Webhooks provide real-time notifications about card rail order status changes, enabling you to update your system immediately when purchases complete, fail, or change status. This eliminates the need for polling and ensures your application stays synchronized with payment events.
Webhook Events
Swipelux sends webhook notifications for these card rail order events:
Event | Description | When it fires |
---|---|---|
order.created | Order was created successfully | Immediately after order creation via API |
order.processing | Payment processing has started | When user initiates payment |
order.completed | Purchase completed successfully | When crypto is transferred to user's wallet |
order.failed | Purchase failed during processing | When payment or transfer fails |
order.cancelled | Order was cancelled | When user cancels or order times out |
Implementation
Implement a Webhook Handler
Create a webhook endpoint that can receive POST requests from Swipelux.
We've prepared example implementations for popular server technologies:
Verify the Webhook Payload
To ensure webhook payload authenticity, we sign it using JWT (JSON Web Token).
You can verify the signature using our public key available at https://api.swipelux.com/api/merchants/webhookKeys
.
Handle the Webhook Payload
Once verified, process the webhook payload to update your system based on the order status change.
Example Webhook Payload
Payload Schema
Prop | Type | Default |
---|---|---|
order | object | - |
status | enum | - |
externalId? | string | - |
orderId | string | - |
eventType | string | - |
eventTs | number | - |
Configure Webhook Endpoint
Once your webhook handler is implemented and deployed, configure the endpoint URL in the Merchant Panel.
Important Requirements:
- Endpoint must be publicly accessible over HTTPS
- Must respond with HTTP 200 status for successful processing
- Should respond within 10 seconds to avoid timeout
- Must handle duplicate events idempotently
Implementation Patterns
Order Status Updates
User Notifications
Error Handling
Best Practices
Idempotency
Always handle webhooks idempotently to avoid duplicate processing:
Retry Logic
Implement exponential backoff for failed webhook processing:
Monitoring
Track webhook processing metrics:
Testing Webhooks
During development, use tools like ngrok to expose your local webhook endpoint: