You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Webhook registration storage (in-memory or PostgreSQL)
src/webhooks/types.ts
TypeScript type definitions
src/webhooks/dispatcher.ts
Sends webhooks with retries & signatures
src/webhooks/service.ts
High-level webhook API
src/webhooks/index.ts
Main export point
src/remittance/events.ts
Remittance event emitter
scripts/test-webhook.ts
Manual testing with web dashboard
examples/webhook-integration.ts
Full integration example
WEBHOOK_IMPLEMENTATION_GUIDE.md
Detailed documentation
Quick Setup (5 minutes)
1. Initialize Webhook System
import{WebhookService,createWebhookStore}from'./src/webhooks';import{remittanceEventEmitter}from'./src/remittance/events';import{Pool}from'pg';constpool=newPool();conststore=createWebhookStore(pool);// Use PostgreSQLconstwebhookService=newWebhookService(store);// Connect events to webhooksremittanceEventEmitter.setWebhookService(webhookService);
SELECT status, COUNT(*) as count
FROM webhook_deliveries
GROUP BY status;
Failed deliveries
SELECT id, event_type, error
FROM webhook_deliveries
WHERE status ='failed'ORDER BY created_at DESC;
Subscriber statistics
SELECTw.url, COUNT(d.id) as deliveries,
SUM(CASE WHEN d.status='success' THEN 1 ELSE 0 END) as successful
FROM webhooks w
LEFT JOIN webhook_deliveries d ONw.id=d.webhook_idGROUP BYw.idORDER BY deliveries DESC;
app.post('/webhooks/remittance',async(req,res)=>{const{ event, data }=req.body;if(event==='remittance.completed'){awaitsendEmail({to: data.recipientEmail,subject: `Your remittance of ${data.amount}${data.currency} is complete!`,body: `Check your bank account for the funds.`,});}res.json({success: true});});
Slack Notification on Failure
app.post('/webhooks/remittance',async(req,res)=>{const{ event, data }=req.body;if(event==='remittance.failed'){awaitaxios.post(SLACK_WEBHOOK_URL,{text: `❌ Remittance ${data.id} failed!\nReason: ${data.reason}`,});}res.json({success: true});});
Update Dashboard in Real-time
app.post('/webhooks/remittance',async(req,res)=>{const{ event, data }=req.body;// Broadcast to connected WebSocket clientsio.emit('remittance-update',{remittanceId: data.id,status: data.status,timestamp: data.updatedAt,});res.json({success: true});});