{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://raw.githubusercontent.com/api-evangelist/entur/main/json-schema/entur-compensation-operation-request-schema.json",
  "title": "CompensationOperationRequest",
  "description": "A request performing an single compensation operation",
  "x-generated": "2026-10-09",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/entur-refund-partner-openapi.yml#/components/schemas/CompensationOperationRequest",
  "type": "object",
  "properties": {
    "elements": {
      "type": "array",
      "description": "A list of compensation elements",
      "items": {
        "$ref": "#/$defs/CompensationElement"
      }
    },
    "additionalTerminalData": {
      "$ref": "#/$defs/TerminalRefundingData"
    },
    "overrideReimbursementType": {
      "type": "string",
      "description": "Used to override the payment method that the refund operations will be registered as. All refund operations that will target a payment transaction that is imported, will be overridden. Available types: CASH"
    }
  },
  "required": [
    "compensationElements"
  ],
  "$defs": {
    "CompensationElement": {
      "type": "object",
      "description": "A element that wraps a sub operation on a given order. Typically when different",
      "properties": {
        "orderLineIds": {
          "type": "array",
          "description": "Optional list of order line ids that are to be compensated. If left empty the whole order is assumed to be compensated",
          "items": {
            "type": "string"
          }
        },
        "compensationAmount": {
          "type": "string",
          "description": "The amount of compensation desired for this order"
        },
        "compensationReason": {
          "type": "string",
          "description": "Optional field describing the reason for the compensation"
        }
      },
      "required": [
        "compensationAmount"
      ],
      "title": "CompensationElement"
    },
    "TerminalRefundingData": {
      "type": "object",
      "description": "Holder for data that needs to be provided when performing a refund on an external terminal",
      "properties": {
        "additionalData": {
          "type": "object",
          "additionalProperties": {
            "type": "string"
          },
          "description": "Any extra transaction data which could be relevant can be specified as a key value map of strings. If there exists keys here that clash with specific types in this request, the fields in the request are prioritized"
        },
        "baxNumber": {
          "type": "string",
          "description": "When performing an offline refund to card terminal, the BAX-number is mandatory info"
        },
        "obfuscatedCardNumber": {
          "type": "string",
          "description": "The obfuscated value of the card number the refund was performed against"
        },
        "paymentType": {
          "type": "string",
          "description": "The type of payment method that is provided to the terminal for refunding"
        },
        "rrn": {
          "type": "string",
          "description": "Reconciliation reference number used to track an order (transaction) through different economy systems. Generated by a terminal"
        },
        "terminalId": {
          "type": "string",
          "description": "When performing an offline refund to card terminal, the terminal id is mandatory info"
        },
        "transactionConfirmedAt": {
          "type": "string",
          "format": "date-time",
          "description": "Datetime when credit transaction was completed externally by the client."
        }
      },
      "required": [
        "baxNumber",
        "obfuscatedCardNumber",
        "paymentType",
        "rrn",
        "terminalId",
        "transactionConfirmedAt"
      ],
      "title": "TerminalRefundingData"
    }
  }
}