TLV
From jPOS.org
Contents |
TLV Support
IMPORTANT NOTICE: As of jPOS 1.5.0, there's new clean TLV support (org.jpos.tlv). See the example below
Let us define some TAGs first
public final static int APPLICATION_EXPIRATION_DATE=0x5F24;
public final static int TERMINAL_COUNTRY_CODE=0x5F1A;
public final static int TXN_CURRENCY_CODE=0x5F2A;
public final static int PSN=0x5F34;
public final static int AIP=0x82;
public final static int AID=0x84;
public final static int TVR=0x95;
public final static int PAN=0x5A;
public final static int TRANSACTION_DATE=0x9A;
public final static int TRANSACTION_TYPE=0x9C;
public final static int AMOUNT=0x9F02;
public final static int AMOUNT_OTHER=0x9F03;
public final static int APPLICATION_VERSION_NUMBER=0x9F09;
public final static int ISSUER_APPLICATION_DATA=0x9F10;
public final static int APPLICATION_CRYPTOGRAM=0x9F26;
public final static int CRYPTOGRAM_INFORMATION_DATA=0x9F27;
public final static int APPLICATION_TRANSACTION_COUNTER=0x9F36;
public final static int UNPREDICTABLE_NUMBER=0x9F37;
Here is some sample data
byte[] pan=ISOUtil.hex2byte("1234560000000017"};
byte[] psn=ISOUtil.hex2byte("01");
byte[] amount=ISOUtil.hex2byte("000000001000");
byte[] amountOther=ISOUtil.hex2byte("000000000000");
byte[] aip=ISOUtil.hex2byte("1C00");
byte[] atc=ISOUtil.hex2byte("0001");
byte[] iad=ISOUtil.hex2byte("06010A03A03000");
byte[] terminal_country_code=ISOUtil.hex2byte("0840");
byte[] txn_currency_code=ISOUtil.hex2byte("0840");
byte[] tvr=ISOUtil.hex2byte("0000000000");
byte[] txndate=ISOUtil.hex2byte("051230");
byte[] txntype=ISOUtil.hex2byte("00");
byte[] unpridicatablenumber=ISOUtil.hex2byte("12345678");
byte[] arqc=ISOUtil.hex2byte("AABBDACCB5DD82FF");
Creating TLV Data
TLVList list=new TLVList();
list.append(PSN,psn);
list.append(PAN,pan);
list.append(AIP,aip);
list.append(APPLICATION_TRANSACTION_COUNTER,atc);
list.append(ISSUER_APPLICATION_DATA,iad);
list.append(AMOUNT,amount);
list.append(AMOUNT_OTHER,amountOther);
list.append(TERMINAL_COUNTRY_CODE,terminal_country_code);
list.append(TVR,tvr);
list.append(TXN_CURRENCY_CODE,txn_currency_code);
list.append(TRANSACTION_DATE,txndate);
list.append(TRANSACTION_TYPE,txntype);
list.append(UNPREDICTABLE_NUMBER,unpridicatablenumber);
list.append(APPLICATION_CRYPTOGRAM,arqc);
byte[] f55=list.pack();
Which can be set to ISOMsg
msg.set(55,f55);
Parsing TLV Data
TLVList tlv=new TLVList();
tlv.unpack((byte[])msg.getValue(55));
byte[] iad=tlv.find(EMVTags.ISSUER_APPLICATION_DATA).getValue();
System.out.println("IAD:"+ISOUtil.hexString(iad));

