stripemanager

package
v0.0.0-...-c8bebc6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 19, 2025 License: BSD-4-Clause Imports: 27 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrDefaultPaymentMethodNotFound = errors.New("DefaultPaymentMethod not found")

Functions

func BoolPointer

func BoolPointer(v bool) *bool

func CountTotalInvoices

func CountTotalInvoices(subscriptionID string) (int64, error)

func GetCustomerByID

func GetCustomerByID(ctx context.Context, customerID string) (customerDetails *stripe.Customer, err error)

func IsValidEmail

func IsValidEmail(email string) bool

Types

type AddSeatReply

type AddSeatReply struct {
	SubscriptionID string `json:"subscriptionID" validate:"required"`
	Success        bool   `json:"success" validate:"required"`
	EMail          string `json:"email" validate:"required"`
}

type AddSeatRequest

type AddSeatRequest struct {
	SubscriptionID string              `json:"subscriptionID" validate:"required"`
	EMail          string              `json:"email" validate:"required"`
	Roles          []mongomanager.Role `json:"roles" validate:"required"`
}

type Address

type Address struct {
	City       string  `json:"city" validate:"required"`
	Country    string  `json:"country" validate:"required"`
	Line1      string  `json:"line1" validate:"required"`
	Line2      *string `json:"line2" validate:"required"`
	PostalCode string  `json:"postal_code" validate:"required"`
}

type BillingAddressReply

type BillingAddressReply struct {
	SubscriptionID string  `json:"subscriptionID" validate:"required"`
	Name           string  `json:"name" validate:"required"`
	Address        Address `json:"address" validate:"required"`
	Phone          string  `json:"phone" validate:"required"`
}

type BillingAddressRequest

type BillingAddressRequest struct {
	SubscriptionID string `json:"subscriptionID" validate:"required"`
}

type BillingPortalReply

type BillingPortalReply struct {
	URL string `json:"url" validate:"required"`
}

type CancelStateReply

type CancelStateReply struct {
	SubscriptionID    string `json:"subscriptionID" validate:"required"`
	CancelAtPeriodEnd *bool  `json:"cancel_at_period_end" validate:"required"`
}

type ChangePaymentReply

type ChangePaymentReply struct {
	SetupIntentID string `json:"setupintentid" validate:"required"`
	ClientSecret  string `json:"clientsecret" validate:"required"`
	EMail         string `json:"email" validate:"required"`
}

type CheckoutCreateSubscriptionReply

type CheckoutCreateSubscriptionReply struct {
	Status         string `json:"status" validate:"required"`
	SubscriptionID string `json:"subscriptionID" validate:"required"`
	ProductName    string `json:"productName" validate:"required"`
	EMail          string `json:"email" validate:"required"`
	TrialEnd       int64  `json:"trialEnd" validate:"gte=0"`
}

type CheckoutCreateSubscriptionRequest

type CheckoutCreateSubscriptionRequest struct {
	ProductID string `json:"productID" binding:"required"`
	Quantity  int64  `json:"quantity" binding:"required"`
}

type CheckoutProductReply

type CheckoutProductReply struct {
	ProductID             string `json:"productID" validate:"required"`
	Name                  string `json:"name" validate:"required"`
	StorageAmount         int64  `json:"storageAmount" validate:"required"`
	StorageUnit           string `json:"storageUnit" validate:"required"`
	TrialDays             int64  `json:"trialDays" validate:"required"`
	PricePerMonth         int64  `json:"pricePerMonth" validate:"required"`
	Currency              string `json:"currency" validate:"required"`
	HasValidPaymentMethod *bool  `json:"has_valid_payment_method" validate:"required"`
}

type CheckoutProductRequest

type CheckoutProductRequest struct {
	ProductID string `json:"productID" binding:"required"`
}

type CheckoutSetupIntentReply

type CheckoutSetupIntentReply struct {
	SetupIntentID string `json:"setupIntentID" validate:"required"`
	ClientSecret  string `json:"clientSecret" validate:"required"`
}

type CheckoutSetupIntentRequest

