How To Parse and Find TLV Message (EMV Data) Using JPOS 1.x

On my previous article I already show you simple method to parse TLV message using JPOS version 2.x. In this article, I change the JPOS version to 1.x. Since the ISOMsg class does not have getBytes() method to the specific data element, we need new method to get bytes of data element that has TLV data.

//this is method to change String to array of byte
private byte[] stringtoArByte(String value) {
	byte[] hasil = new byte[value.length()];
	for (int i = 0; i < value.length(); i++) {
		hasil[i] = (byte) value.charAt(i);
	return hasil;

//method to print all EMV Data
public void printData(ISOMsg isoMsg){
    //EMV data on DE55
    if (iSOMsg.hasField(55)) {
        TLVList tlvData = new TLVList();
        for (TLVMsg tLVMsg : tlvData.getTags()) {
            System.out.println("EMVtag : " + Integer.toHexString(tLVMsg.getTag()));
            System.out.println("Value on String Type : " + ISOUtil.hexString(tLVMsg.getValue()));

If you want to get value from specific tag, this is the sample example.

public boolean hasTag(int tag){
	return tlvData.findIndex(tag) > -1;

//value of tag use hexaint 
//example for PAN Sequence Number, you use 0x5F34
public void printSpecificTag(int tag, TLVList tlvData){
	String toPrint = "No Data..!!";
		toPrint = "Value from tag " + Integer.toHexString(tag) + " : " + tlvData.find(tag).getValue()

Hope this simpel article can help 🙂

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s