arazzo: 1.0.1 info: title: Block Square Take Payment And Verify summary: Take a card payment and immediately re-read it to confirm the final status. description: >- A payment-with-confirmation pattern. The workflow charges a payment source and then fetches the same payment back by id to confirm whether it settled to COMPLETED or landed in another state. Each step inlines its bearer token and request body, including the idempotency key Square requires when creating a payment. version: 1.0.0 sourceDescriptions: - name: squareApi url: ../openapi/block-square-api-openapi.yaml type: openapi workflows: - workflowId: take-payment-and-verify summary: Create a payment, then read it back to confirm its settled status. description: >- Charges the supplied source for the supplied amount at a location, then retrieves the created payment by id and branches on whether the payment completed. inputs: type: object required: - accessToken - locationId - sourceId - amount properties: accessToken: type: string description: Square access token presented as a Bearer credential. locationId: type: string description: The seller location accepting the payment. sourceId: type: string description: The payment source id (card nonce or token) to charge. amount: type: integer description: The amount to charge in the smallest currency denomination. currency: type: string description: The ISO 4217 currency code for the charge. default: USD paymentIdempotencyKey: type: string description: Idempotency key for the create-payment request. steps: - stepId: createPayment description: Charge the supplied payment source for the requested amount. operationId: create-payment parameters: - name: Authorization in: header value: Bearer $inputs.accessToken requestBody: contentType: application/json payload: source_id: $inputs.sourceId idempotency_key: $inputs.paymentIdempotencyKey amount_money: amount: $inputs.amount currency: $inputs.currency location_id: $inputs.locationId successCriteria: - condition: $statusCode == 200 outputs: paymentId: $response.body#/payment/id paymentStatus: $response.body#/payment/status - stepId: verifyPayment description: Read the created payment back by id to confirm its final status. operationId: get-payment parameters: - name: Authorization in: header value: Bearer $inputs.accessToken - name: payment_id in: path value: $steps.createPayment.outputs.paymentId successCriteria: - condition: $statusCode == 200 outputs: verifiedStatus: $response.body#/payment/status totalMoney: $response.body#/payment/total_money onSuccess: - name: settled type: end criteria: - context: $response.body condition: $.payment.status == "COMPLETED" type: jsonpath - name: notSettled type: end criteria: - context: $response.body condition: $.payment.status != "COMPLETED" type: jsonpath outputs: paymentId: $steps.createPayment.outputs.paymentId verifiedStatus: $steps.verifyPayment.outputs.verifiedStatus