{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://raw.githubusercontent.com/api-evangelist/cm-com/main/json-schema/cm-com-transaction-schema.json",
  "title": "Transaction",
  "description": "A transaction",
  "x-generated": "2026-10-13",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/cm-com-payments-pos-cloud-api-v1-9-0-openapi.yml#/components/schemas/Transaction",
  "required": [
    "id",
    "creation_datetime",
    "merchant_order_reference",
    "merchant_id",
    "type",
    "status",
    "store",
    "amount"
  ],
  "type": "object",
  "properties": {
    "id": {
      "description": "Unique identifier generated by PayPlaza for this transaction.<br />Format will be 31 numeric characters",
      "pattern": "[0-9]{31}",
      "type": "string"
    },
    "creation_datetime": {
      "allOf": [
        {
          "$ref": "#/$defs/ZonedDateTime"
        },
        {
          "description": "Datetime identifying the moment the transaction was created at CM.com and in CM.com timezone.<br />The creation date is specified in the <a href=\"https://en.wikipedia.org/wiki/ISO_8601\">ISO 8601</a> format.<br />The date on the receipt is formatted to the store timezone. pattern: \"ISO 8601: \"YYYY-MM-DD'T'hh:mm:ssZ\""
        }
      ]
    },
    "merchant_order_reference": {
      "description": "Identifier provided by the merchant when creating the transaction.",
      "maxLength": 14,
      "minLength": 1,
      "pattern": "([0-9a-zA-Z]|-|_){1,14}}",
      "type": "string"
    },
    "brand": {
      "description": "Optional field, which will only be filled if this transaction is authorized by a processor.<br /><br />Identifies the brand on the bankcard of the consumer, possible values:<br />AMEX, CIRRUS, CUP, DINERS, DISCOVER, JCB, MAESTRO, MASTERCARD, VISA, V_PAY.",
      "type": [
        "string",
        "null"
      ]
    },
    "system_trace_audit_number": {
      "description": "Optional field, which will only be filled if this transaction is authorized by a processor.<br /><br />Identifier generated by PayPlaza to trace a transaction through its lifecycle with a processor.<br />* Format is a 6 digit number, but should be treated as a string.<br />* Unique per day per processor, so not unique for merchants.",
      "type": [
        "string",
        "null"
      ]
    },
    "receipt": {
      "description": "Optional field, which will only be filled if this transaction cleared or cancelled.<br /><br />Plain text description of the transaction, contains required information needed to print a proof of the transaction of the consumer.",
      "type": [
        "string",
        "null"
      ]
    },
    "merchant_receipt": {
      "description": "Optional field.<br /><br />Plain text description of the transaction, contains required information needed to print a proof of the transaction of the merchant.",
      "type": [
        "string",
        "null"
      ]
    },
    "original_id": {
      "description": "Optional field, which will only be filled if this transaction is a REFUND.<br /><br />This field contains the id of the original PURCHASE transaction to which this transaction is a refund.",
      "pattern": "[0-9]{31}",
      "type": [
        "string",
        "null"
      ]
    },
    "authorization_code": {
      "description": "Optional field, which will only be filled if this transaction is authorized by a processor.<br /><br />This field contains the authentication provided by the processor of the transaction.",
      "pattern": "[0-9]{6}",
      "type": [
        "string",
        "null"
      ]
    },
    "merchant_id": {
      "description": "Identifier of the merchant that initiated this transaction.",
      "type": "string"
    },
    "processor_terminal_id": {
      "description": "Optional field, which will only be filled after this transaction is authorized.<br /><br />Terminal ID provided by the processor of the transaction.",
      "type": [
        "string",
        "null"
      ]
    },
    "type": {
      "$ref": "#/$defs/TransactionType"
    },
    "amount": {
      "$ref": "#/$defs/Amount"
    },
    "store": {
      "type": [
        "object",
        "null"
      ],
      "allOf": [
        {
          "$ref": "#/$defs/Store1"
        }
      ]
    },
    "result": {
      "type": [
        "string",
        "null"
      ],
      "allOf": [
        {
          "$ref": "#/$defs/TransactionResult"
        }
      ]
    },
    "status": {
      "$ref": "#/$defs/TransactionStatus"
    }
  },
  "$defs": {
    "Amount": {
      "description": "Describes how much money the transaction should be.<br />'value' is a number value with a dot (.) as decimal separator. It should NOT have any digit grouping or thousands separators<br />'currency' is a 3-letter-code, compliant with <a href=\"https://en.wikipedia.org/wiki/ISO_4217\">ISO 4217</a>",
      "required": [
        "value",
        "currency"
      ],
      "type": "object",
      "properties": {
        "value": {
          "pattern": "\\d+\\.\\d{2}",
          "type": "number"
        },
        "currency": {
          "description": "Currency Code",
          "enum": [
            "EUR",
            "USD",
            "GBP"
          ],
          "type": "string"
        }
      }
    },
    "Store1": {
      "title": "StoreSummary",
      "description": "Information about Store where merchant can do transactions.",
      "required": [
        "uuid",
        "name"
      ],
      "type": "object",
      "properties": {
        "uuid": {
          "allOf": [
            {
              "$ref": "#/$defs/UUID"
            },
            {
              "description": "Identifier of the store"
            }
          ]
        },
        "name": {
          "description": "Name of the store",
          "maxLength": 255,
          "minLength": 1,
          "type": "string"
        }
      }
    },
    "TransactionResult": {
      "description": "Final outcome of processing the transaction.<dl><dt>APPROVED</dt><dd>Indicates that the bank of the consumer authorized the payment.</dd><dt>DECLINED</dt><dd>Indicates that the bank of the consumer does NOT approve the payment.</dd></dl>",
      "enum": [
        "APPROVED",
        "DECLINED"
      ],
      "type": "string"
    },
    "TransactionStatus": {
      "description": "<strong>Current state of a transaction.</strong><dl><dt>CREATED</dt><dd>Transaction is created and waiting authorization.</dd><dt>AUTHORIZED</dt><dd>Transaction is authorized and awaiting clearance.</dd><dt>CLEARED</dt><dd>Transaction is cleared and is completed successfully.</dd><dt>CANCELLED</dt><dd>Transaction is cancelled and is completed unsuccessfully.</dd>",
      "enum": [
        "CREATED",
        "AUTHORIZED",
        "CLEARED",
        "CANCELLED"
      ],
      "type": "string"
    },
    "TransactionType": {
      "description": "<dl><dt>PURCHASE</dt><dd>Indicates a purchase where the money will flow from the consumer to the merchant</dd><dt>PRE_AUTH</dt><dd>Indicates a claim on a certain amount of money on the bankaccount of the consumer</dd><dt>REFUND</dt><dd>Indicates a refunds where the money will flow from the merchant back to the consumer</dd></dl>",
      "enum": [
        "PURCHASE",
        "PRE_AUTH",
        "REFUND"
      ],
      "type": "string"
    },
    "UUID": {
      "format": "uuid",
      "pattern": "[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}",
      "type": "string"
    },
    "ZonedDateTime": {
      "format": "date-time",
      "type": "string"
    }
  }
}