subscription

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Aug 5, 2026 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Overview

Package subscription registers the `safedep subscription` domain: the tenant's plan and access lifecycle - status, free trial, paid subscription, on-demand (overage) billing, and the billing portal. It is named for the user's intent (plan/access), not the billing mechanism; low-level billing detail (invoices, payment methods) is delegated to the provider portal.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Register

func Register(root *cobra.Command, a *app.App)

Register wires the subscription command tree onto root.

Types

type AccountStatus

type AccountStatus struct {
	Status       string
	Tier         string
	Trial        *TrialInfo // set only when in an active trial
	Entitlements []string
	OnDemand     *OnDemandState // best-effort; nil if unavailable
}

type CheckoutInput

type CheckoutInput struct {
	Seats      uint32
	SuccessURL string
	CancelURL  string
}

type CheckoutResult

type CheckoutResult struct {
	Outcome      string // checkoutSuccess | checkoutNeeded | checkoutError
	URL          string
	ErrorCode    string
	ErrorMessage string
}

type Customer

type Customer struct {
	ID      string
	Name    string
	Email   string
	Phone   string
	Country string
	State   string
	City    string
	Postal  string
	Line1   string
	Line2   string
	TaxID   string
}

type CustomerCreator

type CustomerCreator interface {
	CreateCustomer(ctx context.Context, in CustomerInput) (*Customer, []ProviderError, error)
}

type CustomerGetter

type CustomerGetter interface {
	// GetCustomer returns the billing customer and whether one exists. A
	// missing customer is (nil, false, nil), not an error.
	GetCustomer(ctx context.Context) (*Customer, bool, error)
}

type CustomerInput

type CustomerInput struct {
	Name    string
	Phone   string
	Country string
	State   string
	City    string
	Postal  string
	Line1   string
	Line2   string
	TaxID   string
}

type FeatureOverage added in v0.4.0

type FeatureOverage struct {
	CapKind        string // "units" | "monetary"
	CapUnits       int64
	UnitPriceMinor int64
	CapAmountMinor int64
	Currency       string
}

type FeatureUsage added in v0.4.0

type FeatureUsage struct {
	FeatureKey        string
	DisplayName       string
	UnitLabel         string
	IncludedLimit     int64 // -1 unlimited, 0 not-available, >0 finite
	Consumed          int64
	Seats             int64
	Tier              string
	PeriodEnd         time.Time
	Provisional       bool // enforcement == PROVISIONAL
	Overage           *FeatureOverage
	OverageUsed       int64
	OverageUsedMinor  int64
	SettlementPending bool // settlement_status == PENDING
}

FeatureUsage is the CLI-side view of one metered feature's usage. Numbers are copied from the API as-is; the CLI performs no billing math.

type OnDemandDisabler

type OnDemandDisabler interface {
	DisableOnDemand(ctx context.Context) (*OnDemandState, error)
}

type OnDemandEnabler

type OnDemandEnabler interface {
	EnableOnDemand(ctx context.Context, terms string) (*OnDemandState, error)
}

type OnDemandState

type OnDemandState struct {
	Enabled             bool
	PaymentMethodOnFile bool
	Posture             string
	Usage               []FeatureUsage
}

type OnDemandStateGetter

type OnDemandStateGetter interface {
	OnDemandState(ctx context.Context) (*OnDemandState, error)
}

type PortalOpener

type PortalOpener interface {
	Portal(ctx context.Context, returnURL string) (string, error)
}

type ProviderError

type ProviderError struct {
	Type    string
	Param   string
	Message string
}

type Service

type Service struct {
	// contains filtered or unexported fields
}

func NewService

func NewService(conn *grpc.ClientConn) *Service

func (*Service) ActivateTrial

func (s *Service) ActivateTrial(ctx context.Context) error

func (*Service) Checkout

func (s *Service) Checkout(ctx context.Context, in CheckoutInput) (*CheckoutResult, error)

func (*Service) CreateCustomer

func (s *Service) CreateCustomer(ctx context.Context, in CustomerInput) (*Customer, []ProviderError, error)

func (*Service) DisableOnDemand

func (s *Service) DisableOnDemand(ctx context.Context) (*OnDemandState, error)

func (*Service) EnableOnDemand

func (s *Service) EnableOnDemand(ctx context.Context, terms string) (*OnDemandState, error)

func (*Service) GetCustomer

func (s *Service) GetCustomer(ctx context.Context) (*Customer, bool, error)

func (*Service) OnDemandState

func (s *Service) OnDemandState(ctx context.Context) (*OnDemandState, error)

func (*Service) Portal

func (s *Service) Portal(ctx context.Context, returnURL string) (string, error)

func (*Service) Status

func (s *Service) Status(ctx context.Context) (*AccountStatus, error)

type StatusGetter

type StatusGetter interface {
	Status(ctx context.Context) (*AccountStatus, error)
}

type Subscriber

type Subscriber interface {
	Checkout(ctx context.Context, in CheckoutInput) (*CheckoutResult, error)
}

type TrialActivator

type TrialActivator interface {
	ActivateTrial(ctx context.Context) error
}

type TrialInfo

type TrialInfo struct {
	DaysRemaining int32
	ExpiresAt     time.Time
}

Jump to

Keyboard shortcuts

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