使用JPOS的PISO 8583子字段

时间:2016-01-12 06:50:25

标签: java payment iso8583 jpos

<isopackager>
........other iso fields....
........

    <isofieldpackager
              id="57"
              length="999"
              name="Terminal Line Encrypted Data"
              class="org.jpos.iso.IFA_LLLCHAR"
              packager="org.jpos.iso.packager.ISO87BPackager">
              <isofield
                  id="0"
                  length="4"
                  name="TLE Header Indicator"
                  class="org.jpos.iso.IF_CHAR"/>
                  <isofield
                  id="1"
                  length="2"
                  name="HSS-E2EE Version"
                  class="org.jpos.iso.IF_CHAR"/>  
                  <isofield
                  id="2"
                  length="3"
                  name="EFT Secure Acquirer ID"
                  class="org.jpos.iso.IF_CHAR"/>  
                  <isofield
                  id="3"
                  length="8"
                  name="Line Encryption Terminal ID"
                  class="org.jpos.iso.IF_CHAR"/>  
                  <isofield
                  id="4"
                  length="4"
                  name="Encryption Method"
                  class="org.jpos.iso.IF_CHAR"/>  
                  <isofield
                  id="5"
                  length="10"
                  name="Line Encryption Key ID"
                  class="org.jpos.iso.IFB_LLBINARY"/>  
                  <isofield
                  id="6"
                  length="2"
                  name="Protected-Text Length"
                  class="org.jpos.iso.IFB_LLBINARY"/>  
                  <isofield
                  id="7"
                  length="8"
                  name="Reserved"
                  class="org.jpos.iso.IFB_LLBINARY"/>  
                   <isofield
                  id="8"
                  length="999"
                  name="999"
                  class="org.jpos.iso.IFA_LLLBINARY"/>  
    </isofieldpackager>
</isopackager>

我使用jpos库设置DE57的复合字段/子字段,如下所示:

GenericPackager packager = new GenericPackager("iso87binary.xml");
 ISOMsg iso57 = new ISOMsg(57);
            iso57.setPackager(packager);
            ISOField iso57_0 =  new ISOField(0, "HTLE");
            ISOField iso57_1 = new ISOField(1, "04");
            ISOField iso57_2 = new ISOField(2, "000");
            ISOField iso57_3 = new ISOField(3, "M0220001");
            ISOField iso57_4 = new ISOField(4, "2190");
            ISOField iso57_5 = new ISOField(5, "0000010172D54C600102");
            ISOField iso57_6 = new ISOField(6, "64");
            ISOField iso57_7 = new ISOField(7, "00000000");
            ISOField iso57_8 = new ISOField(8, "95CA5E94F182A9949A7C7BA202143C4E212087E626E5F5C1C63AD173F733D339");
            iso57.set(iso57_0);
            iso57.set(iso57_1);
            iso57.set(iso57_2);
            iso57.set(iso57_3);
            iso57.set(iso57_4);
            iso57.set(iso57_5);
            iso57.set(iso57_6);
            iso57.set(iso57_7);
            iso57.set(iso57_8);
            isoMsg.set(iso57);

当我将DE57打印为:

isoMsg.getString(57)

我得到了空。但是当我将它打印为子字段时,我可以看到值(循环运行整个iso消息@ i = 57):

                System.out.printf("Field (%s) = %s%n", i+".0", isoMsg.getString(i+".0"));
                System.out.printf("Field (%s) = %s%n", i+".1", isoMsg.getString(i+".1"));
                System.out.printf("Field (%s) = %s%n", i+".2", isoMsg.getString(i+".2"));
                System.out.printf("Field (%s) = %s%n", i+".3", isoMsg.getString(i+".3"));
                System.out.printf("Field (%s) = %s%n", i+".4", isoMsg.getString(i+".4"));
                System.out.printf("Field (%s) = %s%n", i+".5", isoMsg.getString(i+".5"));
                System.out.printf("Field (%s) = %s%n", i+".6", isoMsg.getString(i+".6"));
                System.out.printf("Field (%s) = %s%n", i+".7", isoMsg.getString(i+".7"));
                System.out.printf("Field (%s) = %s%n", i+".8", isoMsg.getString(i+".8"));

为什么我在前面的案例中没有得到这个值。

1 个答案:

答案 0 :(得分:3)

您不必创建iso57内部消息,您可以:

ISOMsg m = new ISOMsg();
m.set("57.0", "HTLE");
m.set("57.1", "04");
m.set("57.2", "000");
...
...

然后你可以打电话:

m.getString("57.0") to get the result "HTLE"
m.getString("57.1") to get "04"

等等。