HOME / COMMUNITY Switch to knowledge base

Issues when using webhooks for auto-direct debit collection


Some of our customers have auto-direct debit with us, this means we collect all invoices automatically via direct debit, when the invoice is created via a recurring profile quickfile does it automatically and we do not have any issue with this, but when we create single invoices we had to remember which customers were on auto-collection or not.

So we created an app that connected to the API and checked all client invoices and send a request if we were meant to do it.

This caused issues because of the number of API calls we were doing so we changed our approach to use Webhooks instead and that’s were we found some issues.

  1. As there is no webhook for “InvoiceStatusChanged”, we do this when the invoice is created, but the direct debit request is sent when the invoice is still a draft, and if we are building an invoice and saving it (e.g. Create an invoice, add item 1 save, add item 2 save), it do the direct debit collection with the value of the item 1.

  2. If we copy an invoice from a customer that is meant to be used for a different client, the direct debit collection is done for the client where the invoice was copied from.

Do you currently have a workaround this or can we have a new hook done for “InvoiceStatusChanged”?


Hi @APereira

I just want to clarify the query here if that’s OK?

Is it the case that you’re triggering the direct debit request on an InvoiceCreated webhook? But because of this, the direct debit is being requested for the original client (rather than the one that it’s changed to), and only for partial lines rather than the complete invoice, because of the timing?

Hi @QFMathew,

Yes that’s correct.

We use the trigger “InvoiceCreated” to fire a direct debit collection if the client has requested auto-collection.

On normal situations we create a new invoice from scratch and when we save it, it requests which is okay.

If we save the invoice as draft so we can add more stuff, it creates the request straight away when we save it as draft, and then when we amend the invoice it doesn’t trigger again, because the invoice was already created. (that was obvious but we haven’t thought about it).

If we do copy an invoice from a different client, it creates the request of this client, not to the one we changed it to.

I think the only solution is to have a trigger when “InvoiceStatusChanged” like we have for the estimates, this will allow us to only trigger this when the invoice status is changed to sent.

Appreciate it’s not ideal, but perhaps checking the invoice details when you receive an invoice created or invoice updated webhook would be the best way to handle this for you.

For example:

  1. Receive an InvoiceCreated or InvoiceUpdated webhook

  2. Grab the Id from the payload

  3. Use the Invoice_Get endpoint to get the invoice details

  4. Check the “STATUS” field, and only act if the status is set to “SENT”

Or, add a delay to trigger the direct debit collection (e.g. set up a scheduled task/cron job)

Hi @QFMathew,

That’s similar to what we had before and we been contacted by Glen because of the amount of API requests we were doing.

When an invoice is created (even as a draft) it will trigger an InvoiceCreated, if I grab the ID here, I will need to be querying the invoice every now and again increasing the amount of requests I do.

If I do it on InvoiceUpdated, this update can be a description update, and I will be querying the API again for no reason on this cases.

Hence why I think the best solution would be a similar webhook to “EstimatesStatusChange”, this would allow us not only to only act when invoice status is changed to “Sent” but also to act on different status providing more functionality and flexibility.

I can also delay the direct debit collection request, but it will be a margin for error, as sometimes draft invoices are created and they stay as draft for days.

Hi @APereira

I’m pleased to say we have introduced a new InvoiceSent webhook which may help you here.

Here’s an example:

	"PayLoad": {
		"InvoicesSent": [{
			"TimeStamp": "2020-09-01T20:58:40",
			"Id": 17137034,
			"InvoiceType": "INV"
		"Timestamp": "2020-09-01T21:59:59.7222303+01:00",
		"Signature": "#################",
		"Hookid": "#################"

This topic was automatically closed after 4 days. New replies are no longer allowed.