Configure the webhook

When the shopper clicks Place Order, the order is submitted. However, if any item in the order has an external price, the server first invokes the External Price Validation function webhook, which sends the external pricing data to the pricing system for verification.

Invoking the webhook ensures that the external prices have not changed since the last pricing operation and that the prices in the cart have not been modified.

For example, the following shows part of a sample request issued by this webhook:

...
"currencyCode" : "USD",
"operation" : "externalPricing",
"externalPrices": [
    {
      "externalPriceQuantity": 1,
      "externalPrice": 21,
      "catRefId": "xsku1013"
    },
    {
      "externalPriceQuantity": -1,
      "externalPrice": 18,
      "catRefId": "xsku1007"
    }
  ]
...

To send this data to the pricing system, you configure the webhook by specifying the URL, username, and password for accessing the pricing system. (See Configure webhooks.) If your environment uses account-based storefronts, you might also specify the account. You must also configure the pricing system to read the external pricing data, verify whether it is valid, and send a response that includes the appropriate response code. The response code should be one of the following:

  • 5001 (VALID_EXTERNAL_PRICES)
  • 5002 (INVALID_EXTERNAL_PRICES)

For example, if the external price data is valid, the response body might be:

{
  "ResponseCode": "5001"
}

If the response code is 5001, the order is submitted. If the response code is 5002, the order is not submitted, and an error is displayed on the checkout page. You can write custom logic to correct the error (for example, by removing items from the cart and then putting them back in so that the widget retrieves up-to-date price data from the external pricing system).