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

# Process Checkout

> Complete the checkout process, create order, and process payment

<Warning>
  This endpoint is currently shown as a preview of what's currently in development and is subject to change.
</Warning>

## Overview

This endpoint completes the checkout process by creating an order and processing payment. Use this after collecting all necessary checkout information and customer details.


## OpenAPI

````yaml api-reference/pre-release/openapi-spec-preview.yaml post /checkout
openapi: 3.0.3
info:
  title: CoCart Preview API
  description: >
    CoCart Preview provides enhanced REST API endpoints for WooCommerce headless
    e-commerce solutions.

    This API extends CoCart with additional functionality for checkout, customer
    account management, and order handling.


    ## Authentication


    The API supports multiple authentication methods:

    - **Cart Key**: For guest customers, pass the cart key via `Cart-Key` header
    or `cart_key` parameter

    - **Basic Auth**: For registered customers using username/password

    - **JWT**: For registered customers using JWT tokens (requires JWT plugin)

    - **Session**: For logged-in WordPress users


    ## Base URL


    All API endpoints are prefixed with `/wp-json/cocart/preview/`


    ## Response Format


    All responses follow the CoCart standard format with consistent error
    handling and data structure.
  termsOfService: http://cocartapi.com/terms-of-conditions-polar/
  contact:
    email: support@cocartapi.com
  license:
    name: GNU General Public License v3.0
    url: http://www.gnu.org/licenses/gpl-3.0.html
  version: 0.0.1
servers:
  - url: '{protocol}://{host}/wp-json/cocart/preview'
    description: API Preview
    variables:
      protocol:
        enum:
          - http
          - https
        default: https
      host:
        default: example-store.com
        description: Your store domain
security: []
tags:
  - name: Checkout
    description: Complete checkout process including payment and order creation
  - name: My Account
    description: Customer account information and profile management
  - name: My Orders
    description: Customer order history and details
  - name: My Downloads
    description: Customer digital downloads
  - name: My Subscriptions
    description: Customer subscription management
externalDocs:
  description: Find out more about CoCart API
  url: https://docs.cocartapi.com
paths:
  /checkout:
    post:
      tags:
        - Checkout
      summary: Process checkout
      description: Complete the checkout process, create order, and process payment
      operationId: processCheckout
      requestBody:
        description: Checkout completion data
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CheckoutProcessRequest'
      responses:
        '200':
          description: Checkout processed successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CheckoutProcessResponse'
              examples:
                checkoutProcessed:
                  $ref: '#/components/examples/CheckoutProcessResponseExample'
        '400':
          description: Bad request - validation failed
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '401':
          description: Unauthorized - authentication required
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '500':
          description: Internal server error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
components:
  schemas:
    CheckoutProcessRequest:
      type: object
      required:
        - billing_address
      properties:
        billing_address:
          $ref: '#/components/schemas/BillingAddress'
        shipping_address:
          $ref: '#/components/schemas/ShippingAddress'
        use_different_billing:
          type: boolean
          description: Whether to use a different billing address from shipping
          default: true
        payment_method:
          type: string
          description: Payment method ID
        payment_data:
          type: array
          items:
            $ref: '#/components/schemas/PaymentData'
          description: Payment data to pass through to the payment gateway
        shipping_method:
          type: string
          description: Shipping method ID
        currency:
          type: string
          description: >-
            Currency code for the order (e.g., USD, EUR, GBP). Enables
            multi-currency support with compatible plugins. If not provided,
            store default will be used.
          example: USD
          pattern: ^[A-Z]{3}$
        create_account:
          type: boolean
          description: Create customer account during checkout (for guest checkout)
          default: false
        customer_password:
          type: string
          description: >-
            Password for new customer account (required if create_account is
            true)
        customer_note:
          type: string
          description: Customer note for the order
    CheckoutProcessResponse:
      type: object
      properties:
        order_id:
          type: integer
          description: Created order ID
        status:
          type: string
          description: Order status
        order_key:
          type: string
          description: Order key
        order_number:
          type: string
          description: Order number
        payment_result:
          type: object
          properties:
            payment_status:
              type: string
              enum:
                - success
                - failed
                - no_payment_required
            redirect_url:
              type: string
              format: uri
              description: Redirect URL after payment
            message:
              type: string
              description: Payment message
        customer_id:
          type: integer
          description: Customer ID
        billing_address:
          $ref: '#/components/schemas/BillingAddress'
        shipping_address:
          $ref: '#/components/schemas/ShippingAddress'
        cart_key:
          type: string
          nullable: true
          description: Cart key (null after successful checkout)
    Error:
      type: object
      required:
        - code
        - message
      properties:
        code:
          type: string
          description: Error code identifier
        message:
          type: string
          description: Human-readable error message
        data:
          type: object
          description: Additional error data
          properties:
            status:
              type: integer
              description: HTTP status code
    BillingAddress:
      type: object
      properties:
        first_name:
          type: string
          description: First name
        last_name:
          type: string
          description: Last name
        company:
          type: string
          description: Company name
        address_1:
          type: string
          description: Address line 1
        address_2:
          type: string
          description: Address line 2
        city:
          type: string
          description: City name
        state:
          type: string
          description: State/County
        postcode:
          type: string
          description: Postal code
        country:
          type: string
          description: Country code
        phone:
          type: string
          description: Phone number
        email:
          type: string
          format: email
          description: Email address
    ShippingAddress:
      type: object
      properties:
        first_name:
          type: string
          description: First name
        last_name:
          type: string
          description: Last name
        company:
          type: string
          description: Company name
        address_1:
          type: string
          description: Address line 1
        address_2:
          type: string
          description: Address line 2
        city:
          type: string
          description: City name
        state:
          type: string
          description: State/County
        postcode:
          type: string
          description: Postal code
        country:
          type: string
          description: Country code
    PaymentData:
      type: object
      required:
        - key
        - value
      properties:
        key:
          type: string
          description: Payment data key
          example: wc-stripe-payment-token
        value:
          oneOf:
            - type: string
            - type: boolean
            - type: integer
          description: Payment data value
  examples:
    CheckoutProcessResponseExample:
      value:
        order_id: 789
        status: processing
        order_key: wc_order_abc123xyz
        order_number: '789'
        payment_result:
          payment_status: success
          redirect_url: >-
            https://example.com/checkout/order-received/789/?key=wc_order_abc123xyz
          message: Payment successful
        customer_id: 123
        billing_address:
          first_name: John
          last_name: Doe
          email: john@example.com
          phone: '+1234567890'
          address_1: 123 Main St
          address_2: Apt 4B
          city: Anytown
          state: CA
          postcode: '12345'
          country: US
          company: ''
        shipping_address:
          first_name: John
          last_name: Doe
          address_1: 123 Main St
          address_2: Apt 4B
          city: Anytown
          state: CA
          postcode: '12345'
          country: US
          company: ''
        cart_key: null

````