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 .
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.
{
"external_id": "12345678",
"webhook": {
"active": true,
"url": "https://mysoftware.com/webhook"
}
}
{
"external_id": "39772921",
"webhook_url": "https://mysoftware.com/webhook/{invoice_id}"
}
When a webhook URL is configured, the following messages will be sent.
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.
Il y a au plus trois tentatives de renvoi. Chaque délai du tableau est calculé à partir de la tentative précédente plutôt qu'à partir du webhook initial; la troisième et dernière tentative est donc effectuée environ trois heures plus tard. Si celle-ci échoue également, le message n'est plus renvoyé.