SR-012 — Reusable Checkout Orchestration: System Requirements

By Engineering Team•October 2, 2026•6 min read
Metadata Details
System Name shop-service + order-service + inventory-service + shipment-service + pii-service + payment-service — Reusable Product/Checkout Orchestration
Document ID SR-2026-CHO-001
Author Engineering Team
Status Approved

Traces back to BRD-011 — Reusable Product-to-Order Journey With Trustworthy Totals.


Functional Requirements

Shared Pricing / Stock / Shipment Resolution

  • FR-01 (Single Consolidated Checkout-Info Call): inventory-service’s GetCheckoutInfo MUST be the single call that resolves per-SKU price, discount price, stock, tax (HSN/GST), warehouse, and weight for a given set of order lines, and MUST be the one call both shop-service’s product-detail preview (product_full_section.go’s getProductShipmentEstimate) and its real checkout path (checkout_imp_svc.go’s resolveCheckoutInfo) use — neither caller MUST independently re-derive pricing or tax. (Gap — the GST rate this resolves is read as a flat percentage stored directly per-SKU, not via a category/HSN-driven slab mapping as real Indian GST rules require; tracked as technical debt — see Technical Debt — Reusable Checkout Orchestration Gaps, TD-06.)
  • FR-02 (Shared Shipment-Serviceability Service): shipment.IShipmentService.GetServiceability MUST be a single shared service method, called identically by the product-detail preview and by checkout, rather than each caller holding its own repository call and item-building logic.
  • FR-03 (Non-Fatal vs. Mandatory Shipment-Lookup Handling): a shipment-serviceability lookup failure on the product-detail preview MUST degrade to an empty shipment-estimate field without failing the overall request; the identical lookup failure during checkout MUST hard-fail the request, since a price summary cannot be computed without a shipping fee.

Cart & Buy-Now Unification

  • FR-04 (Single Checkout Entry Point for Cart and Buy Now): checkout MUST expose one entry point accepting one input DTO (GetCheckoutDetailsInput{ProductID, VariantID, Quantity}); an empty VariantID MUST resolve raw lines from the persisted cart, and a non-empty VariantID MUST construct a single synthetic line directly, without writing it into the persisted cart first.
  • FR-05 (Differentiated Stale-Line Handling): a cart line whose SKU no longer resolves against the checkout-info response MUST be skipped with a warning, allowing checkout to continue without it; the identical miss on a Buy Now line MUST be a hard not-found error, since there is no persisted cart row to fall back on.
  • FR-06 (Cross-Screen Pricing Consistency): checkout’s per-item effective price and savings calculation MUST use the same price-resolution function the cart screen’s own item listing uses, and the price-summary savings total MUST use the same formula as the cart screen’s own savings total.

Checkout Session Caching

  • FR-07 (Full Aggregate Caching On Every Checkout Read): every checkout read MUST cache the complete resolved aggregate — addresses, order items, tax summary, warehouse, weight breakdown, shipment tier options, allowed payment methods, and price summary — into a checkout-session record under a freshly minted token, before returning the result to the caller.
  • FR-08 (Insert-Only Session, One Scoped Update Exception): the checkout-session collection MUST be insert-only, with exactly one scoped exception: a payment-method/courier re-quote operation MAY update the same record’s shipment-tier and price-summary fields in place, by token, without touching the record’s tenant/owner/creation fields.
  • FR-09 (Live Re-Resolution on Re-Quote, Cache Reuse for the Rest): a re-quote operation MUST always re-resolve the customer’s addresses live and always re-quote shipment live against the shipment service — never from the cached session — because both the available tiers and their cost-on-delivery surcharge can differ by payment method; the same operation MUST read order items, tax summary, and warehouse information from the cached session rather than re-resolving them.
  • FR-10 (Session Time-To-Live): the checkout-session record MUST expire automatically after a fixed, short window (1 hour, per shop-service’s CheckoutSessionTTL constant). (Gap — a dependent service’s own documentation states a different window than this authoritative value; tracked as technical debt — see Technical Debt — Reusable Checkout Orchestration Gaps, TD-02.)

