using System; using System.Collections.Generic; using Experian.Payments.BankWizardHosted; ... /// 1. Create and populate a ValidateRequest instance. In this example a 'gb' validation request is populated with sort code 070116 and account number 00006555. ValidateRequest validationRequest = new ValidateRequest(); validationRequest.itemisationID = "User defined -> Branch id"; validationRequest.reportString = "User defined -> User ID"; validationRequest.language = "en"; validationRequest.ISOCountry = "gb"; validationRequest.checkingLevel = CheckingLevel.Account; validationRequest.BBAN = new BBANBaseType[] { new BBANBaseType() { index = "1", Value = "070116" }, new BBANBaseType() { index = "2", Value = "00003036" } }; /// 2. Create a new service proxy. Change the hostedServiceURL to the URL supplied by Experian. using (BankWizard_v1_0_Service hostedService = new BankWizard_v1_0_Service()) { hostedService.Url = "bankwizardhosted url"; hostedService.Timeout = 5000; /// 3. To access the SoapContext see the files provided in Service\src. The first argument in the WASPToken constructor comes from a successful WASP authentication request. hostedService.RequestSoapContext.Security.Tokens.Add(new WASPToken(token)); hostedService.RequestSoapContext.Security.MustUnderstand = false; /// 4. Perform validation. ValidateResponse validationResponse = hostedService.Validate(validationRequest); /// 5. How to check to see if there were errors. List<Condition> conditions = new List<Condition>(validationResponse.conditions); if (!conditions.Exists(c => c.severity == ConditionSeverity.error)) { /// 6. How to find BBAN fields which have been transposed. List<BBANBaseType> responseBBans = new List<BBANBaseType>(validationResponse.BBAN); responseBBans.ForEach(responseBBan => { List<BBANBaseType> requestBBans = new List<BBANBaseType>(validationRequest.BBAN); BBANBaseType requestBBan = requestBBans.Find(b => b.index == responseBBan.index); if (requestBBan != null && !requestBBan.Value.Equals(responseBBan.Value)) Console.WriteLine("Transposed BBAN Field : " + responseBBan.index + " " + responseBBan.Value); }); /// 7. Process the results. In this example, output to the console. Console.WriteLine("IBAN : " + validationResponse.IBAN); Console.WriteLine("Data Access Key : " + validationResponse.dataAccessKey); } else { /// 8. What errors were generated during the validation call? conditions.ForEach(c => { if (c.severity == ConditionSeverity.error) Console.WriteLine(c.severity + "[" + c.code + "] " + c.Value); }); } } |