SDK Example: Checkout Cart (Fall ‘19)

Use the example SDK code in this topic to check out a cart.

1// Instantiate the input object for checkoutCart to specify parameters
2const input = digitalCommerce.checkoutCartInput();
3input.catalogCode = "Mobiles"; // use your Catalog Code
4input.accountId = "001f200001eSlhe"; // use your account Id
5input.cartContextKey = "d5ff11cccd19472ca7c21fa80bc93d2a";
6
7// Used in Checkout process to persist shopping cart content into SF Database
8digitalCommerce
9  .checkoutCart(input)
10  .then(response => {
11    Logger.info(
12      "Vlocity digital commerce checkout cart for anonymous user: " +
13        JSON.stringify(response)
14    );
15  })
16  .catch(error => {
17    Logger.info("checkout cart for anonymous user rest call failed" + error);
18  });

Possible error conditions:

“checkoutCartInput::getAPIPath() must have catalogCode.”

“checkoutCartInput::getAPIPath() must have accountId.”

“checkoutCartInput::getAnonymousSiteRestUrl() must have catalogCode.”

“checkoutCartInput::getAnonymousSiteRestUrl() must have accountId.”

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