Documentation
¶
Overview ¶
Package api hosts the order module's surfaces: the public checkout and guest tracking (rate-limited, no auth chain) and the admin order list, detail, and lifecycle transitions (JWT-protected, admin-gated). Everything writes through kernel/httpx — a new surface with no legacy envelope contract.
Index ¶
- type Handler
- func (h *Handler) Checkout(w http.ResponseWriter, r *http.Request)
- func (h *Handler) GetInvoiceSettings(w http.ResponseWriter, r *http.Request)
- func (h *Handler) GetOrder(w http.ResponseWriter, r *http.Request)
- func (h *Handler) InvoiceOrder(w http.ResponseWriter, r *http.Request)
- func (h *Handler) ListOrders(w http.ResponseWriter, r *http.Request)
- func (h *Handler) SetManualPayee(payee *ManualPayee)
- func (h *Handler) SetShippingOrder(w http.ResponseWriter, r *http.Request)
- func (h *Handler) TrackOrder(w http.ResponseWriter, r *http.Request)
- func (h *Handler) TransitionOrder(w http.ResponseWriter, r *http.Request)
- func (h *Handler) UpdateInvoiceSettings(w http.ResponseWriter, r *http.Request)
- type InvoiceSettingsStore
- type InvoiceSupport
- type ManualPayee
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
Handler serves the order surfaces over the adopted service; New builds it once with the admin capability resolver.
func New ¶
func New(service *ordersdomain.Service, resolve kernel.CapabilityResolver, invoice *InvoiceSupport) *Handler
New builds the handler over the adopted service and the capability resolver gating the admin surface.
func (*Handler) Checkout ¶
func (h *Handler) Checkout(w http.ResponseWriter, r *http.Request)
Checkout handles POST /checkout: claims the presented cart into a pending order (the atomic delete arbitrates parallel checkouts) and snapshots its prices, SKUs, and titles.
func (*Handler) GetInvoiceSettings ¶
func (h *Handler) GetInvoiceSettings(w http.ResponseWriter, r *http.Request)
GetInvoiceSettings handles GET /orders/invoice-settings: the live seller identity and PPN rate the next rendered invoice will use.
func (*Handler) GetOrder ¶
func (h *Handler) GetOrder(w http.ResponseWriter, r *http.Request)
GetOrder handles GET /orders/{orderID}: one order with its items.
func (*Handler) InvoiceOrder ¶
func (h *Handler) InvoiceOrder(w http.ResponseWriter, r *http.Request)
InvoiceOrder streams the order's invoice PDF: derived on demand from the stored record, never persisted. Unknown orders read as not found; a module without a renderer answers unavailable instead of serving an empty surface.
func (*Handler) ListOrders ¶
func (h *Handler) ListOrders(w http.ResponseWriter, r *http.Request)
ListOrders handles GET /orders: the newest orders first, the status filter optional, keyed cursor pagination.
func (*Handler) SetManualPayee ¶
func (h *Handler) SetManualPayee(payee *ManualPayee)
SetManualPayee adopts the manual payee block for guest tracking payloads. A nil payee leaves tracking payloads without the payee section.
func (*Handler) SetShippingOrder ¶
func (h *Handler) SetShippingOrder(w http.ResponseWriter, r *http.Request)
SetShippingOrder replaces the shipping line of a pending order. Settled, expired, or cancelled orders refuse with INVALID_TRANSITION; negative amounts are a validation error.
func (*Handler) TrackOrder ¶
func (h *Handler) TrackOrder(w http.ResponseWriter, r *http.Request)
TrackOrder handles GET /orders/{orderNumber}?email=&token=: guest tracking behind the three-factor gate. All of number, email, and the per-order tracking token must match; everything else reads as not found. A pending order with a configured payee carries the manualPayee block for the tracking panel; absent payee leaves the current panel unchanged.
func (*Handler) TransitionOrder ¶
func (h *Handler) TransitionOrder(w http.ResponseWriter, r *http.Request)
TransitionOrder handles POST /orders/{orderID}/status: one lifecycle move, validated against the transition map, emailing the customer.
func (*Handler) UpdateInvoiceSettings ¶
func (h *Handler) UpdateInvoiceSettings(w http.ResponseWriter, r *http.Request)
UpdateInvoiceSettings handles PUT /orders/invoice-settings: validates the block, persists it through the module's config write-back, and adopts it for the next rendered invoice without a restart. An explicit zero rate is preserved — non-PKP sellers charge no PPN.
type InvoiceSettingsStore ¶
type InvoiceSettingsStore interface {
InvoiceSettings() ordersdomain.InvoiceSettings
SetInvoiceSettings(settings ordersdomain.InvoiceSettings) error
}
InvoiceSettingsStore reads and writes the live invoice settings. The module owns the state (mutex-guarded) and persists it through the config write-back seam; GET and PUT /orders/invoice-settings serve it. A nil store leaves the settings surface unavailable.
type InvoiceSupport ¶
type InvoiceSupport struct {
Settings ordersdomain.InvoiceSettings
Renderer ordersdomain.InvoiceRenderer
Store InvoiceSettingsStore
}
InvoiceSupport carries the invoice endpoint's collaborators: the seller identity and PPN rate plus the PDF renderer. A nil support leaves the endpoint unconfigured. Store, when present, supersedes Settings so the invoice reflects an admin edit without a restart.
type ManualPayee ¶
ManualPayee is the destination account for manual bank transfers, adopted from the [payments.manual] config block via the composition root. Empty means no payee block is configured and tracking payloads carry no payee section.