stripe

package
v1.28.0 Latest Latest
Warning

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

Go to latest
Published: Feb 22, 2026 License: AGPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetBillingCycleFromPrice

func GetBillingCycleFromPrice(priceInterval stripe.PriceRecurringInterval) string

GetBillingCycleFromPrice determines billing cycle from price interval

func GetPriceFromSubscription

func GetPriceFromSubscription(sub *stripe.Subscription) string

GetPriceFromSubscription extracts the price ID from a subscription

Types

type CheckoutSessionParams

type CheckoutSessionParams struct {
	CustomerID   string
	PriceID      string
	Quantity     int64
	SuccessURL   string
	CancelURL    string
	OrgID        string
	OrgName      string
	Plan         string
	BillingCycle string
	TrialDays    int               // Trial period in days (0 = no trial)
	Metadata     map[string]string // Additional metadata for user-level subscriptions
}

CheckoutSessionParams contains parameters for creating a checkout session

type Client

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

Client wraps Stripe API client with application-specific methods

func NewClient

func NewClient(apiKey, webhookSecret string) *Client

NewClient creates a new Stripe client

func (*Client) CancelSubscription

func (c *Client) CancelSubscription(subscriptionID string, cancelAtPeriodEnd bool) (*stripe.Subscription, error)

CancelSubscription cancels a subscription

func (*Client) ConstructWebhookEvent

func (c *Client) ConstructWebhookEvent(payload []byte, signature string) (stripe.Event, error)

ConstructWebhookEvent constructs and verifies a webhook event

func (*Client) CreateCheckoutSession

func (c *Client) CreateCheckoutSession(params CheckoutSessionParams) (*stripe.CheckoutSession, error)

CreateCheckoutSession creates a Stripe Checkout session

func (*Client) CreateCustomer

func (c *Client) CreateCustomer(params CreateCustomerParams) (*stripe.Customer, error)

CreateCustomer creates a new Stripe customer

func (*Client) CreateSubscription

func (c *Client) CreateSubscription(customerID, priceID string, metadata map[string]string) (*stripe.Subscription, error)

CreateSubscription creates a new subscription for a customer

func (*Client) GetCustomer

func (c *Client) GetCustomer(customerID string) (*stripe.Customer, error)

GetCustomer retrieves a Stripe customer by ID

func (*Client) GetSubscription

func (c *Client) GetSubscription(subscriptionID string) (*stripe.Subscription, error)

GetSubscription retrieves a subscription by ID

func (*Client) ListCustomerSubscriptions

func (c *Client) ListCustomerSubscriptions(customerID string) ([]*stripe.Subscription, error)

ListCustomerSubscriptions lists all subscriptions for a customer

func (*Client) ListInvoices

func (c *Client) ListInvoices(customerID string, limit int64) ([]*stripe.Invoice, error)

ListInvoices lists invoices for a customer

func (*Client) PreviewPlanChange

func (c *Client) PreviewPlanChange(subscriptionID string, newPriceID string, newQuantity int64) (*stripe.Invoice, error)

PreviewPlanChange previews the cost of switching to a different plan/price. Uses the same upcoming invoice API as seat changes but with a different price ID.

func (*Client) PreviewSeatChange

func (c *Client) PreviewSeatChange(subscriptionID string, newQuantity int64) (*stripe.Invoice, error)

PreviewSeatChange uses Stripe's upcoming invoice API to show what the user will be charged (or credited) if they change seat count. No mutation occurs.

func (*Client) ReactivateSubscription

func (c *Client) ReactivateSubscription(subscriptionID string) (*stripe.Subscription, error)

ReactivateSubscription reactivates a subscription set to cancel

func (*Client) UpdateCustomer

func (c *Client) UpdateCustomer(customerID string, params *stripe.CustomerParams) (*stripe.Customer, error)

UpdateCustomer updates a Stripe customer

func (*Client) UpdateSubscriptionPlan

func (c *Client) UpdateSubscriptionPlan(subscriptionID string, newPriceID string, newQuantity int64, metadata map[string]string) (*stripe.Subscription, error)

UpdateSubscriptionPlan replaces the price on an existing subscription (plan change). This is the industry-standard approach for changing plans when the customer already has an active subscription with a payment method on file. Stripe handles proration automatically — the customer is NOT redirected to a new checkout page.

func (*Client) UpdateSubscriptionQuantity

func (c *Client) UpdateSubscriptionQuantity(subscriptionID string, quantity int64) (*stripe.Subscription, error)

UpdateSubscriptionQuantity updates the quantity (seats) for the first subscription item. This is used for seat-based (per-user) billing. Stripe will apply proration according to your account settings and the subscription's collection method.

type CreateCustomerParams

type CreateCustomerParams struct {
	Email        string
	Name         string
	OrgID        string // Organization ID (for metadata)
	BillingEmail string
}

CreateCustomerParams contains parameters for creating a customer

type StripeSubscription

type StripeSubscription = stripe.Subscription

StripeSubscription is a type alias for stripe.Subscription for external use

Jump to

Keyboard shortcuts

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