Swell · Arazzo Workflow

Swell Build Cart and Convert to Order

Version 1.0.0

Create a cart, populate its items, then convert it into an order.

1 workflow 1 source API 1 provider
View Spec View on GitHub CommerceHeadless CommerceAPI-FirstB2CB2BSubscriptionsMarketplacesWholesaleStorefrontCheckoutPaymentsCartsOrdersCatalogInternationalizationArazzoWorkflows

Provider

swell-io

Workflows

build-cart-and-convert-to-order
Create a cart, set its items, then create an order from it.
Posts a cart, updates it with line items, then posts an order using the same account and items.
3 steps inputs: account_id, currency, items outputs: cartId, orderId, orderNumber
1
createCartStep
createCart
Create an empty cart tied to the supplied account.
2
addItemsStep
updateCart
Update the cart with the supplied line items.
3
convertToOrderStep
createOrder
Create an order carrying the same account and items, converting the pending cart into a real order.

Source API Descriptions

Arazzo Workflow Specification

swell-io-build-cart-convert-order-workflow.yml Raw ↑
arazzo: 1.0.1
info:
  title: Swell Build Cart and Convert to Order
  summary: Create a cart, populate its items, then convert it into an order.
  description: >-
    The backend equivalent of a guided checkout. The workflow creates a cart for
    an account, updates that cart with line items, then creates an order that
    carries the same account and items so the pending purchase request becomes a
    real order. Each step spells out its request inline so the flow can be read
    and executed without opening the underlying OpenAPI description.
  version: 1.0.0
sourceDescriptions:
- name: swellBackendApi
  url: ../openapi/swell-backend-api-openapi.yml
  type: openapi
workflows:
- workflowId: build-cart-and-convert-to-order
  summary: Create a cart, set its items, then create an order from it.
  description: >-
    Posts a cart, updates it with line items, then posts an order using the same
    account and items.
  inputs:
    type: object
    required:
    - account_id
    - items
    properties:
      account_id:
        type: string
        description: The account the cart and order belong to.
      items:
        type: array
        description: Line items to place in the cart and resulting order.
        items:
          type: object
      currency:
        type: string
        description: ISO 4217 currency code.
  steps:
  - stepId: createCartStep
    description: Create an empty cart tied to the supplied account.
    operationId: createCart
    requestBody:
      contentType: application/json
      payload:
        account_id: $inputs.account_id
        currency: $inputs.currency
    successCriteria:
    - condition: $statusCode == 201
    outputs:
      cartId: $response.body#/id
  - stepId: addItemsStep
    description: Update the cart with the supplied line items.
    operationId: updateCart
    parameters:
    - name: id
      in: path
      value: $steps.createCartStep.outputs.cartId
    requestBody:
      contentType: application/json
      payload:
        items: $inputs.items
    successCriteria:
    - condition: $statusCode == 200
    outputs:
      cartId: $response.body#/id
      subTotal: $response.body#/sub_total
      grandTotal: $response.body#/grand_total
  - stepId: convertToOrderStep
    description: >-
      Create an order carrying the same account and items, converting the
      pending cart into a real order.
    operationId: createOrder
    requestBody:
      contentType: application/json
      payload:
        account_id: $inputs.account_id
        items: $inputs.items
        currency: $inputs.currency
    successCriteria:
    - condition: $statusCode == 201
    outputs:
      orderId: $response.body#/id
      orderNumber: $response.body#/number
      grandTotal: $response.body#/grand_total
  outputs:
    cartId: $steps.addItemsStep.outputs.cartId
    orderId: $steps.convertToOrderStep.outputs.orderId
    orderNumber: $steps.convertToOrderStep.outputs.orderNumber