Documentation
¶
Index ¶
- Constants
- Variables
- type Client
- func (c *Client) ListOrgs(ctx context.Context) ([]Org, error)
- func (c *Client) Live() bool
- func (c *Client) LookupPhases(ctx context.Context, org string) (ps []Phase, err error)
- func (c *Client) LookupUsage(ctx context.Context, org string) ([]Usage, error)
- func (c *Client) Pull(ctx context.Context, limit int) ([]Feature, error)
- func (c *Client) Push(ctx context.Context, fs []Feature, cb func(f Feature, err error))
- func (c *Client) ReportUsage(ctx context.Context, org, feature string, use Report) error
- func (c *Client) Subscribe(ctx context.Context, org string, phases []Phase) (err error)
- func (c *Client) SubscribeTo(ctx context.Context, org string, fs []Feature) error
- func (c *Client) SubscribeToPlan(ctx context.Context, org, plan string) error
- func (c *Client) WhoIs(ctx context.Context, org string) (id string, err error)
- type Feature
- type Org
- type Phase
- type Report
- type Tier
- type Usage
Constants ¶
View Source
const Inf = 1<<63 - 1
Variables ¶
View Source
var ( ErrFeatureExists = errors.New("feature already exists") ErrFeatureNotFound = errors.New("feature not found") )
Errors
View Source
var (
ErrOrgNotFound = errors.New("org not found")
)
Errors
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct { Logf func(format string, args ...any) Stripe *stripe.Client Clock string // contains filtered or unexported fields }
func (*Client) LookupPhases ¶
func (*Client) LookupUsage ¶
func (*Client) Push ¶
Push pushes each feature in fs to Stripe as a product and price combination. A new price and product are created in Stripe if one does not already exist.
Each call to push is subject to rate limiting via the clients shared rate limit.
func (*Client) ReportUsage ¶
func (*Client) SubscribeTo ¶
SubscribeTo subscribes org to the provided features. If a subscription has already begun, the current phase will be updated; otherwise a new subscription will be created and go into effect immediatly.
func (*Client) SubscribeToPlan ¶
type Feature ¶
type Feature struct { ProviderID string // identifier set by the billing engine provider Plan string // the plan ID prefixed with ("plan:") PlanTitle string // a human readable title for the plan Name string // the feature name prefixed with ("feature:") Title string // a human readable title for the feature // Interval specifies the billing interval for the feature. // // Known intervals are "@daily", "@weekly", "@monthly", and "@yearly". Interval string // Currency is the ISO 4217 currency code for the feature. // // Known currencies look like "usd", "eur", "gbp", "cad", "aud", "jpy", "chf", // etc. Please see your billing engine provider for a complete list. Currency string // Base is the base price for the feature. If Tiers is not empty, then Base // is ignored. Base int // Mode specifies the billing mode for use with Tiers. // // Known modes are "graduated" and "volume". Mode string // Aggregate specifies the usage aggregation method for use with Tiers. // // Known aggregates are "sum", "max", "last", and "perpetual". Aggregate string // Tiers optionally specifies the pricing tiers for this feature. If // empty, feature is billed at the beginning of each billing period at // the flat rate specified by Base. If non-empty, the feature is billed // at the end of each billing period based on usage, and at a price // determined by Tiers, Mode, and Aggregate. Tiers []Tier // ReportID is the ID for reporting usage to the billing provider. ReportID string }
Feature holds identifying, pricing, and billing information for a feature.
Click to show internal directories.
Click to hide internal directories.