Exemple #1
0
        private ProcessConfigResponseType MakeRequest(ExecuteRequestType execRequest)
        {
            var service = InitService();

            if (service == null)
            {
                Log.Error("Auth service problems, please check");
                throw new AuthenticationException("Auth problems, please see log.");
            }
            return(service.ExecuteRequestOperation(execRequest));
        }
Exemple #2
0
        //-----------------------------------------------------------------------------------
        public AccountVerificationResults AccountVerificationForcedWithCustomAddress(string foreName, string middleName, string surname,
                                                                                     string gender, DateTime birth,
                                                                                     string houseNumber, string houseName, string street, string district,
                                                                                     string town, string county, string postCode,
                                                                                     string branchCode, string accountNumber, int customerId, string xmlForDebug = "")
        {
            var result = new AccountVerificationResults();

            var key = String.Format("{0}_{1}", branchCode, accountNumber);

            var address = new AddressType
            {
                AddressStatus = AddressStatusType.Current,
                TypeOfAddress = TypeOfAddressType.UK,
                AddressDetail = new AddressDetailType
                {
                    PostCode    = postCode,
                    HouseNumber = houseNumber,
                    HouseName   = houseName,
                    Address1    = street,
                    Address2    = district,
                    Address3    = town,
                    Address4    = county,
                    Country     = "GB"
                }
            };
            //BWA
            var execRequestBwa = new ExecuteRequestType
            {
                EIHHeader = new EIHHeaderType
                {
                    ClientUser  = "******",
                    ReferenceId = "1234"
                },
                ResponseType           = ResponseType.Detail,
                ProcessConfigReference = new ProcessConfigReferenceType {
                    ItemElementName = ItemChoiceType.ProcessConfigName, Item = "BWA"
                },
                Consent      = ConsentType.Yes,
                PersonalData = new PersonalDataType
                {
                    Name = new NameType
                    {
                        Forename   = foreName,
                        Surname    = surname,
                        MiddleName = middleName
                    },
                    BirthDate          = birth,
                    BirthDateSpecified = true,
                    GenderSpecified    = true
                },
                Addresses       = new[] { address },
                BankInformation = new BankInformationType
                {
                    CheckContext          = CheckContextType.DirectCredit,
                    CheckContextSpecified = true,
                    AccountReference      = new[]
                    {
                        new AccountReferenceType {
                            TypeOfReference = TypeOfReferenceType.BankBranchCode, Reference = branchCode, ReferenceIndex = "1"
                        },
                        new AccountReferenceType {
                            TypeOfReference = TypeOfReferenceType.AccountNumber, Reference = accountNumber, ReferenceIndex = "2"
                        }
                    }
                }
            };

            execRequestBwa.PersonalData.Gender = gender == "M" ? GenderType.Male : GenderType.Female;

            try
            {
                ProcessConfigResponseType r;
                if (string.IsNullOrEmpty(xmlForDebug))
                {
                    try
                    {
                        r = MakeRequest(execRequestBwa);
                    }
                    catch (AuthenticationException exception)
                    {
                        result.Error = exception.Message;
                        return(result);
                    }
                }
                else
                {
                    r = GetRequestFromXml(xmlForDebug);
                }

                var writeLog = Utils.WriteLog(execRequestBwa, r, ExperianServiceType.Bwa, customerId);
                _bankCacheRepository.Set(key, r, writeLog.ServiceLog);

                result.Parse(r);
            }
            catch (Exception exception)
            {
                Log.Error(exception);
                result.Error = exception.Message;
                Utils.WriteLog(execRequestBwa, string.Format("Excecption: {0}", exception.Message), ExperianServiceType.Bwa, customerId);
            }

            return(result);
        }
