Authorizations
One PaymentAuthorization per checkout session, with allocations per shipment group.
Introduction
REST contract of the customer-payments bounded context of the digital storefront, as the service serves it. Customer Payments moves money with the shipment facts: authorize at checkout, capture each shipment group's allocation when it ships (FulfillmentShipped), release on cancellation (FulfillmentCancelled), refund on lost or returned packages (PackageLost, PackageReturned), and re-authorize uncaptured allocations before the provider's authorization validity expires. The provider is reached through an ACL port (Authorize, Capture, Void, Refund, Reauthorize) with deterministic idempotency keys per (operation, authorizationId, groupNo); the storefront never sees a card number, only PSP tokens. This surface is called by checkout (authorize, void) and by storefront ops (refunds, reads); captures, releases and re-authorizations arrive as Kafka events or policies, never as REST writes. Errors are RFC 9457 problem details (application/problem+json) whose type is /problems/<slug>; shared types are not-found (404), illegal-transition (409), concurrent-update (409) and validation-failed (422), plus one kebab-case slug per Err of the model, and the idempotency problems idempotency-key-required and idempotency-key-invalid (400) and idempotency-key-reused (409). Every write (each POST) takes an Idempotency-Key header: a retry with the same key and the same request (method, path, body) replays the first answer (Idempotency-Replayed: true). A 2xx is stored for 24 hours, and so is a refusal that is final for the request (malformed-request, allocation-mismatch, negative-amount); a refusal that depends on state that can change (not-found, concurrent-update, illegal-transition, over-refund, payment-declined, validation-failed) and a 5xx are never stored: the key is released, the same Idempotency-Key runs the request again, and another request under it is a new request, not idempotency-key-reused. Otherwise the same key with another request is 409 idempotency-key-reused. A body that is not one JSON object of the declared fields (unknown field, trailing data, over 64 KiB, a NUL character) is 400 malformed-request; a NUL character in a path is 404 resource-not-found. Any operation can answer 500 internal-error. The two collection reads are keyset-paged ({items, nextCursor}; invalid-limit, invalid-cursor and unknown-query-parameter are 400). No authentication.
Authorizations
Authorizations
Authorize the quote total of a checkout session
AuthorizePayment. One authorization per checkout session (ErrDuplicateAuthorization; a replay with the same Idempotency-Key returns the existing one; so does a new key while the session holds a live authorization, answered 200 instead of 201). checkout calls this with key <sessionId>:auth and one allocation per shipment group (1 to 50, distinct groupNo); allocations must sum to the authorized total (ErrAllocationMismatch). On a provider decline the record is DECLINED (terminal, 201 with declineReason) and the checkout session stays open for another token.
Get one authorization with its allocations
GetAuthorization.
Get one refund
GetRefund.
List authorizations by order or checkout session
ListAuthorizations. Exactly one of orderId or checkoutSessionId is required (none or both is 422 validation-failed). Keyset-paged, oldest first (createdAt, authorizationId): follow nextCursor until it is absent and repeat the filter on every page request.
List refunds of an order
ListRefunds. Keyset-paged, oldest first (createdAt, refundId): follow nextCursor until it is absent and repeat orderId on every page request.
Refunds
Refunds
Request a manual refund (ops only)
RequestRefund, the ops route. Automatic refunds come from the RefundOnLostPackage and RefundOnReturnToSender policies. The order must have an authorization (else 404). groupNo is optional: absent or 0 refunds at the order level. Refunds of an order (and of a group) never exceed the captured total (ErrOverRefund); FAILED refunds do not count. The provider is tried once in the same call: the answer is 201 with the refund SUCCEEDED, FAILED (provider decline, failureCode set) or still REQUESTED (provider unreachable; a policy retries it), never 503.
Retry a failed refund (ops only)
RetryRefund, the ops route; no request body. Moves a FAILED refund back to REQUESTED and tries the provider once more, at most 5 attempts in all. The answer is 200 with the Refund as it stands after that attempt (SUCCEEDED, FAILED again with failureCode, or still REQUESTED when the provider is unreachable); it is never 503. A refund that is not FAILED, or whose attempts are used up, is 409 illegal-transition.
Void an uncaptured authorization
VoidAuthorization. checkout calls this with key <sessionId>:void, and only after a definitive rejection of the place-order step (never while the outcome is in doubt; that side is guarded by checkout's ErrPlacementInDoubt). VoidUnboundAuthorizations also voids an authorization that no CheckoutCompleted bound within 24 h.