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.

// Instantiate the input object for submitOrder to specify parameters
const input = digitalCommerce.createSubmitOrderInput();
input.email = "YOUR EMAIL ID";
input.catalogCode = "CATALOG CODE";
input.cartContextKey = "CART CONTEXT KEY";
input.orderId = "ORDER ID"; // optional parameter

// Invoke submitOrder API
digitalCommerce
  .submitOrder(input)
  .then(response => {
    Logger.info(
      "Vlocity digital commerce submitOrder: " + JSON.stringify(response)
    );
  })
  .catch(error => {
    Logger.info("submitOrder apexrest call failed" + error);
  });

Possible error conditions:

"SubmitOrderInput::getRequestPayload() must have email."

"SubmitOrderInput::getRequestPayload() must have catalogCode."

"SubmitOrderInput::getRequestPayload() must have cartContextKey."