Real-time event notifications for payments, orders, and account updates with signature verification.
Webhooks allow your application to receive real-time notifications when events happen in your Etail Depot account. Instead of polling our API, you can configure webhook endpoints to be notified immediately when events occur.
payment.succeeded
- Payment completed successfullypayment.failed
- Payment failed or was declinedpayment.refunded
- Payment was refundedorder.created
- New order placedorder.fulfilled
- Order shipped or completedorder.cancelled
- Order was cancelledaccount.updated
- Account information changedcard.issued
- New card was issuedtransaction.created
- New transaction recordedcurl -X POST https://api.etaildepot.com/v2/webhooks \
-H "Authorization: Bearer your_api_key" \
-H "Content-Type: application/json" \
-d '{
"url": "https://yourdomain.com/webhooks/etaildepot",
"events": ["payment.succeeded", "payment.failed"],
"description": "Payment notifications"
}'
// Node.js Express example
app.post('/webhooks/etaildepot', (req, res) => {
const event = req.body;
// Verify webhook signature
const signature = req.headers['etail-signature'];
if (!verifySignature(req.body, signature)) {
return res.status(400).send('Invalid signature');
}
// Process the event
switch (event.type) {
case 'payment.succeeded':
handlePaymentSuccess(event.data);
break;
case 'payment.failed':
handlePaymentFailure(event.data);
break;
}
res.status(200).send('OK');
});
const crypto = require('crypto');
function verifySignature(payload, signature) {
const expected = crypto
.createHmac('sha256', process.env.WEBHOOK_SECRET)
.update(payload, 'utf8')
.digest('hex');
return crypto.timingSafeEqual(
Buffer.from(signature, 'hex'),
Buffer.from(expected, 'hex')
);
}
{
"id": "evt_1234567890",
"type": "payment.succeeded",
"created": 1640995200,
"data": {
"object": {
"id": "pay_1234567890",
"amount": 10000,
"currency": "USD",
"status": "succeeded",
"customer": {
"id": "cust_12345",
"email": "customer@example.com"
}
}
},
"request": {
"id": "req_1234567890",
"idempotency_key": null
}
}