- For: treasurers
- You get: an email each time a Direct Debit fails or is charged back
- Time: about twenty minutes
- Scopes:
payments:readandpayments.people:read
payment.failed message the moment GoCardless tells us, and your flow emails the treasurer.
The message holds only ids, so the flow reads the payment from the API to get the parent’s name and the amount. That read is also the check that the message is real: a forged message names a payment the API does not list as failed.
You need:
- a group admin, to add the webhook;
- a key with
payments:readandpayments.people:read, created in Settings → Integrations → API keys; - Power Automate with a Premium licence, or a paid Zapier plan.
The sandbox group cannot send webhooks, so build this on your own group. Until a Direct Debit fails, test it with the Send test event button: the flow below ignores the test, which shows the address works.
With Power Automate
1
Create the flow
In Power Automate, choose Create → Instant cloud flow, then Skip. Search for the trigger When an HTTP request is received (it is premium). Set Who can trigger the flow? to Anyone. Choose Save: Power Automate then shows the HTTP URL. Copy it.
2
Add the webhook in Scoutworks
In Settings → Integrations → Webhooks, choose Add webhook. Paste the HTTP URL, describe it as Treasurer: failed Direct Debits, tick payment.failed and choose Add webhook. You do not need the signing secret for this flow.
3
Only act on payment.failed
Add a Condition:
triggerBody()?['type'] is equal to payment.failed. Put the next steps under True. A test event goes to False and does nothing.4
Read the payment back
Under True, add HTTP:
- Method: GET
- URI: type
https://api.scoutworks.app/api/v1/payments?limit=200&updatedSince=and then add this Expression:encodeUriComponent(addHours(triggerBody()?['timestamp'], -1)) - Headers:
Authorization→Bearerfollowed by your key
5
Find this payment
Add Filter array. From: the expression This keeps the payment only if the API also says it failed, was cancelled, was refused by the parent’s bank (
body('HTTP')?['data']. Filter query, in advanced mode:customer_approval_denied) or was charged back. Add a Condition: length(body('Filter_array')) is greater than 0. If it is not, the message did not match a failed payment, so stop there.6
Email the treasurer
Under that condition’s True, add Office 365 Outlook → Send an email (V2). To: the treasurer. Subject:
A Direct Debit has failed. Body, as an expression:202 Accepted as soon as it arrives, which counts as delivered.
With Zapier
1
Catch the hook
Create a Zap. For the trigger, choose Webhooks by Zapier → Catch Hook. Copy the webhook URL Zapier shows.
2
Add the webhook in Scoutworks
In Settings → Integrations → Webhooks, choose Add webhook. Paste the Zapier URL, tick payment.failed and choose Add webhook. Then choose Deliveries and test… → Send test event, and in Zapier choose Test trigger to load the test message.
3
Only act on payment.failed
Add Filter by Zapier: only continue if Type (text) exactly matches
payment.failed.4
Work out the time to read from
Add Formatter by Zapier → Date / Time → Add/Subtract Time. Input: Timestamp. Expression:
-1 hour. To format: YYYY-MM-DDTHH:mm:ss. To timezone: UTC.5
Read the payment back
Add Webhooks by Zapier → GET:
- URL:
https://api.scoutworks.app/api/v1/payments?limit=200&updatedSince=followed by the output of the Formatter step, then the letterZ
Z marks the time as UTC. Do not let Zapier add an offset such as +00:00: a + in a web address reads as a space, and the API refuses the time.- Headers:
Authorization→Bearerfollowed by your key
6
Check it matched
Add Filter by Zapier: only continue if Data Id from the GET step (text) contains Data Payment Id from the trigger.Zapier joins the list into one line of text, so this checks the payment exists and changed in the last hour, but not its status. That is a weaker check than the Power Automate flow’s. Keep the Zapier URL secret.
7
Email the treasurer
Add Email by Zapier → Send Outbound Email, or Gmail or Outlook. To: the treasurer. Subject:
A Direct Debit has failed. In the body, insert Data Amount Pence, Data Charge Date and Data Status from the trigger, and the parent’s name and email from the GET step.Check it works
- In Scoutworks, choose Deliveries and test… → Send test event. The delivery shows as delivered, and nothing is emailed.
- When a real Direct Debit fails, the treasurer gets the email within a minute or two.
- If an email ever goes missing, open Deliveries and test…. A failed delivery shows the answer your flow gave. Fix the flow, then choose Resend.
Variations
- Post to Teams instead. Replace the email with Microsoft Teams → Post message in a chat or channel.
- Collected payments too. Tick payment.confirmed as well. In that branch, keep payments whose status is
confirmedorpaid_out. - A list, not an email. Who hasn’t paid lists every failed Direct Debit in a sheet, refreshed each morning.
If something goes wrong
- No email, and the delivery shows delivered: the read-back found nothing. Check the key has
payments:read, and that the URI still ends with theupdatedSinceexpression. A group with more than 200 payments changed in one hour needs a second page: follownextCursor. - The parent’s name is missing: the key does not have
payments.people:read. - Deliveries fail with 401 or 403: the flow’s address changed, or the flow was switched off. Copy the new address into the webhook with Edit….