{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://raw.githubusercontent.com/api-evangelist/weavr/main/json-schema/weavr-purchase-request-schema.json",
  "title": "PurchaseRequest",
  "x-generated": "2026-10-12",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/weavr-cards-api-openapi.yml#/components/schemas/PurchaseRequest",
  "required": [
    "cardNumber",
    "cvv",
    "expiryDate",
    "merchantName",
    "transactionAmount"
  ],
  "type": "object",
  "properties": {
    "cardNumber": {
      "maxLength": 50,
      "minLength": 16,
      "pattern": "^[0-9 ]*$",
      "type": "string",
      "description": "The 16-digit card number.",
      "x-fieldValidation": "required has_text size(16,50) regex(^[0-9 ]*$)"
    },
    "cvv": {
      "type": "string",
      "description": "The 3-digit cvv",
      "x-fieldValidation": "required has_text"
    },
    "expiryDate": {
      "type": "string",
      "description": "The expiry date in format MMYY",
      "x-fieldValidation": "required has_text"
    },
    "merchantName": {
      "maxLength": 50,
      "minLength": 1,
      "type": "string",
      "description": "The merchant name",
      "x-fieldValidation": "required size(1,50)"
    },
    "merchantId": {
      "maxLength": 15,
      "minLength": 1,
      "type": "string",
      "description": "The merchant id (MID). If not specified, a random value will be used",
      "x-fieldValidation": "size(1,15)"
    },
    "merchantCategoryCode": {
      "maxLength": 4,
      "minLength": 1,
      "type": "string",
      "description": "The merchant category code (MCC). If unspecified or an invalid MCC is specified, the Merchant Code 5399 (Misc. General Merchandise) will be used instead",
      "x-fieldValidation": "size(1,4)"
    },
    "transactionAmount": {
      "allOf": [
        {
          "$ref": "#/$defs/CurrencyAmount"
        },
        {
          "description": "The amount of the purchase",
          "x-fieldValidation": "required"
        }
      ]
    },
    "forexFee": {
      "type": "integer",
      "description": "If this is a cross-currency transaction, the forex fee amount in the card currency. Deprecated; the forex fee percentage configured at the card profile will be applied if this field is not provided",
      "format": "int64",
      "deprecated": true
    },
    "forexPadding": {
      "type": "integer",
      "description": "If this is a cross-currency transaction, the forex padding amount in the card currency. Deprecated; a 2% forex padding will be applied if this field is not provided. Deprecated; a 2% forex padding will be applied if this field is not provided",
      "format": "int64",
      "deprecated": true
    },
    "atmWithdrawal": {
      "type": "boolean",
      "description": "If set to true, this purchase simulates and ATM Withdrawal transaction. MCC will automatically be set to 6011"
    },
    "additionalMerchantData": {
      "allOf": [
        {
          "$ref": "#/$defs/AdditionalMerchantData"
        },
        {
          "description": "Additional merchant data"
        }
      ]
    },
    "cardHolderPresent": {
      "allOf": [
        {
          "$ref": "#/$defs/CardHolderPresent"
        },
        {
          "description": "Optional detail indicating if the card holder was present when the authorisation occurred."
        }
      ]
    },
    "cardPresent": {
      "type": "boolean",
      "description": "Optional detail indicating if the card was present when the authorisation occurred."
    },
    "initiateBiometricThreeDSecure": {
      "type": "boolean",
      "description": "If the card is enrolled for Biometric Authentication, a 3DS Flow is initiated before the Purchase can resume."
    },
    "transactionTimestamp": {
      "type": "integer",
      "description": "Epoch timestamp using millisecond precision.",
      "format": "int64"
    }
  },
  "$defs": {
    "AdditionalMerchantData": {
      "type": "object",
      "properties": {
        "merchantStreet": {
          "type": "string"
        },
        "merchantCity": {
          "type": "string"
        },
        "merchantState": {
          "type": "string"
        },
        "merchantPostalCode": {
          "type": "string"
        },
        "merchantCountry": {
          "maxLength": 3,
          "minLength": 3,
          "pattern": "^[A-Z]*$",
          "type": "string",
          "x-fieldValidation": "size(3,3) regex([A-Z]*)"
        },
        "merchantTelephone": {
          "type": "string"
        },
        "merchantURL": {
          "type": "string"
        },
        "merchantNameOther": {
          "type": "string"
        },
        "merchantNetworkId": {
          "type": "string"
        },
        "merchantContact": {
          "type": "string"
        }
      }
    },
    "CardHolderPresent": {
      "type": "string",
      "enum": [
        "PRESENT",
        "NOT_PRESENT",
        "PRESENCE_UNKNOWN"
      ]
    },
    "CurrencyAmount": {
      "required": [
        "currency"
      ],
      "type": "object",
      "properties": {
        "currency": {
          "maxLength": 3,
          "minLength": 3,
          "pattern": "^[A-Z]*$",
          "type": "string",
          "description": "The currency ISO-4217 code, i.e. a three letter uppercase code, such as GBP, EUR, USD.",
          "x-fieldValidation": "required size(3,3) regex([A-Z]*)"
        },
        "amount": {
          "type": "integer",
          "description": "The monetary amount, scaled to the lowest denomination of the currency. For example, an amount of 1000 for a EUR currency is actually 1000 Euro cents, i.e. EUR 10.00.",
          "format": "int64"
        }
      },
      "description": "A message representing a monetary amount in a particular currency."
    }
  }
}