Configurar webhooks
¿Qué son los webhooks?
Sección titulada «¿Qué son los webhooks?»Cuando ocurre un evento en una transacción, Rivopay envía un POST a tu webhookUrl registrada con los datos del evento.
Configurar tu webhookUrl
Sección titulada «Configurar tu webhookUrl»En la plataforma de cliente podrá configurar su propio webhookUrl en donde recibir los webhooks.
Headers del webhook
Sección titulada «Headers del webhook»| Header | Valor |
|---|---|
Content-Type | application/json |
X-Webhook-Event | Nombre del evento (ej: payin.completed) |
User-Agent | RivopayGateway/1.0 |
Eventos disponibles
Sección titulada «Eventos disponibles»| Evento | Header X-Webhook-Event | Cuándo se dispara |
|---|---|---|
payin.completed | payin.completed | Pago PIX recibido y confirmado |
payin.failed | payin.failed | Pago PIX rechazado o fallido |
payin.reversed | payin.reversed | Pago recibido fue devuelto al pagador |
payout.completed | payout.completed | Transferencia PIX enviada y confirmada |
payout.failed | payout.failed | Transferencia PIX rechazada por el banco |
payout.reversed | payout.reversed | Transferencia fue revertida por el banco receptor |
Ejemplo de endpoint
Sección titulada «Ejemplo de endpoint»app.post('/webhook/rivoplay', express.json(), async (req, res) => { const eventType = req.headers['x-webhook-event']; const payload = req.body; const { txId, status } = payload;
switch (eventType) { case 'payin.completed': await confirmarPedido(txId, payload.netAmount); break; case 'payin.failed': await cancelarPedido(txId); break; case 'payout.failed': await notificarFalloPago(txId, payload.failureReason); break; case 'payout.reversed': await procesarReversion(txId); break; }
// SIEMPRE responde 200 aunque tengas un error interno res.status(200).json({ received: true });});