Documentation
¶
Overview ¶
Package payments provides a minimal provider-agnostic interface for portal billing flows.
Index ¶
Constants ¶
This section is empty.
Variables ¶
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 ¶
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.
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.