Implementing Webhooks
Webhooks allow you to receive real-time notifications about payment events.
Setup
- Configure webhook URL
- Implement endpoint
- Verify signatures
- Process events
Event Types
- payment.success
- payment.failed
- refund.processed
- dispute.created
Security
Always verify webhook signatures to ensure authenticity.
Example Implementation
app.post('/webhooks', (req, res) => {
const signature = req.headers['glocashier-signature'];
const isValid = verifySignature(signature, req.body);
if (!isValid) {
return res.status(400).send('Invalid signature');
}
// Process the webhook
const event = req.body;
handleWebhookEvent(event);
res.status(200).send('Webhook processed');
});