Ipay Merchant API Manual1
Ipay Merchant API Manual1
Document
Ver. 1.0.0
Prepared By:
iPay (Pvt) Limited
No. 984 | Kotte Road | Ethul Kotte | Sri Lanka
Web : www.ipay.lk
Table of Contents
iPay Web Payments gives your purchasers a rearranged checkout encounter that keeps them
neighborhood to your site or mobile application all through the payment authorization process and
gives them a chance to utilize bank account to pay without sharing or entering any sensitive data
on your site.
Register as a merchant. Next log in to the merchant portal by using the username and password.
2. Go to the ‘Merchant Settings’ on the side bar and click on ‘Development Settings’.
Then the page will display a check box which enables the development options. Then the
merchant should enable development by clicking on the checkbox.
3. After enabling development option ‘Developer Portal’ will automatically display on the side
bar. Then go to the ‘Payment Integration’ and merchant should generate his web token by
giving required details.
4. Then Merchant should give value for the ‘Secret’ option. This secret code is used to make
checksum.
5. Merchant should give a Call back API URL. This is use to notify the payment status.
6. Web Token will be automatically displayed when merchant click on Generate Token button.
It is specified for the merchant and when using the JavaScript file which is given for the
merchant from iPay, merchant should use this ‘web token’ in JavaScript file.
iPay Web Merchant Integration JavaScript Library
Merchants have to import iPay JavaScript library in to merchant’s webpage. Merchants should not
download the iPay JavaScript library and use it locally. Merchant should always use the Library
using the CDN given below.
NOTE: If a merchant hasn’t added the JQuery CDN to merchant’s web page, he/she has to add
following script as well to his/her webpage.
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
SANDBOX
<script src="https://sandbox.ipay.lk/resources/js/ipay-web-payments-1.0.0.min.js"></script>
PRODUCTION
script src="https://ipay.lk/resources/js/ipay-web-payments-1.0.0.min.js"></script>
After those steps implement iPay’s JavaScript checkout code snippet in to your web page. (An
example is given below).
ipaywebpayment({
env: 'sandbox', // sandbox | production
token : {
sandbox : 'eyJhbGciOiJIUzUxMiJ9.eyJiYW5rQWNjb3VudCI6ImFjYy5l2RlIjoiZWNoIiw',
production : ''
},
drawPayButton : false, // optional
Function called by the script when a buyer clicks on the iPay button or
Payment()
the particular button given by the website for checkout.
Function called by the script when the buyer confirms the payment or
onConfirm() scan the QR code by iPay APP. Merchant should save the transaction
reference against the order.
Function called by the script when the customer make the payment by
onAuthorize()
iPay APP.
Once the payment is authorized by customer, iPay will trigger onAuthorize() function and notify the
payment status to your call-back API same time. Payment notification will contain the following
data as POST parameters, so you need to make sure the call-back API URL you set is accepting
these parameters on a POST request & update your database accordingly.
The checksum is generated using the below combination of parameters. Checksum is generated
using HMAC SHA256 algorithm.
https://en.wikipedia.org/wiki/HMAC
https://www.jokecamp.com/blog/examples-of-creating-base64-hashes-using-hmac-sha256-in-
different-languages/
Once you receive the payment notification from iPay, you can locally generate this checksum
using above mentioned parameters and the secret you have locally. Your locally generated
checksum should equals to the checksum sent by iPay if the payment notification is valid.
And also once we invoke the call-back API, you should return HTTP response code 200 (OK) if
your whole operation is succeeding from your side. Any other HTTP response code will be taken
as failure responses.
iPay Web Payments comes with a default iPay button which is used to do start the payment process.
Merchants can either use the default button (which is a div tag) given or any custom button (any
relevant tag) or element according to the wish of the merchant.