How to use the API way to consume SAP Commerce Cloud service orders

Jerry recently doing a micro letter and SAP Commerce Cloud integration projects, the latter need to call in the micro-letter Restful API for order creation and reading. Jerry formerly of SAP Commerce Cloud poorly understood, this time took the opportunity to learn a little, got the process of Chengdu Institute of Commerce SAP development team of Jonathan, Kevin and Kate great help and several students expressed gratitude here.

On the official website help.sap.com SAP based on keywords commerce search, the results list will show several products, which will inevitably make this new to commerce like Jerry who was a bit puzzled.

clipboard1,1

In fact, only you need to be patient to open these links one by one to read for a while, you can figure out the differences between these products:

  • SAP Commerce: electricity supplier on SAP On-Premises Solution

  • SAP Commerce Cloud on SAP Infrastructure: SAP Commerce cloud solutions, Commerce core code labeled as a container mirrored by SAP internal tools, deploy, and run SAP's own data center. In a lot of documentation, also known as Commerce Cloud Version One, referred to as CCV1.

  • SAP Commerce Cloud on Public Cloud: SAP Commerce Cloud solutions deployed to run on public clouds, such as Microsoft's Azure, referred to as CCV2.

Have a nice blog on Medium Two Clouds in Practice: A Comparison of SAP Commerce Cloud v1 and v2 introduces CCV1 and contrast CCV2, where Jerry will not go started.

clipboard2,2

回到本文主题,要想消费Commerce Cloud的订单服务,首先需要熟悉一下如何手动在Commerce Cloud里下单。在Commerce Cloud B2C的场景里,下单的流程对我们每个人来说几乎熟悉得不能再熟悉了——和我们日常在某宝上购物如出一辙。

到电商店铺里浏览商品,看中自己心仪的一款产品后,

clipboard3,3

点击Add To Cart把产品加到购物车里:

clipboard4,4

点Check Out去结账:

clipboard5,5

会生成一个购物车ID:

clipboard6,6

维护发货地址。当然我们平时在某宝上购物时,一般都提前在手机app里维护了好几个发货地址,然后结账时只需从中选择一个即可。

clipboard7,7

维护支付方式和明细(Payment Detail),这一步好比我们在某宝上购物选择微信,支付宝,花呗等方式支付。

clipboard8,8

Place Order点击后,成功生成订单,得到订单ID.

clipboard9,9

总结一下,手动下单的流程可以分成这五步:

(1) 创建一个购物车Shopping Cart

(2) 给该购物车里添加产品

(3) 给该购物车维护发货地址

(4) 给该购物车维护支付明细

(5) 执行下单操作,成功生成订单

搞清楚流程之后,接下来需要找到每个步骤分别调用哪些API来实现。

登录SAP官网https://api.sap.com, 根据关键字Commerce Cloud搜索,很容易就能找到所有需要使用的API:

clipboard10,10

Jerry写了一个nodejs应用来演示这些API的用法。这个nodejs应用的完整代码在Jerry的github上。

执行这个应用,在第20行的回调函数里会打印出成功创建的订单ID:

clipboard11,11

根据这个ID到Commerce Cloud的backoffice里,能查找到成功创建的订单:

clipboard12,12
clipboard13,13

Speaking in front of a single manual requires five steps, and Jerry project file, there are seven step.js, two extra steps, one is to obtain Access Token, the other is to set the shopping cart Delivery Mode. The former is a follow-up call the basis for all API's, which completed the logic, when we manually order in the browser, Commerce Cloud application will automatically help us set up, but with a single under the API, we need to explicitly set the Delivery mode API calls , so the final total of seven steps required to complete the creation of the order.

clipboard14,14

Access Token acquisition step, is still using conventional OAuth authentication by client id and client secret in exchange for Access Token.

We first need to be created on a Commerce Cloud OAuth Client, maintenance Client ID, Client Secret, password, token refresh interval information, and other related rights:

clipboard15,15

Then step1_get_token.js, the information maintained by OAuth Client sends a POST request to the OAuth endpoint in exchange for Access Token.

clipboard16,16

Because of privacy reasons, Jerry did not urlconfig.js upload to github, just uploaded a urlconfigTemplate.js, please nodejs before using this application, replace urlconfigTemplate.js in the placeholder to the left and right angle brackets to identify the actual value can then rename into urlconfig.js.

clipboard17,17

For more Jerry's original article, please pay attention to the public number "Wang Zixi":
公众号截图

Guess you like

Origin www.cnblogs.com/sap-jerry/p/11758225.html