Documentation
¶
Overview ¶
Package contract wires the subscription plugin's intent surface into the forge-dashboard contract registry. The `/plans` and `/plans/:id` pages stay declared on the auth contributor; only the intent handlers + their declarations move here.
handlers.go: subscription plugin intent handlers. Moved from the auth contributor's handlers_subscriptions.go. The plugin's Service arrives via Deps (set up in plugins/subscription/contract.go) so handlers skip the engine.Plugin("subscription") indirection.
Index ¶
- func Register(d *dispatcher.Dispatcher, reg contract.Registry, wreg contract.WardenRegistry, ...) error
- type ActivatePlanInput
- type ArchivePlanInput
- type Deps
- type GetPlanInput
- type PlanDetail
- type PlanFeature
- type PlanSummary
- type PlansListResponse
- type PriceTierSummary
- type SubscriptionService
- type SubscriptionSummary
- type SubscriptionsListInput
- type SubscriptionsListResponse
- type UsageSummary
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Register ¶
func Register( d *dispatcher.Dispatcher, reg contract.Registry, wreg contract.WardenRegistry, deps Deps, ) error
Types ¶
type ActivatePlanInput ¶
type ActivatePlanInput struct {
ID string `json:"id"`
}
type ArchivePlanInput ¶
type ArchivePlanInput struct {
ID string `json:"id"`
}
type Deps ¶
type Deps struct {
Engine *authsome.Engine
Service SubscriptionService
Usage func(context.Context, string, string) ([]UsageSummary, error)
}
type GetPlanInput ¶
type GetPlanInput struct {
ID string `json:"id"`
}
type PlanDetail ¶
type PlanDetail struct {
PlanSummary
Features []PlanFeature `json:"features,omitempty"`
Tiers []PriceTierSummary `json:"tiers,omitempty"`
}
type PlanFeature ¶
type PlanSummary ¶
type PlanSummary struct {
ID string `json:"id"`
Name string `json:"name"`
Slug string `json:"slug"`
Description string `json:"description,omitempty"`
Currency string `json:"currency,omitempty"`
Status string `json:"status"`
TrialDays int `json:"trialDays,omitempty"`
BaseAmount int64 `json:"baseAmount"`
BillingPeriod string `json:"billingPeriod,omitempty"`
}
type PlansListResponse ¶
type PlansListResponse struct {
Plans []PlanSummary `json:"plans"`
}
type PriceTierSummary ¶
type SubscriptionService ¶
type SubscriptionService interface {
ListPlans(ctx context.Context, appID string) ([]*plan.Plan, error)
GetPlan(ctx context.Context, planID ledgerid.PlanID) (*plan.Plan, error)
CreatePlan(ctx context.Context, p *plan.Plan) error
UpdatePlan(ctx context.Context, p *plan.Plan) error
ArchivePlan(ctx context.Context, planID ledgerid.PlanID) error
ActivatePlan(ctx context.Context, planID ledgerid.PlanID) error
ListSubscriptions(ctx context.Context, tenantID, appID string, opts subscription.ListOpts) ([]*subscription.Subscription, error)
GetSubscription(ctx context.Context, subID ledgerid.SubscriptionID) (*subscription.Subscription, error)
GetActiveSubscription(ctx context.Context, tenantID, appID string) (*subscription.Subscription, error)
Subscribe(ctx context.Context, tenantID string, planID ledgerid.PlanID, appID string) (*subscription.Subscription, error)
ChangePlan(ctx context.Context, subID ledgerid.SubscriptionID, newPlanID ledgerid.PlanID) error
PauseSubscription(ctx context.Context, subID ledgerid.SubscriptionID) error
ResumeSubscription(ctx context.Context, subID ledgerid.SubscriptionID) error
CancelSubscription(ctx context.Context, subID ledgerid.SubscriptionID, immediately bool) error
ListAllInvoices(ctx context.Context, appID string) ([]*invoice.Invoice, error)
ListInvoices(ctx context.Context, tenantID, appID string) ([]*invoice.Invoice, error)
GetInvoice(ctx context.Context, invID ledgerid.InvoiceID) (*invoice.Invoice, error)
GenerateInvoice(ctx context.Context, subID ledgerid.SubscriptionID) (*invoice.Invoice, error)
MarkInvoicePaid(ctx context.Context, invID ledgerid.InvoiceID, paymentRef string) error
MarkInvoiceVoided(ctx context.Context, invID ledgerid.InvoiceID, reason string) error
ListCoupons(ctx context.Context, appID string) ([]*coupon.Coupon, error)
GetCoupon(ctx context.Context, code, appID string) (*coupon.Coupon, error)
CreateCoupon(ctx context.Context, c *coupon.Coupon) error
DeleteCoupon(ctx context.Context, couponID ledgerid.CouponID) error
ListCatalogFeatures(ctx context.Context, appID string) ([]*feature.Feature, error)
GetCatalogFeature(ctx context.Context, featureID ledgerid.FeatureID) (*feature.Feature, error)
CreateCatalogFeature(ctx context.Context, f *feature.Feature) error
UpdateCatalogFeature(ctx context.Context, f *feature.Feature) error
ArchiveCatalogFeature(ctx context.Context, featureID ledgerid.FeatureID) error
}
SubscriptionService is the surface this package needs from the subscription plugin. Declared as an interface here so the contract subpackage doesn't import plugins/subscription directly (cycle avoidance). The parent contract.go satisfies it by passing the plugin's Service().
type SubscriptionSummary ¶
type SubscriptionSummary struct {
ID string `json:"id"`
TenantID string `json:"tenantId"`
PlanID string `json:"planId"`
Status string `json:"status"`
CurrentPeriodStart string `json:"currentPeriodStart,omitempty"`
CurrentPeriodEnd string `json:"currentPeriodEnd,omitempty"`
CancelAt string `json:"cancelAt,omitempty"`
}
type SubscriptionsListInput ¶
type SubscriptionsListInput struct {
TenantID string `json:"tenantId"`
}
type SubscriptionsListResponse ¶
type SubscriptionsListResponse struct {
Subscriptions []SubscriptionSummary `json:"subscriptions"`
}