billing

package
v1.1.26 Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AddMemberRequest

type AddMemberRequest struct {
	UserID string `json:"userID"`
	Role   string `json:"role"`
}

AddMemberRequest is the body for adding a member to a customer.

type AdminAddCustomerMemberRequest

type AdminAddCustomerMemberRequest struct {
	UserID string `json:"userID"`
	Role   string `json:"role"`
}

AdminAddCustomerMemberRequest is the body for admin adding a member to a customer.

type AdminCustomer

type AdminCustomer struct {
	ID                 string `json:"id"`
	GCID               string `json:"gcid"`
	Name               string `json:"name"`
	Email              string `json:"email"`
	TierName           string `json:"tierName"`
	SubscriptionStatus string `json:"subscriptionStatus"`
	CreatedAt          string `json:"createdAt"`
}

AdminCustomer is a customer in a paginated admin list.

type AdminGetCustomerResponse

type AdminGetCustomerResponse struct {
	ID                 string    `json:"id"`
	GCID               string    `json:"gcid"`
	Name               string    `json:"name"`
	Email              string    `json:"email"`
	BillingAddress     string    `json:"billingAddress"`
	TierName           string    `json:"tierName"`
	SubscriptionStatus string    `json:"subscriptionStatus"`
	CreatedAt          time.Time `json:"createdAt"`
}

AdminGetCustomerResponse is returned when fetching a customer as admin.

type AdminListCustomerMembersResponse

type AdminListCustomerMembersResponse struct {
	Pages   int      `json:"pages"`
	Items   int      `json:"items"`
	Members []Member `json:"members"`
}

AdminListCustomerMembersResponse is the paginated response for admin member listing.

type AdminListCustomersOptions

type AdminListCustomersOptions struct {
	Limit    int    `url:"limit,omitempty"`
	Page     int    `url:"page,omitempty"`
	TierName string `url:"tierName,omitempty"`
	Status   string `url:"status,omitempty"`
}

AdminListCustomersOptions provides filtering for the admin customer list endpoint.

type AdminListTiersOptions

type AdminListTiersOptions struct {
	Active *bool `url:"active,omitempty"`
}

AdminListTiersOptions provides filtering for the admin tier list endpoint.

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client provides access to the Billing API endpoints.

func NewClient

func NewClient(d doFunc) *Client

NewClient creates a new Billing client backed by the root SDK client's do function.

func (*Client) AddMember

func (c *Client) AddMember(ctx context.Context, req AddMemberRequest) error

AddMember adds a member to the current customer.

func (*Client) AdminAddMember

func (c *Client) AdminAddMember(ctx context.Context, customerID string, req AdminAddCustomerMemberRequest) error

AdminAddMember adds a member to a customer as admin.

func (*Client) AdminBillingStatus

func (c *Client) AdminBillingStatus(ctx context.Context) (*GetBillingStatusResponse, error)

AdminBillingStatus returns the billing status for a customer as admin.

func (*Client) AdminDeleteCustomer

func (c *Client) AdminDeleteCustomer(ctx context.Context, customerID string) error

AdminDeleteCustomer deletes a customer by ID as admin.

func (*Client) AdminGetCustomer

func (c *Client) AdminGetCustomer(ctx context.Context, customerID string) (*AdminGetCustomerResponse, error)

AdminGetCustomer fetches a customer by ID as admin.

func (*Client) AdminListCustomerMembers

func (c *Client) AdminListCustomerMembers(ctx context.Context, customerID string, opts *ListOpts) (*AdminListCustomerMembersResponse, error)

AdminListCustomerMembers lists members of a customer as admin.

func (*Client) AdminListCustomers

func (c *Client) AdminListCustomers(ctx context.Context, opts *AdminListCustomersOptions) (*ListCustomersResponse, error)

AdminListCustomers lists customers with optional filtering.

func (*Client) AdminListTiers

func (c *Client) AdminListTiers(ctx context.Context, opts *AdminListTiersOptions) (*GetAllTiersResponse, error)

AdminListTiers lists all billing tiers with optional filtering.

func (*Client) AdminRemoveMember

func (c *Client) AdminRemoveMember(ctx context.Context, customerID, userID string) error

AdminRemoveMember removes a member from a customer as admin.

func (*Client) AdminSetDefaultTier

func (c *Client) AdminSetDefaultTier(ctx context.Context, tierID string) error

AdminSetDefaultTier sets a tier as the default tier.

func (*Client) CreateCustomer

func (c *Client) CreateCustomer(ctx context.Context, req CreateCustomerRequest) error

CreateCustomer creates a new customer.

func (*Client) DeleteCustomer

func (c *Client) DeleteCustomer(ctx context.Context) error

DeleteCustomer deletes the current customer.

func (*Client) GetAllIPLimits

func (c *Client) GetAllIPLimits(ctx context.Context) (*GetAllIPLimitsResponse, error)

GetAllIPLimits returns all IP rate limits (no auth required).

func (*Client) GetAllLimits

func (c *Client) GetAllLimits(ctx context.Context) (*GetAllLimitsResponse, error)

