{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "urn:sbv:iso20022:pain.002.001.11",
  "title": "PaymentStatusReport — pain.002.001.11 (SBV profile)",
  "description": "ISO 20022 pain.002.001.11: Ngân hàng phản hồi trạng thái lệnh thanh toán",
  "type": "object",
  "required": ["Document"],
  "properties": {
    "Document": {
      "type": "object",
      "required": ["CstmrPmtStsRpt"],
      "properties": {
        "CstmrPmtStsRpt": {
          "type": "object",
          "required": ["GrpHdr", "OrgnlGrpInfAndSts"],
          "properties": {
            "GrpHdr": {
              "type": "object",
              "required": ["MsgId", "CreDtTm", "DbtrAgt"],
              "properties": {
                "MsgId":   { "type": "string", "maxLength": 35 },
                "CreDtTm": { "type": "string", "format": "date-time" },
                "DbtrAgt": { "type": "object", "required": ["FinInstnId"], "properties": { "FinInstnId": { "type": "object", "properties": { "BICFI": { "type": "string" } } } } }
              }
            },
            "OrgnlGrpInfAndSts": {
              "type": "object",
              "required": ["OrgnlMsgId", "OrgnlMsgNmId"],
              "properties": {
                "OrgnlMsgId":    { "type": "string", "maxLength": 35 },
                "OrgnlMsgNmId":  { "type": "string", "maxLength": 35 },
                "GrpSts":        { "type": "string", "enum": ["ACTC","ACCP","ACSP","ACSC","ACWC","PNDG","RCVD","RJCT"] },
                "StsRsnInf": {
                  "type": "object",
                  "properties": {
                    "Rsn": { "type": "object", "properties": { "Cd": { "type": "string", "maxLength": 4 } } },
                    "AddtlInf": { "type": "array", "items": { "type": "string", "maxLength": 105 } }
                  }
                }
              }
            },
            "OrgnlPmtInfAndSts": {
              "type": "array",
              "items": {
                "type": "object",
                "properties": {
                  "OrgnlPmtInfId": { "type": "string", "maxLength": 35 },
                  "PmtInfSts":     { "type": "string", "enum": ["ACTC","ACCP","ACSP","ACSC","ACWC","PNDG","RCVD","RJCT"] },
                  "TxInfAndSts": {
                    "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}$" },
                        "TxSts":           { "type": "string", "enum": ["ACTC","ACCP","ACSP","ACSC","ACWC","PNDG","RCVD","RJCT"] }
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}
