forked from Nixius/authelia
78 lines
2.7 KiB
Markdown
78 lines
2.7 KiB
Markdown
# Tiered Pricing Setup
|
||
|
||
Tiered pricing assigns different Stripe prices based on customer count.
|
||
|
||
## Stripe MCP (Cursor)
|
||
|
||
Stripe MCP is configured in `.cursor/mcp.json`. It loads `STRIPE_SECRET_KEY` from `.env` so you can use Stripe tools in Cursor chat (create customers, prices, search docs, etc.).
|
||
|
||
**Enable MCP:** [Stripe Dashboard → Settings → MCP](https://dashboard.stripe.com/settings/mcp) — enable for test and/or live mode.
|
||
|
||
Restart Cursor after adding/updating `.env` so the MCP picks up keys.
|
||
|
||
## Automated Setup Script
|
||
|
||
Create products and prices from your `.env` keys:
|
||
|
||
```bash
|
||
./scripts/stripe-setup.sh # uses .env, prints IDs
|
||
./scripts/stripe-setup.sh --apply # creates prices and updates .env
|
||
./scripts/stripe-setup.sh .env.prod --apply # prod: use prod keys, update .env.prod
|
||
```
|
||
|
||
Then redeploy: `export $(grep -v '^#' .env | xargs) && docker stack deploy -c stack.yml atlas`
|
||
|
||
- **First 10** (FREE_TIER_LIMIT): $0 for 3 months, auto-cancels at end
|
||
- **Next 40** (11–50, YEAR_TIER_LIMIT): $20/year, then $100/month after first year
|
||
- **51+**: $200/month
|
||
|
||
## Stripe Prices to Create
|
||
|
||
In **Stripe Dashboard** → Products → create one product with four prices:
|
||
|
||
1. **$0/month** – recurring monthly, amount 0
|
||
- Used for first 10 signups; subscription is scheduled to cancel in 3 months
|
||
2. **$20/year** – recurring yearly, amount 2000
|
||
3. **$100/month** – recurring monthly, amount 10000
|
||
4. **$200/month** – recurring monthly, amount 20000
|
||
|
||
Copy each price ID (starts with `price_`).
|
||
|
||
## Messaging (env vars)
|
||
|
||
Customize the subscribe page copy without rebuilding:
|
||
|
||
```bash
|
||
LANDING_TAGLINE="Your own workspace, ready in minutes."
|
||
LANDING_FEATURES="Dedicated environment|Secure login|Set up automatically|Cancel anytime"
|
||
```
|
||
|
||
Features use `|` as separator.
|
||
|
||
## Environment Variables
|
||
|
||
```bash
|
||
STRIPE_PRICE_ID_FREE=price_xxx # $0/3mo
|
||
STRIPE_PRICE_ID_YEAR=price_xxx # $20/year
|
||
STRIPE_PRICE_ID_MONTH_100=price_xxx # $100/month
|
||
STRIPE_PRICE_ID_MONTH_200=price_xxx # $200/month
|
||
FREE_TIER_LIMIT=10
|
||
YEAR_TIER_LIMIT=50
|
||
MAX_SIGNUPS=0
|
||
```
|
||
|
||
`STRIPE_PRICE_ID` remains as a fallback if tier-specific prices are not set.
|
||
|
||
## Webhook Events
|
||
|
||
Enable these in **Stripe Dashboard** → Developers → Webhooks:
|
||
|
||
- `checkout.session.completed` – provisions user, schedules free-tier cancel
|
||
- `customer.subscription.deleted` – deprovisions stack
|
||
- `customer.subscription.updated` – status changes
|
||
- `invoice.paid` – migrates $20/year subscriptions to $100/month on renewal
|
||
|
||
## Migration Flow
|
||
|
||
When a customer with a $20/year subscription has their first renewal (after 1 year), the `invoice.paid` webhook switches the subscription to $100/month for the next billing cycle.
|