The Dashboard reads QTO from /subscription but programme/cashflow from
/feature-access, which still computed can_create/limit by hand and so ignored
the one-time free project — those two tools showed 0/0 and "Subscribe" while QTO
showed 0/1. /feature-access now derives entitlement from project_entitlement
(same source as QTO) and exposes free_projects, so all three tools grant the
free first project. Verified for a real new user: limit 1, can_create true on
programme and cashflow.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
feat(billing): free first project per tool, retire Starter tier (3 tiers)
Three product changes requested:
1. Free first project per tool on sign-up. Every new (unsubscribed) user now
gets ONE free project per tool for their whole lifetime, before subscribing.
utils/usage.py: added lifetime_usage() and a free-project branch in
project_entitlement (free_base=1 when base==0 and not admin). billing.py now
derives can_create / project_limit from project_entitlement (single source of
truth) and exposes free_projects.
2. Retired the 50 AED Starter tier -> only 3 paid tiers remain (Professional,
Business, Studio). plans_catalog now excludes tier 1, and /checkout rejects
tier 1 with a 400. PLANS[1] is kept only so existing Starter subs still resolve.
3. Landing / About / Dashboard copy: "1st month (2 projects) free" -> "Start your
1st project for free"; free card shows "Your 1st project free / per tool";
paid cards relabelled TIER 1-3; Dashboard start-bar now shows the create form
to users who still have their free project and only p…
chore: enable qto.* logging + log the payment-sync best-effort blocks
Nothing configured the app loggers, so every diagnostic added across the code
was being dropped. Set the qto logger to INFO and replace the two silent
except:pass around billing reconciliation with logged exceptions. Behavior is
unchanged (still best-effort); failures are now visible.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
diag: log checkout failures and surface the reason in the 502 detail
The checkout fallback swallowed the real exception, so a misconfigured product
id just showed a generic 'try again' with no clue. Now the exception is logged
and its type/message is included in the 502 detail for faster diagnosis. Also
re-raise HTTPException so it isn't masked.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Two payment-correctness fixes:
1) Add-ons are now ONE-TIME. Previously the extra-project allowance was added
permanently to the monthly limit, so buying one add-on granted +1 project
EVERY month forever. Now the monthly tier quota resets monthly, and each
add-on credit is consumed only when creating a project beyond that quota
(settle_project_creation + consume_extra_project). check_limit/billing expose
a single can_create gate; the dashboard uses it instead of used>=limit.
2) The checkout fallback used to INSERT a free 'manual' active subscription (or
grant a free credit) whenever create_checkout_session raised. On a transient
Dodo error this silently gave users paid plans they never bought (e.g. a
phantom tier-2 Work Programme = 4 projects). Now, when Dodo is configured,
the failure returns 502 instead of granting anything; the mock path only
runs locally when no Dodo key exists.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
fix: reconcile add-ons on dashboard load, not only via /activate
The app runs inside an iframe (qshub.online embeds the HF Space), so the
post-payment ?payment_success redirect never reaches the embedded app and
POST /api/billing/activate is never called. Subscriptions still activated
because /subscription auto-syncs on every load, but add-ons were only granted
in force_activate — so a bought extra project never reflected.
Call sync_user_addons from /subscription (runs once per dashboard load and
grants add-ons for all tools in one pass), so extra projects reconcile without
depending on the redirect or the webhook.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Subscriptions and add-ons now activate synchronously on return from checkout
instead of depending on webhooks that were failing silently.
- payments.py: resolve Dodo base URL from API-key prefix (kills test/live env
mismatch); deterministic product_id -> (feature, tier) map; synchronous
force_activate (subscriptions via /subscriptions, add-ons via /payments) with
idempotent grants; log instead of silent except:pass.
- billing.py: new POST /activate endpoint; per-tool extra-project allowance via
extra_projects_for(); feature-access "used" now matches the creation gate;
fix missing safe_execute import.
- usage.py: check_limit uses per-tool add-on column for all tools, not just qto.
- features.py: FEATURE_EXTRA_COL + extra_projects_for() helper.
- Dashboard.jsx: call /activate on payment return (retries, add-on aware);
add-on buttons now buy the correct per-tool add-on instead of a tier-1 sub.
- .env.example: document all 15 products (3 tools x 4 tiers + 1 add-on).
Co-Author…
fix: auto-sync on Dashboard load + fix programme/cashflow subscribe buttons (wrong tier param) + add payment success banner on Dashboard