Documentation
¶
Overview ¶
Package entitlements is a wrapper package for the entitlements service and a basic stripe integration
Index ¶
- Constants
- Variables
- func GetOrganizationIDFromMetadata(metadata map[string]string) string
- func GetOrganizationNameFromMetadata(metadata map[string]string) string
- func GetOrganizationSettingsIDFromMetadata(metadata map[string]string) string
- func GetOrganizationSubscriptionIDFromMetadata(metadata map[string]string) string
- func GetUpdatedFields(props map[string]interface{}, orgCustomer *OrganizationCustomer) (params *stripe.CustomerUpdateParams)
- func IsSubscriptionActive(status stripe.SubscriptionStatus) bool
- func WithKeys(keys map[string]string) func(*QueryBuilder)
- func WithOperator(operator string) func(*QueryBuilder)
- func WritePlansToYAML(product []Product, filename string) error
- func WriteTuplesToYaml(tuples []TupleStruct, filename string) error
- type BillingPortalSession
- type Checkout
- type Config
- type ConfigOpts
- func WithEnabled(enabled bool) ConfigOpts
- func WithPersonalOrgSubscriptionPriceID(personalOrgSubscriptionPriceID string) ConfigOpts
- func WithPrivateStripeKey(privateStripeKey string) ConfigOpts
- func WithPublicStripeKey(publicStripeKey string) ConfigOpts
- func WithStripeBillingPortalSuccessURL(stripeBillingPortalSuccessURL string) ConfigOpts
- func WithStripeCancellationReturnURL(stripeCancellationReturnURL string) ConfigOpts
- func WithStripeWebhookSecret(stripeWebhookSecret string) ConfigOpts
- func WithStripeWebhookURL(stripeWebhookURL string) ConfigOpts
- func WithTrialSubscriptionPriceID(trialSubscriptionPriceID string) ConfigOpts
- type ContactInfo
- type Customer
- type Feature
- type OrganizationCustomer
- type Plan
- type Price
- type PricingTier
- type Product
- type ProductFeature
- type QueryBuilder
- type StripeClient
- func (sc *StripeClient) CancelSubscription(ctx context.Context, id string, params *stripe.SubscriptionCancelParams) (*stripe.Subscription, error)
- func (sc *StripeClient) CancellationBillingPortalSession(ctx context.Context, subsID, custID string) (*BillingPortalSession, error)
- func (sc *StripeClient) CreateBillingPortalPaymentMethods(ctx context.Context, custID string) (*BillingPortalSession, error)
- func (sc *StripeClient) CreateBillingPortalUpdateSession(ctx context.Context, subsID, custID string) (*BillingPortalSession, error)
- func (sc *StripeClient) CreateCustomer(ctx context.Context, c *OrganizationCustomer) (*stripe.Customer, error)
- func (sc *StripeClient) CreatePersonalOrgFreeTierSubs(ctx context.Context, customerID string) (*Subscription, error)
- func (sc *StripeClient) CreatePrice(ctx context.Context, productID string, unitAmount int64, ...) (*stripe.Price, error)
- func (sc *StripeClient) CreateProduct(ctx context.Context, name, description string) (*stripe.Product, error)
- func (sc *StripeClient) CreateSubscription(ctx context.Context, params *stripe.SubscriptionCreateParams) (*stripe.Subscription, error)
- func (sc *StripeClient) CreateTrialSubscription(ctx context.Context, cust *stripe.Customer) (*Subscription, error)
- func (sc *StripeClient) CreateTupleStruct(ctx context.Context) []TupleStruct
- func (sc *StripeClient) DeleteCustomer(ctx context.Context, id string) error
- func (sc *StripeClient) DeleteProduct(ctx context.Context, productID string) (*stripe.Product, error)
- func (sc *StripeClient) FindAndDeactivateCustomerSubscription(ctx context.Context, orgID string) error
- func (sc *StripeClient) FindOrCreateCustomer(ctx context.Context, o *OrganizationCustomer) error
- func (sc *StripeClient) GetAllProductPricesMapped(ctx context.Context) (products []Product)
- func (sc *StripeClient) GetCustomerByStripeID(ctx context.Context, customerID string) (*stripe.Customer, error)
- func (sc *StripeClient) GetFeaturesByProductID(ctx context.Context, productID string) []ProductFeature
- func (sc *StripeClient) GetPrice(ctx context.Context, priceID string) (*stripe.Price, error)
- func (sc *StripeClient) GetPricesMapped(ctx context.Context) (prices []Price)
- func (sc *StripeClient) GetProduct(ctx context.Context, productID string) (*stripe.Product, error)
- func (sc *StripeClient) GetProductByID(ctx context.Context, id string) (*stripe.Product, error)
- func (sc *StripeClient) GetSubscriptionByID(ctx context.Context, id string) (*stripe.Subscription, error)
- func (sc *StripeClient) ListOrCreateSubscriptions(ctx context.Context, customerID string) (*Subscription, error)
- func (sc *StripeClient) ListPrices(ctx context.Context) ([]*stripe.Price, error)
- func (sc *StripeClient) ListProducts(ctx context.Context) (products []*stripe.Product, err error)
- func (sc *StripeClient) MapStripeSubscription(ctx context.Context, subs *stripe.Subscription) *Subscription
- func (sc *StripeClient) SearchCustomers(ctx context.Context, query string) (customers []*stripe.Customer, err error)
- func (sc *StripeClient) UpdateCustomer(ctx context.Context, id string, params *stripe.CustomerUpdateParams) (*stripe.Customer, error)
- func (sc *StripeClient) UpdateProduct(ctx context.Context, productID, name, description string) (*stripe.Product, error)
- func (sc *StripeClient) UpdateSubscription(ctx context.Context, id string, params *stripe.SubscriptionUpdateParams) (*stripe.Subscription, error)
- type StripeOptions
- type Subscription
- type TupleStruct
Constants ¶
const ( StatusSuccess = "success" StatusError = "error" )
Variables ¶
var ( // ErrFoundMultipleCustomers is returned when multiple customers are found ErrFoundMultipleCustomers = errors.New("found multiple customers with the same name") // ErrMultipleSubscriptions = errors.New("multiple subscriptions found") ErrMultipleSubscriptions = errors.New("multiple subscriptions found") // ErrCustomerNotFound is returned when a customer is not found ErrCustomerNotFound = errors.New("customer not found") // ErrCustomerLookupFailed is returned when a customer lookup fails ErrCustomerLookupFailed = errors.New("failed to lookup customer") // ErrCustomerSearchFailed is returned when a customer search fails ErrCustomerSearchFailed = errors.New("failed to search for customer") // ErrProductListFailed is returned when a product list fails ErrProductListFailed = errors.New("failed to list products") // ErrCustomerIDRequired is returned when a customer ID is required ErrCustomerIDRequired = errors.New("customer ID is required") // ErrMissingAPIKey is returned when the API key is missing ErrMissingAPIKey = errors.New("missing API key") )
Functions ¶
func GetOrganizationIDFromMetadata ¶ added in v0.7.4
GetOrganizationIDFromMetadata gets the organization ID from the metadata if it exists, otherwise returns an empty string
func GetOrganizationNameFromMetadata ¶ added in v0.7.4
GetOrganizationNameFromMetadata gets the organization name from the metadata if it exists, otherwise returns an empty string
func GetOrganizationSettingsIDFromMetadata ¶ added in v0.7.4
GetOrganizationSettingsIDFromMetadata gets the organization settings ID from the metadata if it exists, otherwise returns an empty string
func GetOrganizationSubscriptionIDFromMetadata ¶ added in v0.7.4
GetOrganizationSubscriptionIDFromMetadata gets the organization subscription ID from the metadata if it exists, otherwise returns an empty string
func GetUpdatedFields ¶ added in v0.7.4
func GetUpdatedFields(props map[string]interface{}, orgCustomer *OrganizationCustomer) (params *stripe.CustomerUpdateParams)
GetUpdatedFields checks for updates to billing information in the properties and returns a stripe.CustomerParams object with the updated information and a boolean indicating whether there are updates
func IsSubscriptionActive ¶ added in v0.10.11
func IsSubscriptionActive(status stripe.SubscriptionStatus) bool
IsSubscriptionActive checks if a subscription is active based on its status
func WithKeys ¶ added in v0.5.0
func WithKeys(keys map[string]string) func(*QueryBuilder)
WithKeys sets the keys for the query builder
func WithOperator ¶ added in v0.5.0
func WithOperator(operator string) func(*QueryBuilder)
WithOperator sets the operator for the query builder (AND or OR)
func WritePlansToYAML ¶
WritePlansToYAML writes the []Product information into a YAML file.
func WriteTuplesToYaml ¶ added in v0.8.9
func WriteTuplesToYaml(tuples []TupleStruct, filename string) error
WriteTuplesToYaml writes the []TupleStruct information into a YAML file
Types ¶
type BillingPortalSession ¶ added in v0.7.4
type BillingPortalSession struct {
ManageSubscription string `json:"manage_subscription"`
PaymentMethods string `json:"payment_methods"`
Cancellation string `json:"cancellation"`
HomePage string `json:"home_page"`
}
BillingPortalSession holds the billing portal session information
type Config ¶
type Config struct {
// Enabled determines if the entitlements service is enabled
Enabled bool `json:"enabled" koanf:"enabled" default:"false"`
// PublicStripeKey is the key for the stripe service
PublicStripeKey string `json:"publicStripeKey" koanf:"publicStripeKey" default:""`
// PrivateStripeKey is the key for the stripe service
PrivateStripeKey string `json:"privateStripeKey" koanf:"privateStripeKey" default:""`
// StripeWebhookSecret is the secret for the stripe service
StripeWebhookSecret string `json:"stripeWebhookSecret" koanf:"stripeWebhookSecret" default:""`
// TrialSubscriptionPriceID is the price ID for the trial subscription
TrialSubscriptionPriceID string `json:"trialSubscriptionPriceID" koanf:"trialSubscriptionPriceID" default:"price_1QKLyeBvxky1R7SvaZYGWyQb"`
// PersonalOrgSubscriptionPriceID is the price ID for the personal org subscription
PersonalOrgSubscriptionPriceID string `json:"personalOrgSubscriptionPriceID" koanf:"personalOrgSubscriptionPriceID" default:"price_1QycPyBvxky1R7Svz0gOWnNh"`
// StripeWebhookURL is the URL for the stripe webhook
StripeWebhookURL string `json:"stripeWebhookURL" koanf:"stripeWebhookURL" default:"https://api.openlane.com/v1/stripe/webhook"`
// StripeBillingPortalSuccessURL
StripeBillingPortalSuccessURL string `json:"stripeBillingPortalSuccessURL" koanf:"stripeBillingPortalSuccessURL" default:"https://console.openlane.com/billing"`
// StripeCancellationReturnURL is the URL for the stripe cancellation return
StripeCancellationReturnURL string `` /* 163-byte string literal not displayed */
// SaaSPricingTiers are the pricing tiers for the SaaS product
SaaSPricingTiers []PricingTier `json:"saasPricingTiers" koanf:"saasPricingTiers"`
// Features are the features for the SaaS product
Features []Feature `json:"features" koanf:"features"`
}
func NewConfig ¶ added in v0.5.0
func NewConfig(opts ...ConfigOpts) *Config
NewConfig creates a new entitlements config
type ConfigOpts ¶ added in v0.5.0
type ConfigOpts func(*Config)
func WithEnabled ¶ added in v0.5.0
func WithEnabled(enabled bool) ConfigOpts
WithEnabled sets the enabled field
func WithPersonalOrgSubscriptionPriceID ¶ added in v0.7.3
func WithPersonalOrgSubscriptionPriceID(personalOrgSubscriptionPriceID string) ConfigOpts
WithPersonalOrgSubscriptionPriceID sets the personal org subscription price ID
func WithPrivateStripeKey ¶ added in v0.5.0
func WithPrivateStripeKey(privateStripeKey string) ConfigOpts
WithPrivateStripeKey sets the private stripe key
func WithPublicStripeKey ¶ added in v0.5.0
func WithPublicStripeKey(publicStripeKey string) ConfigOpts
WithPublicStripeKey sets the public stripe key
func WithStripeBillingPortalSuccessURL ¶ added in v0.5.0
func WithStripeBillingPortalSuccessURL(stripeBillingPortalSuccessURL string) ConfigOpts
WithStripeBillingPortalSuccessURL sets the stripe billing portal success URL
func WithStripeCancellationReturnURL ¶ added in v0.7.4
func WithStripeCancellationReturnURL(stripeCancellationReturnURL string) ConfigOpts
WithStripeCancellationReturnURL sets the stripe cancellation return URL
func WithStripeWebhookSecret ¶ added in v0.5.0
func WithStripeWebhookSecret(stripeWebhookSecret string) ConfigOpts
WithStripeWebhookSecret sets the stripe webhook secret
func WithStripeWebhookURL ¶ added in v0.5.0
func WithStripeWebhookURL(stripeWebhookURL string) ConfigOpts
WithStripeWebhookURL sets the stripe webhook URL
func WithTrialSubscriptionPriceID ¶
func WithTrialSubscriptionPriceID(trialSubscriptionPriceID string) ConfigOpts
WithTrialSubscriptionPriceID sets the trial subscription price ID
type ContactInfo ¶ added in v0.6.5
type ContactInfo struct {
Email string `json:"email"`
Phone string `json:"phone"`
City *string `form:"city"`
Country *string `form:"country"`
Line1 *string `form:"line1"`
Line2 *string `form:"line2"`
PostalCode *string `form:"postal_code"`
State *string `form:"state"`
}
ContactInfo holds the contact information for the organization
type Customer ¶
type Customer struct {
ID string `json:"customer_id" yaml:"customer_id"`
Email string `json:"email" yaml:"email"`
Phone string `json:"phone" yaml:"phone"`
Address string `json:"address" yaml:"address"`
Plans []Plan `json:"plans" yaml:"plans"`
Metadata map[string]string
StripeParams *stripe.CustomerParams
StripeCustomer []stripe.Customer
}
Customer holds the customer information
type Feature ¶
type Feature struct {
ID string `json:"id" yaml:"id"`
Name string `json:"name" yaml:"name"`
Lookupkey string `json:"lookupkey" yaml:"lookupkey"`
}
Feature are part of a product
type OrganizationCustomer ¶ added in v0.5.0
type OrganizationCustomer struct {
OrganizationID string `json:"organization_id"`
OrganizationSettingsID string `json:"organization_settings_id"`
StripeCustomerID string `json:"stripe_customer_id"`
OrganizationName string `json:"organization_name"`
PersonalOrg bool `json:"personal_org"`
OrganizationSubscriptionID string `json:"organization_subscription_id"`
StripeSubscriptionID string `json:"stripe_subscription_id"`
PaymentMethodAdded bool `json:"payment_method_added"`
Features []string
FeatureNames []string
Subscription
ContactInfo
}
OrganizationCustomer is a struct which holds both internal organization infos and external stripe infos
func MapStripeCustomer ¶ added in v0.7.4
func MapStripeCustomer(c *stripe.Customer) *OrganizationCustomer
MapStripeCustomer maps a stripe customer to an organization customer this is used to convert the stripe customer object to our internal customer object we use the metadata to store the organization ID, settings ID, and subscription ID
func (*OrganizationCustomer) Validate ¶ added in v0.5.0
func (o *OrganizationCustomer) Validate() error
Validate checks if the OrganizationCustomer contains necessary fields
type Plan ¶
type Plan struct {
ID string `json:"plan_id" yaml:"plan_id"`
Product string `json:"product_id" yaml:"product_id"`
Price string `json:"price_id" yaml:"price_id"`
StartDate int64 `json:"start_date" yaml:"start_date"`
EndDate int64 `json:"end_date" yaml:"end_date"`
StripeParams *stripe.SubscriptionParams
StripeSubscription []stripe.Subscription
Products []Product
Features []Feature
TrialEnd int64
Status string
}
Plan is the recurring context that holds the payment information
type Price ¶
type Price struct {
ID string `json:"price_id" yaml:"price_id"`
Price float64 `json:"price" yaml:"price"`
Currency string `json:"currency" yaml:"currency"`
ProductID string `json:"product_id" yaml:"-"`
ProductName string `json:"product_name" yaml:"product_name"`
Interval string `json:"interval" yaml:"interval"`
StripeParams *stripe.PriceParams `json:"stripe_params,omitempty" yaml:"stripe_params,omitempty"`
StripePrice []stripe.Price `json:"stripe_price,omitempty" yaml:"stripe_price,omitempty"`
}
Price holds stripe price params and the associated Product
type PricingTier ¶ added in v0.8.9
type PricingTier struct {
Name string `json:"name" koanf:"name"`
ID string `json:"id" koanf:"id"`
Price int64 `json:"price" koanf:"price"`
Features []string `json:"features" koanf:"features"` // List of feature IDs
}
PricingTier is the defined relationship between the product and price
type Product ¶
type Product struct {
ID string `json:"product_id" yaml:"product_id"`
Name string `json:"name" yaml:"name"`
Description string `json:"description,omitempty" yaml:"description,omitempty"`
Features []Feature `json:"features" yaml:"features"`
Prices []Price `json:"prices" yaml:"prices"`
StripeParams *stripe.ProductParams `json:"stripe_params,omitempty" yaml:"stripe_params,omitempty"`
StripeProduct []stripe.Product `json:"stripe_product,omitempty" yaml:"stripe_product,omitempty"`
}
Product holds what we'd more commply call a "tier"
type ProductFeature ¶
type ProductFeature struct {
FeatureID string `json:"feature_id" yaml:"feature_id"`
ProductID string `json:"product_id"`
Name string `json:"name" yaml:"name"`
Lookupkey string `json:"lookupkey" yaml:"lookupkey"`
}
ProductFeature is the defined relationship between the product and feature
type QueryBuilder ¶ added in v0.5.0
type QueryBuilder struct {
// contains filtered or unexported fields
}
QueryBuilder is a struct that holds the query builder
func NewQueryBuilder ¶ added in v0.5.0
func NewQueryBuilder(options ...func(*QueryBuilder)) *QueryBuilder
NewQueryBuilder creates a new query builder with included options
func (*QueryBuilder) BuildQuery ¶ added in v0.5.0
func (qb *QueryBuilder) BuildQuery() []string
BuildQuery builds the query from the keys
type StripeClient ¶
type StripeClient struct {
// Client is the Stripe client and is used for accessing all subsequent stripe objects, e.g. products, prices, etc.
Client *stripe.Client
// config is the configuration for the Stripe client
Config Config
// contains filtered or unexported fields
}
StripeClient is a client for the Stripe API
func NewStripeClient ¶
func NewStripeClient(opts ...StripeOptions) (*StripeClient, error)
NewStripeClient creates a new Stripe client
func (*StripeClient) CancelSubscription ¶
func (sc *StripeClient) CancelSubscription(ctx context.Context, id string, params *stripe.SubscriptionCancelParams) (*stripe.Subscription, error)
CancelSubscription cancels a subscription
func (*StripeClient) CancellationBillingPortalSession ¶ added in v0.7.4
func (sc *StripeClient) CancellationBillingPortalSession(ctx context.Context, subsID, custID string) (*BillingPortalSession, error)
CancellationBillingPortalSession generates a session in stripe's billing portal which allows the customer to cancel their subscription
func (*StripeClient) CreateBillingPortalPaymentMethods ¶ added in v0.7.4
func (sc *StripeClient) CreateBillingPortalPaymentMethods(ctx context.Context, custID string) (*BillingPortalSession, error)
CreateBillingPortalPaymentMethods generates a session in stripe's billing portal which allows the customer to add / update payment methods
func (*StripeClient) CreateBillingPortalUpdateSession ¶
func (sc *StripeClient) CreateBillingPortalUpdateSession(ctx context.Context, subsID, custID string) (*BillingPortalSession, error)
CreateBillingPortalUpdateSession generates an update session in stripe's billing portal which displays the customers current subscription tier and allows them to upgrade or downgrade
func (*StripeClient) CreateCustomer ¶
func (sc *StripeClient) CreateCustomer(ctx context.Context, c *OrganizationCustomer) (*stripe.Customer, error)
CreateCustomer creates a customer leveraging the openlane organization ID as the organization name, and the email provided as the billing email we assume that the billing email will be changed, so lookups are performed by the organization ID
func (*StripeClient) CreatePersonalOrgFreeTierSubs ¶ added in v0.7.3
func (sc *StripeClient) CreatePersonalOrgFreeTierSubs(ctx context.Context, customerID string) (*Subscription, error)
CreatePersonalOrgFreeTierSubs creates a subscription with the configured $0 price used for personal organizations only
func (*StripeClient) CreatePrice ¶ added in v0.8.9
func (sc *StripeClient) CreatePrice(ctx context.Context, productID string, unitAmount int64, currency, interval string) (*stripe.Price, error)
CreatePrice a price for a product in stripe
func (*StripeClient) CreateProduct ¶ added in v0.8.9
func (sc *StripeClient) CreateProduct(ctx context.Context, name, description string) (*stripe.Product, error)
CreateProduct creates a new product in Stripe
func (*StripeClient) CreateSubscription ¶
func (sc *StripeClient) CreateSubscription(ctx context.Context, params *stripe.SubscriptionCreateParams) (*stripe.Subscription, error)
CreateSubscription creates a new subscription
func (*StripeClient) CreateTrialSubscription ¶
func (sc *StripeClient) CreateTrialSubscription(ctx context.Context, cust *stripe.Customer) (*Subscription, error)
CreateTrialSubscription creates a trial subscription with the configured price
func (*StripeClient) CreateTupleStruct ¶ added in v0.8.9
func (sc *StripeClient) CreateTupleStruct(ctx context.Context) []TupleStruct
CreateTupleStruct creates a tuple struct for each feature of each product
func (*StripeClient) DeleteCustomer ¶
func (sc *StripeClient) DeleteCustomer(ctx context.Context, id string) error
DeleteCustomer deletes a customer by ID from stripe
func (*StripeClient) DeleteProduct ¶ added in v0.8.9
func (sc *StripeClient) DeleteProduct(ctx context.Context, productID string) (*stripe.Product, error)
DeleteProduct deletes a product in Stripe
func (*StripeClient) FindAndDeactivateCustomerSubscription ¶ added in v0.10.11
func (sc *StripeClient) FindAndDeactivateCustomerSubscription(ctx context.Context, orgID string) error
FindAndDeactivateCustomerSubscription finds a customer by the organization ID and deactivates their subscription this is used when an organization is deleted - we retain the customer record and keep a referenced to the deactivated subscription we do not delete the customer record in stripe for record / references we also do not delete the subscription record in stripe for record / references a cancelled active subscription will set to cancel at period end, a trialing subscription will be set to end immediately
func (*StripeClient) FindOrCreateCustomer ¶ added in v0.6.7
func (sc *StripeClient) FindOrCreateCustomer(ctx context.Context, o *OrganizationCustomer) error
FindOrCreateCustomer attempts to lookup a customer by the organization ID which is set in both the name field attribute as well as in the object metadata field
func (*StripeClient) GetAllProductPricesMapped ¶ added in v0.8.9
func (sc *StripeClient) GetAllProductPricesMapped(ctx context.Context) (products []Product)
GetAllProductPricesMapped retrieves all products and prices from stripe which are active
func (*StripeClient) GetCustomerByStripeID ¶ added in v0.5.0
func (sc *StripeClient) GetCustomerByStripeID(ctx context.Context, customerID string) (*stripe.Customer, error)
GetCustomerByStripeID gets a customer by ID
func (*StripeClient) GetFeaturesByProductID ¶ added in v0.8.9
func (sc *StripeClient) GetFeaturesByProductID(ctx context.Context, productID string) []ProductFeature
GetFeaturesByProductID retrieves all product features from stripe which are active and maps them into a []ProductFeature struct
func (*StripeClient) GetPricesMapped ¶ added in v0.8.9
func (sc *StripeClient) GetPricesMapped(ctx context.Context) (prices []Price)
GetPricesMapped retrieves all prices from stripe which are active and maps them into a []Price struct
func (*StripeClient) GetProduct ¶ added in v0.8.9
GetProduct retrieves a product by its ID
func (*StripeClient) GetProductByID ¶ added in v0.6.7
GetProductByID gets a product by ID
func (*StripeClient) GetSubscriptionByID ¶
func (sc *StripeClient) GetSubscriptionByID(ctx context.Context, id string) (*stripe.Subscription, error)
GetSubscriptionByID gets a subscription by ID
func (*StripeClient) ListOrCreateSubscriptions ¶
func (sc *StripeClient) ListOrCreateSubscriptions(ctx context.Context, customerID string) (*Subscription, error)
ListStripeSubscriptions lists stripe subscriptions by customer
func (*StripeClient) ListPrices ¶ added in v0.8.9
ListPrices retrieves all prices from stripe
func (*StripeClient) ListProducts ¶ added in v0.8.9
ListProducts lists all products in Stripe
func (*StripeClient) MapStripeSubscription ¶ added in v0.7.4
func (sc *StripeClient) MapStripeSubscription(ctx context.Context, subs *stripe.Subscription) *Subscription
MapStripeSubscription maps a stripe.Subscription to a "internal" subscription struct
func (*StripeClient) SearchCustomers ¶ added in v0.5.0
func (sc *StripeClient) SearchCustomers(ctx context.Context, query string) (customers []*stripe.Customer, err error)
SearchCustomers searches for customers with a structured stripe query as input leverage QueryBuilder to construct more complex queries, otherwise see: https://docs.stripe.com/search#search-query-language
func (*StripeClient) UpdateCustomer ¶
func (sc *StripeClient) UpdateCustomer(ctx context.Context, id string, params *stripe.CustomerUpdateParams) (*stripe.Customer, error)
UpdateCustomer updates a customer in stripe with the provided params and ID
func (*StripeClient) UpdateProduct ¶ added in v0.8.9
func (sc *StripeClient) UpdateProduct(ctx context.Context, productID, name, description string) (*stripe.Product, error)
UpdateProduct updates a product in Stripe
func (*StripeClient) UpdateSubscription ¶
func (sc *StripeClient) UpdateSubscription(ctx context.Context, id string, params *stripe.SubscriptionUpdateParams) (*stripe.Subscription, error)
UpdateSubscription updates a subscription
type StripeOptions ¶
type StripeOptions func(*StripeClient)
StripeOptions is a type for setting options on the Stripe client
func WithAPIKey ¶
func WithAPIKey(apiKey string) StripeOptions
WithAPIKey sets the API key for the Stripe client
func WithBackends ¶ added in v0.7.4
func WithBackends(backends *stripe.Backends) StripeOptions
WithBackends sets the backends for the Stripe client
func WithConfig ¶ added in v0.5.0
func WithConfig(config Config) StripeOptions
WithConfig sets the config for the Stripe client
type Subscription ¶
type Subscription struct {
ID string `json:"plan_id" yaml:"plan_id"`
ProductID string `json:"product_id" yaml:"product_id"`
PriceID string `json:"price_id" yaml:"price_id"`
StartDate int64 `json:"start_date" yaml:"start_date"`
EndDate int64 `json:"end_date" yaml:"end_date"`
StripeParams *stripe.SubscriptionParams
StripeSubscription []stripe.Subscription
StripeProduct []stripe.Product
StripeFeature []stripe.ProductFeature
Products []Product
Features []Feature
Prices []Price
TrialEnd int64
Status string
StripeCustomerID string
OrganizationID string
DaysUntilDue int64
Metadata map[string]string
}
Subscription is the recurring context that holds the payment information
type TupleStruct ¶ added in v0.8.9
type TupleStruct struct {
User string `yaml:"user"`
Relation string `yaml:"relation"`
Object string `yaml:"object"`
}
TupleStruct represents a tuple of user, relation, and object