How to get started and examples of using JPOS to read from and write to Mastercard IPM format files

1,587 views
Skip to first unread message

harshaper...@gmail.com

unread,
Aug 21, 2014, 9:44:17 PM8/21/14
to jpos-...@googlegroups.com
Hi,

I am very new to JPOS.

I need to read from Mastercard IPM format files and create them.

Reading response file and creating a new file requirement 
- Read the incoming IPM file and encrypt the PAN and also create a masked PAN field and store both in DE 127. Turn off DE 2.
- Read from an incoming IPM file and extract  data from the retrievals messages to a CSV file
- Extract the remaining messages except for a reject message(if one is present) and create another IPM file.
- Extract the reconcilliation details into a file(non IPM)
- Extract the reject message if present into a file(non IPM)


Reading clearing file
- The clearing file created above is sent to another system and it comes back
- DE 127 needs to be turned off and DE 02 needs to be turned on


I have gone through the draft programmer's guide but there is a lot of detail to absorb at once.

Please advise me what I need to do to get started. What I need to download etc.? What is a good IDE to use?

Can I be pointed to example code that reads from and creates MasterCard IPM files?

If the exaample code shows how to handle sub fields also that will be really helpful.

I will be developing on my laptop(Windows 7 64-bit) and deploying the code to Linux. The development and production environments will be Linux.

On another note if I use dd to convert an ascii IPM file to EBCDIC, are there pitfalls to be aware of? Should the Linux LF character be replaced with an EBCDIC equivalent before applying dd to it?

Thanks in advance,

Harsha


chhil

unread,
Aug 22, 2014, 3:02:07 AM8/22/14
to jpos-...@googlegroups.com
Unfortunately you really need to get familiar with the jpos guide in order to attempt using the library.

You need to understand what packagers are and you need to create an xml file which describes how the data is packed in message you want to process.

Say you define your packager file that can understand request message in it call it ipm.xml. This is the most important thing that you need to get right.
You need to walk through the field and set up the right packager for the fields in the ISOMsg. Select field packager based on Ascii/Ebcdic data, length prefixed data that is available.(See guide for ield packagers).

This is a snippet of what a packager xml looks like

<isopackager>
  <isofield
      id="0"
      length="4"
      name="MESSAGE TYPE INDICATOR"
      pad="true"
      class="org.jpos.iso.IFA_NUMERIC"/>
  <isofield
      id="1"
      length="16"
      name="BIT MAP"
      class="org.jpos.iso.IFB_BITMAP"/>
  <isofield
      id="2"
      length="19"
      name="PAN - PRIMARY ACCOUNT NUMBER"
      pad="false"
      class="org.jpos.iso.IFA_LLNUM"
 display = "1"/>
  <isofield
      id="3"
      length="6"
      name="PROCESSING CODE"
      pad="true"
      class="org.jpos.iso.IFA_NUMERIC"/>
....
....



You read your file taking care of its header region and knowing where the record starts and ends,collect the number of bytes for the record.
Lets say data is the byte array containing the read bytes for a record in the ipm file.
GenericPackager pkgr = new GenericPackager("relative location of your ipm.xml from deploy folder");
                ISOMsg m = new ISOMsg();
                m.setPackager(pkgr);
                    m.unpack(data);
Now m contains the parsed data and associated to the fields.
Look at methods ISOMsg provides to access the fields.

e.g. m.getMTI()  m.hasField(48) m.getString(48)
For setting a field you can use m.set(fieldnumber,value) and for unsetting use m.unset(fieldnumbr)

Encryption is something you will need to do using JCE yourself. Masking is provided in the helper class ISOUtil.protect
Using the ISOMsg, you can write new files using standard java file api.




In order to automate this process, read up on DirPoll. Which picks up a file and processes it. You need to provide the processor, that does the reading the file and performing the business logic you have mentioned in your email. 

Bottom line you need to read  http://jpos.org/doc/proguide-draft.pdf. Thee are samples in it that you should try out.
Various things that I have covered custom packagers, unpacking is all explained in the pdf.

-chhil


harshaper...@gmail.com

unread,
Aug 23, 2014, 7:28:28 PM8/23/14
to jpos-...@googlegroups.com
Thanks a lot for the detailed instructions. Let me give it a try and get back to the forum if I need more assistance.
Reply all
Reply to author
Forward
0 new messages