46 lines
1.0 KiB
Go
46 lines
1.0 KiB
Go
package subscriptions
|
|
|
|
import (
|
|
"context"
|
|
"time"
|
|
|
|
"github.com/google/uuid"
|
|
)
|
|
|
|
// Subscriptions provides subscription tier and billing plan access for plugins.
|
|
type Subscriptions interface {
|
|
GetUserTierLevel(ctx context.Context, userID uuid.UUID) (*TierLevel, error)
|
|
GetTierBySlug(ctx context.Context, slug string) (*Tier, error)
|
|
ListTiers(ctx context.Context) ([]Tier, error)
|
|
ListActivePlans(ctx context.Context, tierID uuid.UUID) ([]Plan, error)
|
|
}
|
|
|
|
// TierLevel is the resolved tier for a user.
|
|
type TierLevel struct {
|
|
Level int
|
|
Features []byte
|
|
}
|
|
|
|
// Tier is a subscription tier definition.
|
|
type Tier struct {
|
|
ID uuid.UUID
|
|
Name string
|
|
Slug string
|
|
Level int
|
|
Description string
|
|
Features []byte
|
|
IsDefault bool
|
|
Position int
|
|
}
|
|
|
|
// Plan is an active billing plan within a tier.
|
|
type Plan struct {
|
|
ID uuid.UUID
|
|
TierID uuid.UUID
|
|
BillingInterval string
|
|
Amount int32
|
|
Currency string
|
|
IsActive bool
|
|
CreatedAt time.Time
|
|
}
|