Plans, Trials & Subscriptions
This is where a SaaS makes money - and where Larz shines. A free tier, a paid Pro plan, free trials and recurring billing are decorators and config, not a payments project.
Now the part that turns an app into a business: charging for it. In most frameworks this is a big, error-prone project - payment SDKs, webhooks, entitlement logic, trial handling. In Larz it's the built-in core. We'll add a free tier and a paid Pro plan with a trial, and wire real payments - without writing checkout or webhook code.
@app.paid('$9/mo', trial_days=7) above the route: unentitled visitors are sent through checkout, the trial and renewal are tracked for you, and switching from the dev mock to live Stripe doesn't change your routes. The business logic that usually sprawls across a project collapses into a line.A paid tier in one decorator
Gate premium features behind @paid. An unentitled visitor is automatically sent through checkout; a paying one gets in. Trials are a parameter.
@app.login_required
@app.paid('$9/mo', trial_days=7) # Pro plan, 7-day free trial
@app.get('/pro/reports')
def reports(req):
return render_reports(req.user)
@app.metered('$0.01/call') # or bill per API call from credit
@app.post('/api/v1/enrich')
def enrich(req): ...| Primitive | Use |
|---|---|
| @paid('$9/mo', trial_days=7) | Subscription with a free trial |
| @paid('$29') | One-off purchase |
| @metered('$0.01/call') | Pay-per-use from prepaid credit |
| @plan('pro') | Gate on a named plan/tier |
Free vs paid tiers are just which routes carry @paid or @plan. The framework tracks entitlements, trials and renewals for you.
Real payments, provider-agnostic
In dev, a keyless mock provider drives checkout. To go live, pass a real provider - your routes don't change - and point its webhook at Larz.
from larz.providers import StripeProvider
money.enable(app, provider=StripeProvider(
api_key='sk_live_...', webhook_secret='whsec_...'),
base_url='https://yourapp.com')
# webhook -> /larz/webhook/<provider>: Larz verifies + grants entitlement, no codeWire the business model
- @paid for subscriptions and one-offs; @metered for usage; @plan for tiers.
- Trials are a parameter, not a project.
- Providers are swappable - dev mock to live Stripe/Paddle/etc. with no route changes.
- Add a ledger + PDF invoices with the larz[money] extra (larzledger, larzpdf).
๐ฏ Key takeaways
- Charging is Larz's built-in core - a paid tier is @paid, a trial is a parameter, metering is @metered.
- Free vs paid tiers are just which routes carry @paid/@plan; the framework tracks entitlements and renewals.
- Payments are provider-agnostic: dev mock to live Stripe/Paddle/PayPal/etc. with no route changes.
- Larz verifies webhooks, grants entitlements and records invoices for you; larz[money] adds a ledger + PDF invoices.
Frequently asked
How do free trials and renewals actually work without me coding them?
Larz's money layer tracks entitlements and their state for you. When you write @paid('$9/mo', trial_days=7), the framework handles sending unentitled users through checkout, granting a trial entitlement, and recognising when it converts to a paid subscription or lapses - and it records invoices from verified provider webhooks. You focus on what a paid user can access (the routes behind @paid); the lifecycle (trial, active, renewal, expiry) is managed by the framework and, with the larz[money] extra, modelled explicitly by larzsubscription. You're configuring a business model, not building a billing system.
Is it safe to take real payments with this?
The money logic and entitlement handling are built and tested in the framework, and actual money movement goes through established payment providers (Stripe, Paddle, PayPal, etc.) via their real APIs, with Larz verifying webhook signatures. As with any payment setup you follow the basics - real provider keys from environment variables, HTTPS, and testing in the provider's test mode before going live - but you're not hand-rolling the risky parts. The provider handles card data and compliance; Larz handles the entitlement and invoice logic; you configure and test. The production session covers the go-live checklist.
Related lessons
Accounts, Login & API Keys
Every SaaS starts with users. Larz gives you sign-up, login, sessions, roles and API keys โฆ
Build a SaaS with LarzAdmin Panel & Revenue Dashboard
You need to see and manage what's happening - your data and your money. Larz auto-generateโฆ
Build a SaaS with LarzShip It to Production
A SaaS on your laptop isn't a business. This session takes it live: a real server, real paโฆ