Stripe Billing Manager
Overview
Automate the full customer billing lifecycle via the Stripe API—from subscription creation and plan management to failed payment recovery, refunds, and MRR reporting.
When to Use
- •Creating and managing SaaS subscription plans
- •Handling failed payment dunning sequences automatically
- •Processing refunds based on business rules
- •Generating MRR, churn, and revenue breakdown reports
- •Syncing Stripe customer events to your CRM or database
Instructions
- •Accept inputs: action type (create_subscription/upgrade/downgrade/cancel/refund/report), customer ID or email, plan ID, metadata.
- •Authenticate with Stripe API using the provided secret key.
- •For subscriptions: create or modify subscription with correct proration behavior.
- •For failed payments: initiate dunning sequence—retry logic with configurable intervals and customer notification emails.
- •For refunds: validate refund eligibility, calculate amount (full/partial), submit via Stripe Refunds API.
- •For reports: pull charges, invoices, and subscription data; calculate MRR, ARR, churn rate, ARPU.
- •Sync all events to configured webhook endpoint or database.
- •Return structured result with Stripe object IDs and confirmation details.
Environment
code
STRIPE_SECRET_KEY=sk_live_your_stripe_secret_key STRIPE_WEBHOOK_SECRET=whsec_your_webhook_secret STRIPE_DEFAULT_CURRENCY=usd DATABASE_URL=postgresql://user:pass@host:5432/billing_db
Examples
Input:
code
action: upgrade customer_email: founder@startup.com from_plan: price_starter to_plan: price_growth effective: immediately
Output:
code
Subscription upgraded successfully. Customer: cus_abc123 New plan: price_growth ($299/mo) Proration credit: $47.23 Next invoice: 2026-03-18 Stripe subscription ID: sub_xyz789