The moment it happens
Check VAT numbers on Stripe invoices and email the right person
When Stripe drafts an invoice, an invalid VAT number is flagged to finance; when it's finalised, the customer gets an email from you.
- Runs
- The moment it happens
- Apps
- Gmail, Stripe
- AI
- Not needed
- Access
- Stripe read invoices/customers; gmail.send
Send this to your assistant
Create a ClickRuntime automation: when a Stripe invoice is drafted, re-check the customer's EU VAT number with VIES and email finance if it's invalid; when it's finalised, email the customer from my Gmail.
First time? Adding ClickRuntime to your assistant takes about two minutes.
Why use it
Why teams use this automation
A software company bills European business customers through Stripe and applies the reverse charge when a customer gives a valid VAT number. VAT numbers lapse when companies restructure or close, and an invoice issued without VAT to an invalid number is a tax problem that surfaces months later at audit.
This automation re-checks the VAT number against the EU's VIES service each time Stripe drafts an invoice, while there is still time to fix it, and emails finance if it no longer validates. When the invoice is finalised, the customer receives a short personal email from your Gmail with the link to view and pay it.
What you get out of it
Problems caught before invoicing
An invalid VAT number is flagged while the invoice is still a draft and can be corrected.
Less audit risk
Reverse-charge invoices are only issued against numbers that validated at the time.
Finance only hears about exceptions
Valid numbers pass quietly; only failures produce an email.
A personal invoice email
Customers receive the invoice link from your address, which tends to get faster replies than a system email.
A record of each check
Finance emails include the number checked and the result, which helps when answering questions later.
How it works
What happens, step by step
When Stripe drafts or finalises an invoice, it tells ClickRuntime straight away, and the message is checked to be genuinely from Stripe.
For a draft invoice, it reads the customer's EU VAT number and checks it with the EU's VIES service.
If the number is invalid or cannot be checked, finance gets an email with the customer and invoice details.
For a finalised invoice, the customer gets an email from your Gmail with the link to view and pay it.
Before it runs live
- Connect Google through your own Google app (a one-time, 10-minute setup), so it works with your own Gmail
- Connect Stripe
- Paste your automation's link into the other app's webhook settings
What you get
Build your own
Need it to work differently?
Your own rules
Conditions, thresholds, filters and exceptions, written the way you'd explain them to a colleague.
Any number of apps
One automation can read from one app and update several others. Over 248 apps are ready, and anything with an API works too.
AI where it helps
Summaries, classification, extraction and drafts use ClickRuntime's built-in AI, with no extra key.
On a schedule or on each event
Runs as often as every 5 minutes, or the moment an app sends an event, and keeps track of what it already handled.
Changes you can ask for
- Act only on the items that match your own rules, and skip the rest
- Add an AI step, for example to summarize, sort or draft a reply
- Add another app, for example also send it to Slack
- Combine it with other Gmail and Stripe steps into one automation
Under the hood
The code that runs this automation
import base64
from email.message import EmailMessage
from google.oauth2.credentials import Credentials
from googleapiclient.discovery import build
import stripe
from clickruntime import on_event, credentials, verify, http
def send(to, subject, text):
msg = EmailMessage(); msg["To"], msg["Subject"] = to, subject; msg.set_content(text)
g = build("gmail", "v1", credentials=Credentials(credentials.connection("google", "work")), cache_discovery=False)
g.users().messages().send(userId="me", body={"raw": base64.urlsafe_b64encode(msg.as_bytes()).decode()}).execute()
@on_event
def handle(event):
if not verify.stripe(event.body, event.header("Stripe-Signature"), credentials.secret("STRIPE_WEBHOOK_SECRET")):
return {"ignored": "bad signature"}
inv = event.json["data"]["object"]
if event.json["type"] == "invoice.finalized":
send(inv["customer_email"], f"Invoice {inv['number']}", f"Hello,\n\nYour invoice is ready: {inv['hosted_invoice_url']}\n\nThank you.")
return {"sent": "customer"}
stripe.api_key = credentials.secret("STRIPE_API_KEY")
vat = next((t for t in stripe.Customer.list_tax_ids(inv["customer"]).data if t.type == "eu_vat"), None)
if not vat:
return {"vat": None}
r = http.post("https://ec.europa.eu/taxation_customs/vies/rest-api/check-vat-number", json={"countryCode": vat.value[:2], "vatNumber": vat.value[2:]})
if r.status_code != 200 or not r.json().get("valid"):
send("finance@example.com", f"VAT check failed: {inv.get('customer_name')}", f"VAT number {vat.value} did not validate for draft invoice {inv['id']}.")
return {"vat": vat.value, "status": r.status_code}FAQ
Common questions
Which customers are checked?
What if the VIES service is down?
Does it change the invoice?
What permissions does it need?
Does it need AI?
How many runs does it use?
Can I change how it works?
Related
You might also like
Email buyers their product and receipt after a Stripe payment
As soon as someone pays, they get their download link and a receipt from your own Gmail address.
See how it worksWin back failed payments with a friendly email
When a card fails, the customer gets a short note from you with a link to pay, and a reminder three days later if it's still unpaid.
See how it worksAsk cancelling customers why, and get a weekly churn summary
Customers who cancel get one personal question by email, their replies are sorted by reason, and you get a weekly summary.
See how it worksKeep exploring
Set up “Check VAT numbers on Stripe invoices and email the right person” from your assistant
Copy the prompt above, or connect your assistant first. Free plan, no credit card.