Help us shape the future of Go! Take the 2026 Go Developer Survey

stripe

package
v0.22.0 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package stripe provides Stripe integration for the marketplace.

Index

Constants

This section is empty.

Variables

View Source
var ErrWebhookSecretRequired = errors.New("stripe: webhook signing secret is required")

ErrWebhookSecretRequired is returned when a webhook is verified without a signing secret. An empty secret would accept a signature anyone can compute, so verification fails closed.

View Source
var WebhookEventTypes = []string{
	"checkout.session.completed",
	"checkout.session.async_payment_succeeded",
	"customer.subscription.created",
	"customer.subscription.updated",
	"customer.subscription.deleted",
	"invoice.paid",
	"invoice.payment_failed",
	"account.updated",
}

WebhookEventTypes lists the Stripe event types we handle.

Functions

func VerifyWebhook

func VerifyWebhook(payload []byte, signature, secret string) (*stripe.Event, error)

VerifyWebhook verifies the Stripe webhook signature and returns the parsed event. It returns ErrWebhookSecretRequired when secret is empty.

Types

type CheckoutOption added in v0.14.0

type CheckoutOption func(*CheckoutService)

CheckoutOption configures a CheckoutService.

func WithPurchaserChecker added in v0.14.0

func WithPurchaserChecker(c marketplace.PurchaserChecker) CheckoutOption

WithPurchaserChecker refuses checkout to managed principals with marketplace.ErrManagedPurchaser. Deployments that enable managed principals must set it.

type CheckoutService

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

CheckoutService implements marketplace.CheckoutService using Stripe.

func NewCheckoutService

func NewCheckoutService(cfg Config, listings marketplace.ListingService, licenses marketplace.LicenseService, authzSync marketplace.AuthzSyncer, opts ...CheckoutOption) *CheckoutService

NewCheckoutService creates a new Stripe checkout service.

func (*CheckoutService) CreateCheckoutSession

CreateCheckoutSession creates a Stripe checkout session for a listing.

func (*CheckoutService) ProcessWebhook

func (s *CheckoutService) ProcessWebhook(ctx context.Context, payload []byte, signature string) error

ProcessWebhook handles Stripe webhook events. It refuses every event with ErrWebhookSecretRequired when Config.WebhookSecret is empty.

type Config

type Config struct {
	// SecretKey is the Stripe secret API key.
	SecretKey string

	// WebhookSecret is the Stripe webhook signing secret. ProcessWebhook
	// refuses every event with ErrWebhookSecretRequired while it is empty.
	WebhookSecret string

	// ConnectAccountID is the Stripe Connect account ID (optional, for platforms).
	ConnectAccountID string
}

Config holds Stripe configuration.

type ConnectAccount

type ConnectAccount struct {
	// ID is the Stripe account ID.
	ID string

	// OrganizationID is the platform organization ID.
	OrganizationID uuid.UUID

	// Email is the account email.
	Email string

	// ChargesEnabled indicates if the account can accept charges.
	ChargesEnabled bool

	// PayoutsEnabled indicates if the account can receive payouts.
	PayoutsEnabled bool

	// DetailsSubmitted indicates if onboarding is complete.
	DetailsSubmitted bool
}

ConnectAccount represents a Stripe Connect account for a seller.

type ConnectService

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

ConnectService provides Stripe Connect functionality for marketplace sellers.

func NewConnectService

func NewConnectService(cfg Config) *ConnectService

NewConnectService creates a new Stripe Connect service.

func (s *ConnectService) CreateAccountLink(ctx context.Context, accountID, refreshURL, returnURL string) (string, error)

CreateAccountLink creates an onboarding link for a Connect account.

func (*ConnectService) CreateConnectAccount

func (s *ConnectService) CreateConnectAccount(ctx context.Context, orgID uuid.UUID, email string) (*ConnectAccount, error)

CreateConnectAccount creates a new Stripe Connect Express account for a seller.

func (*ConnectService) CreatePayout

func (s *ConnectService) CreatePayout(ctx context.Context, accountID string, amountCents int64, currency string) (string, error)

CreatePayout initiates a payout to a Connect account.

func (*ConnectService) GetAccountBalance

func (s *ConnectService) GetAccountBalance(ctx context.Context, accountID string) (int64, string, error)

GetAccountBalance retrieves the available balance for a Connect account.

func (*ConnectService) GetConnectAccount

func (s *ConnectService) GetConnectAccount(ctx context.Context, accountID string) (*ConnectAccount, error)

GetConnectAccount retrieves a Connect account by ID.

Jump to

Keyboard shortcuts

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