Has anyone implemented the messaging iso8583 for Amex? I have a port and ip, but when I send an echo message (1804) with a socket it does not answer anything ... The Encoding is EBCDIC. Does anyone have an example? The code is in C#
Console.WriteLine("Send Message Echo...");
ManageConnection.ManageSocket _manage = new ManageConnection.ManageSocket(IpAmex, PortAmex);
TupleList<Encoding, string> _request = new TupleList<Encoding, string>();
_request.Add(Encoding.GetEncoding(500), "1804");
_request.Add(Encoding.UTF8, "2030018000000000");
_request.Add(Encoding.GetEncoding(500), "000000");
_request.Add(Encoding.GetEncoding(500), "112233");
_request.Add(Encoding.GetEncoding(500), "1709141205108318700");
var _response = _manage.SendMessageSocket(_request);
return _response;
public string SendMessageSocket(TupleList<Encoding, string> _messages) {
string _return = String.Empty;
try
{
byte[] bytes = new byte[65000];
IPAddress ipAddress = IPAddress.Parse(IP);
IPEndPoint remoteEP = new IPEndPoint(ipAddress, Port);
Socket sender = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
sender.Connect(remoteEP);
Console.WriteLine("Enviando mensaje....");
var bytesMessage = GetCompleteMessage(_messages);
// This function GetCompleteMessage= byte[] bytesMessage = { 241, 248, 240, 244, 32, 48, 1, 128, 0, 0, 0, 0, 240, 240, 240, 240, 241, 241, 241, 242, 242, 243, 243, 241, 247, 240, 249, 241, 244, 241, 242, 240, 245, 241, 240, 248, 243, 241,248, 247, 240, 240 };
int bytesSent = sender.Send(bytesMessage);
Console.WriteLine("Esperando respuesta....");
int bytesRec = sender.Receive(bytes); //Here don't receive nothing
int len = Array.IndexOf(bytes, byte.MinValue);
var responseString = Encoding.UTF8.GetString(bytes, byte.MinValue, len);
sender.Shutdown(SocketShutdown.Both);
sender.Close();
return xmlResponseString;
}
catch (Exception ex)
{
throw;
}
}
The message is for the ISO8583 Global Credit Authorization Guide (GCAG),
1. ISO8583-like specifications used by American Express.
They used several customized ISO 8583 dialects, for sample:
- Global Credit Authorization Guide (GCAG),
- Global Electronic Data Capture (GEDC) Terminal Message Specification,
- Plural Interface Processing (PIP) Terminal Interface.
Looking to your MTI 1804 I guess it is GCAG and, yes, the message usually EBCDIC encoded.
From your request is not clear exactly the message body. Please Add the hexadecimal representation of your network message. It could show the potential issue with the message body encoding.
We are supporting online services around ISO8583 dialects and financial data.
Here is the GCAG ISO 8583 message body parser.
You can check the outgoing message structure and your EBCDIC encoding.
2. About American Express hosts.
I could agree that there are many TCP/IP Socket services which may forward and exchange message data with Amex or process message themselves, but in fact Amex uses Global Web Services (GWS) IP Payments Gateway in most cases, which is HTTPS connection with specific HTTP Headers.
Because of HTTP/HTTPS data transferring thru GWS the message, even EBCDIC encoded, processed as ASCII hexadecimal string.
TCP/IP Socket connections may have additional message headers, length bytes, starting and ending packet data. Ensure connection requirements for your TCP/IP host.
As an working example of Amex ISO 8583 message processing with test cards authorizations you can try GCAG host simulator posting your request messages directly thru the form or starting HTTPS host simulator service.
3. Example as a bonus
Here is your 1804 message corrected with primary bitmap processed thru Amex GCAG host simulator. Messages structure represented in YAML.
---
# Cheef's parser.
# Copyright (C) 2008-2017 Alexander Shevelev. https://iso8583.info/
# lib : "/lib/AMEX/GCAG/" - Global Credit Authorization Guide
# tool : "host"
# stat : 28 nodes, 14 lookup tables, 92.86% passed (13/14)
host: # AMEX GCAG host simulator
- rq:#"F1F8F0F42030018000000000F0F0F0F0F0F0F1F1F2F2F3F3F1F7F0F9F1F4..F0F0" # AMEX GCAG message
- MTI: "1804" # Message Type ID. // network management request
- DE000: "2030018000000000" # Primary bitmap // 3.11.12.24.25.
- BM0:#"F0F0F0F0F0F0F1F1F2F2F3F3F1F7F0F9F1F4F1F2F0F5F1F0F8F3F1F8F7F0F0" # Fields at Primary Bitmap
- DE003:#"000000" # PC // System Audit Control/Echo Message
- S01: "00" # Transaction Code. // Goods and service
- S02: "00" # Account, from. // unspecified
- S03: "00" # Account, to. // unspecified
- DE011: "112233" # STAN.
- DE012:#"170914120510" # Date and time, local transaction
- date: "170914" # Date, local transaction. // 2017.09.14
- time: "120510" # Time, local transaction. // 12:05:10
- DE024: "831" # Function code. // echo test.
- DE025: "8700" # Message reason code (MRC).
- rs:#"F1F8F1F42030010002000000F0F0F0F0F0F0F1F1F2F2F3F3F1F7F0F9F1F4..F0F0" # AMEX GCAG message
- MTI: "1814" # Message Type ID. // network management request response
- DE000: "2030010002000000" # Primary bitmap // 3.11.12.24.39.
- BM0:#"F0F0F0F0F0F0F1F1F2F2F3F3F1F7F0F9F1F4F1F2F0F5F1F0F8F3F1F0F0F0" # Fields at Primary Bitmap
- DE003:#"000000" # PC // System Audit Control/Echo Message
- S01: "00" # Transaction Code. // Goods and service
- S02: "00" # Account, from. // unspecified
- S03: "00" # Account, to. // unspecified
- DE011: "112233" # STAN.
- DE012:#"170914120510" # Date and time, local transaction
- date: "170914" # Date, local transaction. // 2017.09.14
- time: "120510" # Time, local transaction. // 12:05:10
- DE024: "831" # Function code. // echo test.
- DE039: "000" # Action Code // approved.
I don't understand C#, but I implemented AMEX in JAVA. I guess you shouldn't encode bitmap in EBCDIC, but instead only unhex its content. As the bitmap, I mean '2030018000000000
'.
I hope this will help.
Message needs to contain the two-bytes describing the length of the message content. The said two bytes were missing from the message.