JPos - ISO8583消息TLV字段

时间:2017-11-30 14:57:41

标签: java iso8583 jpos

我正在使用jpos库构建一个简单的电子购买财务消息,我使用通用打包器来打包我的消息字段,问题发生在字段48,即TLV字段。

以下是字段48的打包参数。

        <isofieldpackager id="48"
            name="Additional Private Data" 
            length="999"
            class="org.jpos.iso.IFB_LLLBINARY"
            emitBitmap="false" 
            tagMapper="org.jpos.iso.packager.TTTDecimalTagMapper" 
            packager="org.jpos.iso.packager.GenericTaggedFieldsPackager">

            <!--  -->
            <isofield id="1" length="8" name="PSP Identifier" class="ma.XXY.net.merkit.utils.IFA_TTLLBINARY2"/>

            <!--  -->
            <isofield id="2" length="8" name="Ecommerce Acquirer Identifier" class="ma.XXY.net.merkit.utils.IFA_TTLLBINARY2"/>

            <!--  -->
            <isofield id="3" length="3" name="Buyer Country Code" class="ma.XXY.net.merkit.utils.IFA_TTLLBINARY2" />

            <!--  -->
            <isofield id="4" length="20" name="Buyer Card Brand" class="ma.XXY.net.merkit.utils.IFA_TTLLBINARY2" />

            <!--  -->
            <isofield id="5" length="24" name="Buyer IP Address" class="ma.XXY.net.merkit.utils.IFA_TTLLBINARY2" />

            <!--  -->
            <isofield id="6" length="30" name="Buyer email Address" class="ma.XXY.net.merkit.utils.IFA_TTLLBINARY2" />

            <!--  -->
            <isofield id="7" length="14" name="Buyer Phone Number" class="ma.XXY.net.merkit.utils.IFA_TTLLBINARY2" />

            <isofield id="8" length="6" name="Merchant Operation Reference" class="org.jpos.iso.IF_CHAR" />
            <isofield id="9" length="3" name="One Click Indicator" class="org.jpos.iso.IF_CHAR"/>
            <isofield id="10" length="12" name="ISC INTERNET PIN" class="org.jpos.iso.IF_CHAR"/>
            <isofield id="11" length="3" name="One Click Indicator" class="org.jpos.iso.IF_CHAR"/>
            <isofield id="12" length="12" name="ISC INTERNET PIN" class="org.jpos.iso.IF_CHAR"/>

            <!--  -->
            <isofield id="13" length="12" name="One Click Indicator" class="ma.XXY.net.merkit.utils.IFA_TTLLBINARY2"/>

            <!--  -->
            <isofield id="14" length="1" name="ISC INTERNET PIN" class="ma.XXY.net.merkit.utils.IFA_TTLLBINARY2"/>

        </isofieldpackager>

IFA_TTLLBINARY2.java

        public class IFA_TTLLBINARY2 extends ISOTagBinaryFieldPackager {

            public IFA_TTLLBINARY2() {
                super(0,null, BcdPrefixer.LLL, NullPadder.INSTANCE,
                        LiteralBinaryInterpreter.INSTANCE, BcdPrefixer.LL);
            }

            public IFA_TTLLBINARY2 (int len, String description) {
                super(len, description, BcdPrefixer.LLL, NullPadder.INSTANCE,
                        LiteralBinaryInterpreter.INSTANCE, BcdPrefixer.LL);
           }
        }

main.java

    ISOMsg authISOMsg = new ISOMsg();
    ISOMsg authISOMsgResp;
    QMUX qMux;
    IServicesUtils service = new ServiceUtilsImpl();

    logger.info("Initiating Authorization Request for Simple ePurchase Transaction : 11001122222");

    // To be used in header
    String stan = service.generateSTAN();

    // HEADER
    String acquirerTimeOut = service
            .getValuesFromPropertiesFile(new String[] { IConstants.ACQUIRER_MSG_TIMEOUT }, "parameters.properties")
            .get(IConstants.ACQUIRER_MSG_TIMEOUT).toString();

    String issuerTimeOut = service
            .getValuesFromPropertiesFile(new String[] { IConstants.ISSUER_MSG_TIMEOUT }, "parameters.properties")
            .get(IConstants.ISSUER_MSG_TIMEOUT).toString();

    authISOMsg.setHeader(("001" + issuerTimeOut + DateUtils.getHeaderFieldIso(new Date(), stan)).getBytes());

    try {
        // MTI
        authISOMsg.setMTI(IsoConstants.ISO_AUTH_REQUEST_MSG_MTI);

        authISOMsg.set(14, "0819");

        // Merchant Type - not existing in mpi response
        authISOMsg.set(18, "3306");

        // POS Entry Mode
        authISOMsg.set(22, IsoConstants.ISO_AUTH_REQUEST_POS_ENTRY_MODE);

        // POS Condition code
        authISOMsg.set(25,IsoConstants.ISO_AUTH_REQUEST_POS_CONDITION_CODE);

        // Card Acceptor Terminal Identification
        authISOMsg.set(41,"BX023350");

        // Merchant ID
        authISOMsg.set(42, service.reduceMerchantIDLength("*****"));

        //
        authISOMsg.set("48.1","PSP_001");
        authISOMsg.set("48.2","ACQ_002");
        authISOMsg.set("48.3","MAR");
        authISOMsg.set("48.4","VISA INTERNATIONAL");
        authISOMsg.set("48.5","10.0.0.136");
        authISOMsg.set("48.6","*****");
        authISOMsg.set("48.7","******");

        // Currency
        authISOMsg.set(49,"840");

        Q2 scanner = new Q2();
        scanner.start();

        qMux = (QMUX) QMUX.getMUX("clientmux");

        authISOMsgResp = qMux.request(authISOMsg,
        Integer.parseInt(acquirerTimeOut));
        if (authISOMsgResp != null) {
            System.out.println(authISOMsgResp.getString(2));
        }

上面的主要代码表示包含某些字段的Financial msg,我在字段48 时出现的问题。

以下错误会引发以下异常。

    Nested:org.jpos.iso.ISOException: Error reading deploy\packager\basic-packager.xml (org.xml.sax.SAXParseException; systemId: file:basic-packager.xml; 
    lineNumber: 114; columnNumber: 64; Attribute "tagMapper" must be declared for element type "isofieldpackager").

1 个答案:

答案 0 :(得分:1)

您似乎需要使用generic-subtag-packager.dtd来验证您的xml打包程序定义。

您可以将该文件复制到与xml相同的目录中,并将doctype定义替换为此文件:

<!DOCTYPE isopackager SYSTEM "generic-subtag-packager.dtd">

我希望这能解决你的问题。