promo

package
v1.49.51 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 3, 2026 License: MIT Imports: 11 Imported by: 0

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

func GetPromo(c *zip.Ctx) error

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

func PutPromo(c *zip.Ctx) error

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

func Route(r zip.Router, args ...zip.Handler)

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

func Active(c *zip.Ctx) *Promo

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.

func (*Promo) AppliesTo

func (p *Promo) AppliesTo(slug string) bool

AppliesTo reports whether the promo discounts a given plan slug: an empty Plans list means ALL plans, otherwise only the listed slugs.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL