E-Commerce and the Mule Platform with Salesforce Commerce Cloud

E-Commerce and the Mule Platform with Salesforce Commerce Cloud

Here at Admios we've been working with Salesforce Commerce Cloud (SCC), previously known as Demandware, for quite some time now, and we had the idea to meld our use of SCC with our use of the Mule Platform and build a Mulesoft SCC Connector.

How can we build a connector

Using the Mulesoft Connector DevKit we started designing how our connector architecture would look.

SCC offers the OpenCommerce API. “(OCAPI) enables you to access resources using HTTP requests and HTTP responses. Each resource is addressed by its unique URL, which includes the API version. Data is transported using request or header parameters, or within the request body as a JSON document with a defined structure. OCAPI is divided into different APIs: the Shop API allows a client to interact with the system as a shop customer or as an agent shopping on behalf of a customer, the Data API gives create/read/update/delete access to system resources, and the Meta API can be used to get a formal description of the Open Commerce API including custom attributes.” [1]

Using OCAPI as our target-facing, we decided to implement a connector that handles all operations included in SHOP API, leaving DATA and META API for future versions. We built a wrapper around this REST API so we could easily add the remaining API in the next release.

Here is the list of all SHOP API resources:

We've started the certification process and we're planning to release this connector as soon as possible to bring an important player in the e-commerce world to the Mule ecosystem.

How we use the connector

Let’s see some common use cases for the Salesforce Commerce Cloud Connector:

1. Get nearest stores

Step 1:

Create a new Mule Project.

Step 2:

In the Mule Palette, select connectors and drag and drop HTTP Connector in to the flow designer. First we need to config the HTTP request service before using it. Click on the http connector and later in the HTTP tab below. Add a new HTTP Listener Configuration and set the port to 8081, back into the http connector set the Path to "/stores".

Step 3:

In the Mule Palette, select connectors and drag and drop Salesforce Commerce Cloud in to the flow designer, then create a new configuration and set your Credentials from your sandbox ,and select the operation Get Nearest Stores.

Step 4:

Then you can add a Transform Message and use the following snippet to add the classes for the request.

%dw 1.0 %output application/java --- { countryCode: inboundProperties."http.query.params".countryCode as :string, postalCode: inboundProperties."http.query.params".postalCode as :string, maxDistance: inboundProperties."http.query.params".maxDistance as :string } as :object { class : "org.mule.modules.salesforcecommercecloud.client.shop.model.request.StoreLocationRequest" }

Step 5:

Then you can add a Transform Message and use the following snippet to extract the stores from the response.

%dw 1.0 %output application/json --- { stores: payload.data }

Result:

2. Get order status

Step 1:

Create a new Mule Project.

Step 2:

In the Mule Palette, select connectors and drag and drop HTTP Connector in to the flow designer. First we need to config the HTTP request service before using it. Click on the http connector and later in the HTTP tab below. Add a new HTTP Listener Configuration and set the port to 8081, back into the http connector set the Path to "/order".

Step 3:

In the Mule Palette, select connectors and drag and drop Salesforce Commerce Cloud in to the flow designer, then create a new configuration and set your Credentials from your sandbox ,and select the operation Get Order and set the OrderNo as:

#[message.inboundProperties.'http.query.params'.number]

Step 4:  

Then you can add a Transform Message and use the following snippet to extract the order status from the response.

%dw 1.0 %output application/json --- { order_no: payload.orderNo, order_total: payload.orderTotal, order_status: payload.status, payment_status: payload.paymentStatus, shipping_status: payload.shippingStatus }

Result:

What's next?

Catalyst Accelerator for Retail “is a set of API designs and supporting reference implementations, that accelerate the path towards digital transformation.”[2]

Adding a SCC connector to this architecture is the next step on our roadmap. We’ll be adding the following System APIs:

  • Location API
  • Product API
  • Inventory API
  • Customer API
  • Order API

Our next blog post will be a step-by step-guide for using one of our Catalyst Accelerator templates.


[1] https://documentation.demandware.com/DOC1/index.jsp - Getting started with OCAPI 17.7

[2] https://www.mulesoft.com/content/catalyst-accelerator-retail-v2

10 DevOps Optimizations
ECommerce 101

Suscribe to our newsletter

Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.