How to receive payment online using iWallet in java

Hello It’s been a while I posted something on my blog. I have been insanely busy off late and it doesn’t look like it’s slowing down any time soon 😀

So we are going to learn how to use iWallet one of the best secured, stable payment processor in the sub region. The plan of action is to avoid the use of any complex framework that would rather cloud the showcasing of the flow itself. In this tutorial I will use:

  • jdbi library to handle the datalayer part
  • mysql connector java , a java driver for mysql database
  • java servlets to handle our requests and response
  • jsp to show our forms etc.
  • SpringSource Tool Suite as IDE(You can use any Netbeans, IntelliJ)
  • jetty standalone server (You can use any tomcat,tc server,tomEE)
  • maven as a build tool

I will assume in this tutorial that:

  • you know how to build a java web application
  • you have prior knowledge on how CRUD operations
  • you know how to manually add a maven dependency to a project
  • you have prior knowledge on mysql or any other database

Creation of a Merchant Account

That said, welcome to konohashop, kohona is the hidden ninja village of the leaf, I guess kohonamaru, the third grand son was not satisfied with the fact that Naruto walks all over the leaf to buy his ramen from the old man Teuchi the shop owner. To ease that process and enable people do their purchasing at the comfort of their house ,kohonamaru (apparently a techy ninja) contacted iWallet in order to accept payment on the web application built for sale purposes using iWallet. They were asked to create a merchant account.

After that quickly set up, iWallet team verified the konohashop authenticity and then authorized the newly created account to do business on iWallet (So to be a merchant you need to have a merchant account that needs approval or authorization). If you don’t have any by now then pause for 5mn , head to to create a merchant account.

iwallet signup page

iWallet signup page

According to the API at iWallet payLIVE API we need to have :

  • Our Merchant Email
  • Our Merchant Key
  • Set Integration Mode On
  • Set Callback to Our konohashop app

Below is how to get the merchant key, and set the callback url. After iWallet takes the money out of the end users, iWallet will use that callback url to contact our konohashop to inform us of the state of affairs.

iwallet account dashboard

iWallet Dashboard

setting up adequate api config for konohashop

setting up adequate api config for konohashop

saving konoha api config

Saving of the set api config

Integrating with iWallet

Now that we have our account created and validated, we can proceed with integrating the payment into our system. But we do not have the system yet. We will not attempt in creating an actual shopping cart but will build a mimic of it. Here is a proposal of a data model:

konohashop data model

sql file for the schema used is available here on . In order to configure a user to use the database, run the following mysql command:

mysql> GRANT ALL PRIVILEGES ON konohashop.* TO 'teuchi'@localhost IDENTIFIED BY 'shoppu';

Creating the shop web project

In eclipse , create a maven project using the maven-archetypes-webapp archetypes, choose your group id and artifact id. Example the ones used for konohashop are
project id: net.tutorial.djomeda.iwallet
artifact id: konohashop.

In our project what we will be doing is basically captured in this following flowchart. The flowchart tries to capture all the key steps with an effort not to make it too verbose.

iWallet Integration flow

iWallet Integration flow

Setting up dependencies

Once that is created , make sure your pom.xml looks the same or similar like shown below

All would most likely download except the iwallet-java-connector artifact. the reason is that , it’s not yet hosted on any of the maven repository . You would have to manually add it to your IDE by downloading it from here

Adding web.xml

Below is the web.xml that I used, because of jstl you should be using servlet 2.5 API or above to be on the safer side in case you decided to keep your own web.xml file probably generated by your IDE.

Creating Needed classes

For the sake of simplicity , this project will not use a typical implementation of a cart using session etc but will rely on simple form and servlet to simulate checkout process et al. We will use in total 3 different classes. 2 of them are servlets and the other one is a database layer exposing most of the database operations.

Let’s create 2 different packages in the source folder.

  • net.tutorial.djomeda.iwallet.konohashop.servlet
  • net.tutorial.djomeda.iwallet.konohashop.util

