{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "twispay.threeDSecureData.schema.json",
  "type": "object",
  "title": "Twispay 3DS Data",
  "properties": {
    "addrMatch": {
      "type": ["string"],
      "enum": ["Y","N"],
      "title": "Address Match Indicator",
      "description": "Indicates whether the Cardholder Shipping Address and Cardholder Billing Address are the same."
    },
    "browserAcceptHeader": {
      "type": "string",
      "title": "Browser Accept Headers",
      "examples": [ "application/json"],
      "description": "Exact content of the HTTP accept headers as sent to the 3DS Requestor from the Cardholder’s browser.",
      "minLength": 2,
      "maxLength": 2048
    },
    "browserIP": {
      "type": "string",
      "title": "Browser IP Address",
      "default": "",
      "anyOf": [
        { "type": "string", "format": "ipv4" },
        { "type": "string", "format": "ipv6" }
      ],
      "examples": ["10.129.2.251", "2011:0db8:85a3:0101:0101:8a2e:0370:7334"],
      "description": "IP address of the browser as returned by the HTTP headers to the 3DS Requestor."
    },
    "browserJavaEnabled": {
      "type": "boolean",
      "title": "Browser Java Enabled",
      "examples": [true, false],
      "description": "Boolean that represents the ability of the cardholder browser to execute Java. Value is returned from the navigator.javaEnabled property"
    },
    "browserJavaScriptEnabled": {
      "type": "boolean",
      "title": "Browser JavaScript Enabled",
      "examples": [true, false],
      "description": "Boolean that represents the ability of the cardholder browser to execute JavaScript."
    },
    "browserLanguage": {
      "type": ["string"],
      "title": "Browser Language",
      "examples": [ "en" ],
      "description": "Value representing the browser language as defined in IETF BCP47. Returned from navigator.language property.",
      "maxLength": 8,
      "minLength": 1
    },
    "browserColorDepth": {
      "type": ["string"],
      "enum" : ["1", "4", "8", "15", "16", "24", "32", "48"],
      "title": "Browser Screen Color Depth",
      "description": "Value representing the bit depth of the colour palette for displaying images, in bits per pixel. Obtained from Cardholder browser using the screen.colorDepth property."
    },
    "browserScreenHeight": {
      "type": ["string"],
      "title": "Browser Screen Height",
      "description": "Total height of the Cardholder’s screen in pixels. Value is returned from the screen.height property.",
      "examples": [ "1280", "768" ],
      "pattern": "^[1-9][0-9]{0,5}$"
    },
    "browserScreenWidth": {
      "type": ["string"],
      "title": "Browser Screen Width",
      "description": "Total height of the Cardholder’s screen in pixels. Value is returned from the screen.height property.",
      "examples": [ "1440", "984" ],
      "pattern": "^[1-9][0-9]{0,5}$"
    },
    "browserTZ": {
      "type": ["string"],
      "title": "Browser Time Zone",
      "examples": [ "300", "-300", "+300" ],
      "description": "Time-zone offset in minutes between UTC and the Cardholder browser local time. Note that the offset is positive if the local time zone is behind UTC and negative if it is ahead.",
      "pattern": "^[\\+\\-]?[0-9]{1,5}$"
    },
    "browserUserAgent": {
      "type": ["string"],
      "title": "Browser User-Agent",
      "examples": [
        "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.90 Safari/537.36"
      ],
      "minLength": 2,
      "maxLength": 2048
    },
    "billAddrCity": {
      "type": ["string"],
      "title": "Cardholder Billing Address City",
      "description": "The city of the Cardholder billing address associated with the card used for this purchase.",
      "examples": [ "Bill City Name" ],
      "minLength": 1,
      "maxLength": 50
    },
    "billAddrCountry": {
      "type": ["string"],
      "title": "Cardholder Billing Address Country",
      "description": "The country of the Cardholder billing address associated with the card used for this purchase. Shall be the ISO 3166-1 numeric three-digit country code, other than exceptions listed in Table A.5 (901–999, Reserved by ISO to designate country names not otherwise defined)",
      "examples": [ "840" ],
      "pattern": "^[0-9]{3}$"
    },
    "billAddrLine1": {
      "type": ["string"],
      "title": "Cardholder Billing Address Line 1",
      "description": "First line of the street address or equivalent local portion of the Cardholder billing address associated with the card used for this purchase.",
      "examples": [ "Bill Address Line 1" ],
      "minLength": 1,
      "maxLength": 50
    },
    "billAddrLine2": {
      "type": ["string"],
      "title": "Cardholder Billing Address Line 2",
      "description": "Second line  of the street address or equivalent local portion of the Cardholder billing address associated with the card used for this purchase.",
      "examples": [ "Bill Address Line 2" ],
      "minLength": 1,
      "maxLength": 50
    },
    "billAddrLine3": {
      "type": ["string"],
      "title": "Cardholder Billing Address Line 3",
      "description": "Third line of the street address or equivalent local portion of the Cardholder billing address associated with the card used for this purchase.",
      "examples": [ "Bill Address Line 3" ],
      "minLength": 1,
      "maxLength": 50
    },
    "billAddrPostCode": {
      "type": ["string"],
      "title": "Cardholder Billing Address Postal Code",
      "description": "ZIP or other postal code of the Cardholder billing address associated with the card used for this purchase.",
      "examples": [ "Bill Post Code" ],
      "maxLength": 16
    },
    "billAddrState": {
      "type": ["string"],
      "title": "Cardholder Billing Address State",
      "description": "The state or province of the Cardholder billing address associated with the card used for this purchase. Should be the country subdivision code defined",
      "examples": [ "CO" ],
      "maxLength" : 3
    },
    "Email": {
      "type": ["string"],
      "title": "Cardholder Email Address",
      "description": "The email address associated with the account that is either entered by the Cardholder, or is on file with the 3DS Requestor. RFC 5322",
      "examples": [ "example@example.com" ],
      "maxLength": 254,
      "format": "email"
    },
    "homePhone": {
      "type": ["object"],
      "title": "Cardholder Home Phone Number",
      "description": "The home phone number provided by the Cardholder.",
      "required": [
        "cc",
        "subscriber"
      ],
      "properties": {
        "cc": {
          "type": ["string"],
          "title": "Country Code",
          "examples": [ "123" ],
          "pattern": "^[0-9]{1,3}$"
        },
        "subscriber": {
          "type": ["string"],
          "title": "Subscriber",
          "examples": [ "123456789" ],
          "maxLength": 15
        }
      }
    },
    "workPhone": {
      "type": ["object"],
      "title": "Cardholder Work Phone Number",
      "description": "The work phone number provided by the Cardholder.",
      "required": [
        "cc",
        "subscriber"
      ],
      "properties": {
        "cc": {
          "type": ["string"],
          "title": "Country Code",
          "examples": [ "123" ],
          "pattern": "^[0-9]{1,3}$"
        },
        "subscriber": {
          "type": ["string"],
          "title": "Subscriber",
          "examples": [ "123456789" ],
          "maxLength": 15
        }
      }
    },
    "mobilePhone": {
      "type": ["object"],
      "title": "Cardholder Mobile Phone Number",
      "description": "The mobile phone number provided by the Cardholder.",
      "required": [
        "cc",
        "subscriber"
      ],
      "properties": {
        "cc": {
          "type": ["string"],
          "title": "Country Code",
          "examples": [ "123" ],
          "pattern": "^[0-9]{1,3}$"
        },
        "subscriber": {
          "type": ["string"],
          "title": "Subscriber",
          "examples": [ "123456789" ],
          "maxLength": 15
        }
      }
    },
    "cardholderName": {
      "type": ["string"],
      "title": "Cardholder Name",
      "examples": [ "Cardholder Name" ],
      "minLength": 2,
      "maxLength": 45
    },
    "shipAddrCity": {
      "type": ["string"],
      "title": "Cardholder Shipping Address City",
      "description": "The city of the Cardholder shipping address associated with the card used for this purchase.",
      "examples": [ "Bill City Name" ],
      "minLength": 1,
      "maxLength": 50
    },
    "shipAddrCountry": {
      "type": ["string"],
      "title": "Cardholder Shipping Address Country",
      "description": "The country of the Cardholder shipping address associated with the card used for this purchase. Shall be the ISO 3166-1 numeric three-digit country code, other than exceptions listed in Table A.5 (901–999, Reserved by ISO to designate country names not otherwise defined)",
      "examples": [ "840" ],
      "pattern": "^[0-9]{3}$"
    },
    "shipAddrLine1": {
      "type": ["string"],
      "title": "Cardholder Shipping Address Line 1",
      "description": "The first line of the street address or equivalent local portion of the shipping address requested by the Cardholder.",
      "examples": [ "Ship Address Line 1" ],
      "minLength": 1,
      "maxLength": 50
    },
    "shipAddrLine2": {
      "type": ["string"],
      "title": "Cardholder Shipping Address Line 2",
      "description": "The second line of the street address or equivalent local portion of the shipping address requested by the Cardholder.",
      "examples": [ "Ship Address Line 2" ],
      "minLength": 1,
      "maxLength": 50
    },
    "shipAddrLine3": {
      "type": ["string"],
      "title": "Cardholder Shipping Address Line 3",
      "description": "The third line of the street address or equivalent local portion of the shipping address requested by the Cardholder.",
      "examples": [ "Ship Address Line 3" ],
      "minLength": 1,
      "maxLength": 50
    },
    "shipAddrPostCode": {
      "type": ["string"],
      "title": "Cardholder Shipping Address Postal Code",
      "description": "The ZIP or other postal code of the shipping address requested by the Cardholder.",
      "examples": [ "Ship Post Code" ],
      "minLength": 1,
      "maxLength": 16
    },
    "shipAddrState": {
      "type": ["string"],
      "title": "Cardholder Shipping Address State",
      "description": "The state or province of the shipping address associated with the card used for this purchase. Should be the country subdivision code defined in ISO 3166-2.",
      "examples": [ "CO" ],
      "minLength": 1,
      "maxLength" : 3
    }
  },
  "if": {
    "properties": { "browserJavaScriptEnabled": { "const": true } }
  },
  "then": {
    "required": [
      "browserAcceptHeader",
      "browserIP",
      "browserJavaEnabled",
      "browserJavaScriptEnabled",
      "browserLanguage",
      "browserColorDepth",
      "browserScreenHeight",
      "browserScreenWidth",
      "browserTZ",
      "browserUserAgent"
    ]
  }
}