static void ParseResponse() { Console.Clear(); Console.WriteLine("Enter Payload :: "); var payload = Console.ReadLine(); var iso = new Iso8583Extended(); try { iso.Unpack(Encoding.UTF8.GetBytes(payload), 0); Console.WriteLine(iso.ToString()); } catch (Exception ex) { Console.WriteLine(ex.InnerException?.Message ?? ex.Message); } }
static void MakeRequest() { Console.Clear(); Console.WriteLine("Enter HOST IP :: "); var hostIp = Console.ReadLine(); Console.WriteLine("Enter HOST PORT :: "); var hostPort = Console.ReadLine(); Console.WriteLine("Enter Payload :: "); var payload = Console.ReadLine(); try { using var tcpClient = new TcpClient(); tcpClient.Connect(String.IsNullOrEmpty(hostIp) ? "196.46.20.30" : hostIp, int.TryParse(hostPort, out int port) ? port : 5334); //"196.46.20.30": 5334 using var client = tcpClient.GetStream(); var requestPayload = new List <byte> { (byte)(payload.Length / 256), (byte)(payload.Length % 256) }; requestPayload.AddRange(Encoding.UTF8.GetBytes(payload)); var responsePayload = new byte[1024]; client.Write(requestPayload.ToArray()); client.ReadTimeout = 30000; int totalRead = client.Read(responsePayload); if (totalRead > 30) { Console.WriteLine(Encoding.UTF8.GetString(responsePayload)); var iso = new Iso8583Extended(); iso.Unpack(responsePayload, 2); Console.WriteLine(iso.ToString()); } } catch (Exception ex) { Console.WriteLine(ex.InnerException?.Message ?? ex.Message); } }
public static byte[] Compose(Transactions transType, string transTime) { var isoMsg = new Iso8583Extended { MessageType = Iso8583.MsgType._0800_NWRK_MNG_REQ }; isoMsg[Iso8583.Bit._011_SYS_TRACE_AUDIT_NUM] = transTime.Substring(0, 6); isoMsg[Iso8583.Bit._012_LOCAL_TRAN_TIME] = transTime.Substring(4); isoMsg[Iso8583.Bit._013_LOCAL_TRAN_DATE] = transTime.Substring(0, 4); isoMsg[Iso8583.Bit._007_TRAN_DATE_TIME] = transTime; isoMsg[Iso8583.Bit._041_CARD_ACCEPTOR_TERMINAL_ID] = "201116FH"; string processingCode = string.Empty; switch (transType) { case Transactions.MasterKey: processingCode = "9A0000"; break; case Transactions.SessionKey: processingCode = "9B0000"; break; case Transactions.PinKey: processingCode = "9G0000"; break; case Transactions.Parameter_Download: processingCode = "9C0000"; isoMsg[Iso8583Rev93.Bit._062_HOTCARD_CAPACITY] = "010083K226873"; isoMsg[Iso8583Rev93.Bit._064_MAC] = "5636DAB244449CD855CAA894C9C488F0C8855784C41F0D2CEB2ED1C5BAC89B84"; /* * [064] = > 5636DAB244449CD855CAA894C9C488F0C8855784C41F0D2CEB2ED1C5BAC89B84 */ break; case Transactions.End_Of_Day: processingCode = "9H0000"; break; case Transactions.Call_Home: processingCode = "9D0000"; isoMsg[Iso8583Rev93.Bit._062_HOTCARD_CAPACITY] = "010083K226873090083K226873100032.1"; /* * [064] = > 99514FA43D3080399D081BC041986E10F03B3D8F9748C1BBA075DEDDA3606B12 */ break; case Transactions.Fnx_Tnx: processingCode = "000000"; /* * F:Logger.c|L:00041| [000] = > 0200 * * F:Logger.c|L:00041| [002] = > 5061230122647035089 * * F:Logger.c|L:00041| [003] = > 000000 * * F:Logger.c|L:00041| [004] = > 000000000200 * * F:Logger.c|L:00041| [007] = > 1106153049 * * F:Logger.c|L:00041| [011] = > 002792 * * F:Logger.c|L:00041| [012] = > 153049 * * F:Logger.c|L:00041| [013] = > 1106 * * F:Logger.c|L:00041| [014] = > 2012 * * F:Logger.c|L:00041| [018] = > 5999 * * F:Logger.c|L:00041| [022] = > 051 * * F:Logger.c|L:00041| [023] = > 000 * * F:Logger.c|L:00041| [025] = > 00 * * F:Logger.c|L:00041| [026] = > 12 * * F:Logger.c|L:00041| [028] = > D00000000 * * F:Logger.c|L:00041| [032] = > 506123 * * F:Logger.c|L:00041| [035] = > 5061230122647035089D2012601002857591 * * F:Logger.c|L:00041| [037] = > 872834768553 * * F:Logger.c|L:00041| [040] = > 601 * * F:Logger.c|L:00041| [041] = > 2035F273 * * F:Logger.c|L:00041| [042] = > 2011LA024839532 * * F:Logger.c|L:00041| [043] = > POS COLLECTIONS ACCO LA LANG * * F:Logger.c|L:00041| [049] = > 566 * * F:Logger.c|L:00041| [055] = > 820258008407A0000003710001950502800080009A032011069C01005F2A0205665F3401009F02060000000002009F03060000000000009F0607A00000037100019F090200029F10200FA501A239F8000000000000000000000F0100000000000000000000000000009F1A0205669F1E08334B3232363837339F26082467965B2C7E08BF9F2701809F3303E0F8C89F34034103029F3501229F3602013A9F3704C882A0E99F4104000027928E0E0000C35000000000410342031F069F530152 * * F:Logger.c|L:00041| [123] = > 51011151134C101 * * F:Logger.c|L:00041| [128] = > 49D0688BA785842A896FB9E0F2D2C3BA142D42AB34F166B403D54B4880709445 */ break; } isoMsg[Iso8583.Bit._003_PROC_CODE] = processingCode; //isoMsg[Iso8583Rev93.Bit._062_HOTCARD_CAPACITY] = serialNumber; Console.WriteLine(isoMsg.ToString()); var isoMessage = new List <byte> { (byte)(isoMsg.PackedLength / 256), (byte)(isoMsg.PackedLength % 256) }; isoMessage.AddRange(isoMsg.ToMsg()); return(isoMessage.ToArray()); }
private static void BuildRequest() { var isoMsg = new Iso8583Extended() { MessageType = Iso8583Extended.MsgType._0800_NWRK_MNG_REQ }; var dataValues = new Dictionary <Int32, String> { { 002, "5399237081652147" }, { 003, "000000" }, { 004, "000000000100" }, { 007, "1125160355" }, { 011, "145279" }, { 012, "160355" }, { 013, "1125" }, { 014, "2309" }, { 018, "5999" }, { 022, "051" }, { 023, "001" }, { 025, "00" }, { 026, "12" }, { 028, "D00000000" }, { 032, "539923" }, { 035, "5399237081652147D2309221013721179" }, { 037, "948927272738" }, { 040, "221" }, { 041, "201116FH" }, { 042, "2011LA024839532" }, { 043, "XPRESSPAYMENTSOLUTIO LA LANG" }, { 049, "566" }, { 055, "820239008407A0000000041010950500000080009A032011259C01005F2A0205665F3401009F02060000000001009F03060000000000009F0607A00000000410109F090200029F10120110A74003020400000000000000000000FF9F1A0205669F1E0830303030303030319F2608807F37AEE936F44C9F2701809F3303E0F8489F34034403029F3501229F3602047E9F3704C35F28659F4104000000019F5301528E14000000000000000042014403410342031E031F03" }, { 123, "51011151134C101" }, { 128, "0534799F87905513443E246E5CB3D42F3D052CBD508856ED1E85F939635CF67F" } }; try { foreach (var item in dataValues) { //isoMsg[item.Key] = item.Value; } while (true) { Console.Clear(); Console.WriteLine("Enter Field Number : "); string fieldNumberV = Console.ReadLine(); Console.WriteLine($"Enter Field {fieldNumberV} value : "); string value = Console.ReadLine(); if (value.Length > 0 && int.TryParse(fieldNumberV, out int fieldNumber)) { isoMsg[fieldNumber] = value; continue; } break; } var built = isoMsg.ToMsg(); Console.Clear(); Console.WriteLine(Encoding.UTF8.GetString(built)); Console.WriteLine(isoMsg.ToString()); } catch (Exception ex) { Console.WriteLine(ex.InnerException?.Message ?? ex.Message); } }