private void ShowVerifyPINOffset() { PINData pinData = new PINData(); QPINInput input = new QPINInput(); try { Array enumPANDataTypeArr = Enum.GetValues(typeof(PANDataType)).OfType <PANDataType>().ToArray(); input.PANDataType = Read_DataType_Input("Enter number or Type for PANDataType:", enumPANDataTypeArr); if (input.PANDataType == "MagTekTrack2Encrypted") { PANDataTrack2 panTrack2 = new PANDataTrack2(); panTrack2.track2 = Read_LongString_Input("Enter Track2 Data:", false); panTrack2.ksn = Read_String_Input("Enter PIN KSN:", false); input.PANData = JsonConvert.SerializeObject(panTrack2); } else { input.PANData = Read_LongString_Input("Enter PAN Data:", false); } Array enumPINDataTypeArr = Enum.GetValues(typeof(PINDataType)).OfType <PINDataType>().ToArray(); input.PINDataType = Read_DataType_Input("Enter PINDataType:", enumPINDataTypeArr); // If you would like to input EPB, KSN for MagTekARQC, remove condition part. if (input.PANDataType != "MagTekARQC") { pinData.epb = Read_String_Input("Enter EPB :", false); pinData.ksn = Read_String_Input("Enter PIN KSN:", false); } if (!string.IsNullOrWhiteSpace(pinData.epb) && !string.IsNullOrWhiteSpace(pinData.ksn)) { input.PINData = JsonConvert.SerializeObject(pinData); } input.RefPINOffset = Read_String_Input("Enter RefPINOffset:", false); input.RefID = Read_String_Input("Enter RefID:", true); Console.WriteLine("Please wait..."); var svc = _serviceProvider.GetService <IQPINClient>(); var result = svc.VerifyPINOffset(input).Result; if (!string.IsNullOrWhiteSpace(result.MagTranID)) { Console.WriteLine("=====================Response Start======================"); Console.WriteLine("Is PinOffset(" + input.RefPINOffset + ") Verified: " + result.Success); Console.WriteLine("MagTranID: " + result.MagTranID); Console.WriteLine("=====================Response End======================"); } } catch (Exception ex) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("Error while VerifyPinOffset : " + ex.Message.ToString()); Console.ForegroundColor = ConsoleColor.White; } }
public async Task <PINOffsetVerificationResponse> VerifyPINOffset(QPINInput input) { string name = Constants.QPIN_URL_VERIFY_PINOFFSET; string urlName = _config.GetValue <string>(name); Uri Host = new Uri(urlName); HttpClient client = GenerateHttpClient(); PINOffsetVerificationResponse pinoffsetVerifyResp = new PINOffsetVerificationResponse(); try { string sc = JsonConvert.SerializeObject(input); using (StringContent strContent = new StringContent(sc, Encoding.UTF8, "application/json")) { HttpResponseMessage response = client.PostAsync(Host, strContent).Result; PrintOutRequestResponse(response, sc); if (response.StatusCode == System.Net.HttpStatusCode.OK) { HttpContent content = response.Content; string pinOffset = await content.ReadAsStringAsync(); Console.WriteLine(TryFormatJson(pinOffset)); if (pinOffset.Contains("\\", StringComparison.Ordinal)) { pinOffset = JsonConvert.DeserializeObject <string>(pinOffset); } pinoffsetVerifyResp = JsonConvert.DeserializeObject(pinOffset, typeof(PINOffsetVerificationResponse)) as PINOffsetVerificationResponse; } else { string content = response.Content.ReadAsStringAsync().Result; var err = JsonConvert.DeserializeObject(content, typeof(QwickPINError)) as QwickPINError; Console.WriteLine("Error Code: " + err.Code + ", Error Message: " + err.Message); } } } catch (Exception ex) when(ex is CommunicationException || ex is ProtocolException || ex is FaultException || ex is Exception) { throw ex; } finally { client.Dispose(); } return(pinoffsetVerifyResp); }