cedros

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2025 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LoadConfig

func LoadConfig(path string) (*config.Config, error)

LoadConfig wraps the internal loader for consumers embedding Cedros Pay.

func NewHandler

func NewHandler(cfg *config.Config, opts ...Option) (http.Handler, func(context.Context) error, error)

NewHandler is a convenience that constructs an App and returns its handler.

func RegisterRoutes

func RegisterRoutes(router chi.Router, app *App)

RegisterRoutes attaches Cedros endpoints to the provided router using an existing App.

Types

type App

type App struct {
	Config           *config.Config
	Store            storage.Store
	Verifier         x402.Verifier
	Notifier         callbacks.Notifier
	Paywall          *paywall.Service
	Stripe           *stripesvc.Client
	CartService      *stripesvc.CartService // Cart service for multi-item checkouts
	Coupons          coupons.Repository     // Coupon repository
	Subscriptions    *subscriptions.Service // Subscription management service
	IdempotencyStore *idempotency.MemoryStore
	// contains filtered or unexported fields
}

App wires the Cedros paywall components for reuse or standalone serving.

func NewApp

func NewApp(cfg *config.Config, opts ...Option) (*App, error)

NewApp assembles Cedros paywall services for embedding.

func (*App) Close

func (a *App) Close() error

Close releases resources owned by the app (verifier, etc).

func (*App) Handler

func (a *App) Handler() http.Handler

Handler exposes the router as an http.Handler.

func (*App) Router

func (a *App) Router() chi.Router

Router returns the chi router with Cedros routes registered.

type Config

type Config = config.Config

Config is an exported alias of the internal configuration struct for embedding use.

type Option

type Option func(*options)

Option configures App construction.

func WithNotifier

func WithNotifier(notifier callbacks.Notifier) Option

WithNotifier injects a payment callback notifier.

func WithRouter

func WithRouter(router chi.Router) Option

WithRouter allows callers to provide an existing chi.Router to register routes onto.

func WithStore

func WithStore(store storage.Store) Option

WithStore sets a custom storage backend.

func WithVerifier

func WithVerifier(verifier x402.Verifier) Option

WithVerifier injects a custom x402 verifier (responsible for validation and settlement).

Jump to

Keyboard shortcuts

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