Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use API to consume SAP order service

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly explains "how to use API to consume SAP's order service." Interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Let's let Xiaobian take you to learn "how to use API to consume SAP order service"!

A search on SAP's website at http://help.sap.com based on the keyword commerce will show several products in the result list, which will inevitably make people like Jerry who are new to commerce feel a little confused.

In fact, it only takes patience to open these links and read them one by one for a while to understand the differences between these products:

SAP Commerce: E-commerce solutions on SAP On-Premises

SAP Commerce Cloud on SAP Infrastructure: A cloud-based solution for SAP Commerce, the Commerce core code is mirrored into a container via SAP internal tools, deployed and run in SAP's own data center. Also known as Commerce Cloud Version One in many documents, CCV1 for short.

SAP Commerce Cloud on Public Cloud: SAP Commerce Cloud solution deployed on public clouds, such as Microsoft Azure, referred to as CCV2.

To consume Commerce Cloud order services, you first need to familiarize yourself with how to manually place orders in Commerce Cloud. In the Commerce Cloud B2C scenario, the process of placing an order is almost familiar to each of us-the same as when we shop on a treasure every day.

Go to the e-commerce store to browse the goods, see a favorite product,

Click Add To Cart to add the product to your cart:

Check Out to checkout:

A shopping cart ID is generated:

Maintain shipping address. Of course, when we usually shop on a treasure, we generally maintain several shipping addresses in the mobile app in advance, and then just choose one of them when checking out.

Maintain payment methods and details. This step is like shopping on a treasure and choosing WeChat, Alipay, flowers, etc.

Click Place Order to successfully generate an order and get the order ID.

To summarize, the manual order process can be divided into these five steps:

(1)Create a Shopping Cart

(2)Add products to this cart

(3)Maintain shipping address for this cart

(4)Maintain payment details for this cart

(5)Order execution, order generation successful

After figuring out the process, you need to figure out which APIs are called for each step.

Visit SAP's website at https://api.sap.com and search for all the APIs you need using the keyword Commerce Cloud:

Jerry wrote a nodejs application to demonstrate the use of these APIs. The complete code for this nodejs application is on Jerry's github.

Executing this application will print the successfully created order ID in the callback function on line 20:

According to this ID, you can find the successfully created order in the backoffice of Commerce Cloud:

As mentioned above, it takes 5 steps to manually place an order, and Jerry's project file has seven step.js, two more steps, one is to obtain the Access Token, and the other is to set the Delivery Mode of the shopping cart. The former is the basis for subsequent calls to all APIs, while the latter completes the logic. When we place an order manually in the browser, the Commerce Cloud application will automatically help us set it, but when we place an order in the API way, we need to explicitly call the API to set the Delivery Mode. Therefore, it takes a total of 7 steps to complete the order creation.

The procedure for obtaining the Access Token is still to use the conventional OAuth authentication, and exchange the Access Token through the client id and client secret.

We first need to create an OAuth Client on Commerce Cloud, maintain Client ID, Client Secret, password, token refresh interval, related permissions and other information:

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

Jerry didn't upload urlconfig.js to github for privacy reasons. He only uploaded urlconfigTemplate.js. Before using this nodejs application, please replace the placeholders identified by left and right angle brackets in urlconfigTemplate.js with actual values, and then rename them to urlconfig.js.

At this point, I believe everyone has a deeper understanding of "how to use API to consume SAP's order service." Let's do it in practice! Here is the website, more related content can enter the relevant channels for inquiry, pay attention to us, continue to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report