3

I am creating a new payment application. What I have is a client application that user selects price, enter its authentication information and then client creates and iso 8583 message and send this data to a bank server.

According to my researches, I can use jPOS for emulating bank server. Actually I need a server for getting the iso messages and response to them but I do not know how can I use jPOS for this propose.

I searched for this in the internet but could not find any resource that answer we clearly. My main question is that whether I need to create an application using jPOS for implementing my requirements or only installing the jPOS on the server is enough for testing my client app?

Artjom B.
  • 61,146
  • 24
  • 125
  • 222
Husein Behboudi Rad
  • 5,434
  • 11
  • 57
  • 115

1 Answers1

2

Well, read jpos library documentation its draft version is available on the web you can find it here

Specific to your question about JPOS Server better to implement your own server. JPos provides class ISOServer e.g. following beans initiates a ISO Server in applicationContext.xml file

<bean id="paymentServer" class="org.jpos.iso.ISOServer">
    <constructor-arg>
        <value>13000</value>
    </constructor-arg>
    <constructor-arg ref="paymentChannel" />
    <constructor-arg ref="paymentServerThreadPool" />
</bean>

<bean id="paymentChannel" class="org.jpos.iso.channel.ASCIIChannel">
    <constructor-arg ref="paymentPackager" />
</bean>

<bean id="paymentPackager" class="com.sample.payment.packager.PaymentPackager"/>

<bean id="paymentServerThreadPool" class="org.jpos.util.ThreadPool">
    <constructor-arg>
        <value>1</value>
    </constructor-arg>
    <constructor-arg>
        <value>100</value>
    </constructor-arg>
    <constructor-arg>
        <value>PaymentServer</value>
    </constructor-arg>
</bean>

<bean id="paymentProcessor" class="com.sample.processors.PaymentProcessor"  init-method="init"/>

Following class to implement packager

public class PaymentPackager extends ISOBasePackager {

    protected ISOFieldPackager fld[] = {
            /* 0000 */ new IFB_NUMERIC  (  4, "Message Type Indicator", false), 
            /* 0001 */ new IFB_BITMAP   ( 16, "Bitmap"),    
            /* 0002 */ new IFB_LLLCHAR  (999, "Primary Account number"),    
            /* 0003 */ new IFB_NUMERIC  (  6, "Processing Code", true),
            /* 0004 */ new IFB_NUMERIC  ( 12, "Amount, Transaction", true),
            //.....
            /* 0063 */ new IFB_LLLCHAR  (999, "Reserved for national use"),
            /* 0064 */ new IFB_BINARY   ( 20, "Message authentication code field"),
            //.....     
            /* 0125 */ new IF_UNUSED    (),
            /* 0126 */ new IF_UNUSED    (),
            /* 0127 */ new IF_UNUSED    (),
            /* 0128 */ new IFB_BINARY   ( 20, "Message authentication code field"),
    };

    public PaymentPackager() {
        super();
        setFieldPackager(fld);      
    }

}

In application entry point class you can get the bean and use like following to attach the channel listener

paymentServer.addISORequestListener(paymentProcessor);

following is the sample listener

public class PaymentProcessor implements ISORequestListener {

    private static Logger log = LoggerFactory.getLogger(PaymentProcessor.class);

    public void init() {

        //do init
    }

    public boolean process (ISOSource source, ISOMsg m){

        log.debug(">PaymentProcessor.process");

        ISOMsg request = (ISOMsg) m.clone();
        ISOMsg response = new ISOMsg();

        //...
        //build your response
        //...

        source.send(response);
        return true;
    }
}

NOTE: I have not implemented it yet but jpos provides new way to implement server and client using Q2 you can see documentation of QServer class to implement server, I'll try to share sample as soon as I could.

Happy coding :)

Mubashar
  • 12,300
  • 11
  • 66
  • 95
  • Very thanks @Mubashar , recently I found some thing about jpos-ee. I am not sure what exactly is this but in the below guide: http://jpos.org/doc/jPOS-EE.pdf they introduced some thing about server and client simulators(page 31-35).What is your idea about that? Isn't better to use it instead of developing a new server emulator by myself? – Husein Behboudi Rad Dec 10 '14 at 10:32
  • 2
    Yes, it would be I haven't used it but I am planning to create a sample simulator according to my need on coming Monday or on weekend. It uses QServer by the way but because I was not sure about it that is why I have shared you the server code. I'll let you know if I got successful with that. – Mubashar Dec 10 '14 at 11:04