payments

package module
v1.7.0 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2026 License: MIT Imports: 7 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package payments is the official commerce payment module: payment methods adopted from store configuration, manual transfer proof submission for guests, and the admin payment decisions that flip orders to paid or keep them waiting. The module never imports the orders packages — it resolves and confirms orders through the Orders seam with the composition root providing the adapter.

Index

Constants

View Source
const (
	// Name is the registry key for this module.
	Name = "payments"

	// Version is the module version reported via Module.Version.
	Version = "0.1.0"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Module

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

Module is the payments kernel module.

func New

func New(options ...Option) *Module

New builds the module and constructs the handler once, so every endpoint shares the adopted service and gateway driver.

func (*Module) Capabilities

func (m *Module) Capabilities() []string

Capabilities contributes the module's permission to the registry so the resolver can grant it (Admin implicitly, custom roles via config when declared).

func (*Module) Init

func (m *Module) Init(_ kernel.Kernel) error

Init wires the module. The handler is already built by New; Init only validates that the adopted service is present — a payments module without its service fails startup loudly instead of serving an empty surface. Migration execution is core-driven (it needs the live *sql.DB, which modules never touch directly).

func (*Module) Migrations

func (m *Module) Migrations() fs.FS

Migrations returns the embedded migration filesystem, laid out per driver subdirectory (the core migration runner selects via Driver.MigrationDir).

func (*Module) Name

func (m *Module) Name() string

Name returns the registry key.

func (*Module) Optional

func (m *Module) Optional() []string

Optional lists soft dependencies. The mailer is structural best-effort: email failures never fail a submission or a decision.

func (*Module) RegisterDualRoutes

func (m *Module) RegisterDualRoutes(r kernel.DualAuthRegistrar)

RegisterDualRoutes declares the admin surface for dual-realm mounting: core serves every path on both the agent stack (Bearer API key) and the browser stack (CSRF plus JWT), dispatched by credential — so AI agents decide payment proofs with the same API key they use for content while the admin SPA keeps working unchanged. Same handlers, same in-handler capability checks on both realms.

func (*Module) RegisterPublicRoutes

func (m *Module) RegisterPublicRoutes(router chi.Router)

RegisterPublicRoutes mounts the public surface (rate-limited, no auth chain): the offered-method enumeration, the guest proof submission, the hosted-session mint, and the gateway webhook (signature-gated).

func (*Module) Requires

func (m *Module) Requires() []string

Requires lists hard dependencies. Payment proofs resolve and confirm orders through the Orders seam, and orders own the checkout flow: with orders disabled there is nothing to pay for, so the module drops from the registry (orders → payments).

func (*Module) Shutdown

func (m *Module) Shutdown() error

Shutdown releases nothing: the handler holds no runtime resources.

func (*Module) Version

func (m *Module) Version() string

Version returns the module version.

type Option

type Option func(*Module)

Option configures a Module. The composition root supplies every option; direct construction without options yields a standalone module that serves nothing (handlers built over nil dependencies must not be invoked).

func WithCapabilityResolver

func WithCapabilityResolver(resolve kernel.CapabilityResolver) Option

WithCapabilityResolver attaches the capability resolver gating the admin surface. Without one every admin request is refused (fail closed).

func WithGateway

func WithGateway(gateway paymentsdomain.Gateway) Option

WithGateway adopts the hosted-checkout driver. Without one the mint surface answers 503 and webhooks refuse validation.

func WithMethods

func WithMethods(methods []paymentsdomain.Method) Option

WithMethods adopts the offered payment methods from store configuration, in the configured order.

func WithService

func WithService(service *paymentsdomain.Service) Option

WithService adopts the payments domain service (composition root). The same instance backs every endpoint.

Directories

Path Synopsis
Package api hosts the payment module's surfaces: the public proof submission for manual transfers, hosted-session minting, and gateway webhooks (rate-limited, no auth chain) plus the admin payment list, detail, and decisions (JWT-protected, admin-gated).
Package api hosts the payment module's surfaces: the public proof submission for manual transfers, hosted-session minting, and gateway webhooks (rate-limited, no auth chain) plus the admin payment list, detail, and decisions (JWT-protected, admin-gated).
Package midtrans is the Midtrans Snap driver for the payments module: it mints hosted-checkout sessions over the Snap REST API and authenticates webhook notifications with the SHA-512 server-key checksum.
Package midtrans is the Midtrans Snap driver for the payments module: it mints hosted-checkout sessions over the Snap REST API and authenticates webhook notifications with the SHA-512 server-key checksum.
Package store is the single-source payment record repository: one implementation against *sql.DB plus a kernel Dialect, following the orders store pattern.
Package store is the single-source payment record repository: one implementation against *sql.DB plus a kernel Dialect, following the orders store pattern.

Jump to

Keyboard shortcuts

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