type CheckoutSetupIntentRequest struct {
	ProductID string `json:"productID" binding:"required"`
	Quantity  int64  `json:"quantity" binding:"required"`
}

type DeleteSeatReply

type DeleteSeatReply struct {
	DeletedSeat mongomanager.Seat `json:"deletedSeat" validate:"required"`
	Success     bool              `json:"success" validate:"required"`
}

type DeleteSeatRequest

type DeleteSeatRequest struct {
	SeatToDelete mongomanager.Seat `json:"seatToDelete" validate:"required"`
}

type Invoice

type Invoice struct {
	InvoiceID      string               `json:"invoiceID" validate:"required"`
	SubscriptionID string               `json:"subscriptionID" validate:"required"`
	Created        int64                `json:"created" validate:"required"`
	Total          int64                `json:"total" validate:"required"`
	Currency       string               `json:"currency" validate:"required"`
	Status         stripe.InvoiceStatus `json:"status" validate:"required"`
	InvoicePDF     string               `json:"invoice_pdf" validate:"required"`
}

type ListInvoicesReply

type ListInvoicesReply struct {
	SubscriptionID string    `json:"subscriptionID" validate:"required"`
	Invoices       []Invoice `json:"invoices" validate:"required"`
	TotalResults   int64     `json:"totalResults" validate:"gte=1"`
}

type ListInvoicesRequest

type ListInvoicesRequest struct {
	SubscriptionID string `json:"subscriptionID" validate:"required"`
	PageSize       int    `json:"pageSize" validate:"gte=1"`
	StartingAfter  string `json:"startingAfter"`
	EndingBefore   string `json:"endingBefore"`
}

type ListSeatReply

type ListSeatReply struct {
	SubscriptionID string              `json:"subscriptionID" validate:"required"`
	MaxSeats       int64               `json:"maxSeats" validate:"required"`
	Seats          []mongomanager.Seat `json:"seats" validate:"required"`
	PageIndex      int                 `json:"pageIndex" validate:"gte=0"`
	TotalResults   int64               `json:"totalResults" validate:"gte=1"`
}

type ListSeatRequest

type ListSeatRequest struct {
	SubscriptionID string `json:"subscriptionID" validate:"required"`
	PageIndex      int    `json:"pageIndex" validate:"gte=0"`
	PageSize       int    `json:"pageSize" validate:"gte=1"`
}

type PaymentHandler

type PaymentHandler struct {
	FirebaseConnection   *firebasemanager.FirebaseConnection
	StripeConnection     *StripeConnection
	MongoConnection      *mongomanager.MongoConnection
	EMailConnection      *emailmanager.EMailConnection
	NewsletterConnection *newslettermanager.NewsletterConnection
	Log                  *zap.Logger
}

func (*PaymentHandler) CancelSubscription

func (paymentHandler *PaymentHandler) CancelSubscription(c context.Context, tokenDetails firebasemanager.TokenDetails, request SubscriptionCancelRequest) (SubscriptionCancelReply, error)

func (*PaymentHandler) ChangeCustomerAddress

func (paymentHandler *PaymentHandler) ChangeCustomerAddress(c context.Context, setupIntent stripe.SetupIntent) error

func (*PaymentHandler) ChangePaymentDefault

func (paymentHandler *PaymentHandler) ChangePaymentDefault(c context.Context, setupIntent stripe.SetupIntent) error

func (*PaymentHandler) CreateCheckoutSetupIntent

func (paymentHandler *PaymentHandler) CreateCheckoutSetupIntent(c context.Context, tokenDetails firebasemanager.TokenDetails, checkoutSetupIntentRequest CheckoutSetupIntentRequest) (CheckoutSetupIntentReply, error)

func (*PaymentHandler) CreateCheckoutSubscription

func (paymentHandler *PaymentHandler) CreateCheckoutSubscription(c context.Context, tokenDetails firebasemanager.TokenDetails, checkoutCreateSubscriptionRequest CheckoutCreateSubscriptionRequest) (CheckoutCreateSubscriptionReply, error)

func (*PaymentHandler) GetBillingAddress