Order Creation

  • FR-11 (Order Creation Resolves the Cached Session Exactly Once): order creation MUST resolve the checkout session once by its token, map it once into a single in-memory snapshot, and build the persisted order, the fulfillment-saga input, and the payment amount all from that one snapshot — never by independently re-deriving price, tax, or shipping from the original downstream services a second time.
  • FR-12 (Verbatim Price-Summary Reuse): the persisted order’s price fields (subtotal, savings, tax, shipping fee, cash-on-delivery charge, round-off, grand total, currency) MUST be copied verbatim from the cached checkout session’s price summary at order-creation time, never recalculated.
  • FR-13 (Idempotent Order Submission): order creation MUST accept a client-supplied idempotency key and MUST guarantee at most one order is created per key under a retried submission, with the guarantee enforced by a storage-level uniqueness constraint rather than an application-level pre-check alone.
  • FR-14 (Server-Side PII Resolution at Order Time): shipping and billing address content MUST be resolved from the central encrypted address store using a stored reference at order-creation time, never trusted from the request body, and the checkout-session cache itself MUST NOT persist raw address content — only a reference to it.

Payment-Method Resolution

  • FR-15 (Payment-Method Availability Sourced From payment-service, Not Hardcoded): the allowed-payment-methods list included in the cached checkout aggregate (FR-07) MUST be resolved via a dedicated call to payment-service’s tenant-scoped payment-method-info API, mapped into {Code, DisplayName, Description} — it MUST NOT be hardcoded in shop-service or any client, and MUST NOT be derived from or bundled into inventory-service’s GetCheckoutInfo call (FR-01), which has no payment-method concern. A payment-method re-quote (FR-09) reuses the same cached list rather than re-calling payment-service, since the set of methods a tenant accepts does not vary by delivery tier or address.

Non-Functional Requirements

Composition & Reuse

  • NFR-01 (Shared Methods, No Caller-Local Reimplementation): GetCheckoutInfo and GetServiceability MUST be consumed identically by every caller that needs the computation they provide — a caller MAY map the shared result into its own local output shape, but MUST NOT reimplement the resolution logic itself, per the platform’s layered architecture standard.
  • NFR-02 (DTO-Based Entry Points): every checkout/order entry point MUST take a single input DTO rather than positional parameters, per the platform’s coding standards.

Consistency

  • NFR-03 (No Duplicated Business Rules Across Client and Server): a rounding or total-derivation formula computed server-side SHOULD NOT also be independently re-implemented client-side for the same figure. (Gap — the client locally re-derives the same round-to-nearest-rupee formula for a non-default delivery tier instead of the server supplying a per-tier total. Tracked as technical debt — see Technical Debt — Reusable Checkout Orchestration Gaps, TD-04.)

Multi-Tenancy & Ownership

  • NFR-04 (Tenant/Owner-Scoped Session Access): every checkout-session read or write MUST be scoped by (tenant_id, created_user_id) in addition to the session’s own token, even though the token itself is globally unique, so a token can never be read or updated across a tenant or ownership boundary.

Cross-Service Data Access

  • NFR-05 (Flagged, Temporary Direct Cross-Service Read): order-service’s direct read of shop-service’s checkout-session collection via a shared MongoDB connection MUST remain an explicitly flagged, temporary exception to this repo’s normal cross-service-read-via-RPC rule — not a precedent for any other cross-service read — pending a dedicated cache-service (e.g. Redis-backed) intended as its long-term replacement. See ADR-00026 for why MongoDB rather than Redis is the right choice today and what should trigger the migration. (Gap — no enforced schema/versioning contract exists between the writer struct and the reader struct across the two services today. Tracked as technical debt — see Technical Debt — Reusable Checkout Orchestration Gaps, TD-03.)

Reliability

  • NFR-06 (Storage-Enforced Idempotency): the idempotency guarantee behind FR-13 MUST be backed by a unique, sparse index on the idempotency key at the storage layer; the service-level pre-check MUST be treated only as a latency optimization, with a duplicate-key error from the storage layer handled by re-fetching and returning the already-created order rather than failing the request.
  • NFR-07 (PII-Before-Persistence Ordering): order creation MUST create the address snapshot in the central encrypted address store before inserting the order record, so that a failed insert after a successful snapshot leaves only a harmless, already-deduplicated orphan snapshot rather than risking an order with no resolvable address.

Documentation Accuracy

  • NFR-08 (Code Is Authoritative Over Module Documentation): where a module’s own documentation and the real implementation disagree on a factual value (e.g. a cache time-to-live), the implementation MUST be treated as authoritative, and the documentation MUST be corrected rather than repeated. (Gap — see FR-10’s note and Technical Debt — Reusable Checkout Orchestration Gaps, TD-02.)