iso-8583-socket-queue icon indicating copy to clipboard operation
iso-8583-socket-queue copied to clipboard

subfield data element management

Open scalpovich opened this issue 5 years ago • 11 comments

Hi Igor, It's possible to manage subfields as tag for some data element? For exemple, field 55 contain many subfields with specific length and format.

FLD           | LENTGH    | VALUE
FLD (055) : (101) :                                                                       .
	> TAG (82  ) ....: [3C00]                                                             .
	> TAG (9F33) ....: [E0F8C8]                                                           .
	> TAG (95  ) ....: [0080008000]

Kindly assist

scalpovich avatar Dec 05 '19 13:12 scalpovich

Hi! What do you mean by "managing"? A callback function?

juks avatar Dec 06 '19 10:12 juks

Hi, Something like way to define each subfields as you implemented for ISO fields fields before packing the iso message . Cause according to somes host specifications for VISA or others there as some subfields by each fields like fields 48, fields 55 etc...

scalpovich avatar Dec 06 '19 13:12 scalpovich

Well, made an improvement.

Two new methods to mind:

  1. Before the whole packet is packed: https://github.com/juks/iso-8583-socket-queue/blob/0ceaa81efcce51536f41a1b4cf12702f21e3a345/lib/iso8583/lib/packager/smartVista.js#L440
  2. Before each field is packed: https://github.com/juks/iso-8583-socket-queue/blob/0ceaa81efcce51536f41a1b4cf12702f21e3a345/lib/iso8583/lib/packager/smartVista.js#L114

juks avatar Dec 08 '19 16:12 juks

Hi igor. thanks for your feedback. I'm afraid to not understand your implementation. Kindly provide an use case for exploitation. I mean an example for field 55

scalpovich avatar Dec 09 '19 09:12 scalpovich

You should do like so for the field definition:

  '55': {
    length: 255,
    name:   'EMV Data',
    type:   'll-bin-char',
    alias:  '',
    beforePack: function(fieldValue) {
        // Work with tags (TLV) values here
        return fieldValue;
    }
  },

If your message has no field 55 and you want to add it explicitly, you may use the following code inbeforeBack method:

  beforePack: function(data) {
    data['55'] = Buffer.from('9f2608571f1e10d4fa4aac9f2701809f100706010a03a4b8029f37045bb074729f3602000c950500800010009a031508189c01009f02060000000010005f2a02064382023c009f1a0206439f03060000000000009f3303e0f0c89f34034403029f3501229f1e0835313230323831358407a00000000310109f41030000565f340101', 'hex');
    return data;
  }

juks avatar Dec 09 '19 10:12 juks

Thank for your revert. Something like this i it correct?

  '55': {
    length: 255,
    name:   'EMV Data',
    type:   'll-bin-char',
    alias:  '',
    beforePack: function(fieldValue) {
           '9F26': {
              length: 8,
              name:   'Application cryptogram',
              type:   'fixed-b',
               alias:  ''
               }
          return fieldValue;
       }
  },

scalpovich avatar Dec 09 '19 11:12 scalpovich

Unfortunatelly, there is no tag layer abstraction inside the beforePack right now. So what you get there is entire field 55 value, that you need to break into parts and process on your own.

juks avatar Dec 09 '19 11:12 juks

Ok i see So what do you mean by

// Work with tags (TLV) values here

Some example

scalpovich avatar Dec 09 '19 16:12 scalpovich

I mean you have fieldValue variable there, representing the field 55 value. So to alter the EMV tags you need to implement it in this method.

juks avatar Dec 09 '19 18:12 juks

@scalpovich you could implement this: https://www.npmjs.com/package/node-tlv

cavebring avatar Dec 12 '19 18:12 cavebring

@cavebring thanks for the information. I will take a look quickly

scalpovich avatar Dec 12 '19 19:12 scalpovich