openapi: 3.1.0
info:
  title: Commerce Orchestrator downstream provider APIs
  version: 0.13.0
  summary: The HTTP APIs the orchestrator calls on your side.
  description: |
    These are the endpoints **you implement** so the orchestrator can reach your
    catalog, pricing, tax, geo, payment and receipt services, plus the optional
    fulfillment, payment delegation and identity linking services.

    Each service has its own base URL (`CATALOG_BASE_URL`, `PRICING_BASE_URL`,
    `TAX_BASE_URL`, `GEO_BASE_URL`, `PAYMENT_BASE_URL`, `RECEIPT_BASE_URL`,
    `FULFILLMENT_BASE_URL`, `PAYMENT_DELEGATION_BASE_URL`,
    `IDENTITY_LINK_BASE_URL`). The paths below are appended to that base URL, so
    one service may serve several tags or each tag may live on its own host.

    Conventions:

    - Money is always an integer in minor units (cents), never a float.
    - Optional fields the orchestrator sends are present with a `null` value
      rather than omitted.
    - Any non-2xx response is treated as a failure of that step. Safe requests
      (GET) and requests that carry `Idempotency-Key` are retried on 408, 425,
      429, 500, 502, 503 and 504, honouring `Retry-After` in seconds (capped at
      30s). Other POSTs are retried only when the connection never established.
    - Authentication is configured per service: none, a bearer token, a static
      API key in a header of your choice, OAuth 2.0 client credentials, and/or
      mutual TLS.

    `tests/openapi_spec_test.rs` in the `integration-adapters` crate checks this
    document against the adapters on every CI run.
  license:
    name: MIT OR Apache-2.0
    identifier: MIT OR Apache-2.0
servers:
  - url: "{base_url}"
    description: The base URL configured for the service (no trailing slash).
    variables:
      base_url:
        default: https://provider.example.com
security:
  - {}
  - bearerAuth: []
  - apiKeyAuth: []
  - oauth2ClientCredentials: []
tags:
  - name: catalog
    description: Item lookup and search. Base URL `CATALOG_BASE_URL`.
  - name: pricing
    description: Line prices and discount codes. Base URL `PRICING_BASE_URL`.
  - name: tax
    description: Tax for a cart. Base URL `TAX_BASE_URL`.
  - name: geo
    description: Whether a sale is allowed where the buyer is. Base URL `GEO_BASE_URL`.
  - name: payment
    description: |
      Authorize, capture, void, refund and state, plus optional 3DS2 step-up.
      Base URL `PAYMENT_BASE_URL`. The `/authentication` endpoints are only
      called when `PAYMENT_AUTHENTICATION_ENABLED=true`.
  - name: receipt
    description: Receipt generation after checkout. Base URL `RECEIPT_BASE_URL`.
  - name: fulfillment
    description: Optional. Shipping and pickup rate quotes. Base URL `FULFILLMENT_BASE_URL`.
  - name: payment-delegation
    description: Optional. ACP delegated payment tokens. Base URL `PAYMENT_DELEGATION_BASE_URL`.
  - name: identity-linking
    description: Optional. UCP identity linking. Base URL `IDENTITY_LINK_BASE_URL`.

