Aller au contenu
← Documentation

Webhooks API

Recevez des notifications en temps réel

Configuration

// Configure Webhook (Dashboard)
const webhook = await client.webhooks.create({
  url: 'https://your-domain.com/webhooks/luneo',
  events: [
    'order.created',
    'order.updated',
    'design.created',
    'payment.succeeded'
  ],
  secret: 'whsec_...' // Auto-generated
});

Webhook Handler

// Webhook Handler
const crypto = require('crypto');

app.post('/webhooks/luneo', (req, res) => {
  const signature = req.headers['x-luneo-signature'];
  const payload = JSON.stringify(req.body);
  
  // Verify signature
  const hash = crypto
    .createHmac('sha256', process.env.WEBHOOK_SECRET)
    .update(payload)
    .digest('hex');
  
  if (hash !== signature) {
    return res.status(401).send('Invalid signature');
  }
  
  // Process event
  const event = req.body;
  logger.info('Event:', event.type, event.data);
  
  res.json({ received: true });
});

Events Disponibles

order.createdNouvelle commande
order.updatedCommande mise à jour
design.createdNouveau design
design.sharedDesign partagé
payment.succeededPaiement réussi
payment.failedPaiement échoué