This solution demonstrates the capabilities provided by all five Catalyst APIs through a python-based order processing workflow. The end-to-end solution is comprised of five services:
- order-processor: Contains the order process workflow definition and all associated activity methods which will be executed as part of the workflow sequence using the Catalyst Workflow API.
- inventory: Receives direct invocation requests sent by the order-processor using the Invocation API to manage inventory state in the Diagrid KV Store through the Catalyst State API.
- notifications: Subscribes to messages published by the order-processor using the Pub/Sub API and subsequently displays those messages through a simple JavaScript user interface.
- shipping: Receives direct invocation requests sent by the order-processor using the Invocation API to simulate the scheduling of order shipments.
- payments: Receives direct invocation requests sent by the order-processor using the Invocation API to process order payments which are sent to the Square API using a Catalyst HTTP output binding.
For a live walkthrough: https://youtu.be/VAVQARDlHDo?t=1930
The solution is comprised of python services:
- Install Python3
The payment app makes use of an HTTP output binding pointing to Square. Follow the steps below to configure:
- Navigate to the Square Developer website and click "Get started"
- If you don't already have an account, select "Sign up". Otherwise, enter existing credentials.
- Add a new application and call it
workflow-payment-app
or your own unique identifier. - Select "Skip" on the subsequent blades.
- On the Credentials page, ensure
Sandbox
is selected in the top slider > findSandbox Access token
> Click "show" > Copy the Access Token value. - Navigate to the directory titled "catalyst-resources" and select the "square-http-binding.yaml" file. Replace
{your-square-api-token}
with the API token retrieved. - Return to the Square Developer portal and underneath the
Sandbox Access Token
section referenced above, copy the value forSandbox API version
and input the value for the HTTP header in the file./services/payments/app.py
on line35
as shown below:
Once you have completed the above steps, you are ready to connect to the Square Payment API from your Dapr Workflow!
NOTE: The application code calls out to the Square Payment API and will randomly select a failing test card or a successful test card to simulate various workflow paths.
Replace unique-project-name
with a name for your workflow project
export WORKFLOW_PROJECT_NAME="unique-project-name"
Install dependencies for the python creation script which will be used to deploy the majority of Catalyst resources needed for this demo.
pip3 install yaspin
Run this script to deploy a catalyst project, scaffold all of the required App IDs and components, and scaffold the dev config file
python3 run.py
The build apps file will go through each application directory and run any app commands necessary to prepare the applications to run. Make sure it is executable using the below command:
chmod +X build-apps.sh
Run the script:
./build-apps.sh
After the above script runs to completion, use the dev config file to run the local apps and connect to Catalyst
diagrid dev start
A test.rest
file is available at the root of this repository and can be used with the VS Code Rest Client
extension.