---
id: WF-COM-CAT-010
title: Price a checkout and settle its audiences at placement
trigger: >-
  Checkout and placement use the common pricing engine. Placement additionally prepares and transactionally
  verifies the eligibility behind discounted audience prices.
product_area: commerce
module: catalog
revision: 1
status: draft
design_intent: confirmed
implementation_evidence: partially-observed
inference: []
source_sha:
  services-commerce: c8b66a98e2490617aec38ba5c8165dd9bd0a8f9b
implements:
  - CAP-COM-CAT-013
  - CAP-COM-CAT-011
moves:
  - STATE-COM-CAT-005
crosses:
  - SVC-COM-CAT-pricing
idempotency: >-
  Pricing owns no preview persistence. Commit-mode extension requests carry the checkout key, and the
  first-sale stamp is written only once.
concurrency: >-
  External preparation happens before placement begins. The final qualification check runs inside the order
  transaction, alongside period first-sale stamping.
hops:
  - 'n': 1
    actor_or_service: Checkout module to pricing port
    action: >-
      Pass checkout header, placeable items, mode, time, buyer and participant audience or adjustment advice
      to pricing.
    anchor: 'services-commerce:modules/pricing/services/checkout-pricing/price-checkout-with-engine.ts'
    seam: sync
    on_failure: Reject preview or placement if the pricing request cannot be processed.
    left_inconsistent: No order-side pricing changes remain.
    observer: The requesting person or service receives the result and any returned refusal.
    provenance: documented
    source: 'services-commerce:modules/pricing/services/checkout-pricing/price-checkout-with-engine.ts'
  - 'n': 2
    actor_or_service: Pricing service
    action: 'Load and assess inputs, then execute pricing and extensions in preview or commit mode.'
    anchor: >-
      services-commerce:modules/pricing/services/extensions/priced-with-extensions.ts:priceCheckoutWithExtensions
    seam: sync
    on_failure: >-
      Reject required extension failures and unsupported order-fee output; record the operational failure
      where supported.
    left_inconsistent: The attempted sale is not saved.
    observer: Request feedback and service logs expose failures where the caller returns them.
    provenance: test
    source: >-
      services-commerce:modules/pricing/tests/integration/services/extensions/priced-with-extensions.integration.spec.js#refuses
      with EXTENSION_UNAVAILABLE naming the extension, and records the exception on the order with the SDK’s
      status (A24)
  - 'n': 3
    actor_or_service: Pricing service
    action: 'Before the order transaction, prepare binding, subject and date rechecks and fetch required facts.'
    anchor: 'services-commerce:modules/pricing/services/placement/audience-settlement.ts:prepareAudienceSettlement'
    seam: sync
    on_failure: Refuse placement if settlement preparation fails.
    left_inconsistent: No period stamp or order has been committed.
    observer: The requesting person or service receives the result and any returned refusal.
    provenance: test
    source: >-
      services-commerce:modules/pricing/tests/integration/services/placement/audience-settlement.integration.spec.js#plans
      one re-check per (binding, subject, date) over the lines an eligibility audience priced, and the periods
      of every line
  - 'n': 4
    actor_or_service: Pricing service inside the placement transaction
    action: >-
      Within placement, recheck eligibility, validate same-cart grant support and stamp first use of priced
      periods.
    anchor: 'services-commerce:modules/pricing/services/placement/audience-settlement.ts'
    seam: sync
    on_failure: Return line-specific lapsed-audience problems and roll back placement.
    left_inconsistent: Failed placement retains neither order nor first-sale changes.
    observer: The requesting person or service receives the result and any returned refusal.
    provenance: test
    source: >-
      services-commerce:modules/pricing/tests/integration/services/placement/audience-settlement.integration.spec.js#refuses
      the placement for a lapsed member, one audience_lapsed problem per line with the portal sentence,
      stamping nothing
branches:
  - 'Standard, operation and same-cart audience lines do not undergo the eligibility-binding recheck.'
waits: []
evidence:
  - >-
    services-commerce at c8b66a98: modules/pricing/services/checkout-pricing/price-checkout-with-engine.ts;
    services/extensions/priced-with-extensions.ts, failure-policy.ts, operational-exceptions.ts;
    services/placement/audience-settlement.ts; services/persistence/pricing-schedules.ts
    (stampPricingPeriodFirstSales); modules/orders/services/placement/place-order.ts (the caller).
  - 'services-commerce at c8b66a98: docs/milestones/COMM-M1-set-up-what-you-sell.md (D5-F1, D14).'
controls: [TC-AZ-001, TC-AZ-002, TC-AZ-003, TC-AZ-004, TC-AZ-005, TC-AZ-006, TC-TEN-001, TC-TEN-002, TC-TEN-003, TC-TEN-004, TC-CRY-001, TC-DAT-001, TC-DAT-002, TC-DAT-003, TC-LOG-004, TC-LOG-005, TC-PI-001, TC-PI-002, TC-PI-003, TC-PI-005, TC-VEN-001, TC-VEN-002, TC-VEN-003, TC-PRV-001, TC-PRV-002]
---

# Price a checkout and settle its audiences at placement

## What It Does

Checkout and placement use the common pricing engine. Placement additionally prepares and transactionally verifies the eligibility behind discounted audience prices.

## The Flow

```mermaid
sequenceDiagram
  participant K as Checkout or orders module
  participant P as Pricing service
  participant X as Extensions
  participant E as Platform eligibility
  participant D as Order transaction
  K->>P: price (preview or placement)
  P->>X: pricing functions, order review (commit mode)
  alt required extension fails
    P-->>K: refused as unavailable, exception recorded
  end
  P->>P: plan re-checks, fetch facts
  K->>D: begin placement
  P->>E: in-transaction re-check per binding
  alt lapsed
    P-->>K: refused per line
    D-->>D: roll back
  else qualifies
    P->>D: stamp first sale of each period
  end
```

## When Something Fails

Reject preview or placement if the pricing request cannot be processed. No order-side pricing changes remain. Reject required extension failures and unsupported order-fee output; record the operational failure where supported. The attempted sale is not saved. Refuse placement if settlement preparation fails. No period stamp or order has been committed. Return line-specific lapsed-audience problems and roll back placement. Failed placement retains neither order nor first-sale changes.

## Open Design Questions

Runtime wiring and dependency coverage remain limited as recorded in the module findings. External preparation happens before placement begins. The final qualification check runs inside the order transaction, alongside period first-sale stamping.
