implement core foundation
This commit is contained in:
@@ -0,0 +1,57 @@
|
||||
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
|
||||
}
|
||||
Reference in New Issue
Block a user