* implement core foundation * inject deps * fix incorrect migration * tail migration * use transaction for migration * fix: inject deps for tests * cleanup billing management for admin * upgrade stripe sdk to v85 * set price env variables * cleanup billing management * allow multiple dev windows * fix: settings scroll * feat: show nice video thumbnail in listview * feat: implement freemium restrictions * remove unnecessary comments * refactor * docs * format * tweak network settings better hierarchy
58 lines
1.4 KiB
Go
58 lines
1.4 KiB
Go
package billing
|
|
|
|
import "time"
|
|
|
|
type Cadence string
|
|
|
|
const (
|
|
CadenceMonthly Cadence = "monthly"
|
|
CadenceAnnual Cadence = "annual"
|
|
)
|
|
|
|
func (c Cadence) IsValid() bool {
|
|
return c == CadenceMonthly || c == CadenceAnnual
|
|
}
|
|
|
|
type Plan string
|
|
|
|
const (
|
|
PlanFree Plan = "free"
|
|
PlanPro Plan = "pro"
|
|
)
|
|
|
|
// Subscription is the persisted projection of a Stripe subscription,
|
|
// reconciled on every webhook event.
|
|
type Subscription struct {
|
|
ID string
|
|
NetworkID string
|
|
StripeCustomerID string
|
|
Status string
|
|
PriceID string
|
|
Cadence Cadence
|
|
Quantity int
|
|
CancelAtPeriodEnd bool
|
|
CurrentPeriodStart time.Time
|
|
CurrentPeriodEnd time.Time
|
|
CreatedAt time.Time
|
|
UpdatedAt time.Time
|
|
}
|
|
|
|
type Status struct {
|
|
Plan Plan `json:"plan"`
|
|
PlanStatus string `json:"plan_status"`
|
|
Cadence *Cadence `json:"cadence"`
|
|
Seats int `json:"seats"` // 0 on free plan; sub.Quantity on pro
|
|
CurrentPeriodEnd *time.Time `json:"current_period_end"`
|
|
CancelAtPeriodEnd bool `json:"cancel_at_period_end"`
|
|
PriceMonthlyCents int64 `json:"price_monthly_cents"`
|
|
PriceAnnualCents int64 `json:"price_annual_cents"`
|
|
}
|
|
|
|
type CheckoutParams struct {
|
|
NetworkID string
|
|
AdminHumanID string
|
|
AdminEmail string
|
|
Cadence Cadence
|
|
Seats int
|
|
}
|