I am trying to pack ISO 8583 message using J8583:
IsoMessage m = mf.newMessage(0x200); // You must use 0x200, 0x400, etc.
m.setValue(3, "000000", IsoType.ALPHA, 6);
m.setValue(11, "000001", IsoType.ALPHA, 6);
m.setValue(41, "3239313130303031", IsoType.ALPHA, 16);
m.setValue(60, "001054455354204D45535347", IsoType.ALPHA, 24);
m.setValue(70, "0301", IsoType.ALPHA, 4);
System.out.println(m.debugString());
How should I get the ISO message before sending to the acquiring host?
There are three ways:
writeData
to get the message encoded as a byte array. It will be your responsibility to write this to a socket, with length headers, terminator, etcwriteToBuffer
if you're using java.nio, to get a ByteBuffer. You can pass the size of the length header (2 or 4 bytes usually), or 0 to omit the length header. The resulting ByteBuffer includes the message terminator, if set.write
, to write the message directly to an OutputStream. You can specify the size of the length header and it will also write the terminator (if set), and flush the stream afterwards.