Skip to content

Price Webhook Notifications

The Price Updates from MyLION deliversnotifications regarding changes to product prices within the MyLION ERP system. By subscribing to this webhook, you can keep your pricing information synchronized with MyLION, ensuring that your customers receive accurate pricing details. This article will delve into the payload structure of the webhook notification and provide insights into interpreting the data for seamless integration.

Payload Structure

The Price Updates Webhook payload adheres to a structured format defined by a JSON schema. Here's an overview of the payload structure:

json
{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "definitions": {
    "ProductPriceCollectionDTO": {
      "type": "object",
      "properties": {
        "productPrices": {
          "type": "array",
          "items": { "$ref": "#/definitions/ProductPriceDTO" }
        }
      },
      "required": ["productPrices"]
    },
    "ProductPriceDTO": {
      "type": "object",
      "properties": {
        "id": { "$ref": "#/definitions/IdDTO" },
        "price": { "$ref": "#/definitions/PriceDTO" }
      },
      "required": ["id", "price"]
    },
    "PriceDTO": {
      "type": "object",
      "properties": {
        "salesPrice": { "$ref": "#/definitions/ProductPriceDetailsDTO" },
        "discountedSalesPrice": { "$ref": "#/definitions/ProductPriceDetailsDTO" },
        "purchasePrice": { "$ref": "#/definitions/ProductPriceDetailsDTO" },
        "customerGroupProductPrices": {
          "type": "array",
          "items": { "$ref": "#/definitions/CustomerGroupProductPriceDTO" }
        },
        "customerGroupProductDiscounts": {
          "type": "array",
          "items": { "$ref": "#/definitions/CustomerGroupProductDiscountDTO" }
        }
      },
      "required": ["salesPrice", "discountedSalesPrice", "purchasePrice", "customerGroupProductPrices", "customerGroupProductDiscounts"]
    },
    "ProductPriceDetailsDTO": {
      "type": "object",
      "properties": {
        "price": { "type": "number" },
        "dateTo": { "type": "string", "format": "date-time" },
        "dateFrom": { "type": "string", "format": "date-time" },
        "scales": {
          "type": "array",
          "items": { "$ref": "#/definitions/PriceScaleDTO" }
        },
        "currency": { "type": "string" }
      },
      "required": ["price", "dateTo", "dateFrom", "scales", "currency"]
    },
    "PriceScaleDTO": {
      "type": "object",
      "properties": {
        "minimumQuantity": { "type": "number" },
        "price": { "type": "number" }
      },
      "required": ["minimumQuantity", "price"]
    },
    "CustomerGroupProductPriceDTO": {
      "type": "object",
      "properties": {
        "price": { "type": "number" },
        "customerGroupIdDTO": { "$ref": "#/definitions/IdDTO" },
        "dateFrom": { "type": "string", "format": "date-time" },
        "dateTo": { "type": "string", "format": "date-time" }
      },
      "required": ["price", "customerGroupIdDTO", "dateFrom", "dateTo"]
    },
    "CustomerGroupProductDiscountDTO": {
      "type": "object",
      "properties": {
        "discountedPrice": { "type": "number" },
        "discountPercentage": { "type": "number" },
        "customerGroupIdDTO": { "$ref": "#/definitions/IdDTO" },
        "dateFrom": { "type": "string", "format": "date-time" },
        "dateTo": { "type": "string", "format": "date-time" }
      },
      "required": ["discountedPrice", "discountPercentage", "customerGroupIdDTO", "dateFrom", "dateTo"]
    },
    "IdDTO": {
      "type": "object",
      "properties": {
        "mylionId": { "type": "integer" },
        "externalId": { "type": "string" }
      },
      "required": ["mylionId", "externalId"]
    }
  }
}

Example:

json
{
  "productPrices": [
    {
      "id": {
        "mylionId": 123,
        "externalId": "ext-456"
      },
      "price": {
        "salesPrice": {
          "price": 100.0,
          "dateTo": "2024-02-14T23:59:59Z",
          "dateFrom": "2024-01-01T00:00:00Z",
          "scales": [
            {
              "minimumQuantity": 1,
              "price": 95.0
            }
          ],
          "currency": "USD"
        },
        "discountedSalesPrice": {
          "price": 90.0,
          "dateTo": "2024-02-14T23:59:59Z",
          "dateFrom": "2024-01-10T00:00:00Z",
          "scales": [],
          "currency": "USD"
        },
        "purchasePrice": {
          "price": 80.0,
          "dateTo": "2024-02-14T23:59:59Z",
          "dateFrom": "2024-01-01T00:00:00Z",
          "scales": [],
          "currency": "USD"
        },
        "customerGroupProductPrices": [],
        "customerGroupProductDiscounts": []
      }
    }
  ]
}
  • productPrices: An array containing details of product prices updates. Each product price update is represented by a ProductPriceDTO object, which includes the following properties:
    • id: The unique identifier of the product price, including both MyLION ID and external ID.
    • price: Details of the product price, including sales price, discounted sales price, purchase price, customer group product prices, and customer group product discounts. This information is encapsulated within the PriceDTO schema.

The PriceDTO schema encompasses various aspects of product pricing, including sales price, discounted sales price, purchase price, and customer group-specific pricing. Each of these attributes contains details such as price, validity period, currency, and pricing scales.

Receiving and Processing

To receive and process Price Updates Webhook notifications, you need to set up a webhook endpoint in your application. When MyLION sends a webhook notification, it will make a POST request to the specified endpoint with the payload containing the updated price information.

To process the Price Webhook Notification from MyLION, you need to set up a receiving endpoint in your application. The endpoint URL should follow this format:

bash
https://<your_base_url>/rest/mylion/v1/product-prices

When MyLION sends a webhook notification, it will make a POST request to the specified endpoint with the payload containing the updated pricing. The expected response is HTTP OK (200), no payload.