openapi: 3.0.3 info: title: Checkout API version: 0.1.0 contact: name: checkout maintainers url: https://github.com/IQVO/checkout description: >- REST contract of the checkout bounded context of the digital storefront, derived from storefront/model/model.yaml (contexts[checkout].rest) and the final model-gap decisions H1-H10. Checkout is the purchase saga: OPEN -> AUTHORIZING -> PLACING -> COMPLETED, with DECLINED (another token may be tried while the price quote is valid), REQUOTE_REQUIRED and FAILED (both carry a void that is retried until it succeeds), and EXPIRED (from OPEN or DECLINED). Authorize before placing (compensatable: void), place the order through customer-ordering POST /checkout (the pivot, via an Anti-Corruption Layer), then retriable steps via events. PLACING is the semantic lock: while the place-order outcome is unknown there is no void and no new attempt; the session answers 202 and the BFF polls. The session stores shopperId and shipToAddressId references, never PII, and the stored placement request is PII-free so ResolveInDoubtPlacements can replay it byte for byte with the same Idempotency-Key (alert at 20 h, give up and void at 22 h, before the network's 24 h idempotency window). Errors are RFC 9457 problem details (application/problem+json) whose type is /problems/; 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. Every POST takes an Idempotency-Key header (1-128 printable ASCII characters): a missing or malformed key is 400 idempotency-key-required / idempotency-key-invalid, a repeat of the same method, path and body replays the stored answer for 24 hours with the response header Idempotency-Replayed: true, and the same key on a different request whose answer was stored is 409 idempotency-key-reused. A 2xx is stored; so is a refusal that is final for the request (malformed-request, session-closed, price-quote-expired) or that committed state (authorization-mismatch: the session was saved DECLINED before the answer). A refusal that a retry can pass is NOT stored and its key is released, so the same Idempotency-Key runs the request again and another body under it is a new request: not-found, cart-not-checkout-ready, placement-in-doubt, void-pending, concurrent-update, illegal-transition, offer-not-quotable, validation-failed and price-quote-rejected, like every 5xx (never stored). The Idempotency-Key is global to the service, not per route. A request body over 64 KiB, malformed JSON, an unknown field or a NUL character (U+0000) in the query string or body is 400 malformed-request; a NUL in the path, or a path identifier longer than 128 characters, is 404. Every error body carries type, title, status, detail and instance. No authentication. servers: - url: http://localhost:8080 tags: - name: CheckoutSessions description: The purchase saga (CheckoutSession). paths: /checkout-sessions: post: tags: [CheckoutSessions] operationId: openCheckoutSession summary: Open a checkout session for a cart description: >- OpenSession. Reads the cart snapshot (shopping-cart GET /carts/{cartId}), checks every selected offer is still QUOTED with margin (delivery-promise GET /delivery-offers/{offerId}), issues the binding PriceQuote (pricing POST /price-quotes) and opens the session. The BFF then shows the review page with the binding total. shipToAddressId references a saved address held by customer-ordering (NG1); the address itself never enters the storefront. parameters: - $ref: '#/components/parameters/IdempotencyKey' requestBody: required: true content: application/json: schema: $ref: '#/components/schemas/OpenSessionRequest' responses: '201': description: The opened session (OPEN). headers: Idempotency-Replayed: $ref: '#/components/headers/IdempotencyReplayed' content: application/json: schema: $ref: '#/components/schemas/CheckoutSession' '400': $ref: '#/components/responses/BadRequest' '409': description: >- cart-not-checkout-ready (ErrCartNotCheckoutReady), concurrent-update, or idempotency-key-reused (the Idempotency-Key was already used with a different request). headers: Idempotency-Replayed: $ref: '#/components/headers/IdempotencyReplayed' content: application/problem+json: schema: $ref: '#/components/schemas/Problem' '422': description: >- validation-failed (a missing reference or an unknown cart), price-quote-rejected (pricing refused the quote request) or offer-not-quotable (ErrOfferNotQuotable, decision H3: a selected offer is no longer QUOTED or expires within 2 minutes; no state changes, the BFF refreshes the cart's delivery quote). content: application/problem+json: schema: $ref: '#/components/schemas/Problem' '502': description: upstream-contract-violation (ErrContractViolation, gap S1/S2 checks) - a sibling answered something that cannot form a session; an alert is raised. content: application/problem+json: schema: $ref: '#/components/schemas/Problem' '503': description: >- A dependency is unreachable (shopping-cart-unavailable, delivery-promise-unavailable or pricing-unavailable); retry with the same Idempotency-Key. Never stored for replay. content: application/problem+json: schema: $ref: '#/components/schemas/Problem' '500': $ref: '#/components/responses/InternalError' /checkout-sessions/{sessionId}: get: tags: [CheckoutSessions] operationId: getCheckoutSession summary: Get a checkout session description: >- GetSession. While PLACING after an in-doubt placement this is the polling endpoint the BFF uses until a definitive outcome. parameters: - $ref: '#/components/parameters/SessionId' responses: '200': description: The session. content: application/json: schema: $ref: '#/components/schemas/CheckoutSession' '400': description: malformed-request (a NUL character in the query string). content: application/problem+json: schema: $ref: '#/components/schemas/Problem' '404': $ref: '#/components/responses/NotFound' '500': $ref: '#/components/responses/InternalError' /checkout-sessions/{sessionId}/confirmations: post: tags: [CheckoutSessions] operationId: confirmCheckoutSession summary: Confirm the session with a payment method token description: >- ConfirmSession with the PSP payment method token (never a card number). AUTHORIZING calls customer-payments POST /payment-authorizations (key `:auth:`, the attempt counter grows on every retry after a decline; allocations per group); the authorized amount must equal the quote total (ErrAuthorizationMismatch). PLACING persists the placement request and calls customer-ordering POST /checkout with Idempotency-Key equal to the sessionId. Outcomes: 200 with the session in a definitive state (COMPLETED, DECLINED, REQUOTE_REQUIRED with requotedOffers after a successful void, or FAILED after a void plus an alert for a contract bug); 202 while the place-order outcome is unknown (the session stays PLACING; poll GET /checkout-sessions/{sessionId}). A DECLINED session may be confirmed again with another token while the price quote is valid. parameters: - $ref: '#/components/parameters/SessionId' - $ref: '#/components/parameters/IdempotencyKey' requestBody: required: true content: application/json: schema: $ref: '#/components/schemas/ConfirmSessionRequest' responses: '200': description: The session in a definitive state (COMPLETED, DECLINED, REQUOTE_REQUIRED or FAILED). headers: Idempotency-Replayed: $ref: '#/components/headers/IdempotencyReplayed' content: application/json: schema: $ref: '#/components/schemas/CheckoutSession' '202': description: >- An outcome is unknown: the authorization (the session stays AUTHORIZING; ResolveStuckAuthorizations re-calls with the same key after 2 minutes) or the place-order step (the session stays PLACING, the semantic lock). Poll GET /checkout-sessions/{sessionId}. headers: Idempotency-Replayed: $ref: '#/components/headers/IdempotencyReplayed' content: application/json: schema: $ref: '#/components/schemas/CheckoutSession' '400': $ref: '#/components/responses/BadRequest' '404': $ref: '#/components/responses/NotFound' '409': description: >- session-closed (ErrSessionClosed), authorization-mismatch (ErrAuthorizationMismatch, the authorization is voided), placement-in-doubt (ErrPlacementInDoubt), void-pending (ErrVoidPending, a previous authorization is still being voided), illegal-transition (a confirm while AUTHORIZING), concurrent-update, or idempotency-key-reused (the Idempotency-Key was already used with a different request). headers: Idempotency-Replayed: $ref: '#/components/headers/IdempotencyReplayed' content: application/problem+json: schema: $ref: '#/components/schemas/Problem' '422': description: >- validation-failed (a missing token) or price-quote-expired (ErrPriceQuoteExpired, contracts-delta S2: open a new session). headers: Idempotency-Replayed: $ref: '#/components/headers/IdempotencyReplayed' content: application/problem+json: schema: $ref: '#/components/schemas/Problem' '500': $ref: '#/components/responses/InternalError' components: parameters: IdempotencyKey: name: Idempotency-Key in: header required: true description: >- Client-generated UUID per logical submit, 1-128 printable ASCII characters. A repeat of the same method, path and body replays the stored answer (response header Idempotency-Replayed: true) when that answer was a 2xx or a refusal that is final or committed state; a refusal a retry can pass, and every 5xx, is not stored: the key is released and the same request runs again. The same key on a different request whose answer was stored is 409 idempotency-key-reused. schema: type: string minLength: 1 maxLength: 128 SessionId: name: sessionId in: path required: true description: A longer identifier than 128 characters is 404, like an unknown one. schema: type: string maxLength: 128 headers: IdempotencyReplayed: description: >- Set to `true` on a replay of a stored answer (a retry carrying the same Idempotency-Key, method, path and body), and only on a replay: the first execution of a key never carries it. schema: type: string enum: ['true'] responses: BadRequest: description: >- malformed-request (bad or empty JSON, unknown field, trailing data, a body over 64 KiB, a NUL character in the query string or body), idempotency-key-required (no Idempotency-Key header) or idempotency-key-invalid (not 1-128 printable ASCII characters). A malformed-request answer is stored under its key and replayed with Idempotency-Replayed: true. content: application/problem+json: schema: $ref: '#/components/schemas/Problem' examples: idempotencyKeyRequired: value: type: /problems/idempotency-key-required title: Idempotency-Key header is required status: 400 detail: send an Idempotency-Key header of 1 to 128 printable ASCII characters, unique per logical request instance: /checkout-sessions idempotencyKeyInvalid: value: type: /problems/idempotency-key-invalid title: Idempotency-Key header is not valid status: 400 detail: the Idempotency-Key must be 1 to 128 printable ASCII characters instance: /checkout-sessions NotFound: description: >- not-found (unknown session) or resource-not-found (a NUL character in the path); an identifier longer than 128 characters is not-found. content: application/problem+json: schema: $ref: '#/components/schemas/Problem' InternalError: description: >- internal-error. The detail is always "an unexpected error occurred"; a 5xx is never stored under the Idempotency-Key. content: application/problem+json: schema: $ref: '#/components/schemas/Problem' schemas: Problem: type: object description: RFC 9457 problem details. required: [type, title, status, detail, instance] properties: type: type: string format: uri-reference description: /problems/, for example /problems/placement-in-doubt. title: type: string status: type: integer minimum: 400 maximum: 599 detail: type: string instance: type: string format: uri-reference description: The escaped request path. Tier: type: string description: >- Delivery service tier. CONSOLIDATED is delivery-promise's opt-in tier of a customer-chosen delivery day; a session carries it only when the shopper selected such an offer in the cart. enum: [SAME_DAY, NEXT_DAY, TWO_DAY, STANDARD, CONSOLIDATED] CapacityBand: type: string description: >- The capacity pressure delivery-promise read on the selected offer's window when it quoted it. A signal only: it changes no offer, window, order or amount. enum: [AMPLE, TIGHT, SCARCE] SessionState: type: string enum: [OPEN, AUTHORIZING, DECLINED, PLACING, REQUOTE_REQUIRED, COMPLETED, EXPIRED, FAILED] OpenSessionRequest: type: object required: [cartId, shopperId, shipToAddressId] properties: cartId: type: string shopperId: type: string shipToAddressId: type: string description: Reference to a saved address in customer-ordering (NG1); never the address itself. ConfirmSessionRequest: type: object required: [paymentMethodToken] properties: paymentMethodToken: type: string description: The PSP token from the hosted fields; never a card number. SessionLine: type: object required: [lineNo, catalogItemId, quantity] properties: lineNo: type: integer minimum: 1 catalogItemId: type: string quantity: type: integer minimum: 1 SessionGroup: type: object required: [groupNo, offerId, tier, lineNos, amountMinor] properties: groupNo: type: integer minimum: 1 offerId: type: string tier: $ref: '#/components/schemas/Tier' lineNos: type: array items: type: integer minimum: 1 amountMinor: type: integer format: int64 minimum: 0 consolidationEligible: type: boolean description: >- Present only for the tier CONSOLIDATED, as the cart's selected offer carried it (delivery-promise ADR 0024): true when the chosen delivery day leaves the network at least one local day to merge the order with others. Omitted for every other tier and when the offer carried none. Information only; it is not sent to customer-ordering. capacityBand: $ref: '#/components/schemas/CapacityBand' RequotedOffer: type: object required: [offerId, groupNo, tier, deliverByEarliest, deliverByLatest, expiresAt] properties: offerId: type: string groupNo: type: integer minimum: 1 tier: $ref: '#/components/schemas/Tier' deliverByEarliest: type: string format: date description: >- Calendar day of the destination: the requoted window's earliest instant read in the offer's time zone (UTC when the network names none, ADR 0008). deliverByLatest: type: string format: date description: >- Calendar day of the destination: the requoted window's latest instant read in the offer's time zone (UTC when the network names none, ADR 0008). expiresAt: type: string format: date-time CheckoutSession: type: object required: [sessionId, state, cartId, cartVersion, shopperId, shipToAddressId, lines, groups, priceQuoteId, currency, totalMinor, quoteExpiresAt, authorizationId, orderId, failureCode, version] properties: sessionId: type: string state: $ref: '#/components/schemas/SessionState' cartId: type: string cartVersion: type: integer format: int64 minimum: 1 shopperId: type: string shipToAddressId: type: string lines: type: array items: $ref: '#/components/schemas/SessionLine' groups: type: array items: $ref: '#/components/schemas/SessionGroup' priceQuoteId: type: string currency: type: string pattern: '^[A-Z]{3}$' totalMinor: type: integer format: int64 minimum: 0 quoteExpiresAt: type: string format: date-time authorizationId: type: string nullable: true description: Always present; null until an authorization is recorded. orderId: type: string nullable: true description: Always present; null until the network's place-order step succeeds (COMPLETED). requotedOffers: type: array description: Present only in REQUOTE_REQUIRED (omitted otherwise); the BFF writes them into the cart as a new quote. items: $ref: '#/components/schemas/RequotedOffer' failureCode: type: string nullable: true description: Always present; null unless FAILED. version: type: integer format: int64 minimum: 1