POST
/v1/webhooksWebhook Configuration
Where the merchant registers their URL to receive status updates. Webhooks allow you to receive real-time notifications about payment events.
Overview
Configure webhooks to receive real-time notifications about payment events. When a payment status changes, we'll send a POST request to your configured URL with the event details.
Available Events:
payment.succeeded- Payment completed successfullypayment.failed- Payment was declined or failedpayment.pending- Payment is being processedrefund.completed- Refund has been processedrefund.failed- Refund could not be processed
Security:
Always verify webhook signatures to ensure requests are from Altafinex. Learn how to verify webhooks
Request
Request Body
Required and optional fields
urlrequired
The HTTPS URL where webhook events will be sent. Must be publicly accessible.
eventsrequired
Array of event types you want to receive. See available events above.
secretoptional
Your webhook secret for signature verification. If not provided, one will be generated.
Code Examples
curl -X POST "https://api.altafinex.com/v1/webhooks" \
-H "Authorization: Bearer YOUR_SECRET_KEY" \
-H "Content-Type: application/json" \
-d '{
"url": "https://your-merchant-site.com/api/webhooks/payment",
"events": [
"payment.succeeded",
"payment.failed",
"refund.completed"
],
"secret": "whsec_your_webhook_secret"
}'Webhook Payload
Example Webhook Payload
What you'll receive when an event occurs
{
"event": "payment.succeeded",
"data": {
"payment_id": "pay_1234567890abcdef",
"status": "succeeded",
"amount": 10000,
"currency": "THB"
},
"timestamp": "2024-01-15T10:30:15Z"
}Response
Status Codes
200
Webhook configured successfully400
Invalid request data401
Authentication failed422
Invalid URL or unreachable endpointSuccess Response
Example response for a successful request
{
"webhook_id": "wh_1234567890abcdef",
"url": "https://your-merchant-site.com/api/webhooks/payment",
"events": [
"payment.succeeded",
"payment.failed",
"refund.completed"
],
"status": "active",
"created_at": "2024-01-15T10:00:00Z"
}Error Response
Example response for an error
{
"error": {
"code": "invalid_url",
"message": "The webhook URL is invalid or unreachable",
"type": "validation_error"
}
}