SDK Example: ValidateOffer (Fall ‘19)

Use the example SDK code in this topic to validate an offer.

1// Instantiate the input object for validateOffer to specify parameters
2const input = digitalCommerce.createValidateOfferInput();
3input.catalogCode = "Phones"; // use your Catalog Code
4input.offerCode = "iPhoneX"; // use your Offer Code
5
6// input.offerConfiguration: use digitalCommerce.getSelectedOffer(offerCode)
7input.offerConfiguration = digitalCommerce.getSelectedOffer(offerCode);
8input.customFields = ["customAttribute__c"]; // optional field which returns your custom attributes or any given keys
9// Invoke ConfigureOfferDetails API via method validateOffer()
10digitalCommerce
11  .validateOffer(input)
12  .then(response => {
13    Logger.info(
14      "vlocity validate offer for anonymous user" + JSON.stringify(response)
15    );
16  })
17  .catch(error => {
18    Logger.info("vlocity validateOffer for anonymous user failed" + error);
19  });

Possible error conditions:

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

“ValidateOfferInput::getAPIPath() must have offerCode.”

“ValidateOfferInput::getPostBody() must have productConfiguration.”