Implementing Webhooks

Webhooks allow you to receive real-time notifications about payment events.

Setup

  1. Configure webhook URL
  2. Implement endpoint
  3. Verify signatures
  4. 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');
});