zemuldo / iso_8583

:credit_card::moneybag: JavaScript library for iso 8583 messaging. Handles message validation & conversion between interfaces using iso 8583 standard. Contributors are welcome.
https://zemuldo.github.io/iso_8583/
MIT License
89 stars 54 forks source link

Bitmap 32 #36

Closed msaphira closed 5 years ago

msaphira commented 5 years ago

Hello, how can i use .getISOJson() to convert iso with 32 bitmap?

zemuldo commented 5 years ago

Can I see a sample of the iso message you want to convert?

msaphira commented 5 years ago

This is the iso message i get from buffer and i want to convert it to json 70800822000000000000004000000000000001125161336000255301

I think my iso message will look like this after i convert it to json

{ "0":"0800", "7":"1125161336", "11":255, "70":"301" }

But this is what i got { '0': '0800', '3': '040000', '4': '000000000011', '5': '251613360002', '11': '55301' .......

And it looks like the function read my secondary bitmap (17-32) as a data elements.

this is my code:

connection.on('data', function(data) { let iso = new iso8583().getIsoJSON(data); }

zemuldo commented 5 years ago

How are you passing the buffer to getIsoJSON? That method takes a buffer within which the bitmaps must be encoded in hexadecimal while in memory and will take 16 bytes. If you parse the buffer with bitmap encoded in another encoding, 16 bytes will have only the first bitmap. The two bitmaps each 8 bytes will take up 16 bytes. Solution: parse the buffer as you get from the source. If you need to convert a string like the one above, this library doesn't support. However if that's how your interface has to receive data, we can help u decode.

msaphira commented 5 years ago

i'm using another library (socketQueue - https://github.com/juks/SocketQueue) to pass the buffer and it works when i use JReactive-8583 library (based in java - https://github.com/kpavlov/jreactive-8583). Now i'm trying to do it in node js. Can you give me example how to parse the buffer after i get it from the source? Thank you :)

zemuldo commented 5 years ago

I have checked socketQueue - https://github.com/juks/SocketQueue, Here is what I have to say. When using data from another source, the data must be encoded such that 2 bytes containe tcp length header indicator, 4 bytes contain the mti and next 16 bytes contain the bitmaps. Its also possible to have only 8 byte mti.

Here is an example from socketqueue example without leng indicator and only primary bitmap

msg = new Buffer('303830302220010000800000393930303030303832333135313731363030303030313833313030303030303031', 'hex');

Now parsing this using our iso package, you have to set lenHeader and secondary bitmap to false.

console.log(myIsoPack.getIsoJSON(msg, {lenHeader: false, }))

This gives

{ '0': '0800',
  '3': '990000',
  '7': '0823151716',
  '11': '000001',
  '24': '831',
  '41': '00000001' }
zemuldo commented 5 years ago

You have to check how the data you receive is encoded before the mti. That way i can help.

msaphira commented 5 years ago

So this library cannot have secondary bitmap? which means that i cannot use data fields from 65-128?

If this library can have a secondary bitmap, would you please give me an example of buffer message with secondary bitmap?

i already tried the example you gave but i got an error message 'failed to unpack at get mti' .

thank you for your help :)

zemuldo commented 5 years ago

It supports both bitmaps. Versions below 2.5.7 do not support primary bitmap without secondary bitmap. Here is a buffer with both bitmaps

<Buffer 00 26 31 32 30 30 c0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 31 36 34 37 36 31 37 33 39 30 30 31 30 31 30 31 31 39>

And here is a buffer with only primary

<Buffer 30 38 30 30 22 20 01 00 00 80 00 00 39 39 30 30 30 30 30 38 32 33 31 35 31 37 31 36 30 30 30 30 30 31 38 33 31 30 30 30 30 30 30 30 31>
zemuldo commented 5 years ago

To make things work, you have to ensure the buffer has a 2 byte length indicator before the mti. If your message starts with the mti then you have to disable the length indicator. check docs for that.

msaphira commented 5 years ago

i'm still a bit confuse about this,

This is my buffer with secondary bitmap <Buffer 00 37 30 38 30 30 38 32 32 30 30 30 30 30 30 30 30 30 30 30 30 30 30 34 30 30 30 30 30 30 30 30 30 30 30 30 30 30 31 32 31 32 30 31 31 38 34 33 30 30 ... >

it's already shown the two bytes of length indicator --> 00 37, and four bytes of mti --> 30 38 30 30

but how can i convert my 32 bytes bitmap to 16 bytes bitmap which contain primary and secondary bitmap?

should i encode all the iso message with Buffer.from(message, 'hex') or just encode the bitmap with Buffer.from(bitmap, 'hex') ?

msaphira commented 5 years ago

i already found a way to convert my incoming buffer. Thank you for your help! :)

zemuldo commented 5 years ago

That is very nice to hear. Very welcome. You can post how you converted to help someone else who may have the same problem. :-)

On Wed, Dec 12, 2018, 12:09 PM msaphira <notifications@github.com wrote:

i already found a way to convert my incoming buffer. Thank you for your help! :)

— You are receiving this because you were assigned. Reply to this email directly, view it on GitHub https://github.com/zemuldo/iso_8583/issues/36#issuecomment-446514615, or mute the thread https://github.com/notifications/unsubscribe-auth/ATB9ZaiFVhEhl-ePRHIK4Lh4vNs6E5L3ks5u4Me-gaJpZM4YxwCz .

msaphira commented 5 years ago
  1. i convert the buffer into string
  2. then i convert it again into buffer which encoded by 'hex'

can i ask you how to convert bitmap into iso 8583 with primary bitmap only?

and i want to know if i can convert buffer into json with custom format? can you give me an example of this? i already tried let message = new iso8583(customFormats).getIsoJson(data);

but nothing change, i still have the default format. Thank you!

zemuldo commented 5 years ago

I will give you an example here

zemuldo commented 5 years ago

@msaphira Are you still having this issue?

msaphira commented 5 years ago

I already solve the issue, thank you :)

On Thu, May 9, 2019, 1:31 PM Danstan Otieno Onyango < notifications@github.com> wrote:

Are you still having this issue?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/zemuldo/iso_8583/issues/36#issuecomment-490761992, or mute the thread https://github.com/notifications/unsubscribe-auth/AKHHUMTJHFKOBGKS2ZJJ5NTPUPAKNANCNFSM4GGHACZQ .

zemuldo commented 5 years ago

Awesome! You can always post the solution here for someone else who may face a similar issue.