> ## Documentation Index
> Fetch the complete documentation index at: https://docs.stella-commerce.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Complete Checkout

> Finalize a checkout via the PaymentMethodHandler registry.

Phase 8-B replaces Phase 4-A's silent-overwrite path. The body is
a discriminated `CheckoutComplete` (Literal['stripe','cod',
'bank_transfer']); the handler decides payment_status, initial
order status, payment_due_at, and payment_method_metadata.

Stripe still arrives via the webhook receiver for buyer-Stripe-
Element flows; this route is the synchronous path used by COD,
(PR-C) bank-transfer, and back-compat Stripe callers that already
have their PI id (e.g. legacy zunkiree-search).



## OpenAPI

````yaml /api-reference/openapi.json post /api/storefront/checkout/{checkout_id}/complete
openapi: 3.1.0
info:
  title: Agentic Commerce API
  description: |2-

        Agentic Commerce API - E-commerce Backend

        ## APIs

        ### Dashboard API (`/api/dashboard`)
        Authenticated endpoints for merchant management:
        - Products, Variants, Options
        - Inventory management
        - Orders and fulfillment
        - Customers
        - Collections

        ### Storefront API (`/api/storefront`)
        Public endpoints for client websites:
        - Product catalog
        - Collections
        - Cart management
        - Checkout

        ### Sync API (`/api/sync`)
        Integration endpoints for zunkiree-search:
        - Product sync
        - Availability checks
        - Order creation from AI widget
        
  version: 1.0.0
