For your microservices, Python + FastAPI really does the job.
By September 2027, for small businesses (like mine, hello!), we'll need to be operational on supporting invoice dematerialization.
So that the government can make sure we're not committing VAT fraud (booo, bad).
Anyway, as far as I'm concerned for ViteUneTable, I have two modes: the first restaurants pay their subscription with GoCardless, the invoice is generated on Axonaut, and the payment is collected by GoCardless.
But for the wave of restaurants coming in now, I don't know them like the first ones, so a deferred payment system like SEPA isn't ideal. Card payment, on the other hand, is instant.
So for that... I use Stripe.
But no integration between Axonaut and Stripe exists for recurring payments (Stripe Billing), and Stripe invoices aren't compliant with digital invoice requirements.
Maybe they will be someday, but not at the moment.
Also, I like having all my figures in Axonaut. I've gotten used to having everything in this tool, so it might as well stay that way.
So how do we do it? Well... Stripe webhooks.
In the past, I didn't use them: the debugging experience is awful, you always have that stress of thinking "what if I'm offline for a few seconds," and it's already happened to me that even with retries, some information doesn't get through. And I can assure you that for invoicing, that can be a real pain.
That's where HookStack comes in. It's on a high-availability infrastructure and therefore designed to never be offline—that's its whole point. And with it, I was able to create a Python + FastAPI script.
HookStack forwards the Stripe webhook (when a payment is confirmed) to my Python script.
The Python script with FastAPI: • Searches for the customer in Axonaut • If they don't exist, it creates them • Creates their invoice • Validates their payment • Sends their invoice by email to the customer, along with a link to their billing customer portal (provided by Axonaut)
The tricky part is that the script takes a few seconds to do all this, so in HookStack, I've set a 30-second timeout.
Also, the script's "state" is managed with HTTP codes: if everything goes well, we return a 200, and HookStack won't retry sending the webhook. If the webhook signature is invalid: 400. And if an API is offline or doesn't respond properly: 500.
In the third case, when HookStack resends the webhook, the script picks up where it left off. This time, the customer exists (and is linked to the Stripe customer ID), if the invoice already exists (the Stripe ID is linked to the invoice), it doesn't recreate it, and so on... all the way to the email.
At first, I wanted to use n8n to do all this, but it actually slows me down more than anything.
A nice little Python and FastAPI script and... it does the job!