Exemple #3
0
        //-----------------------------------------------------------------------------------
        public AccountVerificationResults AccountVerification(string foreName, string middleName, string surname, string gender, DateTime birth, string addressLine1, string addressLine2, string addressLine3, string town, string county, string postCode, string branchCode, string accountNumber, int customerId, bool checkInCacheOnly = false, string xmlForDebug = "")
        {
            var result = new AccountVerificationResults();

            var key = String.Format("{0}_{1}", branchCode, accountNumber);

            Log.DebugFormat("Checking key '{0}' in cache...", key);
            var cachedValue = _bankCacheRepository.Get <ProcessConfigResponseType>(key, null);

            if (cachedValue != null && string.IsNullOrEmpty(xmlForDebug))
            {
                Log.DebugFormat("Will use cache value for key '{0}'", key);
                result.Parse(cachedValue);
                return(result);
            }
            if (checkInCacheOnly)
            {
                return(null);
            }

            var address = FillAddress(addressLine1, addressLine2, addressLine3, town, county, postCode);
            //BWA
            var execRequestBwa = new ExecuteRequestType
            {
                EIHHeader = new EIHHeaderType
                {
                    ClientUser  = "******",
                    ReferenceId = "1234"
                },
                ResponseType           = ResponseType.Detail,
                ProcessConfigReference = new ProcessConfigReferenceType {
                    ItemElementName = ItemChoiceType.ProcessConfigName, Item = "BWA"
                },
                Consent      = ConsentType.Yes,
                PersonalData = new PersonalDataType
                {
                    Name = new NameType
                    {
                        Forename   = foreName,
                        Surname    = surname,
                        MiddleName = middleName
                    },
                    BirthDate          = birth,
                    BirthDateSpecified = true,
                    GenderSpecified    = true
                },
                Addresses       = new[] { address },
                BankInformation = new BankInformationType
                {
                    CheckContext          = CheckContextType.DirectCredit,
                    CheckContextSpecified = true,
                    AccountReference      = new[]
                    {
                        new AccountReferenceType {
                            TypeOfReference = TypeOfReferenceType.BankBranchCode, Reference = branchCode, ReferenceIndex = "1"
                        },
                        new AccountReferenceType {
                            TypeOfReference = TypeOfReferenceType.AccountNumber, Reference = accountNumber, ReferenceIndex = "2"
                        }
                    }
                }
            };

            execRequestBwa.PersonalData.Gender = gender == "M" ? GenderType.Male : GenderType.Female;

            try
            {
                ProcessConfigResponseType r;
                if (string.IsNullOrEmpty(xmlForDebug))
                {
                    try
                    {
                        r = MakeRequest(execRequestBwa);
                    }
                    catch (AuthenticationException exception)
                    {
                        result.Error = exception.Message;
                        return(result);
                    }
                }
                else
                {
                    r = GetRequestFromXml(xmlForDebug);
                }
                var writeLog = Utils.WriteLog(execRequestBwa, r, ExperianServiceType.Bwa, customerId);
                _bankCacheRepository.Set(key, r, writeLog.ServiceLog);

                result.Parse(r);
            }
            catch (Exception exception)
            {
                Log.Error(exception);
                result.Error = exception.Message;
                Utils.WriteLog(execRequestBwa, string.Format("Excecption: {0}", exception.Message), ExperianServiceType.Bwa, customerId);
            }

            return(result);
        }
Exemple #4
0
        //-----------------------------------------------------------------------------------
        public AuthenticationResults Authenticate(string foreName, string middleName, string surname, string gender, DateTime birth, string addressLine1, string addressLine2, string addressLine3, string town, string county, string postCode, int customerId, bool checkInCacheOnly = false, string xmlForDebug = "")
        {
            var result = new AuthenticationResults();

            string key = string.Format("{0}_{1}_{2}_{3}", foreName, middleName, surname, postCode);

            if (string.IsNullOrEmpty(xmlForDebug))
            {
                Log.DebugFormat("Checking key '{0}' in cache...", key);

                var cachedResult = amlResultsRepository.GetAll().FirstOrDefault(aml => aml.LookupKey == key && aml.IsActive);

                bool foundInCache = cachedResult != null;
                if (foundInCache)
                {
                    Log.DebugFormat("Will use cache value for key '{0}'", key);

                    result.AuthenticationIndex = cachedResult.AuthenticationIndex;
                    result.AuthIndexText       = cachedResult.AuthIndexText;
                    result.NumPrimDataItems    = cachedResult.NumPrimDataItems;
                    result.NumPrimDataSources  = cachedResult.NumPrimDataSources;
                    result.NumSecDataItems     = cachedResult.NumSecDataItems;
                    result.StartDateOldestPrim = cachedResult.StartDateOldestPrim;
                    result.StartDateOldestSec  = cachedResult.StartDateOldestSec;
                    result.ReturnedHRPCount    = cachedResult.HighRiskRules.Count;
                    if (result.ReturnedHRPCount == 0)
                    {
                        result.ReturnedHRP = new ReturnedHRPType[0];
                    }
                    else
                    {
                        result.ReturnedHRP = cachedResult.HighRiskRules.Select(rule => new ReturnedHRPType {
                            HighRiskPolRuleID = rule.RuleId, HighRiskPolRuleText = rule.RuleText
                        }).ToArray();
                    }
                    result.Error = cachedResult.Error;

                    return(result);
                }
            }
            if (checkInCacheOnly)
            {
                return(null);
            }

            Log.DebugFormat("Request AML A service for key '{0}'", key);
            var address = FillAddress(addressLine1, addressLine2, addressLine3, town, county, postCode);
            //AML A
            var execRequest = new ExecuteRequestType
            {
                EIHHeader = new EIHHeaderType
                {
                    ClientUser  = "******",
                    ReferenceId = "1234"
                },
                ResponseType           = ResponseType.Detail,
                ProcessConfigReference = new ProcessConfigReferenceType {
                    ItemElementName = ItemChoiceType.ProcessConfigName, Item = "AML A"
                },
                Consent      = ConsentType.Yes,
                PersonalData = new PersonalDataType
                {
                    Name = new NameType
                    {
                        Forename   = foreName,
                        MiddleName = middleName,
                        Surname    = surname
                    },
                    BirthDate          = birth,
                    BirthDateSpecified = true,
                    GenderSpecified    = true
                },
                Addresses = new[] { address }
            };

            execRequest.PersonalData.Gender = gender == "M" ? GenderType.Male : GenderType.Female;

            try
            {
                ProcessConfigResponseType r;
                if (string.IsNullOrEmpty(xmlForDebug))
                {
                    try
                    {
                        r = MakeRequest(execRequest);
                    }
                    catch (AuthenticationException exception)
                    {
                        result.Error = exception.Message;
                        return(result);
                    }
                }
                else
                {
                    r = GetRequestFromXml(xmlForDebug);
                }
                var res = Utils.WriteLog(execRequest, r, ExperianServiceType.Aml, customerId);

                result.Parse(r);

                SaveAmlData(key, res.ServiceLog.Id, res.ServiceLog.InsertDate, result);
            }
            catch (Exception exception)
            {
                Log.Error(exception);
                result.Error = exception.Message;
                Utils.WriteLog(execRequest, string.Format("Excecption: {0}", exception.Message), ExperianServiceType.Aml, customerId);
            }

            return(result);
        }
