SDK Example: Create and Submit the Order (Winter ‘20)

Use the example SDK code in this topic to create and submit the order as the final step in the checkout process.

1// Instantiate the input object for submitOrder to specify parameters
2const input = digitalCommerce.createSubmitOrderInput();
3input.email = "YOUR EMAIL ID";
4input.catalogCode = "CATALOG CODE";
5input.cartContextKey = "CART CONTEXT KEY";
6input.orderId = "ORDER ID"; // optional parameter
7
8// Invoke submitOrder API
9digitalCommerce
10  .submitOrder(input)
11  .then(response => {
12    Logger.info(
13      "Vlocity digital commerce submitOrder: " + JSON.stringify(response)
14    );
15  })
16  .catch(error => {
17    Logger.info("submitOrder apexrest call failed" + error);
18  });

Possible error conditions:

“SubmitOrderInput::getRequestPayload() must have email.”

“SubmitOrderInput::getRequestPayload() must have catalogCode.”

“SubmitOrderInput::getRequestPayload() must have cartContextKey.”