payments

package
v0.1.21 Latest Latest
Warning

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

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

Documentation

Overview

Package payments provides a minimal provider-agnostic interface for portal billing flows.

Index

Constants

This section is empty.

Variables

View Source
var ErrNotConfigured = fmt.Errorf("payments not configured")

ErrNotConfigured is returned when payments are not configured.

Functions

This section is empty.

Types

type CheckoutSession

type CheckoutSession struct {
	ID   string
	URL  string
	Mode string // payment|setup

	// Stripe checkout session lifecycle status (e.g. open|complete|expired).
	Status string
	// Stripe payment status (e.g. paid|unpaid|no_payment_required).
	PaymentStatus string

	CustomerID      string
	PaymentIntentID string
	SetupIntentID   string

	AmountTotal int64
	Currency    string

	Metadata  map[string]string
	ExpiresAt time.Time
}

CheckoutSession is a provider-agnostic representation of a checkout session.

type CreditsCheckoutInput

type CreditsCheckoutInput struct {
	CustomerID string

	PurchaseID   string
	Username     string
	InstanceSlug string
	Month        string
	Credits      int64

	AmountCents int64
	Currency    string

	SuccessURL string
	CancelURL  string
}

CreditsCheckoutInput configures a one-time payment checkout session for purchasing credits.

type EnsureCustomerInput

type EnsureCustomerInput struct {
	Username string
	Email    string
}

EnsureCustomerInput identifies the user/customer to ensure in the provider.

type PaymentMethodDetails

type PaymentMethodDetails struct {
	ID    string
	Type  string
	Brand string
	Last4 string

	ExpMonth int64
	ExpYear  int64
}

PaymentMethodDetails is a normalized snapshot of a payment method attached to a customer.

type Provider

type Provider interface {
	Name() string

	EnsureCustomer(ctx context.Context, in EnsureCustomerInput) (customerID string, err error)
	CreateCreditsCheckout(ctx context.Context, in CreditsCheckoutInput) (*CheckoutSession, error)
	CreateSetupCheckout(ctx context.Context, in SetupCheckoutInput) (*CheckoutSession, error)

	ParseWebhookEvent(ctx context.Context, headers map[string][]string, body []byte) (*WebhookEvent, error)
	ResolveSetupPaymentMethod(ctx context.Context, setupIntentID string) (*PaymentMethodDetails, error)
}

Provider is a minimal provider-agnostic payments interface used by the portal.

func NewProvider

func NewProvider(name string, ssmClient secrets.SSMAPI) Provider

NewProvider constructs a payments Provider by name. The ssmClient is used by the Stripe provider to fetch API keys from SSM. Passing nil falls back to the default AWS SSM client.

type SetupCheckoutInput

type SetupCheckoutInput struct {
	CustomerID string
	Username   string

	SuccessURL string
	CancelURL  string
}

SetupCheckoutInput configures a setup checkout session for collecting an overage payment method.

type WebhookEvent

type WebhookEvent struct {
	Type    string
	Session CheckoutSession
}

WebhookEvent is a provider-agnostic representation of a webhook event carrying a checkout session payload.

Jump to

Keyboard shortcuts

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