Webhooks > Introduction

Webhooks are a great way for your system to receive near real-time updates from LegitPay without the need to constantly polling. When enabled, your system will be notified as soon as an event is trigger within LegitPay .

habilitando webhooks

Webhooks can be enabled on a per site or per invoice basis by assigning a webhook URL when calling the associated endpoints. Here is an example of the json data required to enable webhooks for each endpoint.


Punto Final
Muestra JSON
Add/Update Site
When adding or editing a new site, you can enable a webhook at the site level. If a site level webhook is enabled you will receive all invoice and payment notifications for the site.
			
{
  "externalId": "12345678",
  "webhook": {
    "active": true,
    "url": "https://mysoftware.com/webhook"
  }
}


		
Add/Update Invoice
When adding or editing an invoice, you can enable a webhook at the invoice level and you will receive all notifications related to the invoice.
			
{
  "externalId": "39772921",
  "webhookUrl": "https://mysoftware.com/webhook/{invoice_id}"
}


		

Eventos de Webhook

When a webhook URL is configured, the following messages will be sent.

Acción
Detalle
Pago
Un pago en una orden de compra alcanza un nuevo estado, como capturado, liquidado, anulado, reembolsado o con contracargo. Cada estado se envía una vez por pago.
Notificación
Un mensaje de texto o correo electrónico cambió de estado de entrega (enviado, entregado, leído, retrasado o fallido), o el cliente hizo clic en el enlace de pago.

Reintentos

Your webhook URL must answer with a successful HTTP status code (any 2xx) and should do so within 10 seconds. A non-2xx status, or a connection that cannot be made at all, counts as a failed delivery and the message is re-sent using the following schedule.

Intento de reintentar
Reenviado
#1
5 minutos después de la webhook inicial
#2
1 hora después
#3
2 horas después

Hay tres reintentos como máximo. Cada retraso en la tabla se mide a partir del intento anterior y no del webhook inicial, por lo que el tercer y último intento se realiza unas tres horas después. Si ese también falla, el mensaje no se vuelve a enviar.