Documentation
¶
Overview ¶
Package promo is the platform PLAN promo — the admin-controlled "50% off for a limited time" offer, composed on the existing Promotion model (NOT a parallel model) so the discount that a customer sees on GET /v1/billing/plans is SuperAdmin-configured, never hardcoded in the catalog.
It is a SINGLETON: one platform-wide plan promo, stored as one Promotion in the reserved platform ("admin") namespace, so the public plans endpoint can surface it without a per-org lookup and the SuperAdmin edits it in one place. percentOff + the applicable plan slugs ride the Promotion's Metadata; the window is the Promotion's StartsAt/EndsAt; `active` is its Status. This is the canonical {percentOff, start, end, plans, active} shape (openapi admin Promo).
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetPromo ¶
GetPromo returns the current platform plan promo (SuperAdmin only). When none is configured it returns a zeroed, inactive promo so the admin UI always has a shape to edit.
GET /v1/platform/promo
func PutPromo ¶
PutPromo upserts the singleton platform plan promo (SuperAdmin only). percentOff is clamped to (0,100]; the window/plans/active are stored on the one Promotion.
PUT /v1/platform/promo
func Route ¶
Route mounts the SuperAdmin plan-promo surface at /v1/platform/promo. Like the metrics god-view the route-level token gate is a NO-OP on the IAM path, so each handler re-enforces RequirePlatformAdmin — the real boundary. cloud's /v1/admin/promos (core.Guard) proxies here with the service token.
Types ¶
type Promo ¶
type Promo struct {
PercentOff int `json:"percentOff"`
Start *time.Time `json:"start,omitempty"`
End *time.Time `json:"end,omitempty"`
Plans []string `json:"plans"`
Active bool `json:"active"`
}
Promo is the canonical wire shape: percentOff (whole percent 1..100), the UTC window [start,end], the applicable plan slugs (empty = ALL paid plans), and whether it is active. It maps 1:1 to the openapi admin Promo type.
func Active ¶
Active reports the platform plan promo IF it is active AND within its UTC window right now, else nil. This is the ONE gate both the plans view and any pricing path share, so a promo that is drafted or expired never discounts. Reads the reserved platform namespace so the public (org-less) plans endpoint resolves it.