paths:
  /items/{item_id}:
    get:
      tags: [catalog]
      operationId: getItem
      summary: Fetch one catalog item
      parameters:
        - name: item_id
          in: path
          required: true
          schema: { type: string }
        - $ref: "#/components/parameters/CorrelationId"
      responses:
        "200":
          description: The item.
          content:
            application/json:
              schema: { $ref: "#/components/schemas/CatalogItem" }
              example: { id: sku_1, title: Ceramic mug, price_minor: 1000 }
        "404":
          description: Unknown item.

  /catalog/lookup:
    post:
      tags: [catalog]
      operationId: lookupItems
      summary: Fetch several catalog items by id
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              additionalProperties: false
              required: [ids]
              properties:
                ids:
                  type: array
                  items: { type: string }
      responses:
        "200":
          description: The items that exist. Unknown ids are left out.
          content:
            application/json:
              schema: { $ref: "#/components/schemas/CatalogItemsResponse" }
              example:
                products:
                  - { id: sku_1, title: Ceramic mug, price_minor: 1000 }

  /catalog/search:
    post:
      tags: [catalog]
      operationId: searchItems
      summary: Search the catalog
      description: "`query` is omitted when the caller asked for everything."
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              additionalProperties: false
              properties:
                query: { type: string }
      responses:
        "200":
          description: Matching items.
          content:
            application/json:
              schema: { $ref: "#/components/schemas/CatalogItemsResponse" }
              example:
                products:
                  - { id: sku_1, title: Ceramic mug, price_minor: 1000 }

  /prices/resolve:
    post:
      tags: [pricing]
      operationId: resolvePrices
      summary: Price every line of a cart
      requestBody:
        required: true
        content:
          application/json:
            schema: { $ref: "#/components/schemas/CartProjection" }
      responses:
        "200":
          description: One entry per cart line.
          content:
            application/json:
              schema:
                type: object
                required: [prices]
                properties:
                  prices:
                    type: array
                    items:
                      type: object
                      required: [line_id, unit_price_minor, total_minor]
                      properties:
                        line_id: { type: string }
                        unit_price_minor: { $ref: "#/components/schemas/Minor" }
                        total_minor: { $ref: "#/components/schemas/Minor" }
              example:
                prices:
                  - { line_id: L1, unit_price_minor: 1000, total_minor: 2000 }

  /discounts/resolve:
    post:
      tags: [pricing]
      operationId: resolveDiscounts
      summary: Evaluate the buyer's discount codes
      description: |
        Called only when the cart carries at least one code. Return only the codes
        you grant. A non-2xx response rejects the codes (use it for expired or
        ineligible campaigns). `amount_minor` is positive and is clamped to the
        amount owed.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              additionalProperties: false
              required: [cart, codes]
              properties:
                cart: { $ref: "#/components/schemas/CartProjection" }
                codes:
                  type: array
                  items: { type: string }
      responses:
        "200":
          description: The discounts granted.
          content:
            application/json:
              schema:
                type: object
                properties:
                  discounts:
                    type: array
                    items: { $ref: "#/components/schemas/AppliedDiscount" }
              example:
                discounts:
                  - { code: WELCOME10, description: 10% off, amount_minor: 200, line_id: null }

  /tax/resolve:
    post:
      tags: [tax]
      operationId: resolveTax
      summary: Compute tax for a cart
      requestBody:
        required: true
        content:
          application/json:
            schema: { $ref: "#/components/schemas/CartProjection" }
      responses:
        "200":
          description: Total tax in minor units.
          content:
            application/json:
              schema:
                type: object
                required: [total_tax_minor]
                properties:
                  total_tax_minor: { $ref: "#/components/schemas/Minor" }
              example: { total_tax_minor: 160 }

  /geo/check:
    post:
      tags: [geo]
      operationId: checkGeo
      summary: Decide whether the sale is allowed in the buyer's location
      description: A response with `allowed` false rejects the checkout with `GEO_BLOCKED`.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              additionalProperties: false
              required: [cart, request]
              properties:
                cart: { $ref: "#/components/schemas/CartProjection" }
                request: { $ref: "#/components/schemas/CheckoutRequest" }
      responses:
        "200":
          description: The decision.
          content:
            application/json:
              schema:
                type: object
                required: [allowed]
                properties:
                  allowed: { type: boolean }
              example: { allowed: true }

  /authorize:
    post:
      tags: [payment]
      operationId: authorizePayment
      summary: Authorize the checkout amount
      description: |
        Deduplicate on `Idempotency-Key`: a retry with the same key must return
        the first result, not authorize twice. For Machine Payments Protocol
        payments the orchestrator adds `X-Payment-Method: mpp` and, when known,
        `X-Mpp-Method` and `X-Mpp-Intent`.

        **3DS2 step-up (optional).** When the issuer wants the buyer
        authenticated first, answer `authorized: false` with an
        `authentication_required` object. The checkout pauses; agents are shown
        your hosted device data collection or challenge page. The orchestrator
        then reads `GET /authentication/{authentication_id}` (or receives the
        result from an ACP agent) and calls
        `POST /authentication/{authentication_id}/authorize`. Only send
        `authentication_required` when the deployment sets
        `PAYMENT_AUTHENTICATION_ENABLED=true`; otherwise it is treated as a decline.
      parameters:
        - $ref: "#/components/parameters/IdempotencyKey"
        - name: X-Payment-Method
          in: header
          required: false
          schema: { type: string, enum: [mpp] }
        - name: X-Mpp-Method
          in: header
          required: false
          schema: { type: string }
        - name: X-Mpp-Intent
          in: header
          required: false
          schema: { type: string }
      requestBody:
        required: true
        content:
          application/json:
            schema: { $ref: "#/components/schemas/CheckoutRequest" }
      responses:
        "200":
          description: The authorization outcome.
          content:
            application/json:
              schema:
                type: object
                required: [authorized, reference]
                properties:
                  authorized: { type: boolean }
                  reference:
                    type: string
                    description: Your payment reference, used for capture, void and refund.
                  authentication_required:
                    $ref: "#/components/schemas/PaymentAuthentication"
                    description: |
                      Optional. Present, with `authorized: false`, when 3DS2
                      authentication must happen before you will authorize.
              example: { authorized: true, reference: pay_ref_1 }

  /authentication/{authentication_id}:
    get:
      tags: [payment]
      operationId: getAuthentication
      summary: Report where a 3DS2 authentication stands
      description: |
        Optional (3DS2). Called while a checkout is paused, typically each time
        an agent re-reads the checkout after the buyer finished your challenge
        page. Answer `pending` until the authentication has a final outcome.
      parameters:
        - name: authentication_id
          in: path
          required: true
          schema: { type: string }
      responses:
        "200":
          description: The authentication status.
          content:
            application/json:
              schema:
                type: object
                required: [status]
                properties:
                  status:
                    type: string
                    enum: [pending, completed]
                  result:
                    $ref: "#/components/schemas/AuthenticationResult"
                    description: Required when `status` is `completed`.
              example:
                status: completed
                result:
                  outcome: authenticated
                  electronic_commerce_indicator: "05"
                  three_ds_cryptogram: AAABBBCCC
                  transaction_id: ds_txn_1
                  version: 2.2.0

  /authentication/{authentication_id}/authorize:
    post:
      tags: [payment]
      operationId: authorizeAuthenticated
      summary: Authorize a checkout with a finished 3DS2 authentication
      description: |
        Optional (3DS2). `Idempotency-Key` is the checkout's key with
        `:authenticated` appended, so it never collides with the key that
        `/authorize` answered with the step-up. The orchestrator only calls this
        for outcomes `authenticated` and `attempt_acknowledged`; any other
        outcome fails the checkout without authorizing.
      parameters:
        - $ref: "#/components/parameters/IdempotencyKey"
        - name: authentication_id
          in: path
          required: true
          schema: { type: string }
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              additionalProperties: false
              required: [checkout, result]
              properties:
                checkout: { $ref: "#/components/schemas/CheckoutRequest" }
                result: { $ref: "#/components/schemas/AuthenticationResult" }
      responses:
        "200":
          description: The authorization outcome.
          content:
            application/json:
              schema:
                type: object
                required: [authorized, reference]
                properties:
                  authorized: { type: boolean }
                  reference:
                    type: string
                    description: Your payment reference, used for capture, void and refund.
              example: { authorized: true, reference: pay_ref_1 }

  /capture:
    post:
      tags: [payment]
      operationId: capturePayment
      summary: Capture an authorized payment
      parameters:
        - $ref: "#/components/parameters/IdempotencyKey"
      requestBody:
        required: true
        content:
          application/json:
            schema: { $ref: "#/components/schemas/PaymentLifecycleRequest" }
      responses:
        "200":
          $ref: "#/components/responses/PaymentOperation"

  /void:
    post:
      tags: [payment]
      operationId: voidPayment
      summary: Void an authorized payment
      parameters:
        - $ref: "#/components/parameters/IdempotencyKey"
      requestBody:
        required: true
        content:
          application/json:
            schema: { $ref: "#/components/schemas/PaymentLifecycleRequest" }
      responses:
        "200":
          $ref: "#/components/responses/PaymentOperation"

  /refund:
    post:
      tags: [payment]
      operationId: refundPayment
      summary: Refund a captured payment
      parameters:
        - $ref: "#/components/parameters/IdempotencyKey"
      requestBody:
        required: true
        content:
          application/json:
            schema: { $ref: "#/components/schemas/PaymentLifecycleRequest" }
      responses:
        "200":
          $ref: "#/components/responses/PaymentOperation"

  /state/{transaction_id}:
    get:
      tags: [payment]
      operationId: getPaymentState
      summary: Report the provider's view of a payment, for reconciliation
      description: |
        Optional. Without it, or on 404, any other non-2xx, or an unknown
        `state` value, reconciliation treats the provider state as unknown.
      parameters:
        - name: transaction_id
          in: path
          required: true
          schema: { type: string }
      responses:
        "200":
          description: The payment state.
          content:
            application/json:
              schema:
                type: object
                required: [state]
                properties:
                  state:
                    type: string
                    enum: [authorized, captured, voided, refund_pending, refunded, reconciled, failed]
              example: { state: captured }
        "404":
          description: Unknown transaction.

  /receipts/generate:
    post:
      tags: [receipt]
      operationId: generateReceipt
      summary: Produce the receipt for a completed checkout
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              additionalProperties: false
              required: [cart, result]
              properties:
                cart: { $ref: "#/components/schemas/CartProjection" }
                result: { $ref: "#/components/schemas/TransactionResult" }
      responses:
        "200":
          description: The receipt.
          content:
            application/json:
              schema:
                type: object
                required: [content]
                properties:
                  content:
                    type: string
                    description: Receipt text, or a reference such as a PDF URL.
              example: { content: "Receipt for order_1: 24.60 USD" }

  /fulfillment/quote:
    post:
      tags: [fulfillment]
      operationId: quoteFulfillment
      summary: Quote shipping or pickup options for a destination
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              additionalProperties: false
              required: [cart, method_type, destination, line_item_ids]
              properties:
                cart: { $ref: "#/components/schemas/CartProjection" }
                method_type: { $ref: "#/components/schemas/FulfillmentMethodType" }
                destination: { $ref: "#/components/schemas/FulfillmentDestination" }
                line_item_ids:
                  type: array
                  items: { type: string }
      responses:
        "200":
          description: The quoted options.
          content:
            application/json:
              schema:
                type: object
                required: [options]
                properties:
                  options:
                    type: array
                    items: { $ref: "#/components/schemas/FulfillmentOption" }
              example:
                options:
                  - id: standard
                    title: Standard shipping
                    description: 3-5 business days
                    carrier: UPS
                    earliest_fulfillment_time: null
                    latest_fulfillment_time: null
                    amount_minor: 500

  /delegate_payment:
    post:
      tags: [payment-delegation]
      operationId: delegatePayment
      summary: Exchange a caller's payment credential for a scoped, delegated token
      description: |
        The returned `token` must be a new, scoped credential. Returning the
        caller's own token grants nothing and is not delegation. Deduplicate on
        `Idempotency-Key` so a retry cannot mint two tokens.
      parameters:
        - $ref: "#/components/parameters/IdempotencyKey"
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              additionalProperties: false
              required: [tenant_id, token, metadata]
              properties:
                tenant_id: { type: string }
                token:
                  type: string
                  description: The caller's own payment credential.
                method_type:
                  type: string
                  description: Omitted when the caller did not give one.
                max_amount_minor:
                  $ref: "#/components/schemas/Minor"
                  description: Upper bound the delegated token may authorize. Omitted when unbounded.
                metadata:
                  type: object
                  additionalProperties: { type: string }
      responses:
        "200":
          description: The delegated token.
          content:
            application/json:
              schema:
                type: object
                required: [id, token]
                properties:
                  id: { type: string }
                  token: { type: string }
                  status:
                    type: string
                    default: delegated
                  expires_at:
                    type: [string, "null"]
                    format: date-time
              example:
                id: dlg_1
                token: dlg_tok_scoped
                status: delegated
                expires_at: "2026-12-01T00:00:00Z"

  /identity/link:
    post:
      tags: [identity-linking]
      operationId: linkIdentity
      summary: Link an agent's buyer identity to a merchant account
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              additionalProperties: false
              required: [tenant_id, merchant_id, agent_id, link_token]
              properties:
                tenant_id: { type: string }
                merchant_id: { type: string }
                agent_id: { type: string }
                link_token: { type: string }
      responses:
        "200":
          description: The link record.
          content:
            application/json:
              schema:
                type: object
                required: [link_id]
                properties:
                  link_id: { type: string }
                  status:
                    type: string
                    default: linked
                  expires_at:
                    type: [string, "null"]
                    format: date-time
              example: { link_id: link_1, status: linked, expires_at: null }