In util package create the class class. The purpose of this class is the use of a jdbi library in order to avoid raw jdbc boilerplate and still avoid the complexity of an ORM. After creating the class, make sure it looks like shown below:

In servlet package, create 2 servlets using New > servlet command and you will have your servlet hooked up in the web.xml with url-mapping set up. Let’s create and servlets. Checkout servlet will process our form and do preliminary work with iWallet as documented the in API :

  1. submit the order to iWallet
  2. receive a payment token from iWallet
  3. use that token to construct the redirect url
  4. redirect to iWallet with valid token for end user to make payment

After creating the servlet class , make sure it looks like shown below: will process callback url passed from iWallet to our shop konohashop:

  1. pull callback parameters
  2. verify authenticity of the payment
  3. process the order (what was paid for)
  4. complete the transaction by confirming or cancelling payment whether it’s success or failure

After creating receivecallback servlet , make sure it looks like shown below:

Creating Needed jsp files

Again, for the sake of simplicity this project would use only 3 jsp pages and I am pretty sure this is the most anaemic web application you have done ever. There is no javascript, no css, just the joy of pure java.

In you src/main/webapp folder create 3 jsp files:

  • fixtures.jsp a utility page for populating the database
  • index.jsp a very plain welcome page
  • viewitems.jsp page to display items in the database.

After creating the pages , make sure they look like shown below:




wiring up parameters through properties file

We are getting close to the finish line. The astute reader would have figured out that there is no information about konohashop database nor about our konohashop iWallet merchant account. All the details are saved in properties file called

create a file of the name in src/main/resources folder and have it look like shown below expect the merchant email and key. You would need to use your own merchant email and key.

#database section, self explanatory
username= teuchi
password = shoppu
database =konohashop

# this is your flat shipping cost. You can also pick it from a database somewhere in your application
shippingcost = 30.00

#this is your fixed tax rate too
taxes = 17

# iwallet related details
api.iwallet.merchantEmail= [email protected]
api.iwallet.merchantKey= yourmerchantkey

The project folder structure should look like shown below

project structure

running our konohashop application

I used jetty server but any server should do the job. let’s hit out app at http://localhost:8080/konohashop/fixtures.jsp to populate our database.Let’s then hit the url with http://localhost:8080/konohashop.

index page

To view items for sale , click on viewitems link

view items page

running our konohashop application

To test our payment integration let’s pick, a bowl of ramen and a kunai like shown in the screenshot below

After the checkout button is clicked, our checkout servlet would have called iWallet web service , gotten a valid token and redirects us to the following page which will notify us being in test or integration mode

iWallet testing mode notification

iWallet testing mode notification

After clicking on I am a tester, we are now allowed to see the order form page see the total cost of our purchases. According to the API document we ought to use :
password: paddypaddy

iWallet order form page

iWallet order form page

But just in Case we are curious about what makes our bill, a click on the cart icon would reveal details of the bill as shown below

iWallet cart payment details

iWallet cart payment details

After entering credentials as expected, we are redirected to our konohashop and we get a success message

order payment success message

order payment success message

Voila , I hope this tutorial gave you insight on how to use and interact with iWallet and its SOAP payLIVE API. Project files are available on


  1. Alabi Razaq

    Can this program be used in real project?
    How safe is it?

    1. kodjo-kuma djomeda (Post author)

      Hello Alabi

      This post is deprecated. There is no more iwallet but there is Slydepay. When I get some time, I will write the tutorial for the updated one. There is a new API at and it’s REST you might want that instead. Aside that the service itself is safe to use many are using it without an issue. Thanks for reading though

      1. Kwabena Berko

        For the REST API, are sms prompts automatically sent to the user when mobile payment option is selected?

  2. Evans

    looking for a way to implement mobile money payment android using slydepay but unable to find proper documentation


Leave a Comment

Your email address will not be published. Required fields are marked *

captcha * Time limit is exhausted. Please reload the CAPTCHA.

This site uses Akismet to reduce spam. Learn how your comment data is processed.