Beispiel #1
0
 internal static DirectoryResponse Parse(string xml, ILogger logger)
 {
     try
     {
         var dirRes = DirectoryRes.Deserialize(xml);
         return(new DirectoryResponse(dirRes, xml));
     }
     catch (Exception e1)
     {
         logger.LogError(e1, e1.Message);
         try
         {
             var errRes = AcquirerErrorRes.Deserialize(xml);
             return(new DirectoryResponse(errRes, xml));
         }
         catch (Exception e2)
         {
             logger.LogError(e2, e2.Message);
             return(new DirectoryResponse(e1)
             {
                 RawMessage = xml
             });
         }
     }
 }
        private DirectoryResponse(DirectoryRes dirRes, string xml) : base(xml)
        {
            DirectoryDateTimestamp = dirRes.Directory.directoryDateTimestamp;

            Issuers = (
                from country in dirRes.Directory.Country
                from issuer in country.Issuer
                select new Issuer
            {
                Country = country.countryNames,
                Id = issuer.issuerID,
                Name = issuer.issuerName
            }).ToArray();
        }
        internal static DirectoryResponse Parse(string xml)
        {
            try
            {
                if (xml.Contains("DirectoryRes"))
                {
                    var dirRes = DirectoryRes.Deserialize(xml);
                    return(new DirectoryResponse(dirRes, xml));
                }

                var errRes = AcquirerErrorRes.Deserialize(xml);
                return(new DirectoryResponse(errRes, xml));
            }
            catch (Exception e)
            {
                return(new DirectoryResponse(e, xml));
            }
        }
Beispiel #4
0
        private DirectoryResponse(DirectoryRes dirRes, string xml)
        {
            Error   = null;
            IsError = false;
            DirectoryDateTimestamp = dirRes.Directory.directoryDateTimestamp;
            DebtorBanks            = new List <DebtorBank>();
            RawMessage             = xml;

            foreach (var country in dirRes.Directory.Country)
            {
                foreach (var issuer in country.Issuer)
                {
                    DebtorBanks.Add(new DebtorBank
                    {
                        DebtorBankCountry = country.countryNames,
                        DebtorBankId      = issuer.issuerID,
                        DebtorBankName    = issuer.issuerName
                    });
                }
            }
        }
        /// <summary>
        /// Retrieves both the short list and the long list of issuers.
        /// </summary>
        /// <returns><see cref="Issuers" /> containing the long list and short list of issuers, and the datetime stamp of the last change to the lists.</returns>
        /// <exception cref="XmlSchemaValidationException">Request Xml does not comply with schema.</exception>
        /// <exception cref="IDealException">Respons from iDEAL contains an error.</exception>
        /// <exception cref="ConfigurationErrorsException">Errors in configuration file.</exception>
        /// <exception cref="WebException">Error getting reply from acquirer.</exception>
        /// <exception cref="CryptographicException">Error using client certificate.</exception>
        public Issuers GetIssuerList()
        {
            if (traceSwitch.TraceInfo)
            {
                TraceLine("Start of GetIssuerList()");
            }

            DirectoryReq request = CreateRequest <DirectoryReq>();

            request.Merchant = CreateMerchant <DirectoryReqMerchant>();

            // Serialize the request to an XML string
            string xmlRequest = SerializationHelper.SerializeObject <DirectoryReq>(request);

            var xmlDoc = new XmlDocument();

            xmlDoc.LoadXml(xmlRequest);

            var signatureElement = XmlSignature.XmlSignature.Sign(ref xmlDoc, GetMerchantRSACryptoServiceProvider(), merchantConfig.ClientCertificate.Thumbprint);

            xmlRequest = xmlDoc.OuterXml;

            // Validate the request before sending it to the service
            ValidateXML(xmlRequest);

            // Send request / get respons
            string xmlResponse = GetReplyFromAcquirer(xmlRequest, merchantConfig.acquirerUrlDIR);

            // Validate respons
            ValidateXML(xmlResponse);

            if (!XmlSignature.XmlSignature.CheckSignature(xmlResponse, (RSA)merchantConfig.aquirerCertificate.PublicKey.Key))
            {
                if (traceSwitch.TraceInfo)
                {
                    TraceLine("Xml response was not well signed " + xmlResponse);
                }
                throw new ArgumentException("Response from server is not well signed");
            }

            if (traceSwitch.TraceInfo)
            {
                TraceLine("Response from get issuer list was : " + xmlResponse);
            }

            // Check respons for errors
            CheckError(xmlResponse, Resources.iDealUnavailable);

            DirectoryRes response = (DirectoryRes)SerializationHelper.DeserializeObject <DirectoryRes>(xmlResponse);

            // Create the return object and initialze it with the iDEAL respons Directory
            var issuers = new Issuers(response.Directory);

            if (traceSwitch.TraceInfo)
            {
                TraceLine("End of GetIssuerList()");
            }
            if (traceSwitch.TraceVerbose)
            {
                TraceLine(Format("Returnvalue: {0}", issuers.ToString()));
            }

            return(issuers);
        }