public async Task <bool> VerifyAsync(IdentityVerificationRequest request) { var truliooClient = new TruliooApiClient(_verificationProviderOptions.Username, _verificationProviderOptions.Password); var countryList = await truliooClient.Configuration.GetCountryCodesAsync("Identity Verification"); // todo: Map country iso 3 to country iso 2 code. Abbyy returns iso 3 and Trulioo needs iso 2. var countryCode = countryList.FirstOrDefault(c => c.Equals(request.UserInfo.Nationality)); if (countryCode == null) { throw new Exception($"Provided country code {countryCode} is invalid."); } var verifyRequest = new VerifyRequest { AcceptTruliooTermsAndConditions = true, Demo = true, ConfigurationName = "Identity Verification", CountryCode = countryCode, DataFields = new DataFields { PersonInfo = new PersonInfo { FirstGivenName = request.UserInfo.FirstName, FirstSurName = request.UserInfo.LastName, DayOfBirth = request.UserInfo.DateOfBirth.Day, MonthOfBirth = request.UserInfo.DateOfBirth.Month, YearOfBirth = request.UserInfo.DateOfBirth.Year, Gender = request.UserInfo.Gender }, Passport = new Passport { Mrz1 = request.PassportInfo.Mrz1, Mrz2 = request.PassportInfo.Mrz2, Number = request.PassportInfo.Number, DayOfExpiry = request.PassportInfo.DateOfExpiry.Day, MonthOfExpiry = request.PassportInfo.DateOfExpiry.Month, YearOfExpiry = request.PassportInfo.DateOfExpiry.Year }, } }; var verifyResult = await truliooClient.Verification.VerifyAsync(verifyRequest); return((verifyResult.Errors == null || !verifyResult.Errors.Any()) && verifyResult.Record.RecordStatus.Equals("match")); }
public async Task <bool> VerifyAsync(IdentityVerificationRequest request) { var countryCode = "AU"; // Leveraging the SDK's models instead of re-creating them from scratch. var verifyRequest = new VerifyRequest { AcceptTruliooTermsAndConditions = true, Demo = true, ConfigurationName = "Identity Verification", CountryCode = countryCode, DataFields = new DataFields { PersonInfo = new PersonInfo { FirstGivenName = request.UserInfo.FirstName, FirstSurName = request.UserInfo.LastName, DayOfBirth = request.UserInfo.DateOfBirth.Day, MonthOfBirth = request.UserInfo.DateOfBirth.Month, YearOfBirth = request.UserInfo.DateOfBirth.Year, Gender = request.UserInfo.Gender }, Passport = new Passport { Mrz1 = request.PassportInfo.Mrz1, Mrz2 = request.PassportInfo.Mrz2, Number = request.PassportInfo.Number, DayOfExpiry = request.PassportInfo.DateOfExpiry.Day, MonthOfExpiry = request.PassportInfo.DateOfExpiry.Month, YearOfExpiry = request.PassportInfo.DateOfExpiry.Year }, } }; var payload = JsonConvert.SerializeObject(verifyRequest); var response = await _httpClient.PostAsync("trial/verifications/v1/verify", new StringContent(payload, Encoding.ASCII, "application/json")); // todo: deserialize result to check for match or no match. return(response.IsSuccessStatusCode); }