subscription

package
v0.8.6 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2023 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SyncDelay = time.Second * 60
)

Variables

View Source
var (
	ErrNotFound      = errors.New("subscription not found")
	ErrInvalidUUID   = errors.New("invalid syntax of uuid")
	ErrInvalidID     = errors.New("invalid subscription id")
	ErrInvalidDetail = errors.New("invalid subscription detail")
)

Functions

This section is empty.

Types

type CustomerService

type CustomerService interface {
	GetByID(ctx context.Context, id string) (customer.Customer, error)
	List(ctx context.Context, filter customer.Filter) ([]customer.Customer, error)
}

type Filter

type Filter struct {
	CustomerID string
	State      string
}

type PlanService

type PlanService interface {
	List(ctx context.Context, filter plan.Filter) ([]plan.Plan, error)
	GetByID(ctx context.Context, id string) (plan.Plan, error)
}

type Repository

type Repository interface {
	GetByID(ctx context.Context, id string) (Subscription, error)
	Create(ctx context.Context, subs Subscription) (Subscription, error)
	UpdateByID(ctx context.Context, subs Subscription) (Subscription, error)
	List(ctx context.Context, filter Filter) ([]Subscription, error)
	GetByProviderID(ctx context.Context, id string) (Subscription, error)
}

type Service

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

func NewService

func NewService(stripeClient *client.API, repository Repository,
	customerService CustomerService, planService PlanService) *Service

func (*Service) Cancel

func (s *Service) Cancel(ctx context.Context, id string) (Subscription, error)

func (*Service) Close

func (s *Service) Close() error

func (*Service) Create

func (s *Service) Create(ctx context.Context, sub Subscription) (Subscription, error)

func (*Service) GetByID

func (s *Service) GetByID(ctx context.Context, id string) (Subscription, error)

func (*Service) GetByProviderID

func (s *Service) GetByProviderID(ctx context.Context, id string) (Subscription, error)

func (*Service) Init

func (s *Service) Init(ctx context.Context)

func (*Service) List

func (s *Service) List(ctx context.Context, filter Filter) ([]Subscription, error)

func (*Service) SyncWithProvider

func (s *Service) SyncWithProvider(ctx context.Context, customerID string) error

SyncWithProvider syncs the subscription state with the billing provider

type State

type State string
const (
	StateActive State = "active"
)

type Subscription

type Subscription struct {
	ID         string
	ProviderID string // identifier set by the billing engine provider
	CustomerID string
	PlanID     string

	TrialDays int
	State     string

	Metadata metadata.Metadata

	CreatedAt  time.Time
	UpdatedAt  time.Time
	CanceledAt time.Time
	DeletedAt  time.Time
	EndedAt    time.Time
}

Jump to

Keyboard shortcuts

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