Phase 2 Task 42: public pricing page gated by SELF_SERVE_ENABLED. Backend: - New `GET /api/v1/plans/public` (no auth) returns plan_billing rows joined with plan_limits.max_users (as `max_seats`), filtered to is_public=true AND is_archived=false, ordered by sort_order ASC, plan ASC. Uses get_admin_db (cross-tenant catalog read, same pattern as /config/public). - `PublicPlanResponse` schema in app/schemas/billing.py. - Registered as PUBLIC in api router. Frontend: - `plansApi.getPublic()` client (frontend/src/api/plans.ts). - `PricingPage` at /pricing with hero / 3 plan cards (Pro recommended, Enterprise hides price) / hardcoded v1 comparison table / testimonial placeholder / soft trust strip. - Reads `useAppConfig().self_serve_enabled`; renders a 404 fallback when disabled, never calls the API in that path. - Start free trial CTAs link to /register?plan=starter|pro; Talk to sales links to /contact-sales (page wired in Task 43). Tests: - Backend: only-public-rows + sort-order ordering. - Frontend (Vitest): three plan cards with API prices, /register?plan=pro CTA, /contact-sales CTA, 404 when self_serve_enabled is false, soft trust language (no SOC2 claim). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
65 lines
1.8 KiB
Python
65 lines
1.8 KiB
Python
from typing import Literal, Optional, Dict, Any
|
|
from datetime import datetime
|
|
from pydantic import BaseModel
|
|
|
|
|
|
class CheckoutSessionCreate(BaseModel):
|
|
plan: Literal["pro", "starter", "team", "enterprise"]
|
|
seats: int
|
|
billing_interval: Literal["monthly", "annual"] = "monthly"
|
|
|
|
|
|
class CheckoutSessionResponse(BaseModel):
|
|
url: str
|
|
|
|
|
|
class BillingPortalSessionResponse(BaseModel):
|
|
url: str
|
|
|
|
|
|
class SubscriptionState(BaseModel):
|
|
status: str
|
|
plan: str
|
|
current_period_start: Optional[datetime]
|
|
current_period_end: Optional[datetime]
|
|
cancel_at_period_end: bool
|
|
seat_limit: Optional[int]
|
|
has_pro_entitlement: bool
|
|
is_paid: bool
|
|
|
|
|
|
class PlanBillingState(BaseModel):
|
|
display_name: str
|
|
description: Optional[str] = None
|
|
monthly_price_cents: Optional[int] = None
|
|
annual_price_cents: Optional[int] = None
|
|
|
|
model_config = {"from_attributes": True}
|
|
|
|
|
|
class BillingStateResponse(BaseModel):
|
|
subscription: SubscriptionState
|
|
plan_billing: Optional[PlanBillingState]
|
|
plan_limits: Dict[str, Any]
|
|
enabled_features: Dict[str, bool]
|
|
|
|
|
|
class PublicPlanResponse(BaseModel):
|
|
"""Public-safe view of a billable plan, used by the marketing /pricing page.
|
|
|
|
Sourced from `plan_billing` joined with `plan_limits.max_users` (exposed
|
|
here as `max_seats`). Always filtered server-side to is_public=True and
|
|
is_archived=False, so `is_public` is a constant True for any row returned
|
|
here — included for clarity and forward compatibility.
|
|
"""
|
|
plan: str
|
|
display_name: str
|
|
description: Optional[str] = None
|
|
monthly_price_cents: Optional[int] = None
|
|
annual_price_cents: Optional[int] = None
|
|
max_seats: Optional[int] = None
|
|
sort_order: int
|
|
is_public: bool = True
|
|
|
|
model_config = {"from_attributes": True}
|