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) DashboardWidgets() []ui.DashboardWidget
- func (e *DashboardExtension) ExtensionID() string
- func (e *DashboardExtension) HandleArchivePlan(c forge.Context) error
- func (e *DashboardExtension) HandleCancelSubscription(c forge.Context) error
- func (e *DashboardExtension) HandleCreateAddOn(c forge.Context) error
- func (e *DashboardExtension) HandleCreateCoupon(c forge.Context) error
- func (e *DashboardExtension) HandleCreateFeature(c forge.Context) error
- func (e *DashboardExtension) HandleCreatePlan(c forge.Context) error
- func (e *DashboardExtension) HandleDeleteFeature(c forge.Context) error
- func (e *DashboardExtension) HandleDeletePlan(c forge.Context) error
- func (e *DashboardExtension) HandleExportFeaturesAndPlans(c forge.Context) error
- func (e *DashboardExtension) HandleImportFeaturesAndPlans(c forge.Context) error
- func (e *DashboardExtension) HandleLinkFeatureToPlan(c forge.Context) error
- func (e *DashboardExtension) HandleMarkInvoicePaid(c forge.Context) error
- func (e *DashboardExtension) HandleRemovePaymentMethod(c forge.Context) error
- func (e *DashboardExtension) HandleSetDefaultPaymentMethod(c forge.Context) error
- func (e *DashboardExtension) HandleShowImportForm(c forge.Context) error
- func (e *DashboardExtension) HandleSyncAllFeaturesFromProvider(c forge.Context) error
- func (e *DashboardExtension) HandleSyncAllPlansFromProvider(c forge.Context) error
- func (e *DashboardExtension) HandleSyncFeature(c forge.Context) error
- func (e *DashboardExtension) HandleSyncFeatureFromProvider(c forge.Context) error
- func (e *DashboardExtension) HandleSyncInvoices(c forge.Context) error
- func (e *DashboardExtension) HandleSyncPlan(c forge.Context) error
- func (e *DashboardExtension) HandleSyncPlanFromProvider(c forge.Context) error
- func (e *DashboardExtension) HandleUnlinkFeatureFromPlan(c forge.Context) error
- func (e *DashboardExtension) HandleUpdateFeature(c forge.Context) error
- func (e *DashboardExtension) HandleUpdatePlan(c forge.Context) error
- func (e *DashboardExtension) HandleUpdatePlanFeatureLink(c forge.Context) error
- func (e *DashboardExtension) NavigationItems() []ui.NavigationItem
- func (e *DashboardExtension) Routes() []ui.Route
- func (e *DashboardExtension) ServeAddOnCreatePage(c forge.Context) error
- func (e *DashboardExtension) ServeAddOnDetailPage(c forge.Context) error
- func (e *DashboardExtension) ServeAddOnsListPage(c forge.Context) error
- func (e *DashboardExtension) ServeAddPaymentMethodPage(c forge.Context) error
- func (e *DashboardExtension) ServeAlertsListPage(c forge.Context) error
- func (e *DashboardExtension) ServeAnalyticsDashboardPage(c forge.Context) error
- func (e *DashboardExtension) ServeBillingOverviewPage(c forge.Context) error
- func (e *DashboardExtension) ServeCouponCreatePage(c forge.Context) error
- func (e *DashboardExtension) ServeCouponsListPage(c forge.Context) error
- func (e *DashboardExtension) ServeFeatureCreatePage(c forge.Context) error
- func (e *DashboardExtension) ServeFeatureDetailPage(c forge.Context) error
- func (e *DashboardExtension) ServeFeatureEditPage(c forge.Context) error
- func (e *DashboardExtension) ServeFeatureUsagePage(c forge.Context) error
- func (e *DashboardExtension) ServeFeaturesListPage(c forge.Context) error
- func (e *DashboardExtension) ServeInvoiceDetailPage(c forge.Context) error
- func (e *DashboardExtension) ServeInvoicesListPage(c forge.Context) error
- func (e *DashboardExtension) ServePaymentMethodsPage(c forge.Context) error
- func (e *DashboardExtension) ServePlanCreatePage(c forge.Context) error
- func (e *DashboardExtension) ServePlanDetailPage(c forge.Context) error
- func (e *DashboardExtension) ServePlanEditPage(c forge.Context) error
- func (e *DashboardExtension) ServePlanFeaturesPage(c forge.Context) error
- func (e *DashboardExtension) ServePlansListPage(c forge.Context) error
- func (e *DashboardExtension) ServeSettingsPage(c forge.Context) error
- func (e *DashboardExtension) ServeSubscriptionDetailPage(c forge.Context) error
- func (e *DashboardExtension) ServeSubscriptionsListPage(c forge.Context) error
- func (e *DashboardExtension) ServeUsageDashboardPage(c forge.Context) error
- func (e *DashboardExtension) SetRegistry(registry *dashboard.ExtensionRegistry)
- 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) GetServices() map[string]interface{}
- 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 interface{}) 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 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 ( // Plan errors ErrPlanNotFound = errors.ErrPlanNotFound ErrPlanAlreadyExists = errors.ErrPlanAlreadyExists ErrPlanNotActive = errors.ErrPlanNotActive ErrPlanHasSubscriptions = errors.ErrPlanHasSubscriptions ErrInvalidPlanSlug = errors.ErrInvalidPlanSlug ErrInvalidBillingPattern = errors.ErrInvalidBillingPattern ErrInvalidBillingInterval = errors.ErrInvalidBillingInterval // Subscription errors ErrSubscriptionNotFound = errors.ErrSubscriptionNotFound ErrSubscriptionAlreadyExists = errors.ErrSubscriptionAlreadyExists ErrSubscriptionNotActive = errors.ErrSubscriptionNotActive ErrSubscriptionCanceled = errors.ErrSubscriptionCanceled ErrSubscriptionPaused = errors.ErrSubscriptionPaused ErrCannotDowngrade = errors.ErrCannotDowngrade ErrInvalidQuantity = errors.ErrInvalidQuantity // Add-on errors ErrAddOnNotFound = errors.ErrAddOnNotFound ErrAddOnAlreadyExists = errors.ErrAddOnAlreadyExists ErrAddOnNotActive = errors.ErrAddOnNotActive ErrAddOnNotAvailable = errors.ErrAddOnNotAvailable ErrAddOnAlreadyAttached = errors.ErrAddOnAlreadyAttached ErrAddOnNotAttached = errors.ErrAddOnNotAttached ErrAddOnMaxQuantity = errors.ErrAddOnMaxQuantity // Invoice errors ErrInvoiceNotFound = errors.ErrInvoiceNotFound ErrInvoiceAlreadyPaid = errors.ErrInvoiceAlreadyPaid ErrInvoiceVoided = errors.ErrInvoiceVoided ErrInvoiceNotOpen = errors.ErrInvoiceNotOpen // Usage errors ErrUsageRecordNotFound = errors.ErrUsageRecordNotFound ErrDuplicateUsageRecord = errors.ErrDuplicateUsageRecord ErrInvalidUsageMetric = errors.ErrInvalidUsageMetric ErrInvalidUsageAction = errors.ErrInvalidUsageAction // Payment method errors ErrPaymentMethodNotFound = errors.ErrPaymentMethodNotFound ErrPaymentMethodRequired = errors.ErrPaymentMethodRequired ErrPaymentMethodExpired = errors.ErrPaymentMethodExpired ErrDefaultPaymentMethodDelete = errors.ErrDefaultPaymentMethodDelete // Customer errors ErrCustomerNotFound = errors.ErrCustomerNotFound ErrCustomerAlreadyExists = errors.ErrCustomerAlreadyExists // Provider errors ErrProviderNotConfigured = errors.ErrProviderNotConfigured ErrProviderAPIError = errors.ErrProviderAPIError ErrWebhookSignatureInvalid = errors.ErrWebhookSignatureInvalid ErrWebhookEventUnhandled = errors.ErrWebhookEventUnhandled // Feature/limit errors ErrFeatureLimitExceeded = errors.ErrFeatureLimitExceeded ErrSeatLimitExceeded = errors.ErrSeatLimitExceeded ErrSubscriptionRequired = errors.ErrSubscriptionRequired ErrTrialExpired = errors.ErrTrialExpired // General errors 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]interface{}
}
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) 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(c forge.Context) error
HandleArchivePlan handles plan archiving (deactivation)
func (*DashboardExtension) HandleCancelSubscription ¶
func (e *DashboardExtension) HandleCancelSubscription(c forge.Context) error
HandleCancelSubscription handles subscription cancellation
func (*DashboardExtension) HandleCreateAddOn ¶
func (e *DashboardExtension) HandleCreateAddOn(c forge.Context) error
HandleCreateAddOn handles add-on creation form submission
func (*DashboardExtension) HandleCreateCoupon ¶
func (e *DashboardExtension) HandleCreateCoupon(c forge.Context) error
HandleCreateCoupon handles coupon creation form submission TODO: Implement when couponSvc is added to Plugin
func (*DashboardExtension) HandleCreateFeature ¶
func (e *DashboardExtension) HandleCreateFeature(c forge.Context) error
HandleCreateFeature handles the feature creation form submission
func (*DashboardExtension) HandleCreatePlan ¶
func (e *DashboardExtension) HandleCreatePlan(c forge.Context) error
HandleCreatePlan handles plan creation form submission
func (*DashboardExtension) HandleDeleteFeature ¶
func (e *DashboardExtension) HandleDeleteFeature(c forge.Context) error
HandleDeleteFeature handles feature deletion
func (*DashboardExtension) HandleDeletePlan ¶
func (e *DashboardExtension) HandleDeletePlan(c forge.Context) error
HandleDeletePlan handles permanent plan deletion
func (*DashboardExtension) HandleExportFeaturesAndPlans ¶ added in v0.0.4
func (e *DashboardExtension) HandleExportFeaturesAndPlans(c forge.Context) error
HandleExportFeaturesAndPlans exports features and plans as JSON
func (*DashboardExtension) HandleImportFeaturesAndPlans ¶ added in v0.0.4
func (e *DashboardExtension) HandleImportFeaturesAndPlans(c forge.Context) error
HandleImportFeaturesAndPlans imports features and plans from JSON
func (*DashboardExtension) HandleLinkFeatureToPlan ¶
func (e *DashboardExtension) HandleLinkFeatureToPlan(c forge.Context) error
HandleLinkFeatureToPlan handles linking a feature to a plan
func (*DashboardExtension) HandleMarkInvoicePaid ¶
func (e *DashboardExtension) HandleMarkInvoicePaid(c forge.Context) error
HandleMarkInvoicePaid handles marking an invoice as paid
func (*DashboardExtension) HandleRemovePaymentMethod ¶ added in v0.0.9
func (e *DashboardExtension) HandleRemovePaymentMethod(c forge.Context) error
HandleRemovePaymentMethod removes a payment method via HTMX
func (*DashboardExtension) HandleSetDefaultPaymentMethod ¶ added in v0.0.9
func (e *DashboardExtension) HandleSetDefaultPaymentMethod(c forge.Context) error
HandleSetDefaultPaymentMethod sets a payment method as default via HTMX
func (*DashboardExtension) HandleShowImportForm ¶ added in v0.0.4
func (e *DashboardExtension) HandleShowImportForm(c forge.Context) error
HandleShowImportForm displays the import form page
func (*DashboardExtension) HandleSyncAllFeaturesFromProvider ¶ added in v0.0.5
func (e *DashboardExtension) HandleSyncAllFeaturesFromProvider(c forge.Context) error
HandleSyncAllFeaturesFromProvider syncs all features from the payment provider
func (*DashboardExtension) HandleSyncAllPlansFromProvider ¶
func (e *DashboardExtension) HandleSyncAllPlansFromProvider(c forge.Context) error
HandleSyncAllPlansFromProvider syncs all plans from the payment provider
func (*DashboardExtension) HandleSyncFeature ¶ added in v0.0.5
func (e *DashboardExtension) HandleSyncFeature(c forge.Context) error
HandleSyncFeature handles syncing a feature to the provider
func (*DashboardExtension) HandleSyncFeatureFromProvider ¶ added in v0.0.5
func (e *DashboardExtension) HandleSyncFeatureFromProvider(c forge.Context) error
HandleSyncFeatureFromProvider syncs a feature from the payment provider
func (*DashboardExtension) HandleSyncInvoices ¶ added in v0.0.6
func (e *DashboardExtension) HandleSyncInvoices(c forge.Context) error
HandleSyncInvoices handles syncing invoices from Stripe
func (*DashboardExtension) HandleSyncPlan ¶
func (e *DashboardExtension) HandleSyncPlan(c forge.Context) error
HandleSyncPlan handles syncing a plan to the payment provider
func (*DashboardExtension) HandleSyncPlanFromProvider ¶
func (e *DashboardExtension) HandleSyncPlanFromProvider(c forge.Context) error
HandleSyncPlanFromProvider syncs a single plan from the payment provider
func (*DashboardExtension) HandleUnlinkFeatureFromPlan ¶
func (e *DashboardExtension) HandleUnlinkFeatureFromPlan(c forge.Context) error
HandleUnlinkFeatureFromPlan handles unlinking a feature from a plan
func (*DashboardExtension) HandleUpdateFeature ¶
func (e *DashboardExtension) HandleUpdateFeature(c forge.Context) error
HandleUpdateFeature handles the feature update form submission
func (*DashboardExtension) HandleUpdatePlan ¶
func (e *DashboardExtension) HandleUpdatePlan(c forge.Context) error
HandleUpdatePlan handles plan update form submission
func (*DashboardExtension) HandleUpdatePlanFeatureLink ¶
func (e *DashboardExtension) HandleUpdatePlanFeatureLink(c forge.Context) 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(c forge.Context) error
ServeAddOnCreatePage renders the add-on creation form
func (*DashboardExtension) ServeAddOnDetailPage ¶
func (e *DashboardExtension) ServeAddOnDetailPage(c forge.Context) error
ServeAddOnDetailPage renders the add-on detail page
func (*DashboardExtension) ServeAddOnsListPage ¶
func (e *DashboardExtension) ServeAddOnsListPage(c forge.Context) error
ServeAddOnsListPage renders the add-ons list page
func (*DashboardExtension) ServeAddPaymentMethodPage ¶ added in v0.0.9
func (e *DashboardExtension) ServeAddPaymentMethodPage(c forge.Context) error
ServeAddPaymentMethodPage renders the add payment method page with Stripe Elements
func (*DashboardExtension) ServeAlertsListPage ¶
func (e *DashboardExtension) ServeAlertsListPage(c forge.Context) error
ServeAlertsListPage renders the alerts list page
func (*DashboardExtension) ServeAnalyticsDashboardPage ¶
func (e *DashboardExtension) ServeAnalyticsDashboardPage(c forge.Context) error
ServeAnalyticsDashboardPage renders the analytics dashboard
func (*DashboardExtension) ServeBillingOverviewPage ¶
func (e *DashboardExtension) ServeBillingOverviewPage(c forge.Context) error
ServeBillingOverviewPage renders the billing overview dashboard
func (*DashboardExtension) ServeCouponCreatePage ¶
func (e *DashboardExtension) ServeCouponCreatePage(c forge.Context) error
ServeCouponCreatePage renders the coupon creation form
func (*DashboardExtension) ServeCouponsListPage ¶
func (e *DashboardExtension) ServeCouponsListPage(c forge.Context) error
ServeCouponsListPage renders the coupons list page
func (*DashboardExtension) ServeFeatureCreatePage ¶
func (e *DashboardExtension) ServeFeatureCreatePage(c forge.Context) error
ServeFeatureCreatePage renders the feature creation form
func (*DashboardExtension) ServeFeatureDetailPage ¶
func (e *DashboardExtension) ServeFeatureDetailPage(c forge.Context) error
ServeFeatureDetailPage renders the feature detail page
func (*DashboardExtension) ServeFeatureEditPage ¶
func (e *DashboardExtension) ServeFeatureEditPage(c forge.Context) error
ServeFeatureEditPage renders the feature edit form
func (*DashboardExtension) ServeFeatureUsagePage ¶
func (e *DashboardExtension) ServeFeatureUsagePage(c forge.Context) error
ServeFeatureUsagePage renders the feature usage monitoring page
func (*DashboardExtension) ServeFeaturesListPage ¶
func (e *DashboardExtension) ServeFeaturesListPage(c forge.Context) error
ServeFeaturesListPage renders the features list dashboard
func (*DashboardExtension) ServeInvoiceDetailPage ¶
func (e *DashboardExtension) ServeInvoiceDetailPage(c forge.Context) error
ServeInvoiceDetailPage renders the invoice detail page
func (*DashboardExtension) ServeInvoicesListPage ¶
func (e *DashboardExtension) ServeInvoicesListPage(c forge.Context) error
ServeInvoicesListPage renders the invoices list page
func (*DashboardExtension) ServePaymentMethodsPage ¶ added in v0.0.9
func (e *DashboardExtension) ServePaymentMethodsPage(c forge.Context) error
ServePaymentMethodsPage renders the payment methods management page
func (*DashboardExtension) ServePlanCreatePage ¶
func (e *DashboardExtension) ServePlanCreatePage(c forge.Context) error
ServePlanCreatePage renders the plan creation form
func (*DashboardExtension) ServePlanDetailPage ¶
func (e *DashboardExtension) ServePlanDetailPage(c forge.Context) error
ServePlanDetailPage renders the plan detail page
func (*DashboardExtension) ServePlanEditPage ¶
func (e *DashboardExtension) ServePlanEditPage(c forge.Context) error
ServePlanEditPage renders the plan edit form
func (*DashboardExtension) ServePlanFeaturesPage ¶
func (e *DashboardExtension) ServePlanFeaturesPage(c forge.Context) error
ServePlanFeaturesPage renders the plan features management page
func (*DashboardExtension) ServePlansListPage ¶
func (e *DashboardExtension) ServePlansListPage(c forge.Context) error
ServePlansListPage renders the plans list page
func (*DashboardExtension) ServeSettingsPage ¶
func (e *DashboardExtension) ServeSettingsPage(c forge.Context) error
Settings Page
func (*DashboardExtension) ServeSubscriptionDetailPage ¶
func (e *DashboardExtension) ServeSubscriptionDetailPage(c forge.Context) error
ServeSubscriptionDetailPage renders the subscription detail page
func (*DashboardExtension) ServeSubscriptionsListPage ¶
func (e *DashboardExtension) ServeSubscriptionsListPage(c forge.Context) error
ServeSubscriptionsListPage renders the subscriptions list page
func (*DashboardExtension) ServeUsageDashboardPage ¶
func (e *DashboardExtension) ServeUsageDashboardPage(c forge.Context) error
ServeUsageDashboardPage renders the usage dashboard page
func (*DashboardExtension) SetRegistry ¶
func (e *DashboardExtension) SetRegistry(registry *dashboard.ExtensionRegistry)
SetRegistry sets the extension registry reference (called by dashboard after registration)
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) 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
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 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
Re-export error types for convenience
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 |