SaaS Billing PipelineAI Workflow
End-to-end subscription billing: manage recurring payments, generate PDF invoices, render branded email templates, and send them automatically. Event-driven — invoice is generated and emailed on every successful payment.
Prerequisites
Environment variables
STRIPE_SKSTRIPE_WEBHOOK_SECRETRESEND_KEYInstall
npx radzor@latest recipe add saas-billingAI Prompt
“Run `npx radzor@latest add subscription-billing invoice-generator email-template email-send` to install 4 Radzor components. Then read components/radzor/subscription-billing/radzor.manifest.json, components/radzor/invoice-generator/radzor.manifest.json, components/radzor/email-template/radzor.manifest.json, components/radzor/email-send/radzor.manifest.json and each component's llm/integration.md. Wire them together to end-to-end subscription billing: manage recurring payments, generate PDF invoices, render branded email templates, and send them automatically. Event-driven — invoice is generated and emailed on every successful payment. Use the manifest's inputs (check envVar for required environment variables), outputs (check fields for object shapes), composability (check mapField for field extraction), and actions — don't invent custom interfaces.”
Paste this into Claude Code, Cursor, Windsurf, or any AI coding agent.
Pipeline
SubscriptionBilling
Manages recurring subscriptions via Stripe
InvoiceGenerator
Generates a PDF invoice from the payment data
EmailTemplate
Renders a branded invoice email
EmailSend
Sends the invoice to the customer
Scaffolded Code
// npx radzor@latest add subscription-billing invoice-generator email-template email-send
import { SubscriptionBilling } from "./components/radzor/subscription-billing"
import { InvoiceGenerator } from "./components/radzor/invoice-generator"
import { EmailTemplate } from "./components/radzor/email-template"
import { EmailSend } from "./components/radzor/email-send"
const billing = new SubscriptionBilling({
secretKey: process.env.STRIPE_SK!,
webhookSecret: process.env.STRIPE_WEBHOOK_SECRET!,
})
const invoicer = new InvoiceGenerator({ companyName: "Acme Inc.", currency: "usd", taxRate: 0.2 })
const templates = new EmailTemplate({})
const mailer = new EmailSend({ provider: "resend", apiKey: process.env.RESEND_KEY!, from: "billing@acme.com" })
// Register the invoice email template
templates.registerTemplate("invoice", `
<h1>Invoice {{invoiceNumber}}</h1>
<p>Hi {{customerName}},</p>
<p>Your payment of <strong>${{total}}</strong> has been received.</p>
<p>Please find your invoice attached.</p>
`)
// React to successful payments
billing.on("onSubscriptionCreated", async (event) => {
// Generate PDF invoice
invoicer.setCustomer(event.customerId, event.customerId)
invoicer.addLineItem("Subscription", 1, 29.99)
const { pdf, data } = await invoicer.generate()
// Render email from template
const { html } = await templates.render("invoice", {
invoiceNumber: data.invoiceNumber,
customerName: event.customerId,
total: data.total.toString(),
})
// Send the email
await mailer.send({ to: event.customerId, subject: `Invoice ${data.invoiceNumber}`, html })
})
// Create a subscription
await billing.createSubscription("cus_xxx", "price_monthly")Components used
LLM tip
Pass all 4 radzor.manifest.json files to your agent at once. It will read the outputs of each step and match them against the inputs of the next — wiring the full pipeline without any extra instructions.