plan

package
v1.9.0 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2026 License: MIT Imports: 3 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Feature

type Feature struct {
	types.Entity
	ID        id.FeatureID      `json:"id"`
	CatalogID id.FeatureID      `json:"catalog_id,omitempty"` // links to standalone catalog feature
	Key       string            `json:"key"`
	Name      string            `json:"name"`
	Type      FeatureType       `json:"type"`
	Limit     int64             `json:"limit"`
	Period    Period            `json:"period"`
	SoftLimit bool              `json:"soft_limit"`
	Metadata  map[string]string `json:"metadata,omitempty"`
}

type FeatureType

type FeatureType string
const (
	FeatureMetered FeatureType = "metered"
	FeatureBoolean FeatureType = "boolean"
	FeatureSeat    FeatureType = "seat"
)

type ListOpts

type ListOpts struct {
	Status Status
	Limit  int
	Offset int
}

type Period

type Period string
const (
	PeriodMonthly Period = "monthly"
	PeriodYearly  Period = "yearly"
	PeriodNone    Period = "none"
)

type Plan

type Plan struct {
	types.Entity
	ID           id.PlanID         `json:"id"`
	Name         string            `json:"name"`
	Slug         string            `json:"slug"`
	Description  string            `json:"description"`
	Currency     string            `json:"currency"`
	Status       Status            `json:"status"`
	TrialDays    int               `json:"trial_days"`
	Features     []Feature         `json:"features"`
	Pricing      *Pricing          `json:"pricing,omitempty"`
	AppID        string            `json:"app_id"`
	ProviderID   string            `json:"provider_id,omitempty"`
	ProviderName string            `json:"provider_name,omitempty"`
	Metadata     map[string]string `json:"metadata,omitempty"`
}

func (*Plan) Allows

func (p *Plan) Allows(featureKey string, currentUsage int64) bool

func (*Plan) FindFeature

func (p *Plan) FindFeature(key string) *Feature

type PriceTier

type PriceTier struct {
	FeatureKey string      `json:"feature_key"`
	Type       TierType    `json:"type"`
	UpTo       int64       `json:"up_to"`
	UnitAmount types.Money `json:"unit_amount"`
	FlatAmount types.Money `json:"flat_amount"`
	Priority   int         `json:"priority"`
}

type Pricing

type Pricing struct {
	types.Entity
	ID            id.PriceID  `json:"id"`
	PlanID        id.PlanID   `json:"plan_id"`
	BaseAmount    types.Money `json:"base_amount"`
	BillingPeriod Period      `json:"billing_period"`
	Tiers         []PriceTier `json:"tiers,omitempty"`
}

type Status

type Status string
const (
	StatusActive   Status = "active"
	StatusArchived Status = "archived"
	StatusDraft    Status = "draft"
)

type Store

type Store interface {
	Create(ctx context.Context, p *Plan) error
	Get(ctx context.Context, planID id.PlanID) (*Plan, error)
	GetBySlug(ctx context.Context, slug string, appID string) (*Plan, error)
	List(ctx context.Context, appID string, opts ListOpts) ([]*Plan, error)
	Update(ctx context.Context, p *Plan) error
	Delete(ctx context.Context, planID id.PlanID) error
	Archive(ctx context.Context, planID id.PlanID) error
}

type TierType

type TierType string
const (
	TierGraduated TierType = "graduated"
	TierVolume    TierType = "volume"
	TierFlat      TierType = "flat"
)

Jump to

Keyboard shortcuts

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