Exemple #5
0
        //-----------------------------------------------------------------------------------
        public AuthenticationResults AuthenticateForcedWithCustomAddress(string foreName, string middleName, string surname, string gender, DateTime birth,
                                                                         string houseNumber, string houseName, string street, string district,
                                                                         string town, string county, string postCode, int customerId, string xmlForDebug = "")
        {
            var result = new AuthenticationResults();

            string key = string.Format("{0}_{1}_{2}_{3}", foreName, middleName, surname, postCode);

            Log.DebugFormat("Request AML A service for key '{0}'", key);
            var address = new AddressType
            {
                AddressStatus = AddressStatusType.Current,
                TypeOfAddress = TypeOfAddressType.UK,
                AddressDetail = new AddressDetailType
                {
                    PostCode    = postCode,
                    HouseNumber = houseNumber,
                    HouseName   = houseName,
                    Address1    = street,
                    Address2    = district,
                    Address3    = town,
                    Address4    = county,
                    Country     = "GB"
                }
            };

            //AML A
            var execRequest = new ExecuteRequestType
            {
                EIHHeader = new EIHHeaderType
                {
                    ClientUser  = "******",
                    ReferenceId = "1234"
                },
                ResponseType           = ResponseType.Detail,
                ProcessConfigReference = new ProcessConfigReferenceType {
                    ItemElementName = ItemChoiceType.ProcessConfigName, Item = "AML A"
                },
                Consent      = ConsentType.Yes,
                PersonalData = new PersonalDataType
                {
                    Name = new NameType
                    {
                        Forename   = foreName,
                        MiddleName = middleName,
                        Surname    = surname
                    },
                    BirthDate          = birth,
                    BirthDateSpecified = true,
                    GenderSpecified    = true
                },
                Addresses = new[] { address }
            };

            execRequest.PersonalData.Gender = gender == "M" ? GenderType.Male : GenderType.Female;

            bool hadException           = false;
            ProcessConfigResponseType r = null;

            try
            {
                if (string.IsNullOrEmpty(xmlForDebug))
                {
                    try
                    {
                        r = MakeRequest(execRequest);
                    }
                    catch (AuthenticationException exception)
                    {
                        result.Error = exception.Message;
                        return(result);
                    }
                }
                else
                {
                    r = GetRequestFromXml(xmlForDebug);
                }
            }
            catch (Exception exception)
            {
                hadException = true;
                Log.Error(exception);
                result.Error = exception.Message;
            }

            try
            {
                if (hadException)
                {
                    Utils.WriteLog(execRequest, string.Format("Excecption: {0}", result.Error), ExperianServiceType.Aml, customerId);
                }
                else
                {
                    var writelog = Utils.WriteLog(execRequest, r, ExperianServiceType.Aml, customerId);

                    result.Parse(r);

                    SaveAmlData(key, writelog.ServiceLog.Id, writelog.ServiceLog.InsertDate, result);
                }
            }
            catch (Exception e)
            {
                Log.ErrorFormat("Exception while saving aml data: {0}", e);
            }

            return(result);
        }