provider

package
v1.9.1 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package provider defines the contract that payment provider plugins (Stripe, Braintree, etc.) must implement. Payment methods are always fetched live from the provider and never stored locally.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type PaymentMethod

type PaymentMethod struct {
	ID           string `json:"id"`
	Type         string `json:"type"`  // "card", "bank_account", etc.
	Last4        string `json:"last4"` // last 4 digits
	Brand        string `json:"brand"` // "visa", "mastercard", etc.
	ExpiryMonth  int    `json:"expiry_month"`
	ExpiryYear   int    `json:"expiry_year"`
	IsDefault    bool   `json:"is_default"`
	ProviderName string `json:"provider_name"` // e.g. "stripe"
	ProviderID   string `json:"provider_id"`   // provider's own ID for this method
}

PaymentMethod is a read-only DTO representing a payment method on the provider side. It is never persisted locally.

type Provider

type Provider interface {
	// Name returns the provider identifier (e.g. "stripe", "braintree").
	Name() string

	ListPaymentMethods(ctx context.Context, tenantID string) ([]PaymentMethod, error)

	SyncPlan(ctx context.Context, p *plan.Plan) (providerID string, err error)
	SyncFeature(ctx context.Context, f *feature.Feature) (providerID string, err error)
	SyncSubscription(ctx context.Context, s *subscription.Subscription) (providerID string, err error)
	SyncInvoice(ctx context.Context, inv *invoice.Invoice) (providerID string, err error)

	ImportPlan(ctx context.Context, providerID string) (*plan.Plan, error)
	ImportFeature(ctx context.Context, providerID string) (*feature.Feature, error)
	ImportSubscription(ctx context.Context, providerID string) (*subscription.Subscription, error)
	ImportInvoice(ctx context.Context, providerID string) (*invoice.Invoice, error)

	HandleWebhook(ctx context.Context, payload []byte) (*WebhookResult, error)
}

Provider is the interface that payment provider plugins must implement. It covers bidirectional sync (push local → provider, pull provider → local), live payment-method listing, and webhook handling.

type SyncResult

type SyncResult struct {
	ProviderName string `json:"provider_name"`
	ProviderID   string `json:"provider_id"`
	EntityType   string `json:"entity_type"` // "plan", "feature", "subscription", "invoice"
	EntityID     string `json:"entity_id"`
	Direction    string `json:"direction"` // "push" or "pull"
	Success      bool   `json:"success"`
	Error        string `json:"error,omitempty"`
}

SyncResult describes the outcome of a push or pull sync operation.

type WebhookResult

type WebhookResult struct {
	EventType  string    `json:"event_type"`
	ProviderID string    `json:"provider_id"`
	EntityType string    `json:"entity_type"` // "plan", "subscription", "invoice", etc.
	EntityID   string    `json:"entity_id"`
	Handled    bool      `json:"handled"`
	Error      string    `json:"error,omitempty"`
	Timestamp  time.Time `json:"timestamp"`
}

WebhookResult describes the outcome of processing a single webhook event.

Directories

Path Synopsis
Package stripe is a Stripe payment provider for Ledger.
Package stripe is a Stripe payment provider for Ledger.

Jump to

Keyboard shortcuts

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