The commercetools solutions provide a one-stop service to set up your own shop on the internet, it handles your purchase, pricing, and checkouts, Interplay makes it much simpler to integrate its APIs and services and easier to handle transactions, so for this project, we will be creating an e-commerce website backend.
1) Commercetools merchant account, you can make it in mc.commercetools.com
2) Register if not having an account
3) Got to "Dashboard" and create a new project on a name your choice
4) After creating your project the "ProjectKey" gets generated, also take note of "clientID" and "clientSecret"
1) Get customer details by customerID :
Search nodes :
Drop them in the editor and connect them as shown below:
Edit the node HTTP to capture customer information by ID :
Enter your Project Key, ClientID, and Client Secret Keys in Get-auth-node and it is very important to authenticate every request and easy by reusing this node.
Generated Token is used for assigning cart to customer and transaction.
This Get-auth-token is always needed for interaction with commercetools API hence we can reuse this exact node by copy-pasting with other nodes.
Get-customer-by-id node hits API to commercetools to get the customer data by its ID and key.
the final flow should be similar to this :
2) Fetch all categories from the project :
find "Get-categories" node
and make flow with other three nodes, HTTP, Get-auth-token, and HTTP response
same as above, modify HTTP node similar to this :
Get-auth-token: same as the previous node.
Get -Categories: You can modify them like this :
The final flows should be :
3) fetch-all-products :
Search for Get-products :
make flow by copying earlier nodes: HTTP, Get-auth-token, and HTTP response
as in this project, we are hitting /products, change HTTP node as :
Also modifying "Get Products" node as :
The final node will look like this :
4) Fetch a product by productID :
Find "HTTP "
Function (we need 2 hence 2 times) :
HTTP request :
HTTP Response :
From these nodes, make flow like this: Modify HTTP node such as :
Modify Node.js function as :
Get-auth-token: Same as previous flows
Function (2nd node named "NodeJS function" ) :
HTTP request :
The final Flow looks Similar this :
5) Creating Cart for customer :
Find "HTTP","HTTP Response", "NodeJS function", "Get-auth-token", "Get-cart" and connect them as shown :
Edit HTTP :
NodeJS function :
Creat-cart Node :
6) Request Checkout API :
Find "HTTP","HTTP Response", "Get-auth-token", "Create-order" and connect them as shown :
as we hitting on /checkout
HTTP node :
Create-order node :
The flow should look similar to this:
7) Fetch cart content from the consumer :
Search for Get-cart-by-customer-id:
Search and drop "HTTP", "HTTP response" and copy "Get-auth-token" from previous flows, and connect them like this :
as we are hitting " /cartByCustomerId " Modify HTTP node as :
Get-auth-token: as a previous flow
8) Fetch-Order-list: This flow is similar to 6) Request Checkout API but instead of "Get-cart-by-customer-id" we take "Get-order-by-id"
Get Order By ID :
9) Fetch Customer List :
Search and Drop "HTTP""HTTP responce", "Get-auth-token","Function","Create-customer" and create flow similar to this :
Here "Create-customer" modified as :
By These examples, we can easily integrate an e-commerce set up easily!