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
85 stars 50 forks source link

Field 127.25 - Integrated circuit card (ICC) Data - XML support #95

Closed mkevin1993 closed 3 years ago

mkevin1993 commented 3 years ago

Request to add a feature for xml support in field 127.25

The current implementation creates subfields of 127.25 from the data received in field 127. If a subfield is sent separately and not in HEX, the lib breaks.

Example: The following data works well: All subfields are derived from the hex in field 127.

{
  "0": "0200",
  "2": "4761735683548903",
  "3": "000000",
  "4": "000000007834",
  "11": "0000002",
  "14": "2009",
  "18": "7659",
  "22": "051",
  "23": "001",
  "25": "00",
  "26": "12",
  "32": "108600",
  "41": "12000014",
  "42": "TERMINAL_DIGITA",
  "43": "TERMINAL BUSINESS 1 0000000 TEXASUS US  ",
  "49": "404",
  "56": "1510",
  "123": "51010151134C101",
  "127": "000000800000000001567C19517C0000000000000000247900000000000014A00000000310105800BE925"
  }

The elements of subfield 127.25 are parsed correctly because data is in HEX format.

When field 127.25 is sent separately(not parsed from 127) and as XML, parsing breaks

{
  "0": "0200",
  "2": "4761735683548903",
  "3": "000000",
  "4": "000000007834",
  "11": "0000002",
  "14": "2009",
  "18": "7659",
  "22": "051",
  "23": "001",
  "25": "00",
  "26": "12",
  "32": "108600",
  "41": "12000014",
  "42": "TERMINAL_DIGITA",
  "43": "TERMINAL BUSINESS 1 0000000 TEXASUS US  ",
  "49": "404",
  "56": "1510",
  "123": "51010151134C101",
  "127.25": "<IccData><IccRequest><AmountAuthorized>000000002341</AmountAuthorized><AmountOther>000000000000</AmountOther><ApplicationIdentifier>14A0000000031010</ApplicationIdentifier><ApplicationInterchangeProfile>5000</ApplicationInterchangeProfile><ApplicationTransactionCounter>0008</ApplicationTransactionCounter><Cryptogram>D17AC224D703ED03</Cryptogram><CryptogramInformationData>80</CryptogramInformationData><InterfaceDeviceSerialNumber>3332303030303632</InterfaceDeviceSerialNumber><IssuerApplicationData>1406011203A09800</IssuerApplicationData><TerminalApplicationVersionNumber>0096</TerminalApplicationVersionNumber><TerminalVerificationResult>4280000800</TerminalVerificationResult><TransactionCurrencyCode>404</TransactionCurrencyCode><TransactionDate>201008</TransactionDate><TransactionSequenceCounter>800000144</TransactionSequenceCounter><TransactionType>00</TransactionType><UnpredictableNumber>9FACCF09</UnpredictableNumber></IccRequest></IccData>"
}

Below is the stack trace

TypeError: Cannot read property 'LenType' of undefined
    at Main.rebuildExtensions_127_25 (/home/acc/example/node_modules/iso_8583/lib/8583.js:333:27)
    at Main.rebuildExtensions (/home/acc/example/node_modules/iso_8583/lib/8583.js:402:17)
    at Main.module.exports (/home/acc/example/node_modules/iso_8583/lib/pack/assemble127_extensions.js:13:20)
    at Main.assemble0_127_Fields (/home/acc/example/node_modules/iso_8583/lib/pack/assemble0_127_Fields.js:40:38)
    at Main.getBufferMessage (/home/acc/example/node_modules/iso_8583/lib/8583.js:584:30)

Solution suggestion: If field 127.25 is sent/present it should be left as is

Thanks.

zemuldo commented 3 years ago

Could you explain what you mean by If a subfield is sent separately and not in HEX You mean sent with each field but in XML like I see?

mkevin1993 commented 3 years ago

Yes. Field 127.25 specifically. The xml data will include all the sub fields of 127.25 i.e 127.25.2, 127.25.3, 127.25.4, 127.25.5 ... and so on. So if a payload contains field 127.25, there should be no need to parse the respective sub fields.

zemuldo commented 3 years ago

I see so your case you have "127.25" as XML string , Two questions:

mkevin1993 commented 3 years ago

Both yes