Step by Step to create orders by consuming SAP Commerce Cloud Restful API
Recently Jerry is working on an integration project about creating orders in Wechat platform by consuming SAP Commerce Cloud Restful API.
Consultants who didn't touch SAP Commerce before(such as Jerry ) might get confused once they saw the search result by key word "commerce" in https://help.sap.com:

Several products with similar name are listed in search result.
SAP Commerce:SAP commerce solution based on On-Premises deployment approach
SAP Commerce Cloud on SAP Infrastructure & SAP Commerce Cloud on Public Cloud: as their names give a very clear hint: both are SAP Commerce solution based on cloud, and differentiated by the underlying cloud infrastructure the solution are running. SAP Commerce Cloud on SAP Infrastructure are sometimes called Commerce Cloud Version One and CCV1 for short, while the latter called CCV2.
There is a nice blog Two clouds in practice: a comparison of SAP Commerce Cloud v1 and v2in medium comparing both.

Back to my task, it's helpful if we play around in Commerce Cloud storefront UI to create a order manually to get ourselves familar with the process.
Log in to storefront and browse the site:

And identify a favourite product and add it to cart by pressing button "ADD TO CART":

Press CHECK OUT to proceed:

Now we get a cart ID:

Maintain shipping address:

Maintain payment details:

Once Place Order button is clicked, the order is successfully created with an automatically populated order ID:

In summary, the process of order manual creation in SAP Commerce Cloud consists of five steps:
(1) create a Shopping Cart
(2) add products into the cart
(3) maintain shipping address to the cart
(4) maintain payment details to the cart
(5) execution place order action on the cart to get order created
Now we should figure out for each step, what exactly APIs should be called.
Go to https://api.sap.com, search by keyword "Commerce Cloud", and it's easy to find the supported API list there.

Jerry has written a simple nodejs application to demonstrate how to consume such APIs to create orders in SAP Commerce Cloud. The whole source code is uploaded to my github.
Execute the application, and we can observe the successflly created order with its ID in callback function in line 20:

Search the ID in Commerce Cloud backoffice UI to check the details of created order.


As introduced before, it's necessary to go through five steps to have an order generated. And in Jerry's project there are totally seven "step.js" implementation files, why?
For the additional two step.js, one is for access token retrieve and the other for cart delivery mode set operation. Access token will be appended to the header fields of all the subsequent API calls for authorization purpose. And the cart delivery mode will be set implicitly if performed in storefront UI via browser whereas an explicit API call is necessary in our case. As a result totally seven HTTP roundtrip is needed in API consumption case.

The access token fetch is implemented by following OAuth protocol: send the OAuth Client ID and secret to SAP Commerce Cloud OAuth endpoint to get the issued access token.
First we have to create a new OAuth Client in SAP Commerce Cloud backoffice:

Then in file "step1_get_token.js", send a HTTP POST to Commerce Cloud Authentication endpoint to request access token:

For privacy reason I didn't upload urlconfig.js to github which contains the dedicated url of my own Commerce Cloud API endpoint. Instead I upload the template file: urlconfigTemplate.js. Just replace the place holder marked with "<>" with your actual value there, rename the template file back to urlconfig.js. After that you can create orders in your own Commerce Cloud tenant.

要获取更多Jerry的原创文章,请关注公众号"汪子熙":

Step by Step to create orders by consuming SAP Commerce Cloud Restful API的更多相关文章
- Step by Step Process of Migrating non-CDBs and PDBs Using ASM for File Storage (Doc ID 1576755.1)
Step by Step Process of Migrating non-CDBs and PDBs Using ASM for File Storage (Doc ID 1576755.1) AP ...
- [转]Bootstrap 3.0.0 with ASP.NET Web Forms – Step by Step – Without NuGet Package
本文转自:http://www.mytecbits.com/microsoft/dot-net/bootstrap-3-0-0-with-asp-net-web-forms In my earlier ...
- Step by step Process of creating APD
Step by step Process of creating APD: Business Scenario: Here we are going to create an APD on top o ...
- Tomcat Clustering - A Step By Step Guide --转载
Tomcat Clustering - A Step By Step Guide Apache Tomcat is a great performer on its own, but if you'r ...
- [ZZ] Understanding 3D rendering step by step with 3DMark11 - BeHardware >> Graphics cards
http://www.behardware.com/art/lire/845/ --> Understanding 3D rendering step by step with 3DMark11 ...
- Step by Step Recipe for Securing Kafka with Kerberos
Short Description: Step by Step Recipe for Securing Kafka with Kerberos. Article I found it is a lit ...
- PyTorch in Action: A Step by Step Tutorial
PyTorch in Action: A Step by Step Tutorial PyTorch in Action: A Step by Step Tutorial Installation ...
- 课程五(Sequence Models),第一 周(Recurrent Neural Networks) —— 1.Programming assignments:Building a recurrent neural network - step by step
Building your Recurrent Neural Network - Step by Step Welcome to Course 5's first assignment! In thi ...
- 课程四(Convolutional Neural Networks),第一周(Foundations of Convolutional Neural Networks) —— 2.Programming assignments:Convolutional Model: step by step
Convolutional Neural Networks: Step by Step Welcome to Course 4's first assignment! In this assignme ...
随机推荐
- C++多线程下出现内存越界问题总结
工作中遇到这样一个问题,某个多级流水多线程的程序,在压力测试下会偶现segmentation fault11错误,错误出现在运行类函数的地方,而后排查后发现是由于多线程争抢导致类被析构后才走入判断,导 ...
- 扩展自easyui的combo组件的下拉多选控件
首先上效果图 代码片段: 有需要的朋友微信联系我. 如果这篇文章对您有帮助,您可以打赏我 技术交流QQ群:15129679
- /etc/bashrc
[ "$PS1" = "\\s-\\v\\\$ " ] && PS1="[\[\e[34;1m\]\u@\[\e[0m\]\[\e[3 ...
- [Tableau] Tableau for BI
主要链接 Tableau AWS 上的 Tableau Server Tableau on AWS Quick Starts Tableau教程[本篇来源] Tableau Desktop for U ...
- 报错:ImportError: cannot import name "KafkaProducer" from "kafka"
报错背景: 在Pycharm中安装完成kafka-python之后,我开始在代码中引入kafka的包. from kafka import KafkaProducer 但是引入之后报错 报错现象: 报 ...
- 如何在LabWIndows/CVI中调用LabVIEW DLL
首先请参考官方的文档 http://digital.ni.com/public.nsf/websearch/70995EC2CA1B523386256DD4004F3DE6?OpenDocument ...
- 改进初学者的PID-测量的比例介绍
最近看到了Brett Beauregard发表的有关PID的系列文章,感觉对于理解PID算法很有帮助,于是将系列文章翻译过来!在自我提高的过程中,也希望对同道中人有所帮助.作者Brett Beaure ...
- python 可变数据类型 和 不可变数据类型
在 python 中,类型属于对象,变量是没有类型的: a=[1,2,3] a="Runoob"以上代码中,[1,2,3] 是 List 类型,"Runoob" ...
- 消息发送函数OSMboxPostOpt()
消息发送函数OSMboxPostOpt() 作用,ucos 3中的消息邮箱,具有广播功能,发送一条消息就可以使所有等待该消息的任务进入就绪状态,从而完成消息分发功能,具有一个消息唤醒多个任务的机制.
- IFC文件介绍
IFC是一个数据交换标准, 用于不同系统交换和共享数据. IFC是采用EXPRESS语言定义的实体关系模型,由几百个实体对象组成.实体对象包括建筑要素如IfcWall,几何元素如IfcExtruded ...