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
- type Module
- func (m *Module) Capabilities() []string
- func (m *Module) Init(_ kernel.Kernel) error
- func (m *Module) Migrations() fs.FS
- func (m *Module) Name() string
- func (m *Module) Optional() []string
- func (m *Module) RegisterDualRoutes(r kernel.DualAuthRegistrar)
- func (m *Module) RegisterPublicRoutes(router chi.Router)
- func (m *Module) Requires() []string
- func (m *Module) Shutdown() error
- func (m *Module) Version() string
- type Option
Constants ¶
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 ¶
New builds the module and constructs the handler once, so every endpoint shares the adopted service and gateway driver.
func (*Module) Capabilities ¶
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 ¶
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 ¶
Migrations returns the embedded migration filesystem, laid out per driver subdirectory (the core migration runner selects via Driver.MigrationDir).
func (*Module) Optional ¶
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 ¶
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 ¶
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).
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. |