将子域设置给 IsoMessage 对象

huangapple go评论69阅读模式
英文:

J8583 set Subfields to IsoMessage object

问题

如何使用J8583库为IsoMessage对象设置子字段?
我使用j8583库发送ISO8583消息,其中只需要整数数据元索引,如字段7、11和12。

public void createIsoMessage(){
    MessageFactory<IsoMessage> messageFactory = new MessageFactory<>();
    IsoMessage isoMessage = messageFactory.newMessage(0x800);
    isoMessage.setValue(7, "0601163045", IsoType.DATE10, 10);
    isoMessage.setValue(11, "163045", IsoType.DATE10, 6);
    isoMessage.setValue(12, "163045", IsoType.DATE10, 6);
}

但我需要发送具有子字段的数据元,例如字段:
127.2
127.3
127.12
127.25.3
127.25.4,但是我只能使用setValue()函数设置整数数据元索引。

我需要能够设置具有子字段的数据元,特别是数据元127,以便发送支付处理器所需的ICCDATA。

英文:

How can I set subfields to an IsoMessage object using the J8583 library?
I use the j8583 library for sending ISO8583 messages which require only whole number data element indexes such as fields 7,11 and 12

public void createIsoMessage(){
        MessageFactory&lt;IsoMessage&gt; messageFactory = new MessageFactory&lt;&gt;();
        IsoMessage isoMessage = messageFactory.newMessage(0x800);
        isoMessage.setValue(7, &quot;0601163045&quot;, IsoType.DATE10, 10);
        isoMessage.setValue(11, &quot;163045&quot;, IsoType.DATE10, 6);
        isoMessage.setValue(12, &quot;163045&quot;, IsoType.DATE10, 6);
    }

But I need to send data elements that have subfields such as fields:
127.2
127.3
127.12
127.25.3
127.25.4, however I can only set integer data element indexes using the setValue() function

I need to be able to set data elements, particularly data element 127, that have subfields to be able to send ICCDATA which is required by the payment processor.

答案1

得分: 2

这是来自j8583文档的内容:

您还可以创建一个CompositeField,将多个子字段存储在其中,并将其存储在IsoMessage中的任何字段中,指定与CustomField相同的实例:

CompositeField f = new CompositeField().addValue(new IsoValue<String>(IsoType.ALPHA, "one", 5))
    .addValue(new IsoValue<String>(IsoType.LLVAR, "two"))
    .addValue(new IsoValue<Long>(IsoType.NUMERIC, 123l, 6))
    .addValue(new IsoValue<String>(IsoType.ALPHA, "OK", 2));
message.setValue(125, f, f, IsoType.LLLVAR, 0);
英文:

This is from the j8583 doc

> You can also create a CompositeField, store several subfields inside it, and store it in any field inside an IsoMessage, specifying the same instance as the CustomField:

CompositeField f = new CompositeField().addValue(new IsoValue&lt;String&gt;(IsoType.ALPHA, &quot;one&quot;, 5))
    .addValue(new IsoValue&lt;String&gt;(IsoType.LLVAR, &quot;two&quot;))
    .addValue(new IsoValue&lt;Long&gt;(IsoType.NUMERIC, 123l, 6))
    .addValue(new IsoValue&lt;String&gt;(IsoType.ALPHA, &quot;OK&quot;, 2));
message.setValue(125, f, f, IsoType.LLLVAR, 0);

huangapple
  • 本文由 发表于 2023年6月1日 23:42:25
  • 转载请务必保留本文链接:https://go.coder-hub.com/76383617.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定