Block · Arazzo Workflow

Block Square Catalog Browse And Order Verify

Version 1.0.0

Browse catalog items, open an order, and branch on whether the order is OPEN.

1 workflow 1 source API 1 provider
View Spec View on GitHub CommerceCryptocurrencyeCommerceFintechPaymentsPoint Of SaleSquareArazzoWorkflows

Provider

block

Workflows

catalog-browse-and-order-verify
List catalog items, create an order, and branch on the order state.
Lists catalog ITEM objects, opens an order at the location with the supplied line items, and branches on whether the order returned in the OPEN state so a caller knows it is ready to be paid.
2 steps inputs: accessToken, catalogTypes, lineItems, locationId, orderIdempotencyKey outputs: firstItemId, orderId, orderState
1
listCatalog
list-catalog
List catalog objects of the requested types to source the order.
2
createOrder
create-order
Open an order with the supplied line items and check its state.

Source API Descriptions

Arazzo Workflow Specification

block-catalog-browse-and-order-verify-workflow.yml Raw ↑
arazzo: 1.0.1
info:
  title: Block Square Catalog Browse And Order Verify
  summary: Browse catalog items, open an order, and branch on whether the order is OPEN.
  description: >-
    A catalog browse with an order state check. The workflow lists catalog
    items, opens an order at the location, and then branches on whether the
    returned order is in the OPEN state, ready for payment. Each step inlines its
    bearer token and request body, including the idempotency key Square requires
    on the order write.
  version: 1.0.0
sourceDescriptions:
- name: squareApi
  url: ../openapi/block-square-api-openapi.yaml
  type: openapi
workflows:
- workflowId: catalog-browse-and-order-verify
  summary: List catalog items, create an order, and branch on the order state.
  description: >-
    Lists catalog ITEM objects, opens an order at the location with the supplied
    line items, and branches on whether the order returned in the OPEN state so a
    caller knows it is ready to be paid.
  inputs:
    type: object
    required:
    - accessToken
    - locationId
    - lineItems
    properties:
      accessToken:
        type: string
        description: Square access token presented as a Bearer credential.
      locationId:
        type: string
        description: The seller location the order is associated with.
      catalogTypes:
        type: string
        description: Comma-separated list of CatalogObject types to return.
        default: ITEM
      lineItems:
        type: array
        description: Order line items, each with a name, quantity, and base_price_money.
        items:
          type: object
      orderIdempotencyKey:
        type: string
        description: Idempotency key for the create-order request.
  steps:
  - stepId: listCatalog
    description: List catalog objects of the requested types to source the order.
    operationId: list-catalog
    parameters:
    - name: Authorization
      in: header
      value: Bearer $inputs.accessToken
    - name: types
      in: query
      value: $inputs.catalogTypes
    successCriteria:
    - condition: $statusCode == 200
    outputs:
      firstItemId: $response.body#/objects/0/id
  - stepId: createOrder
    description: Open an order with the supplied line items and check its state.
    operationId: create-order
    parameters:
    - name: Authorization
      in: header
      value: Bearer $inputs.accessToken
    requestBody:
      contentType: application/json
      payload:
        idempotency_key: $inputs.orderIdempotencyKey
        order:
          location_id: $inputs.locationId
          line_items: $inputs.lineItems
    successCriteria:
    - condition: $statusCode == 200
    outputs:
      orderId: $response.body#/order/id
      orderState: $response.body#/order/state
      orderTotal: $response.body#/order/total_money
    onSuccess:
    - name: orderOpen
      type: end
      criteria:
      - context: $response.body
        condition: $.order.state == "OPEN"
        type: jsonpath
    - name: orderNotOpen
      type: end
      criteria:
      - context: $response.body
        condition: $.order.state != "OPEN"
        type: jsonpath
  outputs:
    firstItemId: $steps.listCatalog.outputs.firstItemId
    orderId: $steps.createOrder.outputs.orderId
    orderState: $steps.createOrder.outputs.orderState