Documentation ¶
Index ¶
- Variables
- type BillingScheme
- type Feature
- type Filter
- type Price
- type PriceRepository
- type PriceTierMode
- type PriceUsageType
- type Repository
- type Service
- func (s *Service) AddPlan(ctx context.Context, planID string, featureOb Feature) error
- func (s *Service) Create(ctx context.Context, feature Feature) (Feature, error)
- func (s *Service) CreatePrice(ctx context.Context, price Price) (Price, error)
- func (s *Service) GetByID(ctx context.Context, id string) (Feature, error)
- func (s *Service) GetPriceByFeatureID(ctx context.Context, id string) ([]Price, error)
- func (s *Service) GetPriceByID(ctx context.Context, id string) (Price, error)
- func (s *Service) List(ctx context.Context, flt Filter) ([]Feature, error)
- func (s *Service) Update(ctx context.Context, feature Feature) (Feature, error)
- func (s *Service) UpdatePrice(ctx context.Context, price Price) (Price, error)
- type Tier
Constants ¶
This section is empty.
Variables ¶
Functions ¶
This section is empty.
Types ¶
type BillingScheme ¶
type BillingScheme string
const ( BillingSchemeFlat BillingScheme = "flat" BillingSchemeTiered BillingScheme = "tiered" )
func BuildBillingScheme ¶
func BuildBillingScheme(s string) BillingScheme
func (BillingScheme) ToStripe ¶
func (b BillingScheme) ToStripe() string
type Feature ¶
type Feature struct { ID string `json:"id" yaml:"id"` ProviderID string `json:"provider_id" yaml:"provider_id"` // in case of stripe, provider id and id are same PlanIDs []string // plans this feature belongs to, this is optional and can be empty Name string `json:"name" yaml:"name"` // a machine friendly name for the feature Title string `json:"title" yaml:"title"` // a human friendly title for the feature Description string `json:"description" yaml:"description"` // CreditAmount is amount of credits that are awarded/consumed when buying/using this feature CreditAmount int64 `json:"credit_amount" yaml:"credit_amount"` // Prices for the feature, return only, should not be set when creating a feature Prices []Price `json:"prices" yaml:"prices"` State string `json:"state" yaml:"state"` Metadata metadata.Metadata `json:"metadata" yaml:"metadata"` CreatedAt time.Time UpdatedAt time.Time DeletedAt *time.Time }
Feature is a product feature and has a corresponding product in the billing engine
type Price ¶
type Price struct { ID string `json:"id" yaml:"id"` FeatureID string `json:"feature_id" yaml:"feature_id"` ProviderID string `json:"provider_id" yaml:"provider_id"` Name string `json:"name" yaml:"name"` // a machine friendly name for the price // BillingScheme specifies the billing scheme for the price // known schemes are "tiered" and "flat". Default is "flat" BillingScheme BillingScheme `json:"billing_scheme" yaml:"billing_scheme" default:"flat"` // Currency Three-letter ISO 4217 currency code in lower case // like "usd", "eur", "gbp" // https://www.six-group.com/en/products-services/financial-information/data-standards.html Currency string `json:"currency" yaml:"currency" default:"usd"` // Amount price in the minor currency unit // Minor unit is the smallest unit of a currency, e.g. 1 dollar equals 100 cents (with 2 decimals). Amount int64 `json:"amount" yaml:"amount"` // UsageType specifies the usage type for the price // known types are "licensed" and "metered". Default is "licensed" UsageType PriceUsageType `json:"usage_type" yaml:"usage_type" default:"licensed"` // MeteredAggregate specifies the aggregation method for the price // known aggregations are "sum", "last_during_period" and "max". Default is "sum" MeteredAggregate string `json:"metered_aggregate" yaml:"metered_aggregate" default:"sum"` // Interval is the interval at which the plan is billed // e.g. day, week, month, year Interval string `json:"interval" yaml:"interval"` Metadata metadata.Metadata `json:"metadata" yaml:"metadata"` // TierMode specifies the tier mode for the price // known modes are "graduated" and "volume". Default is "graduated" // In volume-based, the maximum quantity within a period determines the per-unit price // In graduated, pricing changes as the quantity increases to specific thresholds TierMode string `json:"tier_mode" yaml:"tier_mode" default:"graduated"` // Tiers specifies the optional tiers for the price // only applicable when BillingScheme is "tiered" Tiers []Tier `json:"tiers" yaml:"tiers"` State string `json:"state" yaml:"state"` CreatedAt time.Time UpdatedAt time.Time DeletedAt *time.Time }
Price is a product price and has a corresponding price in the billing engine when creating a price, the feature must already exist when subscribing to a plan, the price must already exist
type PriceRepository ¶
type PriceRepository interface { GetByID(ctx context.Context, id string) (Price, error) GetByName(ctx context.Context, name string) (Price, error) Create(ctx context.Context, price Price) (Price, error) UpdateByID(ctx context.Context, price Price) (Price, error) List(ctx context.Context, flt Filter) ([]Price, error) }
type PriceTierMode ¶
type PriceTierMode string
const ( PriceTierModeGraduated PriceTierMode = "graduated" PriceTierModeVolume PriceTierMode = "volume" )
type PriceUsageType ¶
type PriceUsageType string
const ( PriceUsageTypeLicensed PriceUsageType = "licensed" PriceUsageTypeMetered PriceUsageType = "metered" )
func BuildPriceUsageType ¶
func BuildPriceUsageType(s string) PriceUsageType
func (PriceUsageType) ToStripe ¶
func (p PriceUsageType) ToStripe() string
type Repository ¶
type Repository interface { GetByID(ctx context.Context, id string) (Feature, error) GetByName(ctx context.Context, name string) (Feature, error) Create(ctx context.Context, feature Feature) (Feature, error) UpdateByName(ctx context.Context, feature Feature) (Feature, error) List(ctx context.Context, flt Filter) ([]Feature, error) }
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
func NewService ¶
func NewService(stripeClient *client.API, repository Repository, priceRepository PriceRepository) *Service
func (*Service) CreatePrice ¶
func (*Service) GetPriceByFeatureID ¶
func (*Service) GetPriceByID ¶
Click to show internal directories.
Click to hide internal directories.