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的原创文章,请关注公众号"汪子熙":
相关推荐
在React中使用RESTful API 关于如何在React中使用RESTful API的简单实现。 随之而来的是,此应用程序已作为Pusher博客上的文章记录在案。 你可以阅读建立要设置此项目,请首先克隆存储库$ git clone ...
gs-consuming-rest, 使用 RESTful Web服务 目录你将构建什么。你需要什么。获取REST资源使应用程序执行正常。使用 Spring Boot 服务管理应用程序生命周期。摘要文件另请参阅本指南引导你完成创建使用rest式web服务的...
This book is your step-by-step guide to building your business website in Drupal, complete with a blog, events calendar, catalogue of products and services, and more. In this book, we will build a ...
ARKit by Tutorials: Building Augmented Reality Apps in Swift 4.2, 2nd Edition by Chris Language-2019(pdf)-分卷4-共5分卷 解压密码:19990323 ARKit by Tutorials: Building Augmented Reality Apps in ...
ARKit by Tutorials: Building Augmented Reality Apps in Swift 4.2, 2nd Edition by Chris Language-2019(pdf)-分卷3-共5分卷 解压密码:19990323 ARKit by Tutorials: Building Augmented Reality Apps in ...
ARKit by Tutorials: Building Augmented Reality Apps in Swift 4.2, 2nd Edition by Chris Language English | 2019 | ISBN: 1942878711 | 496 Pages | True PDF, CODE | 1623 MB Learn ARKit, Apple’s New ...
This book is for intermediate to advanced developers who want to create ARKit apps and learn about the intricacies of developing for Augmented Reality on iOS. Topics Covered in ARKit by Tutorials ...
ARKit by Tutorials: Building Augmented Reality Apps in Swift 4.2, 2nd Edition by Chris Language English | 2019 | ISBN: 1942878711 | 496 Pages | True PDF, CODE | 1623 MB Learn ARKit, Apple’s New ...
ARKit by Tutorials: Building Augmented Reality Apps in Swift 4.2, 2nd Edition by Chris Language-2019(pdf)-分卷2-共5分卷 解压密码:19990323 ARKit by Tutorials: Building Augmented Reality Apps in ...
ARKit by Tutorials: Building Augmented Reality Apps in Swift 4.2, 2nd Edition by Chris Language-2019(pdf)-分卷1-共5分卷 解压密码:19990323 ARKit by Tutorials: Building Augmented Reality Apps in ...
ARKit by Tutorials: Building Augmented Reality Apps in Swift 4.2, 2nd Edition by Chris Language-2019(pdf)-分卷0-共5分卷 解压密码:19990323 ARKit by Tutorials: Building Augmented Reality Apps in ...
teach you how to delegate many time-consuming and repetitive tasks to Excel by using its built-in language, VBA (Visual Basic for Applications). By executing special commands and statements and using ...
ARKit by Tutorials: Building Augmented Reality Apps in Swift 4.2, 2nd Edition by Chris Language English | 2019 | ISBN: 1942878711 | 496 Pages | True PDF, CODE | 1623 MB Learn ARKit, Apple’s New ...
ARKit by Tutorials: Building Augmented Reality Apps in Swift 4.2, 2nd Edition by Chris Language English | 2019 | ISBN: 1942878711 | 496 Pages | True PDF, CODE | 1623 MB Learn ARKit, Apple’s New ...
ARKit by Tutorials: Building Augmented Reality Apps in Swift 4.2, 2nd Edition by Chris Language English | 2019 | ISBN: 1942878711 | 496 Pages | True PDF, CODE | 1623 MB Learn ARKit, Apple’s New ...