Documentation ¶
Index ¶
- Constants
- Variables
- func Email(organization *database.Organization) string
- type Biller
- type Customer
- type Invoice
- type Orb
- func (o *Orb) CancelSubscriptionsForCustomer(ctx context.Context, customerID string, ...) (time.Time, error)
- func (o *Orb) ChangeSubscriptionPlan(ctx context.Context, subscriptionID string, plan *Plan) (*Subscription, error)
- func (o *Orb) CreateCustomer(ctx context.Context, organization *database.Organization, ...) (*Customer, error)
- func (o *Orb) CreateSubscription(ctx context.Context, customerID string, plan *Plan) (*Subscription, error)
- func (o *Orb) DeleteCustomer(ctx context.Context, customerID string) error
- func (o *Orb) FindCustomer(ctx context.Context, customerID string) (*Customer, error)
- func (o *Orb) GetActiveSubscription(ctx context.Context, customerID string) (*Subscription, error)
- func (o *Orb) GetDefaultPlan(ctx context.Context) (*Plan, error)
- func (o *Orb) GetInvoice(ctx context.Context, invoiceID string) (*Invoice, error)
- func (o *Orb) GetPlan(ctx context.Context, id string) (*Plan, error)
- func (o *Orb) GetPlanByName(ctx context.Context, name string) (*Plan, error)
- func (o *Orb) GetPlans(ctx context.Context) ([]*Plan, error)
- func (o *Orb) GetPublicPlans(ctx context.Context) ([]*Plan, error)
- func (o *Orb) GetReportingGranularity() UsageReportingGranularity
- func (o *Orb) GetReportingWorkerCron() string
- func (o *Orb) IsInvoicePaid(ctx context.Context, invoice *Invoice) bool
- func (o *Orb) IsInvoiceValid(ctx context.Context, invoice *Invoice) bool
- func (o *Orb) MarkCustomerTaxExempt(ctx context.Context, customerID string) error
- func (o *Orb) Name() string
- func (o *Orb) ReportUsage(ctx context.Context, usage []*Usage) error
- func (o *Orb) UnmarkCustomerTaxExempt(ctx context.Context, customerID string) error
- func (o *Orb) UnscheduleCancellation(ctx context.Context, subscriptionID string) (*Subscription, error)
- func (o *Orb) UpdateCustomerEmail(ctx context.Context, customerID, email string) error
- func (o *Orb) UpdateCustomerPaymentID(ctx context.Context, customerID string, provider PaymentProvider, ...) error
- func (o *Orb) WebhookHandlerFunc(ctx context.Context, jc jobs.Client) httputil.Handler
- type PaymentProvider
- type Plan
- type PlanType
- type Quotas
- type Subscription
- type SubscriptionCancellationOption
- type Usage
- type UsageReportingGranularity
Constants ¶
View Source
const ( SupportEmail = "support@rilldata.com" DefaultTimeZone = "UTC" )
Variables ¶
View Source
var ErrCustomerIDRequired = errors.New("customer id is required")
View Source
var ErrNotFound = errors.New("not found")
Functions ¶
func Email ¶ added in v0.49.0
func Email(organization *database.Organization) string
Types ¶
type Biller ¶
type Biller interface { Name() string GetDefaultPlan(ctx context.Context) (*Plan, error) GetPlans(ctx context.Context) ([]*Plan, error) // GetPublicPlans for listing purposes GetPublicPlans(ctx context.Context) ([]*Plan, error) // GetPlan returns the plan with the given biller plan ID. GetPlan(ctx context.Context, id string) (*Plan, error) // GetPlanByName returns the plan with the given Rill plan name. GetPlanByName(ctx context.Context, name string) (*Plan, error) // CreateCustomer creates a customer for the given organization in the billing system and returns the external customer ID. CreateCustomer(ctx context.Context, organization *database.Organization, provider PaymentProvider) (*Customer, error) FindCustomer(ctx context.Context, customerID string) (*Customer, error) UpdateCustomerPaymentID(ctx context.Context, customerID string, provider PaymentProvider, paymentProviderID string) error UpdateCustomerEmail(ctx context.Context, customerID, email string) error DeleteCustomer(ctx context.Context, customerID string) error // CreateSubscription creates a subscription for the given organization. Subscription starts immediately. CreateSubscription(ctx context.Context, customerID string, plan *Plan) (*Subscription, error) // GetActiveSubscription returns the active subscription for the given organization GetActiveSubscription(ctx context.Context, customerID string) (*Subscription, error) // CancelSubscriptionsForCustomer cancels all the subscriptions for the given organization and returns the end date of the subscription CancelSubscriptionsForCustomer(ctx context.Context, customerID string, cancelOption SubscriptionCancellationOption) (time.Time, error) // ChangeSubscriptionPlan changes the plan of the given subscription immediately and returns the updated subscription ChangeSubscriptionPlan(ctx context.Context, subscriptionID string, plan *Plan) (*Subscription, error) // UnscheduleCancellation cancels the scheduled cancellation for the given subscription and returns the updated subscription UnscheduleCancellation(ctx context.Context, subscriptionID string) (*Subscription, error) GetInvoice(ctx context.Context, invoiceID string) (*Invoice, error) IsInvoiceValid(ctx context.Context, invoice *Invoice) bool IsInvoicePaid(ctx context.Context, invoice *Invoice) bool MarkCustomerTaxExempt(ctx context.Context, customerID string) error UnmarkCustomerTaxExempt(ctx context.Context, customerID string) error ReportUsage(ctx context.Context, usage []*Usage) error GetReportingGranularity() UsageReportingGranularity GetReportingWorkerCron() string // WebhookHandlerFunc returns a http.HandlerFunc that can be used to handle incoming webhooks from the payment provider. Return nil if you don't want to register any webhook handlers. jobs is used to enqueue jobs for processing the webhook events. WebhookHandlerFunc(ctx context.Context, jobs jobs.Client) httputil.Handler }
type Orb ¶
type Orb struct {
// contains filtered or unexported fields
}
func (*Orb) CancelSubscriptionsForCustomer ¶
func (*Orb) ChangeSubscriptionPlan ¶
func (*Orb) CreateCustomer ¶
func (o *Orb) CreateCustomer(ctx context.Context, organization *database.Organization, provider PaymentProvider) (*Customer, error)
func (*Orb) CreateSubscription ¶
func (*Orb) DeleteCustomer ¶ added in v0.51.0
func (*Orb) FindCustomer ¶ added in v0.48.0
func (*Orb) GetActiveSubscription ¶ added in v0.50.0
func (*Orb) GetInvoice ¶ added in v0.50.0
func (*Orb) GetPlanByName ¶
func (*Orb) GetReportingGranularity ¶
func (o *Orb) GetReportingGranularity() UsageReportingGranularity
func (*Orb) GetReportingWorkerCron ¶
func (*Orb) IsInvoicePaid ¶ added in v0.50.0
func (*Orb) IsInvoiceValid ¶ added in v0.50.0
func (*Orb) MarkCustomerTaxExempt ¶ added in v0.51.0
func (*Orb) UnmarkCustomerTaxExempt ¶ added in v0.51.0
func (*Orb) UnscheduleCancellation ¶ added in v0.50.0
func (*Orb) UpdateCustomerEmail ¶ added in v0.49.0
func (*Orb) UpdateCustomerPaymentID ¶ added in v0.48.0
type PaymentProvider ¶ added in v0.48.0
type PaymentProvider string
const (
PaymentProviderStripe PaymentProvider = "stripe"
)
type Plan ¶
type Plan struct { ID string // ID of the plan in the external billing system Name string // Unique name of the plan in Rill, can be empty if biller does not support it PlanType PlanType DisplayName string Description string TrialPeriodDays int Default bool Public bool Quotas Quotas Metadata map[string]string }
type Subscription ¶
type SubscriptionCancellationOption ¶
type SubscriptionCancellationOption int
const ( SubscriptionCancellationOptionEndOfSubscriptionTerm SubscriptionCancellationOption = iota SubscriptionCancellationOptionImmediate )
type UsageReportingGranularity ¶
type UsageReportingGranularity string
const ( UsageReportingGranularityNone UsageReportingGranularity = "" UsageReportingGranularityHour UsageReportingGranularity = "hour" )
Click to show internal directories.
Click to hide internal directories.