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的原创文章,请关注公众号"汪子熙":

原文地址:https://www.cnblogs.com/sap-jerry/p/11790996.html

时间: 2024-11-02 00:52:40

Step by Step to create orders by consuming SAP Commerce Cloud Restful API的相关文章

C# 2012 step by step 学习笔记8 CHAPTER 9 Creating Value types with enumerations and Structures

C# 2012 step by step 学习笔记8 CHAPTER 9 Creating Value types with enumerations and Structures things about 1. Declare an enumeration type. 2. Create and use an enumeration type. 3. Declare a structure type. 4. Create and use a structure type. 5. Explain

C++开发WPF,Step by Step

示例代码 使用C++来开发WPF,主要是如何在MFC(Win32)的窗口中Host WPF的Page.下面我就做个详细的介绍. 一.创建工程, 由于MFC的Wizard会生成很多用不到的代码,所以我准备从一个空的工程开始创建一个MFC的工程. a)         打开VS2005,菜单File->New->Projects-, 左面选择Visual C++->Win32,右面选择Win32 Console Application,给工程起个名字CPlusPlus_WPF, Ok进入下一

Step by Step for configuration of sending customize IDOC/自定义IDOC发送配置

<div style="width: 600px; max-width: 100%; margin-bottom:5px;"><a href="https://docs.com/gan-gavin/6042/idoc-step-by-step-for-configuration-of-sending" title="自定义IDOC配置/Step by Step for configuration of sending customize

Program for Linux USB-devices driver step by step (ONE)

Program for Linux USB-devices driver 开始啃硬骨头~ 这里我打算一步步给出USB device driver 的demo,希望有心能能够共同交流学习. 希望认识更多对Linux有兴趣的geek. 目前由于环境和自身能力方面原因还没能做实物的测试,篇章的最后打算给出一个在x86上模拟USB读写的driver,以后能够做实物测试之后再更新this blog 我的联系方式: [email protected](由于偶不能登QQ,所以thunder bird的邮件只要

【Step By Step】将Dotnet Core部署到Docker下

一.使用.Net Core构建WebAPI并访问Docker中的Mysql数据库 这个的过程大概与我之前的文章<尝试.Net Core—使用.Net Core + Entity FrameWork Core构建WebAPI(一)>一致. 但是在我们这里,由于docker中无法部署sql server,所以我采用了Mysql数据库,顺便吐槽一下 SQL Server真的太贵了,阿里云的Mysql实例价格和SQL Server实例价格差10倍,真的好夸张. Mysql官方的EF Core支持刚刚出

[py]python写一个通讯录step by step V3.0

python写一个通讯录step by step V3.0 参考: http://blog.51cto.com/lovelace/1631831 更新功能: 数据库进行数据存入和读取操作 字典配合函数调用实现switch功能 其他:函数.字典.模块调用 注意问题: 1.更优美的格式化输出 2.把日期换算成年龄 3.更新操作做的更优雅 准备工作 db准备 - 创建数据库 mysql> create database txl charset utf8; Query OK, 1 row affecte

WPF MVVM 架构 Step By Step(4)(添加bindings - 完全去掉后台代码)

原文:WPF MVVM 架构 Step By Step(4)(添加bindings - 完全去掉后台代码) 之前的改进已经挺棒的,但是我们现在知道了后台代码的问题,那是否可能把后台代码全部去除呢?这时候就该WPF binding 和 commands 来做的事情了. WPF就是以超吊的binding,commans和声明式编程而闻名的.声明式编程意思就是相比于全部用C#代码来写,我们也可以用XAML来表示c#代码.Binding可以帮助我们把2个不同的WPF对象连接起来来发送和接收数据. 你看到

Step by Step Guide: How to Configure SSL/TLS on ORACLE RAC (with SCAN) (Doc ID 1448841.1)

In this Document   Goal   Solution   References Applies to: Advanced Networking Option - Version 11.2.0.2 to 12.2.0.1 [Release 11.2 to 12.2]Oracle Net Services - Version 12.2.1.2.0 to 12.2.1.2.0 [Release 12.2]Information in this document applies to a

Step by Step guide for SAP Support Backbone Update

Prerequisites. All customers with ABAP-based SAP systems needs to switch to the new infrastructure before January 2020 to ensure smooth connectivity. Resolution for Solution Manager. Look at this step-by-step guide by Praveena Subramani https://blogs