func (paymentHandler *PaymentHandler) GetBillingAddress(c context.Context, tokenDetails firebasemanager.TokenDetails, request BillingAddressRequest) (BillingAddressReply, error)

func (*PaymentHandler) GetBillingPortal

func (paymentHandler *PaymentHandler) GetBillingPortal(c context.Context, tokenDetails firebasemanager.TokenDetails) (billingPortalModel BillingPortalReply, err error)

func (*PaymentHandler) GetCancelState

func (paymentHandler *PaymentHandler) GetCancelState(c context.Context, tokenDetails firebasemanager.TokenDetails, subscriptionID string) (CancelStateReply, error)

func (*PaymentHandler) GetChangePaymentSetupIntent

func (paymentHandler *PaymentHandler) GetChangePaymentSetupIntent(c context.Context, tokenDetails firebasemanager.TokenDetails) (ChangePaymentReply, error)

func (*PaymentHandler) GetCheckoutProduct

func (paymentHandler *PaymentHandler) GetCheckoutProduct(c context.Context, tokenDetails firebasemanager.TokenDetails, checkoutProductRequest CheckoutProductRequest) (CheckoutProductReply, error)

func (*PaymentHandler) GetCustomerByUID

func (paymentHandler *PaymentHandler) GetCustomerByUID(ctx context.Context, uid string) (customerDetails *stripe.Customer, err error)

func (*PaymentHandler) GetCustomerIDByUID

func (paymentHandler *PaymentHandler) GetCustomerIDByUID(ctx context.Context, uid string) (string, error)

func (*PaymentHandler) GetMyPermission

func (paymentHandler *PaymentHandler) GetMyPermission(c context.Context, tokenDetails firebasemanager.TokenDetails, request PermissionRequest) (PermissionReply, error)

func (*PaymentHandler) GetPaymentMethodOverview

func (paymentHandler *PaymentHandler) GetPaymentMethodOverview(c context.Context, tokenDetails firebasemanager.TokenDetails) (PaymentMethodOverviewReply, error)

func (*PaymentHandler) GetProductTiers

func (paymentHandler *PaymentHandler) GetProductTiers(c context.Context, prodType ProductType) (ProductTiersReply, error)

func (*PaymentHandler) GetSubscriptionAddSeat

func (paymentHandler *PaymentHandler) GetSubscriptionAddSeat(c context.Context, tokenDetails firebasemanager.TokenDetails, request AddSeatRequest) (AddSeatReply, error)

func (*PaymentHandler) GetSubscriptionDetailByID

func (paymentHandler *PaymentHandler) GetSubscriptionDetailByID(c context.Context, tokenDetails firebasemanager.TokenDetails, subscriptionID string) (SubscriptionDetailReply, error)

func (*PaymentHandler) GetSubscriptionInvoices

func (paymentHandler *PaymentHandler) GetSubscriptionInvoices(c context.Context, tokenDetails firebasemanager.TokenDetails, request ListInvoicesRequest) (ListInvoicesReply, error)

func (*PaymentHandler) GetSubscriptionListSeats

func (paymentHandler *PaymentHandler) GetSubscriptionListSeats(c context.Context, tokenDetails firebasemanager.TokenDetails, request ListSeatRequest) (ListSeatReply, error)

func (*PaymentHandler) GetSubscriptionRemoveSeat

func (paymentHandler *PaymentHandler) GetSubscriptionRemoveSeat(c context.Context, tokenDetails firebasemanager.TokenDetails, request DeleteSeatRequest) (DeleteSeatReply, error)

func (*PaymentHandler) GetSubscriptionSeatDetail

func (paymentHandler *PaymentHandler) GetSubscriptionSeatDetail(c context.Context, tokenDetails firebasemanager.TokenDetails, request SeatDetailRequest) (SeatDetailReply, error)

func (*PaymentHandler) GetSubscriptionUpdateSeat

func (paymentHandler *PaymentHandler) GetSubscriptionUpdateSeat(c context.Context, tokenDetails firebasemanager.TokenDetails, request UpdateSeatDetailRequest) (UpdateSeatDetailReply, error)

func (*PaymentHandler) GetSubscriptionsOverview

