Implementation
Event processing requirements
Example webhook implementation
// Node.js/Express example
app.post('/relay-webhook', async (req, res) => {
try {
// Immediately acknowledge receipt
res.status(200).json({ received: true });
// Process asynchronously
processEventAsync(req.body);
} catch (error) {
// Log error but still return 200
console.error('Error acknowledging event:', error);
res.status(200).json({ received: true, error: 'logged' });
}
});
async function processEventAsync(event) {
// Check for duplicate using transaction ID
if (await isDuplicate(event.Id)) {
console.log(`Duplicate event ${event.Id} - skipping`);
return;
}
// Process the event
await saveTransaction(event);
await updateInventory(event.SoldItems);
await updateReporting(event);
}Idempotency implementation
Last updated
Was this helpful?
