{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "urn:sbv:iso20022:pain.007.001.09",
  "title": "CustomerPaymentReversal — pain.007.001.09 (SBV profile)",
  "description": "ISO 20022 pain.007.001.09: Yêu cầu thu hồi lệnh thanh toán",
  "type": "object",
  "required": ["Document"],
  "properties": {
    "Document": {
      "type": "object",
      "required": ["CstmrPmtRvsl"],
      "properties": {
        "CstmrPmtRvsl": {
          "type": "object",
          "required": ["GrpHdr", "OrgnlGrpInf"],
          "properties": {
            "GrpHdr": {
              "type": "object",
              "required": ["MsgId", "CreDtTm", "NbOfTxs", "InitgPty"],
              "properties": {
                "MsgId":    { "type": "string", "maxLength": 35 },
                "CreDtTm":  { "type": "string", "format": "date-time" },
                "NbOfTxs":  { "type": "string", "pattern": "^[0-9]{1,15}$" },
                "InitgPty": { "type": "object", "properties": { "Nm": { "type": "string", "maxLength": 140 } } }
              }
            },
            "OrgnlGrpInf": {
              "type": "object",
              "required": ["OrgnlMsgId", "OrgnlMsgNmId"],
              "properties": {
                "OrgnlMsgId":   { "type": "string", "maxLength": 35 },
                "OrgnlMsgNmId": { "type": "string", "maxLength": 35 }
              }
            },
            "OrgnlPmtInfAndRvsl": {
              "type": "array",
              "items": {
                "type": "object",
                "properties": {
                  "OrgnlPmtInfId":  { "type": "string", "maxLength": 35 },
                  "RvslPmtInfId":   { "type": "string", "maxLength": 35 },
                  "RvslRsnInf": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "Rsn": { "type": "object", "properties": { "Cd": { "type": "string" } } }
                      }
                    }
                  },
                  "TxInf": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "OrgnlEndToEndId": { "type": "string", "maxLength": 35 },
                        "OrgnlUETR":       { "type": "string", "pattern": "^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$" },
                        "OrgnlInstdAmt":   { "type": "object", "properties": { "_": { "type": "string" }, "$": { "type": "object", "properties": { "Ccy": { "type": "string" } } } } }
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}
