英文:
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<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);
}
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<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);
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论