18 — Stripe Global Pricing (USD base + adaptive conversion)
Version: 1.7
Last Updated: 2026-05-31 16:24:32
Companion to the Stripe Global Pricing Setup plan. This document is the operational handbook for LynCareOS subscription pricing: how to change prices, rotate keys, turn Adaptive Pricing on or off, and understand where each number comes from.
Module bundles per tier must match 02-REQUIREMENTS.md §2.2 and
backend/billing/tiers.json— not marketing copy alone.
Audience: The operator/founder. No prior Stripe knowledge assumed.
Companion docs:
- 17-HARDENING-SCALE-RUNBOOK.md — day-2 ops for the surrounding infrastructure.
backend/billing/tiers.json— the single source of truth.backend/scripts/stripe_seed_tiers.py— propagates tiers.json to Stripe + the database.backend/scripts/stripe_archive_non_tier_catalog.py— archives non-tier Stripe Products (modules, packs, add-ons) when trimming the live catalog.
1a. Live catalog scope (tier plans only)
Section titled “1a. Live catalog scope (tier plans only)”As of 2026-05-27, production Stripe live mode sells only the three annual subscription tiers. Each tier has seven active Prices:
| Currency | Role |
|---|---|
| USD | Base price from tiers.json → usd |
| AUD, NZD, GBP, EUR, CAD, INR | Fixed local prices from tiers.json → local_prices |
Not in the live Stripe catalog (deferred until product packaging is finalised):
- À la carte module monthly subscriptions (
stripe_seed_module_prices) - Condition pack one-time purchases (
stripe_seed_condition_packs) - Extra care recipient add-on
The app enforces this in production via BILLING_TIER_PLANS_ONLY (defaults
to true when ENVIRONMENT=production). Add-on purchase API endpoints return
503; the Subscriptions admin page shows plan upgrade and module access
only.
To restore extras later: seed the relevant catalogues, set
BILLING_TIER_PLANS_ONLY=false, redeploy the app image that exposes add-on
UI. See 21-STRIPE-LIVE-SWITCHOVER.md §4.1b.
1. Mental model (read me first)
Section titled “1. Mental model (read me first)”LynCareOS sells three annual subscription tiers:
| Slug | Display name | USD/year | Modules unlocked (from backend/billing/tiers.json) |
|---|---|---|---|
essential | Essential | $39 | medication_dispensing, care_calendar, condition_templates |
professional | Family | $69 | above + prescription_management, sleep_tracking, vitals_tracking, key_contacts, custom_observations, family_help, family_journal, preventive_care |
complete | Complete | $99 | above + shopping, pain_tracking, care_observations, goals_of_care, clinical_episodes, patient_voice, and all specialty observation modules |
care_servicesis not intiers.json(legacy subscription rows only). See 02-REQUIREMENTS.md REQ-MOD-03.
All three are priced in USD in Stripe. Customers in other countries see prices in their local currency (AUD, GBP, EUR, NZD, CAD, etc.) because we enable Stripe Adaptive Pricing on the account. Stripe handles the FX and settlement; we never store a second price.
The marketing page (marketing/palliative/index.html) shows a
preview of the local currency next to the USD amount, using a
separate mid-market rate lookup (api.frankfurter.app) so the
customer isn’t surprised on the checkout page. That preview is
cosmetic — the authoritative number is whatever Stripe Checkout
displays.
tiers.json ──► stripe_seed_tiers.py ──► Stripe Products+Prices │ │ │ │ └──► Postgres stripe_tiers table │ └─► GET /api/billing/tiers ──► marketing index.html └─► GET /api/billing/fx (local-currency preview) └─► POST /api/stripe/checkout-session (server resolves price_id)2. What lives where
Section titled “2. What lives where”| Thing | Location | Who edits it |
|---|---|---|
| USD prices + module bundles | backend/billing/tiers.json | You (code review + PR) |
| Stripe Products + Prices | Stripe dashboard (created by seeder) | The seeder script |
| DB mirror (price_id ↔ modules) | stripe_tiers + stripe_tier_local_prices | The seeder script |
| Grandfathered price fallback | Stripe Price metadata lyncareos_tier → tier modules | stripe_service.lookup_modules_for_price (2026-05-30) |
| Product delivery (UX only) | backend/billing/module_delivery.json | You — keep aligned with app + marketing register (e.g. clinical_anatomy = planned, not billable until added to tiers.json) |
| Secret key | STRIPE_SECRET_KEY env var | You (Stripe dashboard) |
| Publishable key | STRIPE_PUBLISHABLE_KEY env var | You (Stripe dashboard) |
| Webhook signing secret | STRIPE_WEBHOOK_SECRET env var | Seeder registers endpoint; Stripe dashboard displays secret |
| Adaptive Pricing toggle | Stripe dashboard → Settings → Currencies | You (one-click) |
| Local-currency preview rates | api.frankfurter.app (free ECB) | Nobody — it just works |
3. The daily workflow
Section titled “3. The daily workflow”3.1 Change a price
Section titled “3.1 Change a price”All prices — USD and local currencies — live in one file:
backend/billing/tiers.json
| Field | What it controls |
|---|---|
usd | Base price charged by Stripe (all markets unless a local_prices entry exists) |
local_prices.AUD | Fixed AUD price shown on the marketing page and charged by Stripe at checkout |
local_prices.GBP | Same for GBP, and so on for NZD, EUR, CAD, INR |
To update any price:
-
Edit
backend/billing/tiers.json— changeusdand/or anylocal_pricesvalues. -
Update the static fallback prices in
marketing/palliative/index.htmlif the USD amounts changed (search fordata-tier-primary— three spans near line 1050). These are only shown for a split second before the API responds, but keep them in sync. -
Commit and push (code review + PR as usual).
-
On the server, run the seeder inside the backend container:
Terminal window docker compose exec backend python -m scripts.stripe_seed_tiersOutput looks like:
[seed] tier=essential usd=39 → product=prod_... price=price_... (active)[seed] tier=professional usd=69 → ...[seed] tier=complete usd=99 → ...[seed] webhook endpoint registered: we_... -
Redeploy the marketing page to Cloudflare Pages:
Terminal window npx wrangler pages deploy marketing/palliative --project-name lyncareos-marketingThe new prices are live immediately —
index.htmlfetches them from/api/billing/tiersat page load.
That’s it. No manual Stripe dashboard changes needed.
3.2 Change which modules a tier unlocks
Section titled “3.2 Change which modules a tier unlocks”Same as 3.1 — edit the modules array in tiers.json and re-run the
seeder. The database stripe_tiers.modules is refreshed, and the next
Stripe webhook for that subscription will provision the new module
list. Existing customers keep their old modules until their next
billing event (renewal, card update, plan change) — if you need to
re-provision immediately for one tenant:
docker compose --env-file .env.production --profile production \ exec app python -m scripts.resync_tenant_subscriptions <tenant_id>Subscriptions on grandfathered Stripe Prices (archived by the seeder but
still renewing) continue to sync: sync_subscription_items reads
metadata.lyncareos_tier on the Price when the price id is no longer in
stripe_tiers. Alternatively, trigger Send test webhook →
customer.subscription.updated for the affected subscription.
3.3 Rotate keys
Section titled “3.3 Rotate keys”Stripe will periodically ask you to rotate the secret and webhook signing keys.
- In the Stripe dashboard create a new secret key (keep the old one active for ~1 hour).
- Update
STRIPE_SECRET_KEYin.envand restart the backend. - Run the seeder again — this verifies the new key works and
re-registers the webhook (which rotates
STRIPE_WEBHOOK_SECRETif Stripe issues a new one). - Revoke the old key in the dashboard.
For the publishable key (STRIPE_PUBLISHABLE_KEY): just update
.env, restart, and hard-refresh the marketing page. It’s safe to
embed — it only lets the browser create payment methods, not charge.
3.4 Move from Test to Live
Section titled “3.4 Move from Test to Live”Operational runbook: the detailed pre-flight, sequential flip, verification, post-flight, and rollback procedure for the production host now lives in 21-STRIPE-LIVE-SWITCHOVER.md. This section is kept as the pricing-model summary of what the flip does at a Stripe-catalogue level. Do not attempt the flip from this doc alone — use doc 21.
At a Stripe-catalogue level, the flip is:
-
In Stripe, toggle the dashboard from Test mode to Live mode.
-
Create three new API keys (secret, publishable). Copy the secret somewhere safe — it’s only shown once.
-
Replace the
sk_test_…/pk_test_…/whsec_…values in your production.env:STRIPE_SECRET_KEY=sk_live_…STRIPE_PUBLISHABLE_KEY=pk_live_…STRIPE_WEBHOOK_SECRET=(leave blank — seeder will register and Stripe will show the new secret in the Webhook settings; paste it in and restart)
-
Restart the backend and run the tier seeder only:
Terminal window docker compose exec app python -m scripts.stripe_seed_tiersIt will create new live Products and Prices (test and live are entirely separate catalogues in Stripe). Do not run
stripe_seed_module_pricesorstripe_seed_condition_packsat launch — see §1a and 21-STRIPE-LIVE-SWITCHOVER.md §3.4. -
Test one full checkout with a real card. Refund yourself.
-
Keep the test keys around in a separate
.env.testfile — you’ll still use them for local development and the CI end-to-end run.
See doc 21 §3 for the exact sequence on the production host (including why
STRIPE_WEBHOOK_SECRET is blanked deliberately between steps 3.2 and
3.5), §4 for how to verify live-mode without breaking live data,
and §6 for rollback.
4. Adaptive Pricing — turn it on, keep it on
Section titled “4. Adaptive Pricing — turn it on, keep it on”Adaptive Pricing is Stripe’s one-click feature that auto-converts your USD price into the customer’s local currency at checkout. Without it, a customer in the UK sees “$39” and their bank does the FX; with it, they see “£31” (or whatever the current Stripe rate is) and their bank sees a GBP charge.
4.1 How to turn it on
Section titled “4.1 How to turn it on”Stripe dashboard → Settings → Currencies → Adaptive Pricing → toggle On. Select the currencies you want to accept (tick at least USD, AUD, GBP, EUR, NZD, CAD for the LynCareOS target markets).
4.2 How to verify it’s working
Section titled “4.2 How to verify it’s working”- Open an incognito window.
- Go to
https://lyncareos.com/(or your test domain). - Use a VPN or Stripe’s test mode country override to appear as GBP.
- Click Subscribe. The hosted Checkout page should show a Price in GBP line with a conversion note.
If it shows USD only, Adaptive Pricing is off or the customer’s country was not ticked.
4.3 How to turn it off (fallback)
Section titled “4.3 How to turn it off (fallback)”Dashboard toggle → Off. All customers see USD and their bank does the FX. The LynCareOS side needs no code change — the marketing page preview still works (it uses its own FX lookup), and checkout still uses the same USD price.
5. The local-currency preview on the marketing page
Section titled “5. The local-currency preview on the marketing page”5.1 Where the number comes from
Section titled “5.1 Where the number comes from”The marketing page shows a local-currency price using fixed prices defined
in tiers.json — not a live FX conversion.
tiers.json → local_prices[currency] → displayed on marketing pagetiers.json → usd → fallback when no local_prices entryIf a visitor’s detected currency (e.g. AUD) has a matching entry in
local_prices, that fixed amount is displayed. Otherwise the USD price
is shown and Stripe Adaptive Pricing handles the conversion at checkout.
5.2 Which currency the browser picks
Section titled “5.2 Which currency the browser picks”- Calls
https://ipapi.co/json/(geo-IP) to detect the visitor’s country and map it to a currency code (AU → AUD, GB → GBP, etc.). - Falls back to
https://ipapi.co/currency/if the JSON call fails. - Falls back to browser locale detection (
Intl.DateTimeFormat). - If all fail, shows USD.
5.3 Adding a new local currency
Section titled “5.3 Adding a new local currency”- Add the currency code and amount to
local_pricesintiers.jsonfor all three tiers. - Run the seeder (see §3.1).
- Redeploy the marketing page.
- Verify: use a VPN or browser locale override to appear in that country.
6. Troubleshooting
Section titled “6. Troubleshooting”“Tier not available yet” on the marketing page
Section titled ““Tier not available yet” on the marketing page”Cause: you deployed new code but forgot to run the seeder, so
stripe_tiers.stripe_price_id is still NULL.
Fix:
docker compose exec backend python -m scripts.stripe_seed_tiersCheckout returns 400 Unknown or unseeded tier
Section titled “Checkout returns 400 Unknown or unseeded tier”Same cause as above — the tier slug in the POST body doesn’t match
any row in stripe_tiers where active = TRUE. Either the seeder
hasn’t run, or you misspelled the slug in tiers.json.
Webhook shows a red dot in the Stripe dashboard
Section titled “Webhook shows a red dot in the Stripe dashboard”Open the failing event → Response tab. If it’s a 400 Invalid webhook signature, STRIPE_WEBHOOK_SECRET is wrong — copy
it again from Developers → Webhooks → Signing secret and restart
the backend.
Customers see “$39” instead of their local currency
Section titled “Customers see “$39” instead of their local currency”Either:
- Their country’s currency isn’t in
local_pricesintiers.json— add it and redeploy (see §3.1). - Stripe Adaptive Pricing is off for that currency — see §4.
A customer disputes the FX rate
Section titled “A customer disputes the FX rate”We don’t set the rate — Stripe does. Point them at Stripe’s Adaptive Pricing documentation and to their card issuer for the exact GBP → USD conversion on the settlement side.
The seeder fails mid-way and prices are inconsistent
Section titled “The seeder fails mid-way and prices are inconsistent”The seeder is idempotent — run it again. It will pick up where it left off: existing products are reused, old prices are archived, new prices are created only where the USD amount changed.
7. Security notes
Section titled “7. Security notes”7.1 Identity encryption at checkout (B4)
Section titled “7.1 Identity encryption at checkout (B4)”After checkout.session.completed, services/stripe_provisioning.py writes encrypted identity fields only — not plaintext users.email or tenants.name (removed in V091). Signup and upgrade paths set users.email_enc, users.email_idx, users.enc_version = 1, and tenants.name_enc, tenants.enc_version = 1 using encrypt_field() / email_blind_index(). Invited carers use the same pattern via /api/auth/register (see 21-STRIPE-LIVE-SWITCHOVER.md §2.5).
Before the first live Checkout in production, complete PHI backfill and V090–V091 per [04 - OPERATIONS/11-DATABASE-SAFETY-AND-MIGRATIONS.md §5](../04 - OPERATIONS/11-DATABASE-SAFETY-AND-MIGRATIONS.md).
- Never commit real keys.
backend/.env.examplehas only placeholders. Production.envlives on the server, not in git. - The publishable key is safe to expose; the secret key is not.
The marketing page only receives the publishable key from
GET /api/billing/tiers. - The checkout-session endpoint is unauthenticated by design (the tenant doesn’t exist yet) but rate-limited at 10/minute per IP.
- Price manipulation is impossible from the client: the body accepts
a
tier_slug, and the server looks up the activestripe_price_idfromstripe_tiers. Even if an attacker sends{"tier_slug": "essential", "price_ids": ["price_someone_elses"]}thetier_slugpath takes precedence.
8. Reference — environment variables
Section titled “8. Reference — environment variables”| Variable | Required | Description |
|---|---|---|
STRIPE_SECRET_KEY | ✅ | sk_test_… or sk_live_…. Server-side only. |
STRIPE_PUBLISHABLE_KEY | ✅ | pk_test_… or pk_live_…. Served to the marketing page. |
STRIPE_WEBHOOK_SECRET | ✅ | whsec_…. Set after first seeder run. |
STRIPE_BILLING_PORTAL_RETURN_URL | optional | Where Billing Portal sends the user after “Return to app”. |
APP_PUBLIC_URL | ✅ | Used to build Checkout success_url / cancel_url. |
BILLING_TIER_PLANS_ONLY | optional | When true, only tier checkout/upgrades are offered (production default). |
REDIS_URL | ✅ | Caches tiers.json payload and FX rates for the marketing page. |
9. Checklists
Section titled “9. Checklists”9.1 First-time setup
Section titled “9.1 First-time setup”- Create Stripe account, verify business.
- Enable Adaptive Pricing (Settings → Currencies).
- Copy test keys into
.env(sk_test_,pk_test_). - Run
docker compose exec backend python -m scripts.stripe_seed_tiers. - Copy the
whsec_signing secret from the webhook registration output intoSTRIPE_WEBHOOK_SECRETand restart. - Hit
GET /api/billing/tiersand confirm all three tiers carrystripe_price_id. - Do one full test checkout with card
4242 4242 4242 4242. - Verify the tenant was provisioned (
SELECT id, enc_version, name_enc IS NOT NULL AS has_name_enc FROM tenants WHERE stripe_customer_id = '<id>'). - Verify the owner user has encrypted email (
SELECT enc_version, email_idx IS NOT NULL FROM users WHERE id = <owner_id>). - Verify the correct modules were unlocked (
SELECT module FROM subscriptions WHERE tenant_id = …).
9.2 Going live
Section titled “9.2 Going live”- Regenerate keys in live mode.
- Update
.envon the production server. - Run
stripe_seed_tiersonly against production (not module/pack seeders). - Paste the live
whsec_into.envand restart. - Confirm Stripe dashboard → Products shows 3 active tier Products only.
- If extras were accidentally seeded earlier, run
stripe_archive_non_tier_catalog(dry-run first). - Real-card checkout → refund.
- Bookmark the Stripe dashboard and this document.
Last updated: tier-plans-only live catalog scope (2026-05-27). Keep this
document in sync with any change to tiers.json, the seeder, or the billing
router.