Documentation ¶
Index ¶
- Constants
- Variables
- type AuthnService
- type Checkout
- type CreditService
- type CustomerService
- type Filter
- type OrganizationService
- type PlanService
- type ProductService
- type Repository
- type Service
- func (s *Service) Apply(ctx context.Context, ch Checkout) (*subscription.Subscription, *product.Product, error)
- func (s *Service) Close() error
- func (s *Service) Create(ctx context.Context, ch Checkout) (Checkout, error)
- func (s *Service) CreateSessionForPaymentMethod(ctx context.Context, ch Checkout) (Checkout, error)
- func (s *Service) GetByID(ctx context.Context, id string) (Checkout, error)
- func (s *Service) Init(ctx context.Context)
- func (s *Service) List(ctx context.Context, filter Filter) ([]Checkout, error)
- func (s *Service) SyncWithProvider(ctx context.Context, customerID string) error
- type State
- type SubscriptionService
Constants ¶
View Source
const ( SessionValidity = time.Hour * 24 SyncDelay = time.Second * 60 // ProductQuantityMetadataKey is the metadata key for the quantity of the product // it's necessary to cast as this properly because while storing metadata, it's serialized as json // and when retrieved, it's always an interface{} of float64 type ProductQuantityMetadataKey = "product_quantity" // AmountTotalMetadataKey is the metadata key for the total amount of the checkout // same goes for this as well, it's always an interface{} of float64 type AmountTotalMetadataKey = "amount_total" CurrencyMetadataKey = "currency" ProviderIDSubscriptionMetadataKey = "provider_subscription_id" InitiatorIDMetadataKey = "initiated_by" )
Variables ¶
Functions ¶
This section is empty.
Types ¶
type AuthnService ¶ added in v0.8.34
type AuthnService interface {
GetPrincipal(ctx context.Context, assertions ...authenticate.ClientAssertion) (authenticate.Principal, error)
}
type Checkout ¶
type Checkout struct { ID string ProviderID string // identifier set by the billing engine provider CustomerID string PlanID string // uuid of plan if resource type is subscription SkipTrial bool // if set, no trial period CancelAfterTrial bool // if set, cancel subscription after trial period ProductID string // CancelUrl is the URL to which provider sends customers when payment is canceled CancelUrl string // SuccessUrl is the URL to which provider sends customers when payment is complete SuccessUrl string // CheckoutUrl is the URL to which provider sends customers to finish payment CheckoutUrl string State string PaymentStatus string Metadata metadata.Metadata CreatedAt time.Time UpdatedAt time.Time ExpireAt time.Time }
type CreditService ¶
type CustomerService ¶
type OrganizationService ¶ added in v0.8.13
type PlanService ¶
type ProductService ¶ added in v0.8.14
type Repository ¶
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
func NewService ¶
func NewService(stripeClient *client.API, stripeAutoTax bool, repository Repository, customerService CustomerService, planService PlanService, subscriptionService SubscriptionService, productService ProductService, creditService CreditService, orgService OrganizationService, authnService AuthnService) *Service
func (*Service) Apply ¶ added in v0.8.16
func (s *Service) Apply(ctx context.Context, ch Checkout) (*subscription.Subscription, *product.Product, error)
Apply applies the actual request directly without creating a checkout session for example when a request is created for a plan, it will directly subscribe without actually paying for it
func (*Service) CreateSessionForPaymentMethod ¶ added in v0.8.16
type SubscriptionService ¶
type SubscriptionService interface { List(ctx context.Context, filter subscription.Filter) ([]subscription.Subscription, error) Create(ctx context.Context, sub subscription.Subscription) (subscription.Subscription, error) GetByProviderID(ctx context.Context, id string) (subscription.Subscription, error) Cancel(ctx context.Context, id string, immediate bool) (subscription.Subscription, error) HasUserSubscribedBefore(ctx context.Context, customerID string, planID string) (bool, error) }
Click to show internal directories.
Click to hide internal directories.