func (paymentHandler *PaymentHandler) GetSubscriptionsOverview(c context.Context, tokenDetails firebasemanager.TokenDetails) (subscriptionOverview []SubscriptionOverviewReply, err error)

func (*PaymentHandler) ResumeSubscription

func (paymentHandler *PaymentHandler) ResumeSubscription(c context.Context, tokenDetails firebasemanager.TokenDetails, request SubscriptionResumeRequest) (SubscriptionResumeReply, error)

func (*PaymentHandler) UpdateBillingAddress

func (paymentHandler *PaymentHandler) UpdateBillingAddress(c context.Context, tokenDetails firebasemanager.TokenDetails, request UpdateBillingAddressRequest) (UpdateBillingAddressReply, error)

type PaymentMethodOverviewCard

type PaymentMethodOverviewCard struct {
	Brand    string `json:"brand"`
	Last4    string `json:"last4"`
	ExpMonth uint64 `json:"exp_month"`
	ExpYear  uint64 `json:"exp_year"`
}

type PaymentMethodOverviewPayPal

type PaymentMethodOverviewPayPal struct {
	Email string `json:"email"`
}

type PaymentMethodOverviewReply

type PaymentMethodOverviewReply struct {
	HasValidPaymentMethod          *bool                          `json:"has_valid_payment_method" validate:"required"`
	Type                           string                         `json:"type" validate:"required"`
	PaymentMethodOverviewCard      PaymentMethodOverviewCard      `json:"card,omitempty"`
	PaymentMethodOverviewSEPADebit PaymentMethodOverviewSEPADebit `json:"sepa_debit,omitempty"`
	PaymentMethodOverviewPayPal    PaymentMethodOverviewPayPal    `json:"paypal,omitempty"`
}

type PaymentMethodOverviewSEPADebit

type PaymentMethodOverviewSEPADebit struct {
	Country string `json:"country"`
	Last4   string `json:"last4"`
}

type PermissionReply

type PermissionReply struct {
	MySeat mongomanager.Seat `json:"mySeat" validate:"required"`
}

type PermissionRequest

type PermissionRequest struct {
	SubscriptionID string `json:"subscriptionID" validate:"required"`
}

type ProductTier

type ProductTier struct {
	ProductType   ProductType `json:"productType" validate:"required"`
	ProductID     string      `json:"productID" validate:"required"`
	Name          string      `json:"name" validate:"required"`
	StorageAmount int         `json:"storageAmount" validate:"required"`
	StorageUnit   string      `json:"storageUnit" validate:"required"`
	TrialDays     int64       `json:"trialDays" validate:"required"`
	PricePerMonth int64       `json:"pricePerMonth" validate:"required"`
}

type ProductTiersReply

type ProductTiersReply struct {
	ProductType  ProductType   `json:"productType" validate:"required"`
	ProductTiers []ProductTier `json:"productTiers" validate:"required"`
}

type ProductTiersRequest

type ProductTiersRequest struct {
	ProductType ProductType `json:"productType" validate:"required"`
}

type ProductType

type ProductType string
const (
	ProductNextcloud ProductType = "Nextcloud"
	ProductSynology  ProductType = "Synology"
)

type SeatDetailReply

type SeatDetailReply struct {
	SelectedSeat mongomanager.Seat `json:"selectedSeat" validate:"required"`
	MySeat       mongomanager.Seat `json:"mySeat" validate:"required"`
}

type SeatDetailRequest

type SeatDetailRequest struct {
	SubscriptionID string `json:"subscriptionID" validate:"required"`
	UID            string `json:"uid" validate:"required"`
}

type SetupIntentMeta

type SetupIntentMeta string
const (
	CreateSubscription SetupIntentMeta = "createSubscription"
	ChangePayment      SetupIntentMeta = "changePayment"
)
const SetupIntentMetaKey SetupIntentMeta = "setupIntentMeta"

type StripeConnection

type StripeConnection struct {
	Key            string
	EndpointSecret string
	Log            *zap.Logger
}

func InitStripeConnection

func InitStripeConnection(ctx context.Context, log *zap.Logger) (*StripeConnection, error)

