tools/stripe_plans.py (1161 bytes)
1 """Make the Stripe prices of the monthly plans. 2 3 The Stripe customer portal switches a subscription only between prices of the 4 Stripe catalogue. This makes one monthly price, with its product, for each 5 monthly plan in backend/pricing.py. The plan id is the lookup key of the price. 6 It is safe to run again: a plan that has a matching price keeps it. 7 8 # on the server, from the checkout, with the server's settings 9 runuser -u subplz -- .venv/bin/python tools/stripe_plans.py 10 11 Then let the customer portal switch between these prices (Stripe: Settings -> 12 Billing -> Customer portal -> customers can switch plans). 13 """ 14 15 from __future__ import annotations 16 17 import sys 18 from pathlib import Path 19 20 sys.path.insert(0, str(Path(__file__).resolve().parent.parent)) 21 22 from backend import payments # noqa: E402 23 24 25 def main() -> int: 26 try: 27 rows = payments.ensure_plan_prices() 28 except payments.PaymentsUnavailable as exc: 29 print(exc) 30 return 1 31 for plan_id, price_id, made in rows: 32 print(f"{plan_id}: {price_id} ({'made now' if made else 'already there'})") 33 return 0 34 35 36 if __name__ == "__main__": 37 raise SystemExit(main())