stripemanager

package
v0.0.0-...-ccc70e5 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2024 License: BSD-4-Clause Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BoolPointer

func BoolPointer(v bool) *bool

func GetCustomerByID

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

Types

type BillingPortalReply

type BillingPortalReply struct {
	URL string `json:"url" 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:"required"`
}

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"`
}

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 PaymentHandler

type PaymentHandler struct {
	FirebaseConnection *firebasemanager.FirebaseConnection
	StripeConnection   *StripeConnection
	MongoConnection    *mongomanager.MongoConnection
	Log                *zap.Logger
}

func (*PaymentHandler) CancelSubscription

func (paymentHandler *PaymentHandler) CancelSubscription(c context.Context, tokenDetails firebasemanager.TokenDetails, request SubscriptionCancelRequest) (SubscriptionCancelReply, 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) GetBillingPortal

func (paymentHandler *PaymentHandler) GetBillingPortal(c context.Context, tokenDetails firebasemanager.TokenDetails) (billingPortalModel BillingPortalReply, err 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) GetPaymentMethodOverview

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

func (*PaymentHandler) GetSubscriptionDetailByID

func (paymentHandler *PaymentHandler) GetSubscriptionDetailByID(c context.Context, tokenDetails firebasemanager.TokenDetails, subscriptionID string) (subscriptionDetailReply SubscriptionDetailReply, err 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)

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 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 {
	ID                string `json:"id" validate:"required"`
	CancelAtPeriodEnd *bool  `json:"cancel_at_period_end" validate:"required"`
	CancelAt          int64  `json:"cancel_at"`
}

type SubscriptionCancelRequest

type SubscriptionCancelRequest struct {
	ID string `json:"id" 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"`
}

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 {
	ID                string `json:"id" validate:"required"`
	CancelAtPeriodEnd *bool  `json:"cancel_at_period_end" validate:"required"`
}

type SubscriptionResumeRequest

type SubscriptionResumeRequest struct {
	ID string `json:"id" binding:"required"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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