Skip to content

Phase 1: billing usage visibility, Stripe portal, tenant-auth binding - #8

Merged
vorflux[bot] merged 1 commit into
mainfrom
vorflux/phase1-billing-tenant-auth
Jul 22, 2026
Merged

Phase 1: billing usage visibility, Stripe portal, tenant-auth binding#8
vorflux[bot] merged 1 commit into
mainfrom
vorflux/phase1-billing-tenant-auth

Conversation

@crewcricle

Copy link
Copy Markdown
Contributor

Billing usage visibility, Stripe Billing Portal, tenant-auth binding, and durable trial email sends.

Changes

  • Tenant-auth binding (C8/D20): new require_client_id dependency derives client_id from JWT identity via user_client_map, never from request input. Strict verify_supabase_jwt_strict rejects with 401 when SUPABASE_JWT_SECRET is unset (no anonymous fallback). Migration 013_user_client_map.sql with RLS service_role_all.
  • GET /billing/usage: returns per-job-type {used, cap, remaining} from TRIAL_CAPS (single source in trial_gate.py). Active subscriptions report unlimited (cap/remaining = null). Handles missing keys (0), missing client (404), cross-tenant rejection.
  • POST /billing/portal: creates Stripe Billing Portal session, parametrized with configuration (not configuration_id), return URL → dashboard settings. Missing customer → 422, Stripe error → 502.
  • Durable trial emails (C4): jobs/trial_emails.py Resend sends now enqueue via arq send_email_task. Idempotency recorded before enqueue, rolled back on enqueue failure (no phantom records blocking future sends).
  • Config/docs: STRIPE_PORTAL_CONFIG_ID and DASHBOARD_URL documented in DEPLOY.md and backend/.env.example.

Testing

Test Command Result
Unit suite (117 tests) cd backend && uv run pytest tests/ -q 117 passed, 2 pre-existing warnings
Phase 1 tests (30 tests) uv run pytest tests/unit/test_{tenant_auth,billing_usage,billing_portal,trial_emails_enqueue}.py -q 30 passed
Migration apply (scratch Postgres) Apply 001013 on fresh postgres:15 All 13 applied cleanly; user_client_map PK, FK, RLS verified

Cross-tenant denial, empty-secret rejection, active-sub unlimited, idempotency rollback all verified in unit tests. Live Stripe portal and real JWT deferred to post-deploy per agreed workflow.

Artifacts


Attached Images

[phase1_test_results.log]


Session Details

  • Session: View Session
  • Requested by: Unknown
  • Address comments on this PR. Add (aside) to your comment to have me ignore it.

@vorflux
vorflux Bot merged commit caa6c08 into main Jul 22, 2026
3 of 4 checks passed
vorflux Bot pushed a commit that referenced this pull request Jul 22, 2026
…uare OAuth, images (#9)

* Phase 3: multi-location bi-directional menu sync, canonical store, Square OAuth, images

* Phase 4: Maps Local Pack rank, competitor structured data, GBP provisioning, Yelp posting (#7)

Co-authored-by: crewcricle <280911048+crewcricle@users.noreply.github.com>

* Phase 1: billing usage visibility, Stripe portal, tenant-auth binding (#8)

Co-authored-by: crewcricle <280911048+crewcricle@users.noreply.github.com>

---------

Co-authored-by: crewcricle <280911048+crewcricle@users.noreply.github.com>
@crewcricle
crewcricle deleted the vorflux/phase1-billing-tenant-auth branch July 26, 2026 13:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant