Skip to content

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.

As of 2026-05-27, production Stripe live mode sells only the three annual subscription tiers. Each tier has seven active Prices:

CurrencyRole
USDBase price from tiers.json → usd
AUD, NZD, GBP, EUR, CAD, INRFixed 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.


LynCareOS sells three annual subscription tiers:

SlugDisplay nameUSD/yearModules unlocked (from backend/billing/tiers.json)
essentialEssential$39medication_dispensing, care_calendar, condition_templates
professionalFamily$69above + prescription_management, sleep_tracking, vitals_tracking, key_contacts, custom_observations, family_help, family_journal, preventive_care
completeComplete$99above + shopping, pain_tracking, care_observations, goals_of_care, clinical_episodes, patient_voice, and all specialty observation modules

care_services is not in tiers.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)

ThingLocationWho edits it
USD prices + module bundlesbackend/billing/tiers.jsonYou (code review + PR)
Stripe Products + PricesStripe dashboard (created by seeder)The seeder script
DB mirror (price_id ↔ modules)stripe_tiers + stripe_tier_local_pricesThe seeder script
Grandfathered price fallbackStripe Price metadata lyncareos_tier → tier modulesstripe_service.lookup_modules_for_price (2026-05-30)
Product delivery (UX only)backend/billing/module_delivery.jsonYou — keep aligned with app + marketing register (e.g. clinical_anatomy = planned, not billable until added to tiers.json)
Secret keySTRIPE_SECRET_KEY env varYou (Stripe dashboard)
Publishable keySTRIPE_PUBLISHABLE_KEY env varYou (Stripe dashboard)
Webhook signing secretSTRIPE_WEBHOOK_SECRET env varSeeder registers endpoint; Stripe dashboard displays secret
Adaptive Pricing toggleStripe dashboard → Settings → CurrenciesYou (one-click)
Local-currency preview ratesapi.frankfurter.app (free ECB)Nobody — it just works

All prices — USD and local currencies — live in one file: backend/billing/tiers.json

FieldWhat it controls
usdBase price charged by Stripe (all markets unless a local_prices entry exists)
local_prices.AUDFixed AUD price shown on the marketing page and charged by Stripe at checkout
local_prices.GBPSame for GBP, and so on for NZD, EUR, CAD, INR

To update any price:

  1. Edit backend/billing/tiers.json — change usd and/or any local_prices values.

  2. Update the static fallback prices in marketing/palliative/index.html if the USD amounts changed (search for data-tier-primary — three spans near line 1050). These are only shown for a split second before the API responds, but keep them in sync.

  3. Commit and push (code review + PR as usual).

  4. On the server, run the seeder inside the backend container:

    Terminal window
    docker compose exec backend python -m scripts.stripe_seed_tiers

    Output 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_...
  5. Redeploy the marketing page to Cloudflare Pages:

    Terminal window
    npx wrangler pages deploy marketing/palliative --project-name lyncareos-marketing

    The new prices are live immediately — index.html fetches them from /api/billing/tiers at page load.

That’s it. No manual Stripe dashboard changes needed.

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:

Terminal window
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.

Stripe will periodically ask you to rotate the secret and webhook signing keys.

  1. In the Stripe dashboard create a new secret key (keep the old one active for ~1 hour).
  2. Update STRIPE_SECRET_KEY in .env and restart the backend.
  3. Run the seeder again — this verifies the new key works and re-registers the webhook (which rotates STRIPE_WEBHOOK_SECRET if Stripe issues a new one).
  4. 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.

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:

  1. In Stripe, toggle the dashboard from Test mode to Live mode.

  2. Create three new API keys (secret, publishable). Copy the secret somewhere safe — it’s only shown once.

  3. 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)
  4. Restart the backend and run the tier seeder only:

    Terminal window
    docker compose exec app python -m scripts.stripe_seed_tiers

    It will create new live Products and Prices (test and live are entirely separate catalogues in Stripe). Do not run stripe_seed_module_prices or stripe_seed_condition_packs at launch — see §1a and 21-STRIPE-LIVE-SWITCHOVER.md §3.4.

  5. Test one full checkout with a real card. Refund yourself.

  6. Keep the test keys around in a separate .env.test file — 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.

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).

  1. Open an incognito window.
  2. Go to https://lyncareos.com/ (or your test domain).
  3. Use a VPN or Stripe’s test mode country override to appear as GBP.
  4. 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.

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”

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 page
tiers.json → usd → fallback when no local_prices entry

If 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.

  1. 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.).
  2. Falls back to https://ipapi.co/currency/ if the JSON call fails.
  3. Falls back to browser locale detection (Intl.DateTimeFormat).
  4. If all fail, shows USD.
  1. Add the currency code and amount to local_prices in tiers.json for all three tiers.
  2. Run the seeder (see §3.1).
  3. Redeploy the marketing page.
  4. Verify: use a VPN or browser locale override to appear in that country.

“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:

Terminal window
docker compose exec backend python -m scripts.stripe_seed_tiers

Checkout 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_prices in tiers.json — add it and redeploy (see §3.1).
  • Stripe Adaptive Pricing is off for that currency — see §4.

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.


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.example has only placeholders. Production .env lives 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 active stripe_price_id from stripe_tiers. Even if an attacker sends {"tier_slug": "essential", "price_ids": ["price_someone_elses"]} the tier_slug path takes precedence.

VariableRequiredDescription
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_URLoptionalWhere Billing Portal sends the user after “Return to app”.
APP_PUBLIC_URL✅Used to build Checkout success_url / cancel_url.
BILLING_TIER_PLANS_ONLYoptionalWhen true, only tier checkout/upgrades are offered (production default).
REDIS_URL✅Caches tiers.json payload and FX rates for the marketing page.

  • 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 into STRIPE_WEBHOOK_SECRET and restart.
  • Hit GET /api/billing/tiers and confirm all three tiers carry stripe_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 = …).
  • Regenerate keys in live mode.
  • Update .env on the production server.
  • Run stripe_seed_tiers only against production (not module/pack seeders).
  • Paste the live whsec_ into .env and 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.