Invoice Ready Webhook
Amberflo.io integrates with Stripe and AWS Marketplace for automatically settling invoices, but you are not limited to these payment providers.
If you have your own payment system or use a different service, you can set up a webhook to be notified of new invoices that are ready to be paid and improve your payment automation.
A webhook is an HTTP POST request that we make to an endpoint you control, with some specific payload.
Every time a new invoice is ready to be paid, Amberflo publishes the ready-product-invoices event. In order to receive the webhook request, you'll need to subscribe to it.
You can do so by making a POST request to the Webhook API . Here is an example:
Notice the authHeader parameter. This header will be added to the webhook request in order to allow your endpoint to authenticate it.
Now, whenever there is a new invoice ready to be paid, you'll get a POST request (like the one below) on your endpoint.
This is what a webhook request to your endpoint will look like:
Note that the content of data is the same that is returned by the Customer Invoice API, so you can always call it to verify the invoice status.
Amberflo's webhook system expects the endpoint to return a status code 200 upon success. Any other status code will be considered a failure.
The webhook system will retry a few times to send the request whenever there is a failure. For this reason, it is important that the endpoint be idempotent, as the same event may hit it multiple times. For the case of invoices, you can use the invoiceUri as idempotence key.
Because there is a limited number of attempts to send the webhook, your system should have a fallback mechanism to ensure the invoices get settled. You can achieve this by periodically checking the Customer Invoice API and the Account Event API. The first lets you list all invoices for a given customer, while the later lets you check if there have been failed attempts to send the webhook.