Auto-Send PDF Invoices From Stripe
When a Stripe payment succeeds, the agent generates a professional PDF invoice and emails it to the customer automatically.
freelancers and consultantsE-commerce Operator
What it does
You get paid faster because your agent instantly creates a professional PDF invoice and emails it to customers whenever a Stripe payment succeeds. This automatic process handles extracting details and sending the attachment via Gmail without needing any manual work from you after setup.
Step by step
- Configure a Stripe webhook endpoint that listens specifically for the 'invoice.payment_succeeded' event type.
- Map the incoming JSON payload fields such as customer_email and total to variables in your code node.
- Construct an HTML string using standard table tags to format line items, subtotal, tax, and grand total.
Where the LLM does the work
- Generate a clean, responsive CSS stylesheet for the invoice template that looks professional on both desktop and mobile screens.
- Draft concise email body text that summarizes the payment details while encouraging the customer to view the attached PDF.
- Refine error handling logic in the code node to gracefully manage missing customer data or malformed webhook payloads.
Watch out for
Stripe sends amounts in cents so you must divide by 100 and format as currency before displaying them in the HTML template.
Gmail API requires valid OAuth scopes for send_mail which can cause authentication failures if not pre-configured correctly.
Large PDF attachments might exceed Gmail size limits so ensure the generated file is compressed or under the 25MB threshold.
Tools that fit
The agent brief
Everything your agent needs, including the gotchas. Copy it and go.
You are helping me build the following AI agent workflow. ## Goal Auto-Send PDF Invoices From Stripe: When a Stripe payment succeeds, the agent generates a professional PDF invoice and emails it to the customer automatically. ## Specification - What it does: You get paid faster because your agent instantly creates a professional PDF invoice and emails it to customers whenever a Stripe payment succeeds. This automatic process handles extracting details and sending the attachment via Gmail without needing any manual work from you after setup. - Trigger: Triggered by an event (Event · on new payment) - Autonomy: Fully hands-off - Expected setup effort: about an afternoon - Tools/services involved: - Stripe: Payment webhook trigger - Code: Data normalization and HTML generation - Gmail: Sending invoice emails ## Known pitfalls, handle each one explicitly in your implementation 1. Stripe sends amounts in cents so you must divide by 100 and format as currency before displaying them in the HTML template. 2. Gmail API requires valid OAuth scopes for send_mail which can cause authentication failures if not pre-configured correctly. 3. Large PDF attachments might exceed Gmail size limits so ensure the generated file is compressed or under the 25MB threshold. ## Reference implementation https://n8n.io/workflows/8030 (workflow template) Fetch and inspect this before building. If it matches my stack, adapt it; if not, rebuild the pattern with my tools. ## Process requirements 1. Before building: ask me which of the listed tools I actually use and what my platform is (n8n / Make / code / other). Do not assume. 2. Adapt the pattern to my answers; do not force the reference stack. 3. Address every pitfall above; tell me how you handled each. 4. Provide a test plan I can run before letting this touch real data. 5. Ask before any step that sends messages, modifies data, or spends money. Source: https://usecasesforagents.com/use-case/auto-send-pdf-invoices-from-stripe/ via usecasesforagents.com
Frequently asked questions
Can I use a different Payments than Stripe?
Yes. Stripe is only the example payments in this recipe. The same flow works with PayPal and Razorpay API. Swap the payments connection and keep the rest of the setup as written.
Want this running in your business?
This is what I do. I design and build AI agents like this one, and keep them running. If you want it set up for your team instead of doing it yourself, get in touch.
Who it's for
Built for freelancers and consultants juggling this across every client, not just one.
Also fits E-commerce Operator.