components:
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: A static bearer token configured for the service.
    apiKeyAuth:
      type: apiKey
      in: header
      name: X-API-Key
      description: A static value in a header. The header name is configurable; `X-API-Key` is an example.
    oauth2ClientCredentials:
      type: oauth2
      description: The orchestrator fetches and caches a token from your token endpoint.
      flows:
        clientCredentials:
          tokenUrl: https://auth.example.com/oauth/token
          scopes: {}

  parameters:
    IdempotencyKey:
      name: Idempotency-Key
      in: header
      required: true
      description: |
        Stable across retries of the same operation. Deduplicate on it: a repeat
        must return the first outcome without applying the effect again.
      schema: { type: string }
    CorrelationId:
      name: X-Correlation-ID
      in: header
      required: false
      description: Sent when the orchestrator has a correlation id for the call.
      schema: { type: string }

  responses:
    PaymentOperation:
      description: The outcome of a capture, void or refund.
      content:
        application/json:
          schema:
            type: object
            required: [success, reference]
            properties:
              success: { type: boolean }
              reference: { type: string }
          example: { success: true, reference: op_ref_1 }

  schemas:
    Minor:
      type: integer
      format: int64
      description: An amount in minor units of the currency (for USD, cents).

    NullableString:
      type: [string, "null"]

    CatalogItem:
      type: object
      required: [id, title, price_minor]
      properties:
        id: { type: string }
        title: { type: string }
        price_minor: { $ref: "#/components/schemas/Minor" }

    CatalogItemsResponse:
      type: object
      required: [products]
      properties:
        products:
          type: array
          items: { $ref: "#/components/schemas/CatalogItem" }

    CartProjection:
      type: object
      description: The orchestrator's view of a cart at the time of the call.
      additionalProperties: false
      required:
        - cart_id
        - version
        - currency
        - merchant_id
        - tenant_id
        - lines
        - subtotal_minor
        - tax_minor
        - total_minor
        - geo_ok
        - status
        - fulfillment
        - fulfillment_minor
        - adjustment_codes
        - discounts
        - discount_minor
      properties:
        cart_id: { type: string, format: uuid }
        version:
          type: integer
          minimum: 0
          description: Increases on every cart mutation.
        currency:
          type: string
          description: ISO 4217 code, for example `USD`.
        merchant_id: { type: string }
        tenant_id: { $ref: "#/components/schemas/NullableString" }
        lines:
          type: array
          items: { $ref: "#/components/schemas/CartLine" }
        subtotal_minor: { $ref: "#/components/schemas/Minor" }
        tax_minor: { $ref: "#/components/schemas/Minor" }
        total_minor: { $ref: "#/components/schemas/Minor" }
        geo_ok: { type: boolean }
        status:
          type: string
          enum: [Draft, CheckoutReady, Cancelled]
        fulfillment:
          anyOf:
            - $ref: "#/components/schemas/FulfillmentState"
            - type: "null"
        fulfillment_minor: { $ref: "#/components/schemas/Minor" }
        adjustment_codes:
          type: array
          items: { type: string }
        discounts:
          type: array
          items: { $ref: "#/components/schemas/AppliedDiscount" }
        discount_minor: { $ref: "#/components/schemas/Minor" }

    CartLine:
      type: object
      additionalProperties: false
      required: [line_id, item_id, title, quantity, unit_price_minor, total_minor]
      properties:
        line_id: { type: string }
        item_id: { type: string }
        title: { type: string }
        quantity: { type: integer, minimum: 0 }
        unit_price_minor: { $ref: "#/components/schemas/Minor" }
        total_minor: { $ref: "#/components/schemas/Minor" }

    AppliedDiscount:
      type: object
      additionalProperties: false
      required: [code, amount_minor]
      properties:
        code: { type: string }
        description: { $ref: "#/components/schemas/NullableString" }
        amount_minor:
          $ref: "#/components/schemas/Minor"
          description: Positive amount deducted.
        line_id:
          $ref: "#/components/schemas/NullableString"
          description: The line it applies to, or null for the whole order.

    CheckoutRequest:
      type: object
      additionalProperties: false
      required:
        - tenant_id
        - merchant_id
        - cart_id
        - cart_version
        - currency
        - customer
        - location
        - payment_intent
        - idempotency_key
      properties:
        tenant_id: { type: string }
        merchant_id: { type: string }
        cart_id: { type: string, format: uuid }
        cart_version: { type: integer, minimum: 0 }
        currency: { type: string }
        customer:
          anyOf:
            - $ref: "#/components/schemas/CustomerHint"
            - type: "null"
        location:
          anyOf:
            - $ref: "#/components/schemas/LocationHint"
            - type: "null"
        payment_intent: { $ref: "#/components/schemas/PaymentIntent" }
        idempotency_key: { type: string }

    CustomerHint:
      type: object
      additionalProperties: false
      required: [email, full_name]
      properties:
        email: { $ref: "#/components/schemas/NullableString" }
        full_name: { $ref: "#/components/schemas/NullableString" }

    LocationHint:
      type: object
      additionalProperties: false
      required: [country_code, region, postal_code, intent]
      properties:
        country_code: { $ref: "#/components/schemas/NullableString" }
        region: { $ref: "#/components/schemas/NullableString" }
        postal_code: { $ref: "#/components/schemas/NullableString" }
        intent: { $ref: "#/components/schemas/NullableString" }

    PaymentIntent:
      type: object
      additionalProperties: false
      required:
        - amount_minor
        - token_or_reference
        - ap2_consent_proof
        - payment_handler_id
        - payment_method_type
        - mpp_method
        - mpp_intent
      properties:
        amount_minor: { $ref: "#/components/schemas/Minor" }
        token_or_reference: { type: string }
        ap2_consent_proof:
          $ref: "#/components/schemas/NullableString"
          description: AP2 mandate or consent proof, when the agent supplied one.
        payment_handler_id: { $ref: "#/components/schemas/NullableString" }
        payment_method_type:
          type: [string, "null"]
          enum: [ap2, mpp, null]
        mpp_method: { $ref: "#/components/schemas/NullableString" }
        mpp_intent: { $ref: "#/components/schemas/NullableString" }

    PaymentLifecycleRequest:
      type: object
      additionalProperties: false
      required: [tenant_id, merchant_id, transaction_id, amount_minor, idempotency_key]
      properties:
        tenant_id: { type: string }
        merchant_id: { type: string }
        transaction_id: { type: string }
        amount_minor: { $ref: "#/components/schemas/Minor" }
        idempotency_key: { type: string }

    TransactionResult:
      type: object
      additionalProperties: false
      required:
        - transaction_id
        - status
        - totals_breakdown
        - payment_reference
        - receipt_payload
        - correlation_id
        - audit_trail_id
        - payment_state
        - order_id
      properties:
        transaction_id: { type: string }
        status:
          type: string
          enum: [Completed, Rejected, AuthFailed, CommitFailed, TimedOut]
        totals_breakdown: { $ref: "#/components/schemas/TotalsBreakdown" }
        payment_reference: { $ref: "#/components/schemas/NullableString" }
        receipt_payload: { $ref: "#/components/schemas/NullableString" }
        correlation_id: { type: string, format: uuid }
        audit_trail_id: { $ref: "#/components/schemas/NullableString" }
        payment_state:
          type: string
          enum: [Authorized, Captured, Voided, RefundPending, Refunded, Reconciled, Failed]
        order_id: { $ref: "#/components/schemas/NullableString" }

    PaymentAuthentication:
      type: object
      additionalProperties: false
      required: [authentication_id]
      description: |
        A 3DS2 step-up. Send at least one of `device_data_collection_url` and
        `challenge_url`: HTTPS pages you host that run the 3DS Method and the
        challenge in the buyer's browser. EMV 3DS messages (CReq/CRes, AReq/ARes)
        never pass through the orchestrator. `acquirer_details` and
        `directory_server` are required for ACP agents, which run delegated
        authentication themselves.
      properties:
        authentication_id:
          type: string
          description: Your id for this authentication, used in the `/authentication` paths.
        device_data_collection_url: { type: string, format: uri }
        challenge_url: { type: string, format: uri }
        acquirer_details: { $ref: "#/components/schemas/AcquirerDetails" }
        directory_server:
          type: string
          enum: [visa, mastercard, american_express]

    AcquirerDetails:
      type: object
      additionalProperties: false
      required: [acquirer_bin, acquirer_country, acquirer_merchant_id, merchant_name]
      properties:
        acquirer_bin: { type: string, maxLength: 11 }
        acquirer_country:
          type: string
          description: ISO 3166-1 alpha-2 country code.
          minLength: 2
          maxLength: 2
        acquirer_merchant_id: { type: string, maxLength: 35 }
        merchant_name: { type: string, maxLength: 40 }
        requestor_id: { type: string, maxLength: 35 }

    AuthenticationResult:
      type: object
      additionalProperties: false
      required: [outcome]
      description: Fields other than `outcome` are omitted when unknown.
      properties:
        outcome:
          type: string
          enum:
            - authenticated
            - attempt_acknowledged
            - informational
            - denied
            - rejected
            - abandoned
            - canceled
            - not_supported
            - processing_error
            - internal_error
        electronic_commerce_indicator:
          type: string
          description: ECI, for example `05`.
        three_ds_cryptogram:
          type: string
          description: CAVV / AAV.
        transaction_id:
          type: string
          description: Directory server transaction id.
        version:
          type: string
          description: EMV 3DS message version, for example `2.2.0`.

    TotalsBreakdown:
      type: object
      additionalProperties: false
      required: [subtotal_minor, tax_minor, discount_minor, fulfillment_minor, total_minor]
      properties:
        subtotal_minor: { $ref: "#/components/schemas/Minor" }
        tax_minor: { $ref: "#/components/schemas/Minor" }
        discount_minor: { $ref: "#/components/schemas/Minor" }
        fulfillment_minor: { $ref: "#/components/schemas/Minor" }
        total_minor: { $ref: "#/components/schemas/Minor" }

    FulfillmentMethodType:
      type: string
      enum: [shipping, pickup]

    PostalAddress:
      type: object
      additionalProperties: false
      properties:
        extended_address: { $ref: "#/components/schemas/NullableString" }
        street_address: { $ref: "#/components/schemas/NullableString" }
        address_locality: { $ref: "#/components/schemas/NullableString" }
        address_region: { $ref: "#/components/schemas/NullableString" }
        address_country: { $ref: "#/components/schemas/NullableString" }
        postal_code: { $ref: "#/components/schemas/NullableString" }
        first_name: { $ref: "#/components/schemas/NullableString" }
        last_name: { $ref: "#/components/schemas/NullableString" }
        phone_number: { $ref: "#/components/schemas/NullableString" }

    FulfillmentDestination:
      description: Exactly one key, `Shipping` or `Retail`.
      oneOf:
        - type: object
          additionalProperties: false
          required: [Shipping]
          properties:
            Shipping:
              type: object
              additionalProperties: false
              required: [id, address]
              properties:
                id: { type: string }
                address: { $ref: "#/components/schemas/PostalAddress" }
        - type: object
          additionalProperties: false
          required: [Retail]
          properties:
            Retail:
              type: object
              additionalProperties: false
              required: [id, name, address]
              properties:
                id: { type: string }
                name: { type: string }
                address:
                  anyOf:
                    - $ref: "#/components/schemas/PostalAddress"
                    - type: "null"

    FulfillmentOption:
      type: object
      required: [id, title, amount_minor]
      properties:
        id: { type: string }
        title: { type: string }
        description: { $ref: "#/components/schemas/NullableString" }
        carrier: { $ref: "#/components/schemas/NullableString" }
        earliest_fulfillment_time: { $ref: "#/components/schemas/NullableString" }
        latest_fulfillment_time: { $ref: "#/components/schemas/NullableString" }
        amount_minor: { $ref: "#/components/schemas/Minor" }

    FulfillmentGroup:
      type: object
      additionalProperties: false
      required: [id, line_item_ids, options, selected_option_id]
      properties:
        id: { type: string }
        line_item_ids:
          type: array
          items: { type: string }
        options:
          type: array
          items: { $ref: "#/components/schemas/FulfillmentOption" }
        selected_option_id: { $ref: "#/components/schemas/NullableString" }

    FulfillmentMethod:
      type: object
      additionalProperties: false
      required: [id, method_type, line_item_ids, destinations, selected_destination_id, groups]
      properties:
        id: { type: string }
        method_type: { $ref: "#/components/schemas/FulfillmentMethodType" }
        line_item_ids:
          type: array
          items: { type: string }
        destinations:
          type: array
          items: { $ref: "#/components/schemas/FulfillmentDestination" }
        selected_destination_id: { $ref: "#/components/schemas/NullableString" }
        groups:
          type: array
          items: { $ref: "#/components/schemas/FulfillmentGroup" }

    FulfillmentState:
      type: object
      additionalProperties: false
      required: [methods]
      properties:
        methods:
          type: array
          items: { $ref: "#/components/schemas/FulfillmentMethod" }
