Use the example SDK code in this topic to validate an offer.
// Instantiate the input object for validateOffer to specify parameters
const input = digitalCommerce.createValidateOfferInput();
input.catalogCode = "Phones"; // use your Catalog Code
input.offerCode = "iPhoneX"; // use your Offer Code
(Fall '20)
// input.offerConfiguration: use digitalCommerce.getSelectedOffer(offerCode)
input.offerConfiguration = digitalCommerce.getSelectedOffer(offerCode);
input.customFields = ["customAttribute__c"]; // optional field which returns your custom attributes or any given keys
input.secureApiCall = false; // set to true if needs secure api calls without context parameters and session key.
// Invoke ConfigureOfferDetails API via method validateOffer()
digitalCommerce
.validateOffer(input)
.then(response => {
Logger.info(
"vlocity validate offer for anonymous user" + JSON.stringify(response)
);
})
.catch(error => {
Logger.info("vlocity validateOffer for anonymous user failed" + error);
});
Possible error conditions:
"ValidateOfferInput::getAPIPath() must have catalogCode."
"ValidateOfferInput::getAPIPath() must have offerCode."
"ValidateOfferInput::getPostBody() must have productConfiguration."