Search Apps Documentation Source Content File Folder Download Copy Actions Download State String Boolean Number Struct Map Slice Pointer Function Closure Reference Nil Package Type Interface Unknown

subscription source realm

Constants 1

Functions 11

Types 4

type Plan

struct
1type Plan struct {
2	ID            string
3	Name          string
4	PricePerCycle int64
5	CycleBlocks   int64
6	Active        bool
7}
source

type Service

struct
 1type Service struct {
 2	admin         string
 3	plans         map[string]*Plan
 4	subs          map[string]*Subscription
 5	nextPlanSeq   int64
 6	nextSubSeq    int64
 7	currentHeight int64
 8	graceCycles   int64 // missed cycles allowed before suspension
 9	revenue       int64
10}
source

Methods on Service

func Cancel

method on Service
1func (s *Service) Cancel(caller, subID string) int64
source

func CreatePlan

method on Service
1func (s *Service) CreatePlan(caller, name string, pricePerCycle, cycleBlocks int64) (string, bool)
source

func DeactivatePlan

method on Service
1func (s *Service) DeactivatePlan(caller, planID string) bool
source

func GetPlan

method on Service
1func (s *Service) GetPlan(id string) (*Plan, bool)
source

func GetSubscription

method on Service
1func (s *Service) GetSubscription(id string) (*Subscription, bool)
source

func ProcessCycle

method on Service
1func (s *Service) ProcessCycle(subID string) bool
source

ProcessCycle attempts to bill a subscription if its due height has passed.

func Reactivate

method on Service
1func (s *Service) Reactivate(subID string, topUp int64) bool
source

func Revenue

method on Service
1func (s *Service) Revenue() int64
source

func Subscribe

method on Service
1func (s *Service) Subscribe(subscriber, planID string, initialDeposit int64) (string, bool)
source

func Tick

method on Service
1func (s *Service) Tick(height int64)
source

func TopUp

method on Service
1func (s *Service) TopUp(subID string, amount int64) bool
source

type Subscription

struct
1type Subscription struct {
2	ID            string
3	Subscriber    string
4	PlanID        string
5	Status        SubStatus
6	NextDueHeight int64
7	MissedCycles  int64
8	Balance       int64 // prepaid credit
9}
source

Source Files 2