Validate Compensation Cards

Purpose

This endpoint allows partners to validate one or more compensation cards against a specific order/basket. It determines if a card is applicable, calculates the associated discounts, or identifies specific validation errors (e.g., expired, invalid).

Request Schema

FieldTypeRequiredDescription
sessionIdStringYesA unique identifier for the session. Required for some integrations to track card validation and subsequent redemption.
compensationCardIdsList[String]YesA list of compensation card codes to be validated.
orderObjectYesThe complete order/basket object to validate the cards against. For more details, see the Channel Order Model Documentation.

Response Schema

The response is a list of objects, where each object represents the validation result for a specific card.

FieldTypeDescription
compensationCardIdStringThe unique code of the card (matches the request).
expiresAtISO8601 StringThe expiration date/time of the card.
validationErrorsList[Object]A list of errors if the card is not applicable. Contains code and message.
discountsList[Object]A list of applicable discounts derived from the card.

Functional Scenarios

Case 1: Adding a New Compensation Card

This occurs when a user enters a new card code. The order object does not yet contain discounts for this card.

Success (Applicable): The response contains the discount details to be applied to the basket.

[
  {
    "compensationCardId": "CARD_ID_1",
    "discounts": [
      {
        "externalId": "CARD_ID_1",
        "offer": { "type": "flat_off", "value": 1000 },
        "provider": "loyalty",
        "scope": { "type": "order" }
      }
    ],
    "expiresAt": "2024-01-01T00:00:00Z",
    "validationErrors": []
  }
]

Failure (Not Applicable): The validationErrors list will explain why the card cannot be used.

[
  {
    "compensationCardId": "CARD_ID_1",
    "discounts": [],
    "expiresAt": "2024-01-01T00:00:00Z",
    "validationErrors": [
      {
        "code": "invalid_code",
        "message": "Invalid compensation card code"
      }
    ]
  }
]

Case 2: Re-validating an Applied Card

This occurs during checkout or basket updates when a card is already present in the order.discounts array.

Still Valid:: The response returns the current applicable discount. This ensures that the partner has the most up-to-date calculation (e.g., if the order total changed, the discount value may have been updated).

[
  {
    "compensationCardId": "CARD_ID_1",
    "discounts": {
      "externalId": "CARD_ID_1",
      "offer": {
        "type": "flat_off",
        "value": 1000
      },
      "provider": "loyalty",
      "scope": {
        "type": "order"
      }
    },
    "expiresAt": "2024-01-01T00:00:00Z",
    "validationErrors": []
  }
]

No Longer Valid: The partner should remove the discount from the order based on the validationErrors.

[
  {
    "compensationCardId": "CARD_ID_1",
    "discounts": [],
    "expiresAt": "2024-01-01T00:00:00Z",
    "validationErrors": [
      {
        "code": "inapplicable_code",
        "message": "The applied code is no longer valid"
      }
    ]
  }
]

Case 3: Removing an Applied Card

This occurs when a partner removes a card ID from the compensationCardIds list, but the discount is still present in the order object.

The Response will only include a validation object for the gift card that remain selected. The response for the removed gift card (CARD_ID_1) will not be returned.

Request example

{
  "compensationCardIds": [
    "CARD_ID_1"
],
  "order": {
    "discounts": [
      {
        "provider": "loyalty",
        "type": "compensation_card",
        "programId": "CARD_ID_1",
        "value": 1000
      },
      {
        "provider": "loyalty",
        "type": "compensation_card",
        "programId": "CARD_ID_2",
        "value": 1000
      }
    ]
  ...
  }
}

Response example

[
  {
    "compensationCardId": "CARD_ID_1",
    "discounts": {
      "externalId": "CARD_ID_1",
      "offer": {
        "type": "flat_off",
        "value": 1000
      },
      "provider": "loyalty",
      "scope": {
        "type": "order"
      }
    },
    "expiresAt": "2024-01-01T00:00:00Z",
    "validationErrors": []
  }
]

5. Standard Status Codes

CodeMeaningDescription
200OKRequest processed successfully. Check individual card objects for validation status.
401UnauthorizedMissing or invalid M2M token.
403ForbiddenFeature not enabled for this account or channel link.
404Not FoundThe provided channelLinkId does not exist.

Path Params
string
required
Body Params
string
required
Response
200
Language
Credentials
OAuth2
LoadingLoading…
Response
Click Try It! to start a request and see the response here!