stripe

package
v0.100.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	// ConfigEnvPrefix is the prefix applied to environment variables for configuring Stripe.
	ConfigEnvPrefix = config.ConfigEnvPrefix + "STRIPE_"
)

Variables

View Source
var ErrInvalidSubscription = errors.New("invalid subscription")

ErrInvalidSubscription indicates there was invalid data sent or received about a subscription.

Functions

func CancelSubscription

func CancelSubscription(user *models.User) error

CancelSubscription will cancel a user's active subscription. Subscription will be cancelled at the end of the current billing period.

https://docs.stripe.com/billing/subscriptions/cancel?dashboard-or-api=api#cancel-at-the-end-of-the-current-billing-period

func HandleWebhook

func HandleWebhook(res http.ResponseWriter, req *http.Request)

HandleWebhook will handle incoming webhook requests from Stripe, that are sent in response to events related to a user's subscription (like plan changes, trial expiry, payment events).

func StopPendingCancellation

func StopPendingCancellation(user *models.User) error

StopPendingCancellation will stop the pending cancellation of a user's subscription.

https://docs.stripe.com/billing/subscriptions/cancel?dashboard-or-api=api#reactivating-canceled-subscriptions

Types

type Checkout

type Checkout struct {
	*stripe.CheckoutSession
}

Checkout is alocal wrapper around the stripe.CheckoutSession object.

func NewCheckoutSession

func NewCheckoutSession(user *models.User, planID string) (*Checkout, error)

NewCheckoutSession creates a new checkout session, that is used to allow a user to purchase a subscription plan.

type Config

type Config struct {
	// APIKey is the Stripe API key for communicating securely with the Stripe API.
	APIKey        string `koanf:"apikey"        validate:"required"`
	BaseURL       string `koanf:"baseurl"       validate:"required,url"`
	WebHookSecret string `koanf:"webhooksecret" validate:"required"`
}

Config structure.

type PortalSession

type PortalSession struct {
	*stripe.BillingPortalSession
}

PortalSession is a local wrapper around the stripe.BillingPortalSession object.

func NewPortalSession

func NewPortalSession(sessionID string) (*PortalSession, error)

NewPortalSession creates a new portal session, which allows a user to manage their subscription plan.

Jump to

Keyboard shortcuts

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