GetAllLimits returns all limits for the customer.

func (*Client) GetAllQuotas

func (c *Client) GetAllQuotas(ctx context.Context) (*GetAllQuotasResponse, error)

GetAllQuotas returns all quotas for the customer.

func (*Client) GetCustomer

func (c *Client) GetCustomer(ctx context.Context) (*GetCustomerResponse, error)

GetCustomer returns the current customer.

func (*Client) GetCustomerTier

func (c *Client) GetCustomerTier(ctx context.Context) (*GetCustomerTierResponse, error)

GetCustomerTier returns the customer's current tier.

func (*Client) GetIPUsage

func (c *Client) GetIPUsage(ctx context.Context) (*GetIPUsageResponse, error)

GetIPUsage returns IP usage data (no auth required).

func (*Client) GetQuotaUsage

func (c *Client) GetQuotaUsage(ctx context.Context) (*GetQuotaUsageResponse, error)

GetQuotaUsage returns quota usage data for the current user.

func (*Client) GetServiceIPLimits

func (c *Client) GetServiceIPLimits(ctx context.Context, serviceName string) (*GetServiceIPLimitsResponse, error)

GetServiceIPLimits returns IP rate limits for a specific service (no auth required).

func (*Client) GetServiceLimits

func (c *Client) GetServiceLimits(ctx context.Context, serviceName string) (*GetServiceLimitsResponse, error)

GetServiceLimits returns limits for a specific service.

func (*Client) GetServiceQuotas

func (c *Client) GetServiceQuotas(ctx context.Context, serviceName string) (*GetServiceQuotasResponse, error)

GetServiceQuotas returns quotas for a specific service.

func (*Client) GetSpecificLimit

func (c *Client) GetSpecificLimit(ctx context.Context, serviceName, featureKey string) (*GetSpecificLimitResponse, error)

GetSpecificLimit returns a specific limit for a service and feature.

func (*Client) GetSpecificQuota

func (c *Client) GetSpecificQuota(ctx context.Context, serviceName, featureKey string) (*GetSpecificQuotaResponse, error)

GetSpecificQuota returns a specific quota for a service and feature.

func (*Client) GetUsage

func (c *Client) GetUsage(ctx context.Context) (*GetUserUsageResponse, error)

GetUsage returns usage data for the current user.

func (*Client) GetUserQuotaUsage

func (c *Client) GetUserQuotaUsage(ctx context.Context, userID string) (*GranularUsageResponse, error)

GetUserQuotaUsage returns granular quota usage for a specific user.

func (*Client) GetUserUsage

func (c *Client) GetUserUsage(ctx context.Context, userID string) (*GranularUsageResponse, error)

GetUserUsage returns granular usage data for a specific user.

func (*Client) LeaveCustomer

func (c *Client) LeaveCustomer(ctx context.Context) error

LeaveCustomer removes the current user from the customer.

func (*Client) ListMembers

func (c *Client) ListMembers(ctx context.Context, opts *ListOpts) (*ListMembersResponse, error)

ListMembers lists members of the current customer with optional pagination.

func (*Client) RemoveMember

func (c *Client) RemoveMember(ctx context.Context, userID string) error

RemoveMember removes a member from the current customer by user ID.

func (*Client) StartPortal

func (c *Client) StartPortal(ctx context.Context) (*StartPortalResponse, error)

StartPortal starts a Stripe billing portal session.

func (*Client) TransferOwnership

func (c *Client) TransferOwnership(ctx context.Context, req TransferOwnershipRequest) error

TransferOwnership transfers customer ownership to another user.

func (*Client) UpdateMember

func (c *Client) UpdateMember(ctx context.Context, req UpdateMemberRequest) error

UpdateMember updates a member's role in the current customer.

func (*Client) UpgradeToPro

func (c *Client) UpgradeToPro(ctx context.Context, req UpgradeToProRequest) (*UpgradeToProResponse, error)

UpgradeToPro creates a Stripe checkout session for upgrading to Pro.

type CreateCustomerRequest

type CreateCustomerRequest struct {
	Name           string `json:"name"`
	Email          string `json:"email"`
	BillingAddress string `json:"billingAddress"`
}

CreateCustomerRequest is the body for creating a new customer.

type GetAllIPLimitsResponse

type GetAllIPLimitsResponse struct {
	IPLimits map[string]any `json:"ipLimits"`
}

GetAllIPLimitsResponse is returned when fetching all IP limits.

type GetAllLimitsResponse

type GetAllLimitsResponse struct {
	CustomerID string         `json:"customerId"`
	TierName   string         `json:"tierName"`
	Limits     map[string]any `json:"limits"`
}

GetAllLimitsResponse is returned when fetching all limits for the customer.

type GetAllQuotasResponse

type GetAllQuotasResponse struct {
	Quotas map[string]any `json:"quotas"`
}

GetAllQuotasResponse is returned when fetching all quotas for the customer.

type GetAllTiersResponse

type GetAllTiersResponse struct {
	Tiers []Tier `json:"tiers"`
}

GetAllTiersResponse is returned when fetching all tiers.