func (*StripeConnection) CreateCustomer

func (stripeConnection *StripeConnection) CreateCustomer(ctx context.Context, email string) (*stripe.Customer, error)

func (*StripeConnection) GetDefaultPaymentMethod

func (stripeConnection *StripeConnection) GetDefaultPaymentMethod(c context.Context, cus *stripe.Customer) (*stripe.PaymentMethod, error)

func (*StripeConnection) GetPaymentMethod

func (stripeConnection *StripeConnection) GetPaymentMethod(c context.Context, paymentMethodID string) (*stripe.PaymentMethod, error)

func (*StripeConnection) GetPrice

func (stripeConnection *StripeConnection) GetPrice(c context.Context, productID string) (*stripe.Price, error)

func (*StripeConnection) GetProduct

func (stripeConnection *StripeConnection) GetProduct(c context.Context, productID string) (*stripe.Product, error)

func (*StripeConnection) GetSubscriptionByID

func (stripeConnection *StripeConnection) GetSubscriptionByID(c context.Context, subscriptionID string) (*stripe.Subscription, error)

type SubscriptionCancelReply

type SubscriptionCancelReply struct {
	SubscriptionID    string `json:"subscriptionID" validate:"required"`
	CancelAtPeriodEnd *bool  `json:"cancel_at_period_end" validate:"required"`
	CancelAt          int64  `json:"cancel_at" validate:"gte=0"`
}

type SubscriptionCancelRequest

type SubscriptionCancelRequest struct {
	SubscriptionID string `json:"subscriptionID" binding:"required"`
}

type SubscriptionDetailReply

type SubscriptionDetailReply struct {
	ID                string `json:"id" validate:"required"`
	Active            *bool  `json:"active" validate:"required"`
	ProductName       string `json:"product_name" validate:"required"`
	ProductType       string `json:"product_type" validate:"required"`
	StorageAmount     int    `json:"storage_amount" validate:"required"`
	UserCount         int64  `json:"user_count" validate:"required"`
	PricePerMonth     int64  `json:"price_per_month" validate:"required"`
	Currency          string `json:"currency" validate:"required"`
	CancelAtPeriodEnd *bool  `json:"cancel_at_period_end" validate:"required"`
	CancelAt          int64  `json:"cancel_at"`
	Status            string `json:"status" validate:"required"`
	TrialEnd          int64  `json:"trial_end"`
	CurrentPeriodEnd  int64  `json:"current_period_end" validate:"required"`
}

type SubscriptionOverviewReply

type SubscriptionOverviewReply struct {
	ID            string `json:"id" validate:"required"`
	Acive         *bool  `json:"active" validate:"required"`
	ProductName   string `json:"productName" validate:"required"`
	ProductType   string `json:"productType" validate:"required"`
	StorageAmount int    `json:"storageAmount" validate:"required"`
	UserCount     int64  `json:"userCount" validate:"required"`
}

type SubscriptionResumeReply

type SubscriptionResumeReply struct {
	SubscriptionID    string `json:"subscriptionID" validate:"required"`
	CancelAtPeriodEnd *bool  `json:"cancel_at_period_end" validate:"required"`
}

type SubscriptionResumeRequest

type SubscriptionResumeRequest struct {
	SubscriptionID string `json:"subscriptionID" binding:"required"`
}

type UpdateBillingAddressReply

type UpdateBillingAddressReply struct {
	SubscriptionID string `json:"subscriptionID" validate:"required"`
}

type UpdateBillingAddressRequest

type UpdateBillingAddressRequest struct {
	SubscriptionID string  `json:"subscriptionID" validate:"required"`
	Name           string  `json:"name" validate:"required"`
	Address        Address `json:"address" validate:"required"`
	Phone          string  `json:"phone" validate:"required"`
}

type UpdateSeatDetailReply

type UpdateSeatDetailReply struct {
	Seat mongomanager.Seat `json:"seat" validate:"required"`
}

type UpdateSeatDetailRequest

type UpdateSeatDetailRequest struct {
	SeatUpdated mongomanager.Seat `json:"seatUpdated" validate:"required"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL