Documentation
¶
Index ¶
- Variables
- func ProjectRoot() string
- type AttachPaymentMethodParams
- type AuthClient
- func (c *AuthClient) CheckPassword(password, hash string) error
- func (c *AuthClient) DeletePasswordTokens(ctx echo.Context, userID int) error
- func (c *AuthClient) GenerateEmailVerificationToken(email string) (string, error)
- func (c *AuthClient) GeneratePasswordResetToken(ctx echo.Context, userID int) (string, *ent.PasswordToken, error)
- func (c *AuthClient) GetAuthenticatedUser(ctx echo.Context) (*ent.User, error)
- func (c *AuthClient) GetAuthenticatedUserID(ctx echo.Context) (int, error)
- func (c *AuthClient) GetValidPasswordToken(ctx echo.Context, userID, tokenID int, token string) (*ent.PasswordToken, error)
- func (c *AuthClient) Login(ctx echo.Context, userID int) error
- func (c *AuthClient) Logout(ctx echo.Context) error
- func (c *AuthClient) RandomToken(length int) (string, error)
- func (c *AuthClient) ValidateEmailVerificationToken(token string) (string, error)
- type CacheClient
- type CacheFlushOp
- type CacheGetOp
- type CacheSetOp
- func (c *CacheSetOp) Data(data any) *CacheSetOp
- func (c *CacheSetOp) Expiration(expiration time.Duration) *CacheSetOp
- func (c *CacheSetOp) Group(group string) *CacheSetOp
- func (c *CacheSetOp) Key(key string) *CacheSetOp
- func (c *CacheSetOp) Save(ctx context.Context) error
- func (c *CacheSetOp) Tags(tags ...string) *CacheSetOp
- type CacheStore
- type Container
- type CreateCustomerParams
- type CreatePaymentIntentParams
- type CreateRefundParams
- type CreateSubscriptionParams
- type CustomerResult
- type InvalidPasswordTokenError
- type MailClient
- type NotAuthenticatedError
- type PaymentClient
- func (c *PaymentClient) AttachPaymentMethodToCustomer(ctx echo.Context, customer *ent.PaymentCustomer, paymentMethodID string, ...) (*ent.PaymentMethod, error)
- func (c *PaymentClient) CancelSubscription(ctx echo.Context, customer *ent.PaymentCustomer, subscriptionID string) error
- func (c *PaymentClient) ConfirmPaymentIntent(ctx echo.Context, paymentIntent *ent.PaymentIntent, paymentMethodID string) error
- func (c *PaymentClient) CreateOneTimePayment(ctx echo.Context, customer *ent.PaymentCustomer, amount int64, ...) (*ent.PaymentIntent, error)
- func (c *PaymentClient) CreateOrGetCustomer(ctx echo.Context, u *ent.User) (*ent.PaymentCustomer, error)
- func (c *PaymentClient) CreateSubscription(ctx echo.Context, customer *ent.PaymentCustomer, priceID string, ...) (*ent.Subscription, error)
- func (c *PaymentClient) GetConfig() *config.Config
- func (c *PaymentClient) GetCustomerPaymentIntents(ctx echo.Context, customer *ent.PaymentCustomer) ([]*ent.PaymentIntent, error)
- func (c *PaymentClient) GetCustomerPaymentMethods(ctx echo.Context, customer *ent.PaymentCustomer) ([]*ent.PaymentMethod, error)
- func (c *PaymentClient) GetCustomerSubscriptions(ctx echo.Context, customer *ent.PaymentCustomer) ([]*ent.Subscription, error)
- func (c *PaymentClient) RefundPayment(ctx echo.Context, paymentIntent *ent.PaymentIntent, amount int64, ...) (*RefundResult, error)
- func (c *PaymentClient) SetDefaultPaymentMethod(ctx echo.Context, customer *ent.PaymentCustomer, paymentMethodID string) error
- type PaymentIntentResult
- type PaymentMethodResult
- type PaymentProvider
- type RefundResult
- type StripeProvider
- func (s *StripeProvider) AttachPaymentMethod(ctx context.Context, paymentMethodID, customerID string) (*PaymentMethodResult, error)
- func (s *StripeProvider) CancelPaymentIntent(ctx context.Context, paymentIntentID string) (*PaymentIntentResult, error)
- func (s *StripeProvider) CancelSubscription(ctx context.Context, subscriptionID string) (*SubscriptionResult, error)
- func (s *StripeProvider) ConfirmPaymentIntent(ctx context.Context, paymentIntentID string, paymentMethodID string) (*PaymentIntentResult, error)
- func (s *StripeProvider) CreateCustomer(ctx context.Context, params *CreateCustomerParams) (*CustomerResult, error)
- func (s *StripeProvider) CreatePaymentIntent(ctx context.Context, params *CreatePaymentIntentParams) (*PaymentIntentResult, error)
- func (s *StripeProvider) CreateRefund(ctx context.Context, params *CreateRefundParams) (*RefundResult, error)
- func (s *StripeProvider) CreateSubscription(ctx context.Context, params *CreateSubscriptionParams) (*SubscriptionResult, error)
- func (s *StripeProvider) DetachPaymentMethod(ctx context.Context, paymentMethodID string) (*PaymentMethodResult, error)
- func (s *StripeProvider) GetCustomer(ctx context.Context, customerID string) (*CustomerResult, error)
- func (s *StripeProvider) GetPaymentIntent(ctx context.Context, paymentIntentID string) (*PaymentIntentResult, error)
- func (s *StripeProvider) GetPaymentMethod(ctx context.Context, paymentMethodID string) (*PaymentMethodResult, error)
- func (s *StripeProvider) GetRefund(ctx context.Context, refundID string) (*RefundResult, error)
- func (s *StripeProvider) GetSubscription(ctx context.Context, subscriptionID string) (*SubscriptionResult, error)
- func (s *StripeProvider) ListPaymentMethods(ctx context.Context, customerID string) ([]*PaymentMethodResult, error)
- func (s *StripeProvider) SetDefaultPaymentMethod(ctx context.Context, customerID, paymentMethodID string) (*PaymentMethodResult, error)
- func (s *StripeProvider) UpdateCustomer(ctx context.Context, customerID string, params *UpdateCustomerParams) (*CustomerResult, error)
- func (s *StripeProvider) UpdateSubscription(ctx context.Context, subscriptionID string, params *UpdateSubscriptionParams) (*SubscriptionResult, error)
- type SubscriptionResult
- type UpdateCustomerParams
- type UpdateSubscriptionParams
- type Validator
Constants ¶
This section is empty.
Variables ¶
var ErrCacheMiss = errors.New("cache miss")
ErrCacheMiss indicates that the requested key does not exist in the cache
Functions ¶
func ProjectRoot ¶
func ProjectRoot() string
Types ¶
type AttachPaymentMethodParams ¶
type AttachPaymentMethodParams struct {
PaymentMethodID string `json:"payment_method_id"`
CustomerID string `json:"customer_id"`
SetAsDefault bool `json:"set_as_default,omitempty"`
Metadata map[string]interface{} `json:"metadata,omitempty"`
}
AttachPaymentMethodParams contains parameters for attaching a payment method
type AuthClient ¶
type AuthClient struct {
// contains filtered or unexported fields
}
AuthClient is the client that handles authentication requests
func NewAuthClient ¶
func NewAuthClient(cfg *config.Config, orm *ent.Client) *AuthClient
NewAuthClient creates a new authentication client
func (*AuthClient) CheckPassword ¶
func (c *AuthClient) CheckPassword(password, hash string) error
CheckPassword check if a given password matches a given hash
func (*AuthClient) DeletePasswordTokens ¶
func (c *AuthClient) DeletePasswordTokens(ctx echo.Context, userID int) error
DeletePasswordTokens deletes all password tokens in the database for a belonging to a given user. This should be called after a successful password reset.
func (*AuthClient) GenerateEmailVerificationToken ¶
func (c *AuthClient) GenerateEmailVerificationToken(email string) (string, error)
GenerateEmailVerificationToken generates an email verification token for a given email address using JWT which is set to expire based on the duration stored in configuration
func (*AuthClient) GeneratePasswordResetToken ¶
func (c *AuthClient) GeneratePasswordResetToken(ctx echo.Context, userID int) (string, *ent.PasswordToken, error)
GeneratePasswordResetToken generates a password reset token for a given user. For security purposes, the token itself is not stored in the database but rather a hash of the token, exactly how passwords are handled. This method returns both the generated token and the token entity which only contains the hash.
func (*AuthClient) GetAuthenticatedUser ¶
GetAuthenticatedUser returns the authenticated user if the user is logged in
func (*AuthClient) GetAuthenticatedUserID ¶
func (c *AuthClient) GetAuthenticatedUserID(ctx echo.Context) (int, error)
GetAuthenticatedUserID returns the authenticated user's ID, if the user is logged in
func (*AuthClient) GetValidPasswordToken ¶
func (c *AuthClient) GetValidPasswordToken(ctx echo.Context, userID, tokenID int, token string) (*ent.PasswordToken, error)
GetValidPasswordToken returns a valid, non-expired password token entity for a given user, token ID and token. Since the actual token is not stored in the database for security purposes, if a matching password token entity is found a hash of the provided token is compared with the hash stored in the database in order to validate.
func (*AuthClient) Login ¶
func (c *AuthClient) Login(ctx echo.Context, userID int) error
Login logs in a user of a given ID
func (*AuthClient) Logout ¶
func (c *AuthClient) Logout(ctx echo.Context) error
Logout logs the requesting user out
func (*AuthClient) RandomToken ¶
func (c *AuthClient) RandomToken(length int) (string, error)
RandomToken generates a random token string of a given length
func (*AuthClient) ValidateEmailVerificationToken ¶
func (c *AuthClient) ValidateEmailVerificationToken(token string) (string, error)
ValidateEmailVerificationToken validates an email verification token and returns the associated email address if the token is valid and has not expired
type CacheClient ¶
type CacheClient struct {
// contains filtered or unexported fields
}
CacheClient is the client that allows you to interact with the cache
func NewCacheClient ¶
func NewCacheClient(store CacheStore) *CacheClient
NewCacheClient creates a new cache client
func (*CacheClient) Flush ¶
func (c *CacheClient) Flush() *CacheFlushOp
Flush creates a cache flush operation
type CacheFlushOp ¶
type CacheFlushOp struct {
// contains filtered or unexported fields
}
CacheFlushOp handles chaining a flush operation
func (*CacheFlushOp) Execute ¶
func (c *CacheFlushOp) Execute(ctx context.Context) error
Execute flushes the data from the cache
func (*CacheFlushOp) Group ¶
func (c *CacheFlushOp) Group(group string) *CacheFlushOp
Group sets the cache group
func (*CacheFlushOp) Key ¶
func (c *CacheFlushOp) Key(key string) *CacheFlushOp
Key sets the cache key
func (*CacheFlushOp) Tags ¶
func (c *CacheFlushOp) Tags(tags ...string) *CacheFlushOp
Tags sets the cache tags
type CacheGetOp ¶
type CacheGetOp struct {
// contains filtered or unexported fields
}
CacheGetOp handles chaining a get operation
func (*CacheGetOp) Fetch ¶
func (c *CacheGetOp) Fetch(ctx context.Context) (any, error)
Fetch fetches the data from the cache
func (*CacheGetOp) Group ¶
func (c *CacheGetOp) Group(group string) *CacheGetOp
Group sets the cache group
type CacheSetOp ¶
type CacheSetOp struct {
// contains filtered or unexported fields
}
CacheSetOp handles chaining a set operation
func (*CacheSetOp) Data ¶
func (c *CacheSetOp) Data(data any) *CacheSetOp
Data sets the data to cache
func (*CacheSetOp) Expiration ¶
func (c *CacheSetOp) Expiration(expiration time.Duration) *CacheSetOp
Expiration sets the expiration duration of the cached data
func (*CacheSetOp) Group ¶
func (c *CacheSetOp) Group(group string) *CacheSetOp
Group sets the cache group
func (*CacheSetOp) Save ¶
func (c *CacheSetOp) Save(ctx context.Context) error
Save saves the data in the cache
func (*CacheSetOp) Tags ¶
func (c *CacheSetOp) Tags(tags ...string) *CacheSetOp
Tags sets the cache tags
type CacheStore ¶
type CacheStore interface {
// contains filtered or unexported methods
}
CacheStore provides an interface for cache storage
type Container ¶
type Container struct {
// Validator stores a validator
Validator *Validator
// Web stores the web framework.
Web *echo.Echo
// Config stores the application configuration.
Config *config.Config
// Cache contains the cache client.
Cache *CacheClient
// Database stores the connection to the database.
Database *sql.DB
// Files stores the file system.
Files afero.Fs
// ORM stores a client to the ORM.
ORM *ent.Client
// Graph is the entity graph defined by your Ent schema.
Graph *gen.Graph
// Mail stores an email sending client.
Mail *MailClient
// Auth stores an authentication client.
Auth *AuthClient
// Tasks stores the task client.
Tasks *backlite.Client
// Payment stores the payment client.
Payment *PaymentClient
// Chat stores the chat room manager.
Chat *chat.RoomManager
// Inertia for React
Inertia *inertia.Inertia
// WebSocketGroup is a route group for WebSocket connections (no CSRF, gzip, timeout).
WebSocketGroup *echo.Group
}
Container contains all services used by the application and provides an easy way to handle dependency injection including within tests.
func NewContainer ¶
func NewContainer() *Container
NewContainer creates and initializes a new Container.
type CreateCustomerParams ¶
type CreateCustomerParams struct {
Email string `json:"email"`
Name string `json:"name,omitempty"`
Metadata map[string]interface{} `json:"metadata,omitempty"`
}
CreateCustomerParams contains parameters for creating a customer
type CreatePaymentIntentParams ¶
type CreatePaymentIntentParams struct {
Amount int64 `json:"amount"`
Currency string `json:"currency"`
CustomerID string `json:"customer_id"`
Description string `json:"description,omitempty"`
Metadata map[string]interface{} `json:"metadata,omitempty"`
}
CreatePaymentIntentParams contains parameters for creating a payment intent
type CreateRefundParams ¶
type CreateRefundParams struct {
PaymentIntentID string `json:"payment_intent_id"`
Amount int64 `json:"amount,omitempty"` // If empty, refund full amount
Reason string `json:"reason,omitempty"`
Metadata map[string]interface{} `json:"metadata,omitempty"`
}
CreateRefundParams contains parameters for creating a refund
type CreateSubscriptionParams ¶
type CreateSubscriptionParams struct {
CustomerID string `json:"customer_id"`
PriceID string `json:"price_id"`
PaymentMethodID string `json:"payment_method_id,omitempty"`
TrialPeriodDays int `json:"trial_period_days,omitempty"`
Metadata map[string]interface{} `json:"metadata,omitempty"`
}
CreateSubscriptionParams contains parameters for creating a subscription
type CustomerResult ¶
type CustomerResult struct {
ID string `json:"id"`
Email string `json:"email"`
Name string `json:"name,omitempty"`
Metadata map[string]interface{} `json:"metadata,omitempty"`
Created time.Time `json:"created"`
}
CustomerResult represents a customer response from the provider
type InvalidPasswordTokenError ¶
type InvalidPasswordTokenError struct{}
InvalidPasswordTokenError is an error returned when an invalid token is provided
func (InvalidPasswordTokenError) Error ¶
func (e InvalidPasswordTokenError) Error() string
Error implements the error interface.
type MailClient ¶
type MailClient struct {
// contains filtered or unexported fields
}
MailClient provides a client for sending email This is purposely not completed because there are many different methods and services for sending email, many of which are very different. Choose what works best for you and populate the methods below. For now, emails will just be logged.
func NewMailClient ¶
func NewMailClient(cfg *config.Config) (*MailClient, error)
NewMailClient creates a new MailClient.
type NotAuthenticatedError ¶
type NotAuthenticatedError struct{}
NotAuthenticatedError is an error returned when a user is not authenticated
func (NotAuthenticatedError) Error ¶
func (e NotAuthenticatedError) Error() string
Error implements the error interface.
type PaymentClient ¶
type PaymentClient struct {
// contains filtered or unexported fields
}
PaymentClient wraps the payment provider and provides high-level operations
func NewPaymentClient ¶
func NewPaymentClient(cfg *config.Config, orm *ent.Client, provider PaymentProvider) *PaymentClient
NewPaymentClient creates a new payment client
func (*PaymentClient) AttachPaymentMethodToCustomer ¶
func (c *PaymentClient) AttachPaymentMethodToCustomer(ctx echo.Context, customer *ent.PaymentCustomer, paymentMethodID string, setAsDefault bool) (*ent.PaymentMethod, error)
AttachPaymentMethodToCustomer securely attaches a PaymentMethod (created by Stripe Elements) to a customer
func (*PaymentClient) CancelSubscription ¶
func (c *PaymentClient) CancelSubscription(ctx echo.Context, customer *ent.PaymentCustomer, subscriptionID string) error
CancelSubscription cancels a subscription
func (*PaymentClient) ConfirmPaymentIntent ¶
func (c *PaymentClient) ConfirmPaymentIntent(ctx echo.Context, paymentIntent *ent.PaymentIntent, paymentMethodID string) error
ConfirmPaymentIntent confirms a payment intent with a payment method
func (*PaymentClient) CreateOneTimePayment ¶
func (c *PaymentClient) CreateOneTimePayment(ctx echo.Context, customer *ent.PaymentCustomer, amount int64, currency, description string) (*ent.PaymentIntent, error)
CreateOneTimePayment creates a payment intent for a one-time payment
func (*PaymentClient) CreateOrGetCustomer ¶
func (c *PaymentClient) CreateOrGetCustomer(ctx echo.Context, u *ent.User) (*ent.PaymentCustomer, error)
CreateOrGetCustomer creates or retrieves an existing payment customer for a user
func (*PaymentClient) CreateSubscription ¶
func (c *PaymentClient) CreateSubscription(ctx echo.Context, customer *ent.PaymentCustomer, priceID string, params *CreateSubscriptionParams) (*ent.Subscription, error)
CreateSubscription creates a new subscription
func (*PaymentClient) GetConfig ¶
func (c *PaymentClient) GetConfig() *config.Config
GetConfig returns the configuration
func (*PaymentClient) GetCustomerPaymentIntents ¶
func (c *PaymentClient) GetCustomerPaymentIntents(ctx echo.Context, customer *ent.PaymentCustomer) ([]*ent.PaymentIntent, error)
GetCustomerPaymentIntents retrieves all payment intents for a customer
func (*PaymentClient) GetCustomerPaymentMethods ¶
func (c *PaymentClient) GetCustomerPaymentMethods(ctx echo.Context, customer *ent.PaymentCustomer) ([]*ent.PaymentMethod, error)
GetCustomerPaymentMethods retrieves all payment methods for a customer
func (*PaymentClient) GetCustomerSubscriptions ¶
func (c *PaymentClient) GetCustomerSubscriptions(ctx echo.Context, customer *ent.PaymentCustomer) ([]*ent.Subscription, error)
GetCustomerSubscriptions retrieves all subscriptions for a customer
func (*PaymentClient) RefundPayment ¶
func (c *PaymentClient) RefundPayment(ctx echo.Context, paymentIntent *ent.PaymentIntent, amount int64, reason string) (*RefundResult, error)
RefundPayment creates a refund for a payment intent
func (*PaymentClient) SetDefaultPaymentMethod ¶
func (c *PaymentClient) SetDefaultPaymentMethod(ctx echo.Context, customer *ent.PaymentCustomer, paymentMethodID string) error
SetDefaultPaymentMethod sets a payment method as the default for a customer
type PaymentIntentResult ¶
type PaymentIntentResult struct {
ID string `json:"id"`
Status string `json:"status"`
Amount int64 `json:"amount"`
Currency string `json:"currency"`
CustomerID string `json:"customer_id"`
Description string `json:"description,omitempty"`
ClientSecret string `json:"client_secret,omitempty"`
Metadata map[string]interface{} `json:"metadata,omitempty"`
Created time.Time `json:"created"`
}
PaymentIntentResult represents a payment intent response from the provider
type PaymentMethodResult ¶
type PaymentMethodResult struct {
ID string `json:"id"`
Type string `json:"type"`
CustomerID string `json:"customer_id,omitempty"`
LastFour string `json:"last_four,omitempty"`
Brand string `json:"brand,omitempty"`
ExpMonth int `json:"exp_month,omitempty"`
ExpYear int `json:"exp_year,omitempty"`
Metadata map[string]interface{} `json:"metadata,omitempty"`
Created time.Time `json:"created"`
}
PaymentMethodResult represents a payment method response from the provider
type PaymentProvider ¶
type PaymentProvider interface {
// Customer operations
CreateCustomer(ctx context.Context, params *CreateCustomerParams) (*CustomerResult, error)
GetCustomer(ctx context.Context, customerID string) (*CustomerResult, error)
UpdateCustomer(ctx context.Context, customerID string, params *UpdateCustomerParams) (*CustomerResult, error)
// Payment intent operations (one-time payments)
CreatePaymentIntent(ctx context.Context, params *CreatePaymentIntentParams) (*PaymentIntentResult, error)
ConfirmPaymentIntent(ctx context.Context, paymentIntentID string, paymentMethodID string) (*PaymentIntentResult, error)
GetPaymentIntent(ctx context.Context, paymentIntentID string) (*PaymentIntentResult, error)
CancelPaymentIntent(ctx context.Context, paymentIntentID string) (*PaymentIntentResult, error)
// Subscription operations
CreateSubscription(ctx context.Context, params *CreateSubscriptionParams) (*SubscriptionResult, error)
GetSubscription(ctx context.Context, subscriptionID string) (*SubscriptionResult, error)
UpdateSubscription(ctx context.Context, subscriptionID string, params *UpdateSubscriptionParams) (*SubscriptionResult, error)
CancelSubscription(ctx context.Context, subscriptionID string) (*SubscriptionResult, error)
// Payment method operations (secure - no raw card data)
GetPaymentMethod(ctx context.Context, paymentMethodID string) (*PaymentMethodResult, error)
AttachPaymentMethod(ctx context.Context, paymentMethodID, customerID string) (*PaymentMethodResult, error)
DetachPaymentMethod(ctx context.Context, paymentMethodID string) (*PaymentMethodResult, error)
ListPaymentMethods(ctx context.Context, customerID string) ([]*PaymentMethodResult, error)
SetDefaultPaymentMethod(ctx context.Context, customerID, paymentMethodID string) (*PaymentMethodResult, error)
// Refund operations
CreateRefund(ctx context.Context, params *CreateRefundParams) (*RefundResult, error)
GetRefund(ctx context.Context, refundID string) (*RefundResult, error)
}
PaymentProvider defines the interface for payment providers (Stripe, PayPal, etc.)
type RefundResult ¶
type RefundResult struct {
ID string `json:"id"`
PaymentIntentID string `json:"payment_intent_id"`
Amount int64 `json:"amount"`
Currency string `json:"currency"`
Status string `json:"status"`
Reason string `json:"reason,omitempty"`
Metadata map[string]interface{} `json:"metadata,omitempty"`
Created time.Time `json:"created"`
}
RefundResult represents a refund response from the provider
type StripeProvider ¶
type StripeProvider struct {
// contains filtered or unexported fields
}
StripeProvider implements the PaymentProvider interface for Stripe
func NewStripeProvider ¶
func NewStripeProvider(cfg *config.Config) *StripeProvider
NewStripeProvider creates a new Stripe payment provider
func (*StripeProvider) AttachPaymentMethod ¶
func (s *StripeProvider) AttachPaymentMethod(ctx context.Context, paymentMethodID, customerID string) (*PaymentMethodResult, error)
AttachPaymentMethod attaches a payment method to a customer in Stripe
func (*StripeProvider) CancelPaymentIntent ¶
func (s *StripeProvider) CancelPaymentIntent(ctx context.Context, paymentIntentID string) (*PaymentIntentResult, error)
CancelPaymentIntent cancels a payment intent in Stripe
func (*StripeProvider) CancelSubscription ¶
func (s *StripeProvider) CancelSubscription(ctx context.Context, subscriptionID string) (*SubscriptionResult, error)
CancelSubscription cancels a sub in Stripe
func (*StripeProvider) ConfirmPaymentIntent ¶
func (s *StripeProvider) ConfirmPaymentIntent(ctx context.Context, paymentIntentID string, paymentMethodID string) (*PaymentIntentResult, error)
ConfirmPaymentIntent confirms a payment intent in Stripe
func (*StripeProvider) CreateCustomer ¶
func (s *StripeProvider) CreateCustomer(ctx context.Context, params *CreateCustomerParams) (*CustomerResult, error)
CreateCustomer creates a new customer in Stripe
func (*StripeProvider) CreatePaymentIntent ¶
func (s *StripeProvider) CreatePaymentIntent(ctx context.Context, params *CreatePaymentIntentParams) (*PaymentIntentResult, error)
CreatePaymentIntent creates a new payment intent in Stripe
func (*StripeProvider) CreateRefund ¶
func (s *StripeProvider) CreateRefund(ctx context.Context, params *CreateRefundParams) (*RefundResult, error)
CreateRefund creates a refund in Stripe
func (*StripeProvider) CreateSubscription ¶
func (s *StripeProvider) CreateSubscription(ctx context.Context, params *CreateSubscriptionParams) (*SubscriptionResult, error)
CreateSubscription creates a new sub in Stripe
func (*StripeProvider) DetachPaymentMethod ¶
func (s *StripeProvider) DetachPaymentMethod(ctx context.Context, paymentMethodID string) (*PaymentMethodResult, error)
DetachPaymentMethod detaches a payment method from a customer in Stripe
func (*StripeProvider) GetCustomer ¶
func (s *StripeProvider) GetCustomer(ctx context.Context, customerID string) (*CustomerResult, error)
GetCustomer retrieves a customer from Stripe
func (*StripeProvider) GetPaymentIntent ¶
func (s *StripeProvider) GetPaymentIntent(ctx context.Context, paymentIntentID string) (*PaymentIntentResult, error)
GetPaymentIntent retrieves a payment intent from Stripe
func (*StripeProvider) GetPaymentMethod ¶
func (s *StripeProvider) GetPaymentMethod(ctx context.Context, paymentMethodID string) (*PaymentMethodResult, error)
GetPaymentMethod retrieves a payment method from Stripe
func (*StripeProvider) GetRefund ¶
func (s *StripeProvider) GetRefund(ctx context.Context, refundID string) (*RefundResult, error)
GetRefund retrieves a refund from Stripe
func (*StripeProvider) GetSubscription ¶
func (s *StripeProvider) GetSubscription(ctx context.Context, subscriptionID string) (*SubscriptionResult, error)
GetSubscription retrieves a sub from Stripe
func (*StripeProvider) ListPaymentMethods ¶
func (s *StripeProvider) ListPaymentMethods(ctx context.Context, customerID string) ([]*PaymentMethodResult, error)
ListPaymentMethods lists payment methods for a customer in Stripe
func (*StripeProvider) SetDefaultPaymentMethod ¶
func (s *StripeProvider) SetDefaultPaymentMethod(ctx context.Context, customerID, paymentMethodID string) (*PaymentMethodResult, error)
SetDefaultPaymentMethod sets a payment method as the default for a customer
func (*StripeProvider) UpdateCustomer ¶
func (s *StripeProvider) UpdateCustomer(ctx context.Context, customerID string, params *UpdateCustomerParams) (*CustomerResult, error)
UpdateCustomer updates a customer in Stripe
func (*StripeProvider) UpdateSubscription ¶
func (s *StripeProvider) UpdateSubscription(ctx context.Context, subscriptionID string, params *UpdateSubscriptionParams) (*SubscriptionResult, error)
UpdateSubscription updates a sub in Stripe
type SubscriptionResult ¶
type SubscriptionResult struct {
ID string `json:"id"`
Status string `json:"status"`
CustomerID string `json:"customer_id"`
PriceID string `json:"price_id"`
Amount int64 `json:"amount"`
Currency string `json:"currency"`
Interval string `json:"interval"`
IntervalCount int `json:"interval_count"`
CurrentPeriodStart time.Time `json:"current_period_start"`
CurrentPeriodEnd time.Time `json:"current_period_end"`
TrialStart *time.Time `json:"trial_start,omitempty"`
TrialEnd *time.Time `json:"trial_end,omitempty"`
CanceledAt *time.Time `json:"canceled_at,omitempty"`
EndedAt *time.Time `json:"ended_at,omitempty"`
Metadata map[string]interface{} `json:"metadata,omitempty"`
Created time.Time `json:"created"`
}
SubscriptionResult represents a subscription response from the provider
type UpdateCustomerParams ¶
type UpdateCustomerParams struct {
Email string `json:"email,omitempty"`
Name string `json:"name,omitempty"`
Metadata map[string]interface{} `json:"metadata,omitempty"`
}
UpdateCustomerParams contains parameters for updating a customer
type UpdateSubscriptionParams ¶
type UpdateSubscriptionParams struct {
PriceID string `json:"price_id,omitempty"`
PaymentMethodID string `json:"payment_method_id,omitempty"`
Metadata map[string]interface{} `json:"metadata,omitempty"`
}
UpdateSubscriptionParams contains parameters for updating a subscription