type GetBillingStatusResponse

type GetBillingStatusResponse struct {
	CustomerID         string `json:"customerId"`
	TierName           string `json:"tierName"`
	SubscriptionStatus string `json:"subscriptionStatus"`
	StripeCustomerID   string `json:"stripeCustomerID"`
	Stacks             int    `json:"stacks"`
}

GetBillingStatusResponse is returned when fetching billing status as admin.

type GetCustomerResponse

type GetCustomerResponse struct {
	ID   string `json:"id"`
	GCID string `json:"gcid"`
}

GetCustomerResponse is returned when fetching the current customer.

type GetCustomerTierResponse

type GetCustomerTierResponse struct {
	TierID             string `json:"tierId"`
	TierName           string `json:"tierName"`
	SubscriptionStatus string `json:"subscriptionStatus"`
	Stacks             int    `json:"stacks"`
}

GetCustomerTierResponse is returned when fetching the customer's tier.

type GetIPUsageResponse

type GetIPUsageResponse struct {
	Usage map[string]any `json:"usage"`
}

GetIPUsageResponse is returned when fetching IP usage.

type GetQuotaUsageResponse

type GetQuotaUsageResponse struct {
	Usage map[string]any `json:"usage"`
}

GetQuotaUsageResponse is returned when fetching quota usage.

type GetServiceIPLimitsResponse

type GetServiceIPLimitsResponse struct {
	Limits map[string]any `json:"limits"`
}

GetServiceIPLimitsResponse is returned when fetching IP limits for a specific service.

type GetServiceLimitsResponse

type GetServiceLimitsResponse struct {
	Limits map[string]any `json:"limits"`
}

GetServiceLimitsResponse is returned when fetching limits for a specific service.

type GetServiceQuotasResponse

type GetServiceQuotasResponse struct {
	Quotas map[string]any `json:"quotas"`
}

GetServiceQuotasResponse is returned when fetching quotas for a specific service.

type GetSpecificLimitResponse

type GetSpecificLimitResponse struct {
	Value       any    `json:"value"`
	Window      string `json:"window"`
	Description string `json:"description"`
}

GetSpecificLimitResponse is returned when fetching a specific limit.

type GetSpecificQuotaResponse

type GetSpecificQuotaResponse struct {
	Value any    `json:"value"`
	Unit  string `json:"unit"`
}

GetSpecificQuotaResponse is returned when fetching a specific quota.

type GetUserUsageResponse

type GetUserUsageResponse struct {
	Services map[string]any `json:"services"`
}

GetUserUsageResponse is returned when fetching usage for the current user.

type GranularUsageResponse

type GranularUsageResponse struct {
	Events []any `json:"events"`
	Total  int   `json:"total"`
}

GranularUsageResponse is returned when fetching granular usage for a user.

type LimitDetail

type LimitDetail struct {
	Value       any    `json:"value"`
	Window      string `json:"window"`
	Description string `json:"description"`
}

LimitDetail contains the details of a single limit.

type ListCustomersResponse

type ListCustomersResponse struct {
	Pages     int             `json:"pages"`
	Items     int             `json:"items"`
	Customers []AdminCustomer `json:"customers"`
}

ListCustomersResponse is the paginated response for admin customer listing.

type ListMembersResponse

type ListMembersResponse struct {
	Pages   int      `json:"pages"`
	Items   int      `json:"items"`
	Members []Member `json:"members"`
}

ListMembersResponse is the paginated response for listing members.

type ListOpts

type ListOpts struct {
	Limit int
	Page  int
}

ListOpts holds pagination parameters for admin list endpoints.

type Member

type Member struct {
	UserID   string    `json:"userID"`
	Role     string    `json:"role"`
	Email    string    `json:"email"`
	JoinedAt time.Time `json:"joinedAt"`
}

Member represents a member of a customer.

type StartPortalResponse

type StartPortalResponse struct {
	URL string `json:"url"`
}

StartPortalResponse is returned when starting a Stripe billing portal session.

type Tier

type Tier struct {
	ID          string `json:"id"`
	Name        string `json:"name"`
	Description string `json:"description"`
	Price       int    `json:"price"`
	IsActive    bool   `json:"isActive"`
}

Tier represents a billing tier.

type TransferOwnershipRequest

type TransferOwnershipRequest struct {
	NewOwnerUserID string `json:"newOwnerUserID"`
}

TransferOwnershipRequest is the body for transferring customer ownership.

type UpdateMemberRequest

type UpdateMemberRequest struct {
	UserID string `json:"userID"`
	Role   string `json:"role"`
}

UpdateMemberRequest is the body for updating a member's role.

type UpgradeToProRequest

type UpgradeToProRequest struct {
	SuccessURL string `json:"successURL"`
	CancelURL  string `json:"cancelURL"`
}

UpgradeToProRequest is the body for upgrading to Pro via Stripe.

type UpgradeToProResponse

type UpgradeToProResponse struct {
	CheckoutURL string `json:"checkoutURL"`
}

UpgradeToProResponse is returned when creating a Pro upgrade checkout.

Jump to

Keyboard shortcuts

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