Documentation
¶
Overview ¶
Package subscription provides a comprehensive SaaS subscription and billing plugin for AuthSome. It supports multiple billing patterns, payment provider integration (Stripe), and organization-scoped subscriptions.
Index ¶
- Constants
- Variables
- func ResolveAddOnService(container forge.Container) (*service.AddOnService, error)
- func ResolveAlertService(container forge.Container) (*service.AlertService, error)
- func ResolveAnalyticsService(container forge.Container) (*service.AnalyticsService, error)
- func ResolveCouponService(container forge.Container) (*service.CouponService, error)
- func ResolveCurrencyService(container forge.Container) (*service.CurrencyService, error)
- func ResolveCustomerService(container forge.Container) (*service.CustomerService, error)
- func ResolveEnforcementService(container forge.Container) (*service.EnforcementService, error)
- func ResolveFeatureService(container forge.Container) (*service.FeatureService, error)
- func ResolveFeatureUsageService(container forge.Container) (*service.FeatureUsageService, error)
- func ResolveInvoiceService(container forge.Container) (*service.InvoiceService, error)
- func ResolvePaymentService(container forge.Container) (*service.PaymentService, error)
- func ResolvePlanService(container forge.Container) (*service.PlanService, error)
- func ResolveSubscriptionService(container forge.Container) (*service.SubscriptionService, error)
- func ResolveTaxService(container forge.Container) (*service.TaxService, error)
- func ResolveUsageService(container forge.Container) (*service.UsageService, error)
- type AfterAddOnAttachHook
- type AfterAddOnDetachHook
- type AfterPlanChangeHook
- type AfterSubscriptionCancelHook
- type AfterSubscriptionCreateHook
- type AfterSubscriptionPauseHook
- type AfterSubscriptionResumeHook
- type AfterSubscriptionUpdateHook
- type BeforeAddOnAttachHook
- type BeforeAddOnDetachHook
- type BeforePlanChangeHook
- type BeforeSubscriptionCancelHook
- type BeforeSubscriptionCreateHook
- type BeforeSubscriptionPauseHook
- type BeforeSubscriptionResumeHook
- type BeforeSubscriptionUpdateHook
- type CheckoutRequest
- type Config
- type DashboardExtension
- func (e *DashboardExtension) BridgeFunctions() []ui.BridgeFunction
- func (e *DashboardExtension) DashboardWidgets() []ui.DashboardWidget
- func (e *DashboardExtension) ExtensionID() string
- func (e *DashboardExtension) HandleArchivePlan(ctx *router.PageContext) (g.Node, error)
- func (e *DashboardExtension) HandleCancelSubscription(ctx *router.PageContext) (g.Node, error)
- func (e *DashboardExtension) HandleCreateAddOn(ctx *router.PageContext) (g.Node, error)
- func (e *DashboardExtension) HandleCreateCoupon(ctx *router.PageContext) (g.Node, error)
- func (e *DashboardExtension) HandleCreateFeature(ctx *router.PageContext) (g.Node, error)
- func (e *DashboardExtension) HandleCreatePlan(ctx *router.PageContext) (g.Node, error)
- func (e *DashboardExtension) HandleDeleteFeature(ctx *router.PageContext) (g.Node, error)
- func (e *DashboardExtension) HandleDeletePlan(ctx *router.PageContext) (g.Node, error)
- func (e *DashboardExtension) HandleExportFeaturesAndPlans(ctx *router.PageContext) (g.Node, error)
- func (e *DashboardExtension) HandleImportFeaturesAndPlans(ctx *router.PageContext) (g.Node, error)
- func (e *DashboardExtension) HandleLinkFeatureToPlan(ctx *router.PageContext) (g.Node, error)
- func (e *DashboardExtension) HandleMarkInvoicePaid(ctx *router.PageContext) (g.Node, error)
- func (e *DashboardExtension) HandleRemovePaymentMethod(ctx *router.PageContext) (g.Node, error)
- func (e *DashboardExtension) HandleSetDefaultPaymentMethod(ctx *router.PageContext) (g.Node, error)
- func (e *DashboardExtension) HandleShowImportForm(ctx *router.PageContext) (g.Node, error)
- func (e *DashboardExtension) HandleSyncAllFeaturesFromProvider(ctx *router.PageContext) (g.Node, error)
- func (e *DashboardExtension) HandleSyncAllPlansFromProvider(ctx *router.PageContext) (g.Node, error)
- func (e *DashboardExtension) HandleSyncFeature(ctx *router.PageContext) (g.Node, error)
- func (e *DashboardExtension) HandleSyncFeatureFromProvider(ctx *router.PageContext) (g.Node, error)
- func (e *DashboardExtension) HandleSyncInvoices(ctx *router.PageContext) (g.Node, error)
- func (e *DashboardExtension) HandleSyncPlan(ctx *router.PageContext) (g.Node, error)
- func (e *DashboardExtension) HandleSyncPlanFromProvider(ctx *router.PageContext) (g.Node, error)
- func (e *DashboardExtension) HandleUnlinkFeatureFromPlan(ctx *router.PageContext) (g.Node, error)
- func (e *DashboardExtension) HandleUpdateFeature(ctx *router.PageContext) (g.Node, error)
- func (e *DashboardExtension) HandleUpdatePlan(ctx *router.PageContext) (g.Node, error)
- func (e *DashboardExtension) HandleUpdatePlanFeatureLink(ctx *router.PageContext) (g.Node, error)
- func (e *DashboardExtension) NavigationItems() []ui.NavigationItem
- func (e *DashboardExtension) Routes() []ui.Route
- func (e *DashboardExtension) ServeAddOnCreatePage(ctx *router.PageContext) (g.Node, error)
- func (e *DashboardExtension) ServeAddOnDetailPage(ctx *router.PageContext) (g.Node, error)
- func (e *DashboardExtension) ServeAddOnsListPage(ctx *router.PageContext) (g.Node, error)
- func (e *DashboardExtension) ServeAddPaymentMethodPage(ctx *router.PageContext) (g.Node, error)
- func (e *DashboardExtension) ServeAlertsListPage(ctx *router.PageContext) (g.Node, error)
- func (e *DashboardExtension) ServeAnalyticsDashboardPage(ctx *router.PageContext) (g.Node, error)
- func (e *DashboardExtension) ServeBillingOverviewPage(ctx *router.PageContext) (g.Node, error)
- func (e *DashboardExtension) ServeCouponCreatePage(ctx *router.PageContext) (g.Node, error)
- func (e *DashboardExtension) ServeCouponsListPage(ctx *router.PageContext) (g.Node, error)
- func (e *DashboardExtension) ServeFeatureCreatePage(ctx *router.PageContext) (g.Node, error)
- func (e *DashboardExtension) ServeFeatureDetailPage(ctx *router.PageContext) (g.Node, error)
- func (e *DashboardExtension) ServeFeatureEditPage(ctx *router.PageContext) (g.Node, error)
- func (e *DashboardExtension) ServeFeatureUsagePage(ctx *router.PageContext) (g.Node, error)
- func (e *DashboardExtension) ServeFeaturesListPage(ctx *router.PageContext) (g.Node, error)
- func (e *DashboardExtension) ServeInvoiceDetailPage(ctx *router.PageContext) (g.Node, error)
- func (e *DashboardExtension) ServeInvoicesListPage(ctx *router.PageContext) (g.Node, error)
- func (e *DashboardExtension) ServePaymentMethodsPage(ctx *router.PageContext) (g.Node, error)
- func (e *DashboardExtension) ServePlanCreatePage(ctx *router.PageContext) (g.Node, error)
- func (e *DashboardExtension) ServePlanDetailPage(ctx *router.PageContext) (g.Node, error)
- func (e *DashboardExtension) ServePlanEditPage(ctx *router.PageContext) (g.Node, error)
- func (e *DashboardExtension) ServePlanFeaturesPage(ctx *router.PageContext) (g.Node, error)
- func (e *DashboardExtension) ServePlansListPage(ctx *router.PageContext) (g.Node, error)
- func (e *DashboardExtension) ServeSettingsPage(ctx *router.PageContext) (g.Node, error)
- func (e *DashboardExtension) ServeSubscriptionDetailPage(ctx *router.PageContext) (g.Node, error)
- func (e *DashboardExtension) ServeSubscriptionsListPage(ctx *router.PageContext) (g.Node, error)
- func (e *DashboardExtension) ServeUsageDashboardPage(ctx *router.PageContext) (g.Node, error)
- func (e *DashboardExtension) SettingsPages() []ui.SettingsPage
- func (e *DashboardExtension) SettingsSections() []ui.SettingsSection
- type OnInvoiceCreatedHook
- type OnInvoicePaidHook
- type OnPaymentFailedHook
- type OnPaymentSuccessHook
- type OnSubscriptionStatusChangeHook
- type OnTrialEndedHook
- type OnTrialEndingHook
- type OnUsageLimitApproachingHook
- type OnUsageLimitExceededHook
- type Plugin
- func (p *Plugin) DashboardExtension() ui.DashboardExtension
- func (p *Plugin) Dependencies() []string
- func (p *Plugin) GetAddOnService() *service.AddOnService
- func (p *Plugin) GetAlertService() *service.AlertService
- func (p *Plugin) GetAnalyticsService() *service.AnalyticsService
- func (p *Plugin) GetConfig() Config
- func (p *Plugin) GetCouponService() *service.CouponService
- func (p *Plugin) GetCurrencyService() *service.CurrencyService
- func (p *Plugin) GetCustomerService() *service.CustomerService
- func (p *Plugin) GetEnforcementService() *service.EnforcementService
- func (p *Plugin) GetExportImportService() *service.ExportImportService
- func (p *Plugin) GetFeatureService() *service.FeatureService
- func (p *Plugin) GetFeatureUsageService() *service.FeatureUsageService
- func (p *Plugin) GetHookRegistry() *SubscriptionHookRegistry
- func (p *Plugin) GetInvoiceService() *service.InvoiceService
- func (p *Plugin) GetPaymentService() *service.PaymentService
- func (p *Plugin) GetPlanService() *service.PlanService
- func (p *Plugin) GetProvider() providers.PaymentProvider
- func (p *Plugin) GetServices() map[string]any
- func (p *Plugin) GetSubscriptionService() *service.SubscriptionService
- func (p *Plugin) GetTaxService() *service.TaxService
- func (p *Plugin) GetUsageService() *service.UsageService
- func (p *Plugin) ID() string
- func (p *Plugin) Init(authInstance core.Authsome) error
- func (p *Plugin) Migrate() error
- func (p *Plugin) RegisterHooks(hooks *hooks.HookRegistry) error
- func (p *Plugin) RegisterRoles(reg any) error
- func (p *Plugin) RegisterRoutes(router forge.Router) error
- func (p *Plugin) RegisterServiceDecorators(services *registry.ServiceRegistry) error
- func (p *Plugin) RegisterServices(container forge.Container) error
- func (p *Plugin) SyncInvoicesFromStripe(ctx context.Context, subID *xid.ID) (int, error)
- type PluginOption
- func WithAutoSyncPlans(enabled bool) PluginOption
- func WithAutoSyncSeats(enabled bool) PluginOption
- func WithDefaultConfig(cfg Config) PluginOption
- func WithDefaultTrialDays(days int) PluginOption
- func WithGracePeriodDays(days int) PluginOption
- func WithProvider(provider providers.PaymentProvider) PluginOption
- func WithRequireSubscription(required bool) PluginOption
- func WithStripeConfig(secretKey, webhookSecret, publishableKey string) PluginOption
- type StripeConfig
- type SubscriptionError
- type SubscriptionHookRegistry
Constants ¶
const ( ServiceNamePlugin = "subscription.plugin" ServiceNamePlanService = "subscription.plan" ServiceNameSubService = "subscription.subscription" ServiceNameAddOnService = "subscription.addon" ServiceNameInvoiceService = "subscription.invoice" ServiceNameUsageService = "subscription.usage" ServiceNamePaymentService = "subscription.payment" ServiceNameCustomerService = "subscription.customer" ServiceNameEnforcementService = "subscription.enforcement" ServiceNameFeatureService = "subscription.feature" ServiceNameFeatureUsageService = "subscription.feature_usage" ServiceNameAlertService = "subscription.alert" ServiceNameAnalyticsService = "subscription.analytics" ServiceNameCouponService = "subscription.coupon" ServiceNameCurrencyService = "subscription.currency" ServiceNameTaxService = "subscription.tax" ServiceNameHookRegistry = "subscription.hook_registry" )
Service name constants for DI container registration.
Variables ¶
var ( // ErrPlanNotFound is returned when a plan is not found. ErrPlanNotFound = errors.ErrPlanNotFound ErrPlanAlreadyExists = errors.ErrPlanAlreadyExists ErrPlanNotActive = errors.ErrPlanNotActive ErrPlanHasSubscriptions = errors.ErrPlanHasSubscriptions ErrInvalidPlanSlug = errors.ErrInvalidPlanSlug ErrInvalidBillingPattern = errors.ErrInvalidBillingPattern ErrInvalidBillingInterval = errors.ErrInvalidBillingInterval // ErrSubscriptionNotFound is returned when a subscription is not found. ErrSubscriptionNotFound = errors.ErrSubscriptionNotFound ErrSubscriptionAlreadyExists = errors.ErrSubscriptionAlreadyExists ErrSubscriptionNotActive = errors.ErrSubscriptionNotActive ErrSubscriptionCanceled = errors.ErrSubscriptionCanceled ErrSubscriptionPaused = errors.ErrSubscriptionPaused ErrCannotDowngrade = errors.ErrCannotDowngrade ErrInvalidQuantity = errors.ErrInvalidQuantity // ErrAddOnNotFound is returned when an add-on is not found. ErrAddOnNotFound = errors.ErrAddOnNotFound ErrAddOnAlreadyExists = errors.ErrAddOnAlreadyExists ErrAddOnNotActive = errors.ErrAddOnNotActive ErrAddOnNotAvailable = errors.ErrAddOnNotAvailable ErrAddOnAlreadyAttached = errors.ErrAddOnAlreadyAttached ErrAddOnNotAttached = errors.ErrAddOnNotAttached ErrAddOnMaxQuantity = errors.ErrAddOnMaxQuantity // ErrInvoiceNotFound is returned when an invoice is not found. ErrInvoiceNotFound = errors.ErrInvoiceNotFound ErrInvoiceAlreadyPaid = errors.ErrInvoiceAlreadyPaid ErrInvoiceVoided = errors.ErrInvoiceVoided ErrInvoiceNotOpen = errors.ErrInvoiceNotOpen // ErrUsageRecordNotFound is returned when a usage record is not found. ErrUsageRecordNotFound = errors.ErrUsageRecordNotFound ErrDuplicateUsageRecord = errors.ErrDuplicateUsageRecord ErrInvalidUsageMetric = errors.ErrInvalidUsageMetric ErrInvalidUsageAction = errors.ErrInvalidUsageAction // ErrPaymentMethodNotFound is returned when a payment method is not found. ErrPaymentMethodNotFound = errors.ErrPaymentMethodNotFound ErrPaymentMethodRequired = errors.ErrPaymentMethodRequired ErrPaymentMethodExpired = errors.ErrPaymentMethodExpired ErrDefaultPaymentMethodDelete = errors.ErrDefaultPaymentMethodDelete // ErrCustomerNotFound is returned when a customer is not found. ErrCustomerNotFound = errors.ErrCustomerNotFound ErrCustomerAlreadyExists = errors.ErrCustomerAlreadyExists // ErrProviderNotConfigured errors. ErrProviderNotConfigured = errors.ErrProviderNotConfigured ErrProviderAPIError = errors.ErrProviderAPIError ErrWebhookSignatureInvalid = errors.ErrWebhookSignatureInvalid ErrWebhookEventUnhandled = errors.ErrWebhookEventUnhandled // ErrFeatureLimitExceeded is returned when a feature limit is exceeded. ErrFeatureLimitExceeded = errors.ErrFeatureLimitExceeded ErrSeatLimitExceeded = errors.ErrSeatLimitExceeded ErrSubscriptionRequired = errors.ErrSubscriptionRequired ErrTrialExpired = errors.ErrTrialExpired // ErrInvalidCurrency is returned when currency is invalid. ErrInvalidCurrency = errors.ErrInvalidCurrency ErrInvalidAppID = errors.ErrInvalidAppID ErrInvalidOrgID = errors.ErrInvalidOrgID )
Re-export domain errors.
var ( IsNotFoundError = errors.IsNotFoundError IsValidationError = errors.IsValidationError IsConflictError = errors.IsConflictError IsLimitError = errors.IsLimitError IsPaymentError = errors.IsPaymentError )
Re-export error helper functions.
var DefaultConfig = core.DefaultConfig
DefaultConfig returns the default plugin configuration.
var NewSubscriptionError = errors.New
NewSubscriptionError creates a new subscription error with context.
var NewSubscriptionHookRegistry = hooks.NewSubscriptionHookRegistry
NewSubscriptionHookRegistry creates a new hook registry.
Functions ¶
func ResolveAddOnService ¶
func ResolveAddOnService(container forge.Container) (*service.AddOnService, error)
ResolveAddOnService resolves the add-on service from the container.
func ResolveAlertService ¶
func ResolveAlertService(container forge.Container) (*service.AlertService, error)
ResolveAlertService resolves the alert service from the container.
func ResolveAnalyticsService ¶
func ResolveAnalyticsService(container forge.Container) (*service.AnalyticsService, error)
ResolveAnalyticsService resolves the analytics service from the container.
func ResolveCouponService ¶
func ResolveCouponService(container forge.Container) (*service.CouponService, error)
ResolveCouponService resolves the coupon service from the container.
func ResolveCurrencyService ¶
func ResolveCurrencyService(container forge.Container) (*service.CurrencyService, error)
ResolveCurrencyService resolves the currency service from the container.
func ResolveCustomerService ¶
func ResolveCustomerService(container forge.Container) (*service.CustomerService, error)
ResolveCustomerService resolves the customer service from the container.
func ResolveEnforcementService ¶
func ResolveEnforcementService(container forge.Container) (*service.EnforcementService, error)
ResolveEnforcementService resolves the enforcement service from the container.
func ResolveFeatureService ¶
func ResolveFeatureService(container forge.Container) (*service.FeatureService, error)
ResolveFeatureService resolves the feature service from the container.
func ResolveFeatureUsageService ¶
func ResolveFeatureUsageService(container forge.Container) (*service.FeatureUsageService, error)
ResolveFeatureUsageService resolves the feature usage service from the container.
func ResolveInvoiceService ¶
func ResolveInvoiceService(container forge.Container) (*service.InvoiceService, error)
ResolveInvoiceService resolves the invoice service from the container.
func ResolvePaymentService ¶
func ResolvePaymentService(container forge.Container) (*service.PaymentService, error)
ResolvePaymentService resolves the payment service from the container.
func ResolvePlanService ¶
func ResolvePlanService(container forge.Container) (*service.PlanService, error)
ResolvePlanService resolves the plan service from the container.
func ResolveSubscriptionService ¶
func ResolveSubscriptionService(container forge.Container) (*service.SubscriptionService, error)
ResolveSubscriptionService resolves the subscription service from the container.
func ResolveTaxService ¶
func ResolveTaxService(container forge.Container) (*service.TaxService, error)
ResolveTaxService resolves the tax service from the container.
func ResolveUsageService ¶
func ResolveUsageService(container forge.Container) (*service.UsageService, error)
ResolveUsageService resolves the usage service from the container.
Types ¶
type AfterAddOnAttachHook ¶
type AfterAddOnAttachHook = hooks.AfterAddOnAttachHook
Re-export hook types for convenience.
type AfterAddOnDetachHook ¶
type AfterAddOnDetachHook = hooks.AfterAddOnDetachHook
Re-export hook types for convenience.
type AfterPlanChangeHook ¶
type AfterPlanChangeHook = hooks.AfterPlanChangeHook
Re-export hook types for convenience.
type AfterSubscriptionCancelHook ¶
type AfterSubscriptionCancelHook = hooks.AfterSubscriptionCancelHook
Re-export hook types for convenience.
type AfterSubscriptionCreateHook ¶
type AfterSubscriptionCreateHook = hooks.AfterSubscriptionCreateHook
Re-export hook types for convenience.
type AfterSubscriptionPauseHook ¶
type AfterSubscriptionPauseHook = hooks.AfterSubscriptionPauseHook
Re-export hook types for convenience.
type AfterSubscriptionResumeHook ¶
type AfterSubscriptionResumeHook = hooks.AfterSubscriptionResumeHook
Re-export hook types for convenience.
type AfterSubscriptionUpdateHook ¶
type AfterSubscriptionUpdateHook = hooks.AfterSubscriptionUpdateHook
Re-export hook types for convenience.
type BeforeAddOnAttachHook ¶
type BeforeAddOnAttachHook = hooks.BeforeAddOnAttachHook
Re-export hook types for convenience.
type BeforeAddOnDetachHook ¶
type BeforeAddOnDetachHook = hooks.BeforeAddOnDetachHook
Re-export hook types for convenience.
type BeforePlanChangeHook ¶
type BeforePlanChangeHook = hooks.BeforePlanChangeHook
Re-export hook types for convenience.
type BeforeSubscriptionCancelHook ¶
type BeforeSubscriptionCancelHook = hooks.BeforeSubscriptionCancelHook
Re-export hook types for convenience.
type BeforeSubscriptionCreateHook ¶
type BeforeSubscriptionCreateHook = hooks.BeforeSubscriptionCreateHook
Re-export hook types for convenience.
type BeforeSubscriptionPauseHook ¶
type BeforeSubscriptionPauseHook = hooks.BeforeSubscriptionPauseHook
Re-export hook types for convenience.
type BeforeSubscriptionResumeHook ¶
type BeforeSubscriptionResumeHook = hooks.BeforeSubscriptionResumeHook
Re-export hook types for convenience.
type BeforeSubscriptionUpdateHook ¶
type BeforeSubscriptionUpdateHook = hooks.BeforeSubscriptionUpdateHook
Re-export hook types for convenience.
type CheckoutRequest ¶
type CheckoutRequest struct {
CustomerID string
PriceID string
Quantity int
SuccessURL string
CancelURL string
AllowPromoCodes bool
TrialDays int
Metadata map[string]any
}
CheckoutRequest for internal use.
type DashboardExtension ¶
type DashboardExtension struct {
// contains filtered or unexported fields
}
DashboardExtension implements ui.DashboardExtension for the subscription plugin.
func NewDashboardExtension ¶
func NewDashboardExtension(plugin *Plugin) *DashboardExtension
NewDashboardExtension creates a new dashboard extension.
func (*DashboardExtension) BridgeFunctions ¶ added in v0.0.15
func (e *DashboardExtension) BridgeFunctions() []ui.BridgeFunction
BridgeFunctions returns bridge functions for the subscription plugin.
func (*DashboardExtension) DashboardWidgets ¶
func (e *DashboardExtension) DashboardWidgets() []ui.DashboardWidget
DashboardWidgets returns dashboard widgets.
func (*DashboardExtension) ExtensionID ¶
func (e *DashboardExtension) ExtensionID() string
ExtensionID returns the unique identifier for this extension.
func (*DashboardExtension) HandleArchivePlan ¶
func (e *DashboardExtension) HandleArchivePlan(ctx *router.PageContext) (g.Node, error)
HandleArchivePlan handles plan archiving (deactivation).
func (*DashboardExtension) HandleCancelSubscription ¶
func (e *DashboardExtension) HandleCancelSubscription(ctx *router.PageContext) (g.Node, error)
HandleCancelSubscription handles subscription cancellation.
func (*DashboardExtension) HandleCreateAddOn ¶
func (e *DashboardExtension) HandleCreateAddOn(ctx *router.PageContext) (g.Node, error)
HandleCreateAddOn handles add-on creation form submission.
func (*DashboardExtension) HandleCreateCoupon ¶
func (e *DashboardExtension) HandleCreateCoupon(ctx *router.PageContext) (g.Node, error)
HandleCreateCoupon handles coupon creation form submission TODO: Implement when couponSvc is added to Plugin.
func (*DashboardExtension) HandleCreateFeature ¶
func (e *DashboardExtension) HandleCreateFeature(ctx *router.PageContext) (g.Node, error)
HandleCreateFeature handles the feature creation form submission.
func (*DashboardExtension) HandleCreatePlan ¶
func (e *DashboardExtension) HandleCreatePlan(ctx *router.PageContext) (g.Node, error)
HandleCreatePlan handles plan creation form submission.
func (*DashboardExtension) HandleDeleteFeature ¶
func (e *DashboardExtension) HandleDeleteFeature(ctx *router.PageContext) (g.Node, error)
HandleDeleteFeature handles feature deletion.
func (*DashboardExtension) HandleDeletePlan ¶
func (e *DashboardExtension) HandleDeletePlan(ctx *router.PageContext) (g.Node, error)
HandleDeletePlan handles permanent plan deletion.
func (*DashboardExtension) HandleExportFeaturesAndPlans ¶ added in v0.0.4
func (e *DashboardExtension) HandleExportFeaturesAndPlans(ctx *router.PageContext) (g.Node, error)
HandleExportFeaturesAndPlans exports features and plans as JSON.
func (*DashboardExtension) HandleImportFeaturesAndPlans ¶ added in v0.0.4
func (e *DashboardExtension) HandleImportFeaturesAndPlans(ctx *router.PageContext) (g.Node, error)
HandleImportFeaturesAndPlans imports features and plans from JSON.
func (*DashboardExtension) HandleLinkFeatureToPlan ¶
func (e *DashboardExtension) HandleLinkFeatureToPlan(ctx *router.PageContext) (g.Node, error)
HandleLinkFeatureToPlan handles linking a feature to a plan.
func (*DashboardExtension) HandleMarkInvoicePaid ¶
func (e *DashboardExtension) HandleMarkInvoicePaid(ctx *router.PageContext) (g.Node, error)
HandleMarkInvoicePaid handles marking an invoice as paid.
func (*DashboardExtension) HandleRemovePaymentMethod ¶ added in v0.0.9
func (e *DashboardExtension) HandleRemovePaymentMethod(ctx *router.PageContext) (g.Node, error)
HandleRemovePaymentMethod removes a payment method via HTMX.
func (*DashboardExtension) HandleSetDefaultPaymentMethod ¶ added in v0.0.9
func (e *DashboardExtension) HandleSetDefaultPaymentMethod(ctx *router.PageContext) (g.Node, error)
HandleSetDefaultPaymentMethod sets a payment method as default via HTMX.
func (*DashboardExtension) HandleShowImportForm ¶ added in v0.0.4
func (e *DashboardExtension) HandleShowImportForm(ctx *router.PageContext) (g.Node, error)
HandleShowImportForm displays the import form page.
func (*DashboardExtension) HandleSyncAllFeaturesFromProvider ¶ added in v0.0.5
func (e *DashboardExtension) HandleSyncAllFeaturesFromProvider(ctx *router.PageContext) (g.Node, error)
HandleSyncAllFeaturesFromProvider syncs all features from the payment provider.
func (*DashboardExtension) HandleSyncAllPlansFromProvider ¶
func (e *DashboardExtension) HandleSyncAllPlansFromProvider(ctx *router.PageContext) (g.Node, error)
HandleSyncAllPlansFromProvider syncs all plans from the payment provider.
func (*DashboardExtension) HandleSyncFeature ¶ added in v0.0.5
func (e *DashboardExtension) HandleSyncFeature(ctx *router.PageContext) (g.Node, error)
HandleSyncFeature handles syncing a feature to the provider.
func (*DashboardExtension) HandleSyncFeatureFromProvider ¶ added in v0.0.5
func (e *DashboardExtension) HandleSyncFeatureFromProvider(ctx *router.PageContext) (g.Node, error)
HandleSyncFeatureFromProvider syncs a feature from the payment provider.
func (*DashboardExtension) HandleSyncInvoices ¶ added in v0.0.6
func (e *DashboardExtension) HandleSyncInvoices(ctx *router.PageContext) (g.Node, error)
HandleSyncInvoices handles syncing invoices from Stripe.
func (*DashboardExtension) HandleSyncPlan ¶
func (e *DashboardExtension) HandleSyncPlan(ctx *router.PageContext) (g.Node, error)
HandleSyncPlan handles syncing a plan to the payment provider.
func (*DashboardExtension) HandleSyncPlanFromProvider ¶
func (e *DashboardExtension) HandleSyncPlanFromProvider(ctx *router.PageContext) (g.Node, error)
HandleSyncPlanFromProvider syncs a single plan from the payment provider.
func (*DashboardExtension) HandleUnlinkFeatureFromPlan ¶
func (e *DashboardExtension) HandleUnlinkFeatureFromPlan(ctx *router.PageContext) (g.Node, error)
HandleUnlinkFeatureFromPlan handles unlinking a feature from a plan.
func (*DashboardExtension) HandleUpdateFeature ¶
func (e *DashboardExtension) HandleUpdateFeature(ctx *router.PageContext) (g.Node, error)
HandleUpdateFeature handles the feature update form submission.
func (*DashboardExtension) HandleUpdatePlan ¶
func (e *DashboardExtension) HandleUpdatePlan(ctx *router.PageContext) (g.Node, error)
HandleUpdatePlan handles plan update form submission.
func (*DashboardExtension) HandleUpdatePlanFeatureLink ¶
func (e *DashboardExtension) HandleUpdatePlanFeatureLink(ctx *router.PageContext) (g.Node, error)
HandleUpdatePlanFeatureLink handles updating a feature-plan link.
func (*DashboardExtension) NavigationItems ¶
func (e *DashboardExtension) NavigationItems() []ui.NavigationItem
NavigationItems returns the navigation items for the dashboard.
func (*DashboardExtension) Routes ¶
func (e *DashboardExtension) Routes() []ui.Route
Routes returns the dashboard routes.
func (*DashboardExtension) ServeAddOnCreatePage ¶
func (e *DashboardExtension) ServeAddOnCreatePage(ctx *router.PageContext) (g.Node, error)
ServeAddOnCreatePage renders the add-on creation form.
func (*DashboardExtension) ServeAddOnDetailPage ¶
func (e *DashboardExtension) ServeAddOnDetailPage(ctx *router.PageContext) (g.Node, error)
ServeAddOnDetailPage renders the add-on detail page.
func (*DashboardExtension) ServeAddOnsListPage ¶
func (e *DashboardExtension) ServeAddOnsListPage(ctx *router.PageContext) (g.Node, error)
ServeAddOnsListPage renders the add-ons list page.
func (*DashboardExtension) ServeAddPaymentMethodPage ¶ added in v0.0.9
func (e *DashboardExtension) ServeAddPaymentMethodPage(ctx *router.PageContext) (g.Node, error)
ServeAddPaymentMethodPage renders the add payment method page with Stripe Elements.
func (*DashboardExtension) ServeAlertsListPage ¶
func (e *DashboardExtension) ServeAlertsListPage(ctx *router.PageContext) (g.Node, error)
ServeAlertsListPage renders the alerts list page.
func (*DashboardExtension) ServeAnalyticsDashboardPage ¶
func (e *DashboardExtension) ServeAnalyticsDashboardPage(ctx *router.PageContext) (g.Node, error)
ServeAnalyticsDashboardPage renders the analytics dashboard.
func (*DashboardExtension) ServeBillingOverviewPage ¶
func (e *DashboardExtension) ServeBillingOverviewPage(ctx *router.PageContext) (g.Node, error)
ServeBillingOverviewPage renders the billing overview dashboard.
func (*DashboardExtension) ServeCouponCreatePage ¶
func (e *DashboardExtension) ServeCouponCreatePage(ctx *router.PageContext) (g.Node, error)
ServeCouponCreatePage renders the coupon creation form.
func (*DashboardExtension) ServeCouponsListPage ¶
func (e *DashboardExtension) ServeCouponsListPage(ctx *router.PageContext) (g.Node, error)
ServeCouponsListPage renders the coupons list page.
func (*DashboardExtension) ServeFeatureCreatePage ¶
func (e *DashboardExtension) ServeFeatureCreatePage(ctx *router.PageContext) (g.Node, error)
ServeFeatureCreatePage renders the feature creation form.
func (*DashboardExtension) ServeFeatureDetailPage ¶
func (e *DashboardExtension) ServeFeatureDetailPage(ctx *router.PageContext) (g.Node, error)
ServeFeatureDetailPage renders the feature detail page.
func (*DashboardExtension) ServeFeatureEditPage ¶
func (e *DashboardExtension) ServeFeatureEditPage(ctx *router.PageContext) (g.Node, error)
ServeFeatureEditPage renders the feature edit form.
func (*DashboardExtension) ServeFeatureUsagePage ¶
func (e *DashboardExtension) ServeFeatureUsagePage(ctx *router.PageContext) (g.Node, error)
ServeFeatureUsagePage renders the feature usage monitoring page.
func (*DashboardExtension) ServeFeaturesListPage ¶
func (e *DashboardExtension) ServeFeaturesListPage(ctx *router.PageContext) (g.Node, error)
ServeFeaturesListPage renders the features list dashboard.
func (*DashboardExtension) ServeInvoiceDetailPage ¶
func (e *DashboardExtension) ServeInvoiceDetailPage(ctx *router.PageContext) (g.Node, error)
ServeInvoiceDetailPage renders the invoice detail page.
func (*DashboardExtension) ServeInvoicesListPage ¶
func (e *DashboardExtension) ServeInvoicesListPage(ctx *router.PageContext) (g.Node, error)
ServeInvoicesListPage renders the invoices list page.
func (*DashboardExtension) ServePaymentMethodsPage ¶ added in v0.0.9
func (e *DashboardExtension) ServePaymentMethodsPage(ctx *router.PageContext) (g.Node, error)
ServePaymentMethodsPage renders the payment methods management page.
func (*DashboardExtension) ServePlanCreatePage ¶
func (e *DashboardExtension) ServePlanCreatePage(ctx *router.PageContext) (g.Node, error)
ServePlanCreatePage renders the plan creation form.
func (*DashboardExtension) ServePlanDetailPage ¶
func (e *DashboardExtension) ServePlanDetailPage(ctx *router.PageContext) (g.Node, error)
ServePlanDetailPage renders the plan detail page.
func (*DashboardExtension) ServePlanEditPage ¶
func (e *DashboardExtension) ServePlanEditPage(ctx *router.PageContext) (g.Node, error)
ServePlanEditPage renders the plan edit form.
func (*DashboardExtension) ServePlanFeaturesPage ¶
func (e *DashboardExtension) ServePlanFeaturesPage(ctx *router.PageContext) (g.Node, error)
ServePlanFeaturesPage renders the plan features management page.
func (*DashboardExtension) ServePlansListPage ¶
func (e *DashboardExtension) ServePlansListPage(ctx *router.PageContext) (g.Node, error)
ServePlansListPage renders the plans list page.
func (*DashboardExtension) ServeSettingsPage ¶
func (e *DashboardExtension) ServeSettingsPage(ctx *router.PageContext) (g.Node, error)
ServeSettingsPage renders the subscription settings page.
func (*DashboardExtension) ServeSubscriptionDetailPage ¶
func (e *DashboardExtension) ServeSubscriptionDetailPage(ctx *router.PageContext) (g.Node, error)
ServeSubscriptionDetailPage renders the subscription detail page.
func (*DashboardExtension) ServeSubscriptionsListPage ¶
func (e *DashboardExtension) ServeSubscriptionsListPage(ctx *router.PageContext) (g.Node, error)
ServeSubscriptionsListPage renders the subscriptions list page.
func (*DashboardExtension) ServeUsageDashboardPage ¶
func (e *DashboardExtension) ServeUsageDashboardPage(ctx *router.PageContext) (g.Node, error)
ServeUsageDashboardPage renders the usage dashboard page.
func (*DashboardExtension) SettingsPages ¶
func (e *DashboardExtension) SettingsPages() []ui.SettingsPage
SettingsPages returns settings pages for the plugin.
func (*DashboardExtension) SettingsSections ¶
func (e *DashboardExtension) SettingsSections() []ui.SettingsSection
SettingsSections returns settings sections (deprecated, using SettingsPages instead).
type OnInvoiceCreatedHook ¶
type OnInvoiceCreatedHook = hooks.OnInvoiceCreatedHook
Re-export hook types for convenience.
type OnInvoicePaidHook ¶
type OnInvoicePaidHook = hooks.OnInvoicePaidHook
Re-export hook types for convenience.
type OnPaymentFailedHook ¶
type OnPaymentFailedHook = hooks.OnPaymentFailedHook
Re-export hook types for convenience.
type OnPaymentSuccessHook ¶
type OnPaymentSuccessHook = hooks.OnPaymentSuccessHook
Re-export hook types for convenience.
type OnSubscriptionStatusChangeHook ¶
type OnSubscriptionStatusChangeHook = hooks.OnSubscriptionStatusChangeHook
Re-export hook types for convenience.
type OnTrialEndedHook ¶
type OnTrialEndedHook = hooks.OnTrialEndedHook
Re-export hook types for convenience.
type OnTrialEndingHook ¶
type OnTrialEndingHook = hooks.OnTrialEndingHook
Re-export hook types for convenience.
type OnUsageLimitApproachingHook ¶
type OnUsageLimitApproachingHook = hooks.OnUsageLimitApproachingHook
Re-export hook types for convenience.
type OnUsageLimitExceededHook ¶
type OnUsageLimitExceededHook = hooks.OnUsageLimitExceededHook
Re-export hook types for convenience.
type Plugin ¶
type Plugin struct {
// contains filtered or unexported fields
}
Plugin implements the subscription plugin for AuthSome.
func NewPlugin ¶
func NewPlugin(opts ...PluginOption) *Plugin
NewPlugin creates a new subscription plugin instance.
func ResolveSubscriptionPlugin ¶
ResolveSubscriptionPlugin resolves the subscription plugin from the container.
func (*Plugin) DashboardExtension ¶
func (p *Plugin) DashboardExtension() ui.DashboardExtension
DashboardExtension returns the dashboard extension.
func (*Plugin) Dependencies ¶
Dependencies declares the plugin dependencies.
func (*Plugin) GetAddOnService ¶
func (p *Plugin) GetAddOnService() *service.AddOnService
GetAddOnService returns the add-on service.
func (*Plugin) GetAlertService ¶
func (p *Plugin) GetAlertService() *service.AlertService
GetAlertService returns the alert service.
func (*Plugin) GetAnalyticsService ¶
func (p *Plugin) GetAnalyticsService() *service.AnalyticsService
GetAnalyticsService returns the analytics service.
func (*Plugin) GetCouponService ¶
func (p *Plugin) GetCouponService() *service.CouponService
GetCouponService returns the coupon service.
func (*Plugin) GetCurrencyService ¶
func (p *Plugin) GetCurrencyService() *service.CurrencyService
GetCurrencyService returns the currency service.
func (*Plugin) GetCustomerService ¶
func (p *Plugin) GetCustomerService() *service.CustomerService
GetCustomerService returns the customer service.
func (*Plugin) GetEnforcementService ¶
func (p *Plugin) GetEnforcementService() *service.EnforcementService
GetEnforcementService returns the enforcement service.
func (*Plugin) GetExportImportService ¶ added in v0.0.4
func (p *Plugin) GetExportImportService() *service.ExportImportService
GetExportImportService returns the export/import service.
func (*Plugin) GetFeatureService ¶
func (p *Plugin) GetFeatureService() *service.FeatureService
GetFeatureService returns the feature service.
func (*Plugin) GetFeatureUsageService ¶
func (p *Plugin) GetFeatureUsageService() *service.FeatureUsageService
GetFeatureUsageService returns the feature usage service.
func (*Plugin) GetHookRegistry ¶
func (p *Plugin) GetHookRegistry() *SubscriptionHookRegistry
GetHookRegistry returns the subscription hook registry.
func (*Plugin) GetInvoiceService ¶
func (p *Plugin) GetInvoiceService() *service.InvoiceService
GetInvoiceService returns the invoice service.
func (*Plugin) GetPaymentService ¶
func (p *Plugin) GetPaymentService() *service.PaymentService
GetPaymentService returns the payment service.
func (*Plugin) GetPlanService ¶
func (p *Plugin) GetPlanService() *service.PlanService
GetPlanService returns the plan service.
func (*Plugin) GetProvider ¶ added in v0.0.15
func (p *Plugin) GetProvider() providers.PaymentProvider
GetProvider returns the payment provider.
func (*Plugin) GetServices ¶
GetServices returns a map of all available services for inspection.
func (*Plugin) GetSubscriptionService ¶
func (p *Plugin) GetSubscriptionService() *service.SubscriptionService
GetSubscriptionService returns the subscription service.
func (*Plugin) GetTaxService ¶
func (p *Plugin) GetTaxService() *service.TaxService
GetTaxService returns the tax service.
func (*Plugin) GetUsageService ¶
func (p *Plugin) GetUsageService() *service.UsageService
GetUsageService returns the usage service.
func (*Plugin) RegisterHooks ¶
func (p *Plugin) RegisterHooks(hooks *hooks.HookRegistry) error
RegisterHooks registers hooks for the subscription plugin.
func (*Plugin) RegisterRoles ¶
RegisterRoles implements the PluginWithRoles interface.
func (*Plugin) RegisterRoutes ¶
RegisterRoutes registers the plugin's HTTP routes.
func (*Plugin) RegisterServiceDecorators ¶
func (p *Plugin) RegisterServiceDecorators(services *registry.ServiceRegistry) error
RegisterServiceDecorators registers service decorators.
func (*Plugin) RegisterServices ¶
RegisterServices registers all subscription services in the DI container Uses vessel.ProvideConstructor for type-safe, constructor-based dependency injection.
type PluginOption ¶
type PluginOption func(*Plugin)
PluginOption is a functional option for configuring the plugin.
func WithAutoSyncPlans ¶
func WithAutoSyncPlans(enabled bool) PluginOption
WithAutoSyncPlans enables automatic plan synchronization to payment provider on create/update.
func WithAutoSyncSeats ¶
func WithAutoSyncSeats(enabled bool) PluginOption
WithAutoSyncSeats enables automatic seat synchronization.
func WithDefaultConfig ¶
func WithDefaultConfig(cfg Config) PluginOption
WithDefaultConfig sets the default configuration for the plugin.
func WithDefaultTrialDays ¶
func WithDefaultTrialDays(days int) PluginOption
WithDefaultTrialDays sets the default trial days.
func WithGracePeriodDays ¶
func WithGracePeriodDays(days int) PluginOption
WithGracePeriodDays sets the grace period for failed payments.
func WithProvider ¶ added in v0.0.15
func WithProvider(provider providers.PaymentProvider) PluginOption
WithProvider sets a custom payment provider implementation This allows users to inject their own provider instead of using Stripe or mock provider.
func WithRequireSubscription ¶
func WithRequireSubscription(required bool) PluginOption
WithRequireSubscription sets whether subscription is required for org creation.
func WithStripeConfig ¶
func WithStripeConfig(secretKey, webhookSecret, publishableKey string) PluginOption
WithStripeConfig sets the Stripe configuration.
type SubscriptionError ¶
type SubscriptionError = errors.SubscriptionError
SubscriptionError is the subscription error type.
type SubscriptionHookRegistry ¶
type SubscriptionHookRegistry = hooks.SubscriptionHookRegistry
Re-export hook types for convenience.
func ResolveSubscriptionHookRegistry ¶
func ResolveSubscriptionHookRegistry(container forge.Container) (*SubscriptionHookRegistry, error)
ResolveSubscriptionHookRegistry resolves the subscription hook registry from the container.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package core defines the core domain types for the subscription plugin.
|
Package core defines the core domain types for the subscription plugin. |
|
Package errors defines domain errors for the subscription plugin.
|
Package errors defines domain errors for the subscription plugin. |
|
Package handlers provides HTTP handlers for the subscription plugin.
|
Package handlers provides HTTP handlers for the subscription plugin. |
|
internal
|
|
|
hooks
Package hooks provides subscription-specific hook types and registry.
|
Package hooks provides subscription-specific hook types and registry. |
|
Package migrations provides migration utilities for the subscription plugin.
|
Package migrations provides migration utilities for the subscription plugin. |
|
Package providers defines the payment provider abstraction for the subscription plugin.
|
Package providers defines the payment provider abstraction for the subscription plugin. |
|
mock
Package mock provides a mock payment provider for testing.
|
Package mock provides a mock payment provider for testing. |
|
paddle
Package paddle provides a stub implementation of the PaymentProvider interface for Paddle.
|
Package paddle provides a stub implementation of the PaymentProvider interface for Paddle. |
|
paypal
Package paypal provides a stub implementation of the PaymentProvider interface for PayPal.
|
Package paypal provides a stub implementation of the PaymentProvider interface for PayPal. |
|
stripe
Package stripe provides Stripe payment provider implementation.
|
Package stripe provides Stripe payment provider implementation. |
|
types
Package types defines shared types for payment providers.
|
Package types defines shared types for payment providers. |
|
Package repository provides data access interfaces and implementations for the subscription plugin.
|
Package repository provides data access interfaces and implementations for the subscription plugin. |
|
Package schema defines the database models for the subscription plugin.
|
Package schema defines the database models for the subscription plugin. |
|
Package service provides business logic services for the subscription plugin.
|
Package service provides business logic services for the subscription plugin. |
|
Package ui provides Pine UI components for the subscription plugin dashboard
|
Package ui provides Pine UI components for the subscription plugin dashboard |