Email receipts to billing email address
Just to be clear: the idea of emailing support@openai.com to request the latest invoice is not mine. I found it in this thread. I only built a small n8n workflow around that idea.
The workflow is very simple:
Once a month, n8n sends an email to support@openai.com asking for the latest invoice.
When the reply arrives, another n8n workflow parses the email body.
It extracts the Stripe invoice link and converts it into the direct PDF invoice URL.
n8n downloads the PDF and sends it to my accounting email address.
The useful part is the Stripe link conversion.
The link received in the email looks like this:
https://invoice.stripe.com/i/...
The direct PDF URL can be generated like this:
https://pay.stripe.com/invoice/.../pdf
In JavaScript, the basic logic is:
const [baseUrl, queryString] = invoiceUrl.split('?');
const pdfBaseUrl = baseUrl.replace(
'https://invoice.stripe.com/i/',
'https://pay.stripe.com/invoice/'
);
const pdfUrl = `${pdfBaseUrl}/pdf${queryString ? `?${queryString}` : ''}`;
Also, Link now sends an email for OpenAI purchases, so in theory that email could be used as a trigger too, instead of sending a monthly request first.
Important note: this workaround is for ChatGPT invoices.
Discussion in the ATmosphere