Beispiel #1
0
        internal virtual DeserializeResponse Deserialize(string payload)
        {
            using (new MethodLogger(s_logger))
            {
                var doc = XDocument.Parse(payload);
                var xph = new XPathHelper(doc, Namespaces);
                int.TryParse(xph.GetTechReturnCode()?.Value, out var techCode);
                int.TryParse(xph.GetBusReturnCode()?.Value, out var busCode);
                int.TryParse(xph.GetNumSegments()?.Value, out var numSegments);
                int.TryParse(xph.GetSegmentNumber()?.Value, out var segmentNo);
                bool.TryParse(xph.GetSegmentNumber()?.Attribute(XmlNames.lastSegment)?.Value, out var lastSegment);
                Enum.TryParse <TransactionPhase>(xph.GetTransactionPhase()?.Value, out var transPhase);

                var dr = new DeserializeResponse
                {
                    BusinessReturnCode  = busCode,
                    TechnicalReturnCode = techCode,
                    NumSegments         = numSegments,
                    SegmentNumber       = segmentNo,
                    LastSegment         = lastSegment,
                    TransactionId       = xph.GetTransactionID()?.Value,
                    Phase      = transPhase,
                    ReportText = xph.GetReportText()?.Value
                };

                s_logger.LogDebug("DeserializeResponse: {response}", dr);
                return(dr);
            }
        }
Beispiel #2
0
        internal virtual DeserializeResponse Deserialize_ebicsKeyManagementResponse(string payload, out ebics.ebicsKeyManagementResponse ebr)
        {
            using (new MethodLogger(s_logger))
            {
                ebr = XMLDeserialize <ebics.ebicsKeyManagementResponse>(payload);
                int.TryParse(ebr.header.mutable.ReturnCode, out var techCode);
                int.TryParse(ebr.body.ReturnCode.Value, out var busCode);
                var dr = new DeserializeResponse
                {
                    BusinessReturnCode  = busCode,
                    TechnicalReturnCode = techCode,
                    ReportText          = ebr.header.mutable.ReportText
                };

                s_logger.LogDebug("DeserializeResponse: {response}", dr);
                return(dr);
            }
        }
Beispiel #3
0
        internal virtual DeserializeResponse Deserialize_ebicsResponse(string payload, out ebics.ebicsResponse ebr)
        {
            using (new MethodLogger(s_logger))
            {
                //do signature validation here
                var doc = new XmlDocument {
                    PreserveWhitespace = true
                };
                doc.LoadXml(payload);
                VerifySignature(doc, Config.Bank.AuthKeys.PublicKey);

                //var doc = XDocument.Parse(payload);
                ebr = XMLDeserialize <ebics.ebicsResponse>(payload);
                int.TryParse(ebr.header.mutable.ReturnCode, out var techCode);
                int.TryParse(ebr.body.ReturnCode.Value, out var busCode);
                int.TryParse([email protected], out var numSegments);
                int.TryParse(ebr.header.mutable.SegmentNumber?.Value, out var segmentNo);
                var lastSegment = ebr.header.mutable.SegmentNumber?.lastSegment;
                Enum.TryParse <TransactionPhase>(ebr.header.mutable.TransactionPhase.ToString(), out var transPhase);

                var dr = new DeserializeResponse
                {
                    BusinessReturnCode  = busCode,
                    TechnicalReturnCode = techCode,
                    NumSegments         = numSegments,
                    SegmentNumber       = segmentNo,
                    LastSegment         = lastSegment ?? true,
                    TransactionId       = [email protected] == null?null:Convert.ToBase64String([email protected]),
                    Phase      = transPhase,
                    ReportText = ebr.header.mutable.ReportText
                };

                s_logger.LogDebug("DeserializeResponse: {response}", dr);
                return(dr);
            }
        }
Beispiel #4
0
 protected void UpdateResponse(Response resp, DeserializeResponse dr)
 {
     resp.BusinessReturnCode  = dr.BusinessReturnCode;
     resp.TechnicalReturnCode = dr.TechnicalReturnCode;
     resp.ReportText          = dr.ReportText;
 }