servers: []
security: []
paths:
  /api/storefront/checkout/{checkout_id}/complete:
    post:
      tags:
        - Storefront
        - Checkout
      summary: Complete Checkout
      description: |-
        Finalize a checkout via the PaymentMethodHandler registry.

        Phase 8-B replaces Phase 4-A's silent-overwrite path. The body is
        a discriminated `CheckoutComplete` (Literal['stripe','cod',
        'bank_transfer']); the handler decides payment_status, initial
        order status, payment_due_at, and payment_method_metadata.

        Stripe still arrives via the webhook receiver for buyer-Stripe-
        Element flows; this route is the synchronous path used by COD,
        (PR-C) bank-transfer, and back-compat Stripe callers that already
        have their PI id (e.g. legacy zunkiree-search).
      operationId: complete_checkout_api_storefront_checkout__checkout_id__complete_post
      parameters:
        - name: checkout_id
          in: path
          required: true
          schema:
            type: string
            format: uuid
            title: Checkout Id
        - name: X-Site-ID
          in: header
          required: true
          schema:
            type: string
            title: X-Site-Id
        - name: X-Stella-Token
          in: header
          required: false
          schema:
            anyOf:
              - type: string
              - type: 'null'
            title: X-Stella-Token
        - name: Idempotency-Key
          in: header
          required: false
          schema:
            anyOf:
              - type: string
              - type: 'null'
            title: Idempotency-Key
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CheckoutComplete'
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CheckoutResponse'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
components:
  schemas:
    CheckoutComplete:
      properties:
        payment_method:
          type: string
          enum:
            - stripe
            - cod
            - bank_transfer
          title: Payment Method
        payment_intent_id:
          anyOf:
            - type: string
            - type: 'null'
          title: Payment Intent Id
        cod:
          anyOf:
            - $ref: '#/components/schemas/CodSubmission'
            - type: 'null'
        bank_transfer_reference:
          anyOf:
            - type: string
            - type: 'null'
          title: Bank Transfer Reference
      type: object
      required:
        - payment_method
      title: CheckoutComplete
      description: |-
        Storefront checkout completion request — Phase 8-B.

        Phase 4-A's freeform `payment_method: str` is replaced by a
        Literal-restricted method discriminator. The PaymentMethodHandler
        registry routes the body to the matching handler. Stripe still
        arrives via the webhook for buyer-Stripe-Element flows; this route
        is for COD + (future PR-C) bank transfer + back-compat callers
        that explicitly know their PI.

        Field rules per method:
          * `stripe`         — `payment_intent_id` required.
          * `cod`            — `cod` block populated; phone required at
                               API time when CodConfig.require_phone=true.
          * `bank_transfer`  — `bank_transfer_reference` optional.
                               Wired in PR-C; this route 422s today via
                               the handler's NotImplementedError.
    CheckoutResponse:
      properties:
        id:
          type: string
          format: uuid
          title: Id
        cart_id:
          type: string
          format: uuid
          title: Cart Id
        email:
          type: string
          title: Email
        shipping_address:
          $ref: '#/components/schemas/AddressSchema'
        billing_address:
          $ref: '#/components/schemas/AddressSchema'
        items:
          items:
            $ref: '#/components/schemas/CartItemResponse'
          type: array
          title: Items
        subtotal:
          type: string
          pattern: ^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$
          title: Subtotal
        tax_amount:
          type: string
          pattern: ^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$
          title: Tax Amount
        shipping_amount:
          type: string
          pattern: ^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$
          title: Shipping Amount
        total:
          type: string
          pattern: ^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$
          title: Total
        currency:
          type: string
          title: Currency
        status:
          type: string
          title: Status
        payment_intent_id:
          anyOf:
            - type: string
            - type: 'null'
          title: Payment Intent Id
        order_id:
          anyOf:
            - type: string
              format: uuid
            - type: 'null'
          title: Order Id
        created_at:
          type: string
          format: date-time
          title: Created At
        updated_at:
          type: string
          format: date-time
          title: Updated At
        completed_at:
          anyOf:
            - type: string
              format: date-time
            - type: 'null'
          title: Completed At
      type: object
      required:
        - id
        - cart_id
        - email
        - shipping_address
        - billing_address
        - items
        - subtotal
        - tax_amount
        - shipping_amount
        - total
        - currency
        - status
        - created_at
        - updated_at
      title: CheckoutResponse
      description: Schema for checkout response.
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    CodSubmission:
      properties:
        phone:
          anyOf:
            - type: string
            - type: 'null'
          title: Phone
        accepted_terms:
          type: boolean
          title: Accepted Terms
          default: false
        notes:
          anyOf:
            - type: string
            - type: 'null'
          title: Notes
      type: object
      title: CodSubmission
      description: |-
        Buyer-supplied COD details. Phase 8-B accepts these but only
        `phone` and `accepted_terms` are checked at the API edge today —
        OTP wiring is Phase 8 Decision 3 (deferred).
    AddressSchema:
      properties:
        first_name:
          anyOf:
            - type: string
            - type: 'null'
          title: First Name
        last_name:
          anyOf:
            - type: string
            - type: 'null'
          title: Last Name
        company:
          anyOf:
            - type: string
            - type: 'null'
          title: Company
        address1:
          anyOf:
            - type: string
            - type: 'null'
          title: Address1
        address2:
          anyOf:
            - type: string
            - type: 'null'
          title: Address2
        city:
          anyOf:
            - type: string
            - type: 'null'
          title: City
        state:
          anyOf:
            - type: string
            - type: 'null'
          title: State
        postal_code:
          anyOf:
            - type: string
            - type: 'null'
          title: Postal Code
        country:
          anyOf:
            - type: string
            - type: 'null'
          title: Country
        phone:
          anyOf:
            - type: string
            - type: 'null'
          title: Phone
      type: object
      title: AddressSchema
      description: >-
        Schema for address. Fields are optional to support simpler address
        formats from AI widget.
    CartItemResponse:
      properties:
        id:
          type: string
          format: uuid
          title: Id
        variant_id:
          type: string
          format: uuid
          title: Variant Id
        product_id:
          type: string
          format: uuid
          title: Product Id
        product_name:
          type: string
          title: Product Name
        variant_name:
          type: string
          title: Variant Name
        sku:
          anyOf:
            - type: string
            - type: 'null'
          title: Sku
        image_url:
          anyOf:
            - type: string
            - type: 'null'
          title: Image Url
        price:
          type: string
          pattern: ^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$
          title: Price
        quantity:
          type: integer
          title: Quantity
        total:
          type: string
          pattern: ^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$
          title: Total
      type: object
      required:
        - id
        - variant_id
        - product_id
        - product_name
        - variant_name
        - sku
        - image_url
        - price
        - quantity
        - total
      title: CartItemResponse
      description: Schema for cart item in response.
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
        input:
          title: Input
        ctx:
          type: object
          title: Context
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError

````