Documentation
¶
Index ¶
- Constants
- Variables
- type Alignment
- type AlignmentUpdate
- type BooleanEntitlementTemplate
- type Discount
- func (d *Discount) AsPercentage() (PercentageDiscount, error)
- func (d *Discount) FromPercentage(discount PercentageDiscount)
- func (d *Discount) Hash() hasher.Hash
- func (d *Discount) MarshalJSON() ([]byte, error)
- func (d *Discount) RateCardKeys() []string
- func (d *Discount) Type() DiscountType
- func (d *Discount) UnmarshalJSON(bytes []byte) error
- func (d *Discount) Validate() error
- type DiscountType
- type Discounts
- type EffectivePeriod
- type EntitlementTemplate
- func (e *EntitlementTemplate) AsBoolean() (BooleanEntitlementTemplate, error)
- func (e *EntitlementTemplate) AsMetered() (MeteredEntitlementTemplate, error)
- func (e *EntitlementTemplate) AsStatic() (StaticEntitlementTemplate, error)
- func (e *EntitlementTemplate) Equal(v *EntitlementTemplate) bool
- func (e *EntitlementTemplate) FromBoolean(t BooleanEntitlementTemplate)
- func (e *EntitlementTemplate) FromMetered(t MeteredEntitlementTemplate)
- func (e *EntitlementTemplate) FromStatic(t StaticEntitlementTemplate)
- func (e *EntitlementTemplate) MarshalJSON() ([]byte, error)
- func (e *EntitlementTemplate) Type() entitlement.EntitlementType
- func (e *EntitlementTemplate) UnmarshalJSON(bytes []byte) error
- func (e *EntitlementTemplate) Validate() error
- type FlatFeeRateCard
- func (r *FlatFeeRateCard) AsMeta() RateCardMeta
- func (r *FlatFeeRateCard) Equal(v RateCard) bool
- func (r *FlatFeeRateCard) Feature() *feature.Feature
- func (r *FlatFeeRateCard) GetBillingCadence() *isodate.Period
- func (r *FlatFeeRateCard) Key() string
- func (r *FlatFeeRateCard) Merge(v RateCard) error
- func (r *FlatFeeRateCard) Type() RateCardType
- func (r *FlatFeeRateCard) Validate() error
- type FlatPrice
- type MeteredEntitlementTemplate
- type PaymentTermType
- type PercentageDiscount
- type Phase
- type PhaseMeta
- type Plan
- type PlanMeta
- type PlanStatus
- type Price
- func (p *Price) AsFlat() (FlatPrice, error)
- func (p *Price) AsTiered() (TieredPrice, error)
- func (p *Price) AsUnit() (UnitPrice, error)
- func (p *Price) Equal(v *Price) bool
- func (p *Price) FromFlat(price FlatPrice)
- func (p *Price) FromTiered(price TieredPrice)
- func (p *Price) FromUnit(price UnitPrice)
- func (p *Price) MarshalJSON() ([]byte, error)
- func (p *Price) Type() PriceType
- func (p *Price) UnmarshalJSON(bytes []byte) error
- func (p *Price) Validate() error
- type PriceTier
- type PriceTierFlatPrice
- type PriceTierUnitPrice
- type PriceType
- type RateCard
- type RateCardMeta
- type RateCardSerde
- type RateCardType
- type RateCards
- type StaticEntitlementTemplate
- type StripeTaxConfig
- type TaxBehavior
- type TaxConfig
- type TieredPrice
- type TieredPriceMode
- type UnitPrice
- type UsageBasedRateCard
- func (r *UsageBasedRateCard) AsMeta() RateCardMeta
- func (r *UsageBasedRateCard) Equal(v RateCard) bool
- func (r *UsageBasedRateCard) Feature() *feature.Feature
- func (r *UsageBasedRateCard) GetBillingCadence() *isodate.Period
- func (r *UsageBasedRateCard) Key() string
- func (r *UsageBasedRateCard) Merge(v RateCard) error
- func (r *UsageBasedRateCard) Type() RateCardType
- func (r *UsageBasedRateCard) Validate() error
Constants ¶
View Source
const DefaultPaymentTerm = InAdvancePaymentTerm
Variables ¶
View Source
var StripeProductTaxCodeRegexp = regexp.MustCompile(`^txcd_\d{8}$`)
Functions ¶
This section is empty.
Types ¶
type Alignment ¶
type Alignment struct {
// BillablesMustAlign indicates whether all billable items in a given phase must share the same BillingPeriodDuration.
BillablesMustAlign bool `json:"billablesMustAlign"`
}
type AlignmentUpdate ¶
type AlignmentUpdate struct {
BillablesMustAlign *bool `json:"billablesMustAlign,omitempty"`
}
AlignmentUpdate is used for the nil-ish comparison of the plan service only
type BooleanEntitlementTemplate ¶
type BooleanEntitlementTemplate struct {
// Metadata a set of key/value pairs describing metadata for the RateCard.
Metadata models.Metadata `json:"metadata,omitempty"`
}
func (*BooleanEntitlementTemplate) Equal ¶
func (t *BooleanEntitlementTemplate) Equal(v *BooleanEntitlementTemplate) bool
func (*BooleanEntitlementTemplate) Validate ¶
func (t *BooleanEntitlementTemplate) Validate() error
type Discount ¶
type Discount struct {
// contains filtered or unexported fields
}
func NewDiscountFrom ¶
func NewDiscountFrom[T PercentageDiscount](v T) Discount
func (*Discount) AsPercentage ¶
func (d *Discount) AsPercentage() (PercentageDiscount, error)
func (*Discount) FromPercentage ¶
func (d *Discount) FromPercentage(discount PercentageDiscount)
func (*Discount) MarshalJSON ¶
func (*Discount) RateCardKeys ¶
func (*Discount) Type ¶
func (d *Discount) Type() DiscountType
func (*Discount) UnmarshalJSON ¶
type DiscountType ¶
type DiscountType string
const (
PercentageDiscountType DiscountType = "percentage"
)
func (DiscountType) StringValues ¶
func (p DiscountType) StringValues() []string
func (DiscountType) Values ¶
func (p DiscountType) Values() []DiscountType
type EffectivePeriod ¶
type EffectivePeriod struct {
// EffectiveFrom defines the time from the Plan becomes active.
EffectiveFrom *time.Time `json:"effectiveFrom,omitempty"`
// EffectiveTO defines the time from the Plan becomes archived.
EffectiveTo *time.Time `json:"effectiveTo,omitempty"`
}
func (EffectivePeriod) Equal ¶
func (p EffectivePeriod) Equal(o EffectivePeriod) bool
Equal returns true if the two EffectivePeriods are equal.
func (EffectivePeriod) Status ¶
func (p EffectivePeriod) Status() PlanStatus
Status returns the current status of the Plan
func (EffectivePeriod) StatusAt ¶
func (p EffectivePeriod) StatusAt(t time.Time) PlanStatus
StatusAt returns the plan status relative to time t.
func (EffectivePeriod) Validate ¶
func (p EffectivePeriod) Validate() error
type EntitlementTemplate ¶
type EntitlementTemplate struct {
// contains filtered or unexported fields
}
EntitlementTemplate is the template used for instantiating entitlement.Entitlement for RateCard.
func NewEntitlementTemplateFrom ¶
func NewEntitlementTemplateFrom[T MeteredEntitlementTemplate | StaticEntitlementTemplate | BooleanEntitlementTemplate](c T) *EntitlementTemplate
func (*EntitlementTemplate) AsBoolean ¶
func (e *EntitlementTemplate) AsBoolean() (BooleanEntitlementTemplate, error)
func (*EntitlementTemplate) AsMetered ¶
func (e *EntitlementTemplate) AsMetered() (MeteredEntitlementTemplate, error)
func (*EntitlementTemplate) AsStatic ¶
func (e *EntitlementTemplate) AsStatic() (StaticEntitlementTemplate, error)
func (*EntitlementTemplate) Equal ¶
func (e *EntitlementTemplate) Equal(v *EntitlementTemplate) bool
func (*EntitlementTemplate) FromBoolean ¶
func (e *EntitlementTemplate) FromBoolean(t BooleanEntitlementTemplate)
func (*EntitlementTemplate) FromMetered ¶
func (e *EntitlementTemplate) FromMetered(t MeteredEntitlementTemplate)
func (*EntitlementTemplate) FromStatic ¶
func (e *EntitlementTemplate) FromStatic(t StaticEntitlementTemplate)
func (*EntitlementTemplate) MarshalJSON ¶
func (e *EntitlementTemplate) MarshalJSON() ([]byte, error)
func (*EntitlementTemplate) Type ¶
func (e *EntitlementTemplate) Type() entitlement.EntitlementType
func (*EntitlementTemplate) UnmarshalJSON ¶
func (e *EntitlementTemplate) UnmarshalJSON(bytes []byte) error
func (*EntitlementTemplate) Validate ¶
func (e *EntitlementTemplate) Validate() error
type FlatFeeRateCard ¶
type FlatFeeRateCard struct {
RateCardMeta
// BillingCadence defines the billing cadence of the RateCard in ISO8601 format.
// When nil (null) it means it is a one time fee.
// Example: "P1D12H"
BillingCadence *isodate.Period `json:"billingCadence"`
}
func (*FlatFeeRateCard) AsMeta ¶
func (r *FlatFeeRateCard) AsMeta() RateCardMeta
func (*FlatFeeRateCard) Equal ¶
func (r *FlatFeeRateCard) Equal(v RateCard) bool
func (*FlatFeeRateCard) Feature ¶
func (r *FlatFeeRateCard) Feature() *feature.Feature
func (*FlatFeeRateCard) GetBillingCadence ¶
func (r *FlatFeeRateCard) GetBillingCadence() *isodate.Period
func (*FlatFeeRateCard) Key ¶
func (r *FlatFeeRateCard) Key() string
func (*FlatFeeRateCard) Merge ¶
func (r *FlatFeeRateCard) Merge(v RateCard) error
func (*FlatFeeRateCard) Type ¶
func (r *FlatFeeRateCard) Type() RateCardType
func (*FlatFeeRateCard) Validate ¶
func (r *FlatFeeRateCard) Validate() error
type FlatPrice ¶
type FlatPrice struct {
// Amount of the flat price.
Amount decimal.Decimal `json:"amount"`
// PaymentTerm defines the payment term of the flat price.
// Defaults to InAdvancePaymentTerm.
PaymentTerm PaymentTermType `json:"paymentTerm,omitempty"`
}
type MeteredEntitlementTemplate ¶
type MeteredEntitlementTemplate struct {
// Metadata a set of key/value pairs describing metadata for the RateCard.
Metadata models.Metadata `json:"metadata,omitempty"`
// IsSoftLimit set to `true` for allowing the subject to use the feature even if the entitlement is exhausted.
IsSoftLimit bool `json:"isSoftLimit,omitempty"`
// IssueAfterReset defines the amount to be automatically granted at entitlement.Entitlement creation or reset.
IssueAfterReset *float64 `json:"issueAfterReset,omitempty"`
// IssueAfterResetPriority defines the grant priority for the default grant.
IssueAfterResetPriority *uint8 `json:"issueAfterResetPriority,omitempty"`
// PreserveOverageAtReset defines whether the overage is preserved after reset.
PreserveOverageAtReset *bool `json:"preserveOverageAtReset,omitempty"`
// UsagePeriod defines the interval of the entitlement in ISO8601 format.
// Defaults to the billing cadence of the rate card.
// Example: "P1D12H"
UsagePeriod isodate.Period `json:"usagePeriod,omitempty"`
}
func (*MeteredEntitlementTemplate) Equal ¶
func (t *MeteredEntitlementTemplate) Equal(v *MeteredEntitlementTemplate) bool
func (*MeteredEntitlementTemplate) Validate ¶
func (t *MeteredEntitlementTemplate) Validate() error
type PaymentTermType ¶
type PaymentTermType string
const ( InAdvancePaymentTerm PaymentTermType = "in_advance" InArrearsPaymentTerm PaymentTermType = "in_arrears" )
func (PaymentTermType) StringValues ¶
func (p PaymentTermType) StringValues() []string
func (PaymentTermType) Values ¶
func (p PaymentTermType) Values() []string
type PercentageDiscount ¶
type PercentageDiscount struct {
// Percentage defines percentage of the discount.
Percentage decimal.Decimal `json:"percentage"`
// RateCards is the list of specific RateCard Keys the discount is applied to.
// If not provided the discount applies to all RateCards in Phase.
RateCards []string `json:"rateCards,omitempty"`
}
func (PercentageDiscount) Hash ¶
func (f PercentageDiscount) Hash() hasher.Hash
func (PercentageDiscount) Validate ¶
func (f PercentageDiscount) Validate() error
type Phase ¶
type Phase struct {
PhaseMeta
// Discounts stores a set of discount(s) applied to all or specific RateCards.
Discounts Discounts `json:"discounts,omitempty"`
// RateCards
RateCards RateCards `json:"rateCards"`
}
type PhaseMeta ¶
type PhaseMeta struct {
// Key is the unique key for Phase.
Key string `json:"key"`
// Name is the name of the Phase.
Name string `json:"name"`
// Description is the detailed description of the Phase.
Description *string `json:"description,omitempty"`
// Metadata stores user defined metadata for Phase.
Metadata models.Metadata `json:"metadata,omitempty"`
// Duration is the duration of the Phase.
Duration *isodate.Period `json:"duration"`
}
type Plan ¶
func (Plan) ValidForCreatingSubscriptions ¶
ValidForCreatingSubscriptions checks if the Plan is valid for creating Subscriptions, a stricter version of Validate
type PlanMeta ¶
type PlanMeta struct {
EffectivePeriod
Alignment
// Key is the unique key for Plan.
Key string `json:"key"`
// Version
Version int `json:"version"`
// Name
Name string `json:"name"`
// Description
Description *string `json:"description,omitempty"`
// Currency
Currency currency.Code `json:"currency"`
// Metadata
Metadata models.Metadata `json:"metadata,omitempty"`
}
type PlanStatus ¶
type PlanStatus string
const ( DraftStatus PlanStatus = "draft" ActiveStatus PlanStatus = "active" ArchivedStatus PlanStatus = "archived" ScheduledStatus PlanStatus = "scheduled" InvalidStatus PlanStatus = "invalid" )
func (PlanStatus) Values ¶
func (s PlanStatus) Values() []string
type Price ¶
type Price struct {
// contains filtered or unexported fields
}
func NewPriceFrom ¶
func NewPriceFrom[T FlatPrice | UnitPrice | TieredPrice](v T) *Price
func (*Price) AsTiered ¶
func (p *Price) AsTiered() (TieredPrice, error)
func (*Price) FromTiered ¶
func (p *Price) FromTiered(price TieredPrice)
func (*Price) MarshalJSON ¶
func (*Price) UnmarshalJSON ¶
type PriceTier ¶
type PriceTier struct {
// UpToAmount defines the quantity will be contained in the tier. Inclusive.
// If null, the tier is open-ended.
UpToAmount *decimal.Decimal `json:"upToAmount,omitempty"`
// FlatPrice defines the flat price component of the tier.
FlatPrice *PriceTierFlatPrice `json:"flatPrice,omitempty"`
// UnitPrice defines the unit price component of the tier.
UnitPrice *PriceTierUnitPrice `json:"unitPrice,omitempty"`
}
PriceTier describes a tier of price(s).
type PriceTierFlatPrice ¶
type PriceTierFlatPrice struct {
// Amount of the flat price.
Amount decimal.Decimal `json:"amount"`
}
func (PriceTierFlatPrice) Validate ¶
func (f PriceTierFlatPrice) Validate() error
type PriceTierUnitPrice ¶
type PriceTierUnitPrice struct {
// Amount of the flat price.
Amount decimal.Decimal `json:"amount"`
}
func (PriceTierUnitPrice) Validate ¶
func (u PriceTierUnitPrice) Validate() error
type RateCardMeta ¶
type RateCardMeta struct {
// Key is the unique key for Plan.
Key string `json:"key"`
// Name of the RateCard
Name string `json:"name"`
// Description for the RateCard
Description *string `json:"description,omitempty"`
// Metadata a set of key/value pairs describing metadata for the RateCard
Metadata models.Metadata `json:"metadata,omitempty"`
// Feature defines optional Feature assigned to RateCard
Feature *feature.Feature `json:"feature,omitempty"`
// EntitlementTemplate defines the template used for instantiating entitlement.Entitlement.
// If Feature is set then template must be provided as well.
EntitlementTemplate *EntitlementTemplate `json:"entitlementTemplate,omitempty"`
// TaxConfig defines provider specific tax information.
TaxConfig *TaxConfig `json:"taxConfig,omitempty"`
// Price defines the price for the RateCard
Price *Price `json:"price"`
}
func (RateCardMeta) Equal ¶
func (r RateCardMeta) Equal(v RateCardMeta) bool
func (RateCardMeta) Validate ¶
func (r RateCardMeta) Validate() error
type RateCardSerde ¶
type RateCardSerde struct {
Type RateCardType `json:"type"`
}
type RateCardType ¶
type RateCardType string
const ( FlatFeeRateCardType RateCardType = "flat_fee" UsageBasedRateCardType RateCardType = "usage_based" )
func (RateCardType) Values ¶
func (s RateCardType) Values() []string
type StaticEntitlementTemplate ¶
type StaticEntitlementTemplate struct {
// Metadata a set of key/value pairs describing metadata for the RateCard.
Metadata models.Metadata `json:"metadata,omitempty"`
// Config stores a JSON parsable configuration for the entitlement.Entitlement.
// This value is also returned when checking entitlement access, and
// it is useful for configuring fine-grained access settings to the feature implemented in customers own system.
Config json.RawMessage `json:"config,omitempty"`
}
func (*StaticEntitlementTemplate) Equal ¶
func (t *StaticEntitlementTemplate) Equal(v *StaticEntitlementTemplate) bool
func (*StaticEntitlementTemplate) Validate ¶
func (t *StaticEntitlementTemplate) Validate() error
type StripeTaxConfig ¶
type StripeTaxConfig struct {
// Code stores the product tax code.
// See: https://docs.stripe.com/tax/tax-codes
// Example:"txcd_10000000"
Code string `json:"code"`
}
func (*StripeTaxConfig) Equal ¶
func (s *StripeTaxConfig) Equal(v *StripeTaxConfig) bool
func (*StripeTaxConfig) Validate ¶
func (s *StripeTaxConfig) Validate() error
type TaxBehavior ¶
type TaxBehavior string
const ( InclusiveTaxBehavior TaxBehavior = "inclusive" ExclusiveTaxBehavior TaxBehavior = "exclusive" )
func (TaxBehavior) Validate ¶
func (t TaxBehavior) Validate() error
func (TaxBehavior) Values ¶
func (t TaxBehavior) Values() []string
type TaxConfig ¶
type TaxConfig struct {
Behavior *TaxBehavior `json:"behavior,omitempty"`
Stripe *StripeTaxConfig `json:"stripe,omitempty"`
}
TaxConfig stores the provider specific tax configs.
func MergeTaxConfigs ¶
type TieredPrice ¶
type TieredPrice struct {
// Mode defines whether the tier is volume-based or graduated.
// * VolumeTieredPrice: the maximum quantity within a period determines the per-unit price
// * GraduatedTieredPrice: pricing can change as the quantity grows
Mode TieredPriceMode `json:"mode"`
// Tiers defines the list of PriceTier.
Tiers []PriceTier `json:"tiers"`
// MinimumAmount defines the least amount the customer committed to spend.
MinimumAmount *decimal.Decimal `json:"minimumAmount,omitempty"`
// MaximumAmount defines the upper limit of amount the customer entitled to spend.
MaximumAmount *decimal.Decimal `json:"maximumAmount,omitempty"`
}
func (*TieredPrice) Equal ¶
func (t *TieredPrice) Equal(v *TieredPrice) bool
func (*TieredPrice) Validate ¶
func (t *TieredPrice) Validate() error
func (*TieredPrice) WithSortedTiers ¶
func (t *TieredPrice) WithSortedTiers() TieredPrice
type TieredPriceMode ¶
type TieredPriceMode string
const ( // In `volume`-based tiering, the maximum quantity within a period determines the per unit price. VolumeTieredPrice TieredPriceMode = "volume" // In `graduated` tiering, pricing can change as the quantity grows. GraduatedTieredPrice TieredPriceMode = "graduated" )
func NewTieredPriceMode ¶
func NewTieredPriceMode(s string) (TieredPriceMode, error)
func (TieredPriceMode) StringValues ¶
func (p TieredPriceMode) StringValues() []string
func (TieredPriceMode) Values ¶
func (p TieredPriceMode) Values() []TieredPriceMode
type UnitPrice ¶
type UnitPrice struct {
// Amount of the unit price.
Amount decimal.Decimal `json:"amount"`
// MinimumAmount defines the least amount the customer committed to spend.
MinimumAmount *decimal.Decimal `json:"minimumAmount,omitempty"`
// MaximumAmount defines the upper limit of amount the customer entitled to spend.
MaximumAmount *decimal.Decimal `json:"maximumAmount,omitempty"`
}
type UsageBasedRateCard ¶
type UsageBasedRateCard struct {
RateCardMeta
// BillingCadence defines the billing cadence of the RateCard in ISO8601 format.
// Example: "P1D12H"
BillingCadence isodate.Period `json:"billingCadence"`
}
func (*UsageBasedRateCard) AsMeta ¶
func (r *UsageBasedRateCard) AsMeta() RateCardMeta
func (*UsageBasedRateCard) Equal ¶
func (r *UsageBasedRateCard) Equal(v RateCard) bool
func (*UsageBasedRateCard) Feature ¶
func (r *UsageBasedRateCard) Feature() *feature.Feature
func (*UsageBasedRateCard) GetBillingCadence ¶
func (r *UsageBasedRateCard) GetBillingCadence() *isodate.Period
func (*UsageBasedRateCard) Key ¶
func (r *UsageBasedRateCard) Key() string
func (*UsageBasedRateCard) Merge ¶
func (r *UsageBasedRateCard) Merge(v RateCard) error
func (*UsageBasedRateCard) Type ¶
func (r *UsageBasedRateCard) Type() RateCardType
func (*UsageBasedRateCard) Validate ¶
func (r *UsageBasedRateCard) Validate() error
Source Files
¶
Click to show internal directories.
Click to hide internal directories.