Merchant Integration Guide
Merchant Integration Guide
Merchant Integration Guide
Contents
1. Introduction .............................................................................................................................................................. 3
2. Plug-in Integration ..................................................................................................................................................... 5
2.1 Plug-in Integration Process: ................................................................................................................................ 5
2.1.1. Merchant Account Verification: .................................................................................................................... 6
2.1.2. Redirection to Secure Checkout Screen ........................................................................................................ 6
2.1.3. Generation of security/Authentication token by Easy Pay ............................................................................ 6
2.1.4. Handling of security/auth_token by Merchant ............................................................................................. 7
2.1.5. Second redirection with security/authentication token to Easypay .............................................................. 7
2.1.6. Checkout Confirmation by Customer: .......................................................................................................... 7
2.2. Plug-in Integration Steps:..................................................................................................................................... 8
2.3. Plug-in Integration Code Samples: ..................................................................................................................... 10
3. Open API .................................................................................................................................................................. 12
3.1. Initiate Transaction: ........................................................................................................................................... 13
3.2. Inquire Transaction: ............................................................................................................................................ 15
3.3. Initiate Credit Card Transaction .......................................................................................................................... 17
4. Instant Payment Notification ................................................................................................................................... 19
5. Encryption Algorithm ............................................................................................................................................... 21
6. Appendix .................................................................................................................................................................. 22
6.1 Sample Code Snippet for .NET ........................................................................................................................... 23
6.2 Sample Code Snippet for Perl ............................................................................................................................ 24
6.3 Sample Code Snippet for Ruby .......................................................................................................................... 25
6.4 Sample Code Snippet for Python ....................................................................................................................... 27
7. Sandbox Environment .............................................................................................................................................. 28
8. Customized Header and Footer................................................................................................................................ 29
Page 2 of 29
1. Introduction
Easypay Solution is an electronic payment solution that enables internet users to make financial
transaction online. It can easily and seamlessly be integrated with any online website and/or
shopping cart and enable users to pay online through Easypay. It allows users to buy online using the
monetary value available in their respective accounts. Easypay Solution provides a platform to local
content, software/app developers, e-commerce merchants a viable payment method that they can
use online. It is similar to PayPal which allows purchasing online, sending and receiving money and
paying through user’s PayPal accounts.
Easypay
Easypay Solution is built upon latest state of the art technologies and toolset that leverages many
features a secure payment solutions system must have. The users require no special technology or
business license, only a valid email address to have an account on Easypay solution.
Apart from this, Easypay provides an Administrative/CRM solution which can be used by agents to
administer the system and to help customers when they need. Different roles and responsibilities
are defined to keep the system manageable and easy.
Page 3 of 29
1.1. Intended Audience and Reading Suggestions
Reader Description
Any role within the organization that uses or defines the current software
Business systems.
Any role within the organization that creates and/or designs the current software
Development
Systems. This includes programmers, architects, and database administrators.
Any role within the organization that confirms the accuracy of the current or
Quality Assurance
Requested functionality.
Any role within the organization that analyzes the current functionality and
Business Analysis
business needs to propose the new or enhanced functionality.
Program and Project Any role within the organization that determines and manages the program and
Management project plans.
Merchants Any merchant willing to integrate ‘Easy Pay’ payment method in his/her website
Page 4 of 29
2. Plug-in Integration
A plug-in is provided to Merchants enabling them to integrate Easypay Solution in their shopping sites.
The plug-in is simple and seamless to integrate and it is compatible with all types of shopping
carts/websites across different browsers and platforms.
Any Merchant registered can use this plug-in in their online retail sites. Easypay solution provides
registered merchants a unique ID. By using that unique Id/store Id, merchants can easily integrate the
plug-in with their online stores.
By integrating with any shopping cart/website the plug-in brings forth the authentication form and
amount input field that the customer wants to pay to the merchants.
Page 5 of 29
2.1.1. Merchant Account Verification:
Customer selects “Pay through Easy Pay” payment method on merchant website. Easypay authenticates
Merchant account, and then verifies store information whether or not store can be used for online
transactions (valid Store Id, Valid Easypay Account). If Merchant’s account is not verified, an error
message and description is sent to postBackURL.
After successful merchant verification customer is redirected to Easypay secure checkout screen
displaying following controls
Your Mobile # - input field
Your Email – input field
Amount – Label displaying product(s) amount from merchant website
Captcha
Proceeds button
The integration allows merchant website to send unique Store ID, Amount, and Post Back URL,
Order Reference Number and Expiry Date as post parameters on the Easypay URL upon redirection
to PG secure checkout screen.
OPS Server
(Token generation)
https://easypay.easypaisa.com.pk/easypay/Confirm.jsf
Page 6 of 29
2.1.4. Handling of security/auth_token by Merchant
http://www.my-online-store.com/transaction/TokenHandler
protected void doPost(HttpServletRequest request, HttpServeletResponse response) throws
ServletException, IOException{
String token=request.getParameter(“auth_token”);
If(!token.equals(“”)){String postBackURL= http://wwww.my-online-
store.com/transaction/TransactionStatus.jsp;
try{response.getWriter().write(postBackURL);}
catch(Exception e){e.printStackTrace();}}}
Customer receives the security token and responds with another post back URL on confirmation of
payment. As customer confirms the payment, merchant sends the same security token back to the
Easypay establishing a handshake of trust between the two systems.
Easypay receives the new Post Back URL and sends the Success / Error message to the new URL.
Easypay validates the token and following parameters are sent to the postBackURL.
status
desc
orderRefNumber
Easypay processes the confirmed Payment, maintains transaction log, debits customer’s account and
credits Merchant’s account. Following is an example of how these parameters will be handled by
merchants on their websites.
Page 7 of 29
2.2. Plug-in Integration Steps:
Following process will be followed by merchants to embed the ‘Easypay’ Plug-in in their stores:
Merchant acquires an account through Easypay agents. A Welcome email containing unique
Store ID and URL is sent to the Merchant after successful registration.
Merchant logins the Easy Pay portal and access ‘Guide to Integration’ menu where Merchant is
presented with step by step instructions to integrate the Easypay plug- in to their shopping
cart/online retail shop.
Following is the sample of flow merchant should find after logging into the Easypay portal.
Merchants having unique store ID embed Easypay plug-in on checkout page of their online stores/
websites. This will integrate “Pay through Easypay” as a payment solution in their websites. The
integration of Easypay plug-in is a simple two-step process:
1. The merchant needs to POST following parameter to the Easypay on the f o l l o w i n g URL:
amount
storeId
postBackURL
orderRefNum
expiryDate (Optional)
merchantHashedReq (Optional)
autoRedirect
paymentMethod (Optional)
emailAddr (Optional)
mobileNum (Optional)
bankIdentifier (Optional)
Page 8 of 29
Parameter O/M Name Explanation Possible Values
Auto Redirect M autoRedirect If merchant wants to redirect to 0/1
final post back URL and the end of
transaction
Payment O paymentMethod If merchant wants the customer to OTC_PAYMENT_METHOD/
Method land on specific payment page. MA_PAYMENT_METHOD/
CC_PAYMENT_METHOD
If ‘bankIdentifier’ is being passed, QR_PAYMENT_METHOD
then this parameter is mandatory
and must be set to
“CC_PAYMENT_METHOD”
(Credit Card Payment Method)
Email Address O emailAddr If the merchant wants to pass the Test.abcd@abcd.com
customer’s entered email address it
would be pre populated on Easypay
checkout screen.
Mobile O mobileNum If the merchant wants to pass the 03325241789
Number customer’s entered mobile number
it would be pre populated on
Easypay checkout screen.
Bank O bankIdentifier If the merchant wants to pass the 6 digit alphanumeric value
Identifier customer’s selected Bank
(Identification Number) in order to
validate the Card Number with
chosen Bank.
After successful redirection the customer would land on the Easypay Checkout Screen where there is a form
to be filled regarding the transaction information.
2. After completing the form in Step 1 the customer will be pressing the Proceed Button and lands
back on the merchant website on the same URL given in postbackURL variable in the first step.
This will be a confirmation screen on merchant’s website to perform a handshake between
Easypay and merchant’s website. The Easypay sends back a parameter named auth_token to
the postbackURL which is sent as a GET parameter. Now the merchant needs to post
back following two parameters again to the following URL:
auth_token
postBackURL
After this redirection the Easypay authenticates the auth_token sent by merchant with the one it has
in the previous step, and upon successful authentication it will make customer land on the successful
checkout screen sending back following two variables to the second postBackURL:
status
desc
orderRefNumber
Page 9 of 29
2.3. Plug-in Integration Code Samples:
Following Code Snippet can be used as a reference for the redirection performed in Step 1:
Output:
After successful implementation, the below button would appear on the website of the merchant.
Following Code Snippet can be used as a reference for the redirection performed in Step 2:
Page 10 of 29
Following Code Snippet can be used as a reference to retrieve the transaction status sent on the fly by
Easypay:
Page 11 of 29
3. Open API
Easypay provides the capability for B2B integrations by exposing core services to external partners to
reuse their existing interfaces in order to integrate with Easypay. There will be no redirection to Easypay
checkout page and external partner’s system will directly invoke Easypay APIs for initiating and inquiring
the transaction.
The communication protocol supported is SOAP over HTTPs. External Systems should have the capability to perform
SSL based communication with the Easypay Load Balancer.
Following are the steps that required for integration via Open API:
2. After the client generation three SOAP operations would be exposed as follows:
a. initiateTransaction – This operation can be used to initiate OTC and MA transactions only.
b. inquireTransaction – This operation can be used to inquire about the status of any transaction.
c. initiateCCTransaction – This operation can be used to initiate Credit Card transactions only.
SOAP UI tool v.5 or above can be used in order to test open APIs.
Page 12 of 29
3.1. Initiate Transaction:
Request Parameters
Response Parameters
Page 13 of 29
Sample Request
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:dto="http://dto.transaction.partner.pg.systems.com/" xmlns:dto1="http://dto.common.pg.systems.com/">
<soapenv:Header />
<soapenv:Body>
<dto:initiateTransactionRequestType> <dto1:username>pg-
systems</dto1:Username>
<dto1:password>9b01234324vxddc0b</dto1:Password>
<channel>Internet</channel>
<orderId>000000001</orderId> <storeId>465</storeId>
<transactionAmount>5000.00</transactionAmount>
<transactionType>OTC</transactionType>
<msisdn></msisdn>
<mobileAccountNo>034632401722</mobileAccountNo>
<emailAddress>abc@test.com</emailAddress>
</dto:initiateTransactionRequestType>
</soapenv:Body>
</soapenv:Envelope>
Sample Response
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<ns3:initiateTransactionResponseType
xmlns:ns2="http://dto.common.pg.systems.com/"
xmlns:ns3="http://dto.transaction.partner.pg.systems.com/">
<ns2:responseCode>0000</ns2:responseCode>
<orderId>000000001</orderId>
<storeId>465</storeId>
<paymentToken>064463</paymentToken> <transactionDateTime>2014-04-
25T19:59:37.981+05:00</transactionDateTime> <paymentTokenExiryDateTime>2014-04-
26T19:59:37.968+05:00</paymentTokenExiryDateTime>
</ns3:initiateTransactionResponseType>
</soapenv:Body>
</soapenv:Envelope>
Page 14 of 29
3.2. Inquire Transaction:
Request Parameters
Response Parameters
Page 15 of 29
Sample Request
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:dto="http://dto.transaction.partner.pg.systems.com/" xmlns:dto1="http://dto.common.pg.systems.com/">
<soapenv:Header />
<soapenv:Body>
<dto:inquireTransactionRequestType> <dto1:username>pg-
systems</dto1:Username>
<dto1:password>9b01234324vxddc0b</dto1:Password>
<orderId>0000001</orderId>
<accountNum>9999999999999999</accountNum>
</dto:inquireTransactionRequestType>
</soapenv:Body>
</soapenv:Envelope>
Sample Response
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<ns3:inquireTransactionResponseType
xmlns:ns2="http://dto.common.pg.systems.com/" xmlns:ns3="http://dto.transaction.partner.pg.systems.com/">
<ns2:responseCode>0000</ns2:responseCode>
<orderId>000001</orderId>
<accountNum>9999999999999999</accountNum>
<storeId>1001</storeId> <storeName>Test
Store</storeName>
<paymentToken>668551</paymentToken>
<transactionId>100591</transactionId>
<transactionStatus>PAID</transactionStatus>
<transactionAmount>10000.00</transactionAmount> <transactionDateTime>2014-04-
25T19:59:37.981+05:00</transactionDateTime> <paymentTokenExiryDateTime>2014-04-
25T19:59:37.981+05:00</paymentTokenExiryDateTime> <transactionPaidDateTime>2014-04-
25T19:59:37.981+05:00</transactionPaidDateTime> <paymentTokenExiryDateTime>2014-04-
26T19:59:37.968+05:00</paymentTokenExiryDateTime> <msisdn>03463240172</msisdn>
<paymentMode>OTC</paymentMode>
</ns3:inquireTransactionResponseType>
</soapenv:Body>
</soapenv:Envelope>
Page 16 of 29
3.3. Initiate Credit Card Transaction
Request Parameters
Response Parameters
Page 17 of 29
Sample Request
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:dto="http://dto.transaction.partner.pg.systems.com/"
xmlns:dto1="http://dto.common.pg.systems.com/">
<soapenv:Header />
<soapenv:Body>
<dto:initiateCCTransactionRequestType>
<dto1:username>pg-systems</dto1:username>
<dto1:password>?</dto1:password>
<orderId>1101</orderId>
<storeId>23</storeId>
<transactionAmount>10</transactionAmount>
<transactionType>CC</transactionType>
<msisdn>03323685741</msisdn>
<emailAddress>test@test.com</emailAddress>
<cardType>Mastercard</cardType>
<pan>5313581000123430 </pan>
<expiryYear>17</expiryYear>
<expiryMonth>05</expiryMonth>
<cvv2>123</cvv2>
</dto:initiateCCTransactionRequestType>
</soapenv:Body>
</soapenv:Envelope>
Sample Response
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<ns3:initiateTransactionResponseType
xmlns:ns2="http://dto.common.pg.systems.com/"
xmlns:ns3="http://dto.transaction.partner.pg.systems.com/">
<ns2:responseCode>0000</ns2:responseCode>
<orderId>000000001</orderId>
<storeId>465</storeId>
<paymentToken>064463</paymentToken> <transactionDateTime>2014-04-
25T19:59:37.981+05:00</transactionDateTime> <paymentTokenExiryDateTime>2014-04-
26T19:59:37.968+05:00</paymentTokenExiryDateTime>
</ns3:initiateTransactionResponseType>
</soapenv:Body>
</soapenv:Envelope>
Page 18 of 29
4. Instant Payment Notification
4.1. Purpose
Instant payment notification message is used to notify merchants about the details of any particular
transaction made by customers using Easypay channel. IPN message is self-configured in Easypay for each
merchant. It is customized as to what details merchant requires in response for any particular transaction.
The IPN message service sends merchant a notification whenever Easypay transaction is created (with
‘Paid’ status) or is updated to ‘Paid’.
IPN Handler URL is the Merchant’s IPN listener URL where Merchant will be expecting the response from
Easypay. IPN message will contain the selected parameters configured for merchant using below
mentioned screen in merchant portal.
Page 19 of 29
4.3 What Merchant need to do?
For Example:
Merchant URL = http://www.TestMerchant.com
Rest API URL = https://easypay.easypaisa.com.pk/easypay-service/rest/v1/order-
status Merchant Account ID = 00001
OrderID = 998877
IPN Message:
https://www.TestMerchant.com?url= https://easypay.easypaisa.com.pk/easypay-service/rest/v1/order-
status/1000223344/998877
Page 20 of 29
5. Encryption Algorithm
In order to mitigate parameter tempering/modification while transfer and posting of data, merchant can encrypt
the request using the hash key provided by Telenor POC. This encrypted request is sent along with the main
request, which then reconciled at OPS end to detect if parameter is changed or not. The encryption can be done
using following algorithm:
1. Create map of all the fields that are part of the request
2. Get the list of field name from the map created in the first step
Collections.sort(fieldNames);
Value: amount=10.0&autoRedirect=0&expiryDate=20150101
151515&orderRefNum=11001&postBackURL=http://localhost:9081/local/status.php&storeId=28
5. Use AES/ECB/PKCS5Padding algorithm to encrypt with the key and string produced in the previous step
Page 21 of 29
6. Appendix
5.1. Simple pseudo Code
storeId
amount
postBackURL
orderRefNum
expiryDate
merchantHashedReq
autoRedirect
paymentMethod
emailAddr
mobileNum
2. Receive the auth_token from the postBackURL in the previous step and post this token along with another
postBackURL to the URL https://easypay.easypaisa.com.pk/easypay/Confirm.jsf , this time POST two
following two variables:
auth_token
postBackURL
3. Retrieve transaction response on the fly from the postBackURL in previous step, two of the variables will be
sent by Easypay:
status
desc
orderRefNumber
Page 22 of 29
6.1 Sample Code Snippet for .NET
Page 23 of 29
6.2 Sample Code Snippet for Perl
use LWP::UserAgent;
my $ua = LWP::UserAgent->new;
my $server_endpoint = "https://easypay.easypaisa.com.pk/easypay/Index.jsf";
my $post_data = '{
"storeId" : "43",
"amount" : "10",
"postBackURL" : "http://www.my.online-store.com/transaction/MessageHandler",
"orderRefNum" : "1101",
"expiryDate" : "20140606 201521",
“merchantHashedReq” : “asdfasdjklfja;lsdkjfa;lskdjflasdf===”,
“autoRedirect” : “0”,
“paymentMethod” : “OTC_PAYMENT_METHOD”,
“emailAddr” : “test.abc@abcddomain.com”,
“mobileNum” : “03321020541”
}';
$req->content($post_data);
my $resp = $ua->request($req);
use LWP::UserAgent;
my $ua = LWP::UserAgent->new;
my $server_endpoint = "https://easypay.easypaisa.com.pk/easypay/Confirm.jsf";
my $req = HTTP::Request->new(POST => $server_endpoint);
$req->header('content-type' => 'application/json');
$req->header('x-auth-token' => 'kfksj48sdfj4jd9d');
my $auth_token = $_Get['auth_token'];
my $post_data = '{
"auth_token" : ' + $auth_token + ',
"postBackURL" : "http://www.my.online-store.com/transaction/MessageHandler1"
}';
$req->content($post_data);
my $resp = $ua->request($req);
Page 24 of 29
6.3 Sample Code Snippet for Ruby
require 'uri'
require 'net/http'
uri = URI.parse("https://easypay.easypaisa.com.pk/easypay/Index.jsf")
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
request = Net::HTTP::Post.new("/v1.1/auth")
request.add_field('Content-Type', 'application/json')
request.body = {
'storeId' => '43',
'amount' => '10',
'postBackURL' => 'http://www.my.online-store.com/transaction/MessageHandler',
'orderRefNum' => '1101',
'expiryDate' => '20140606 201521',
‘merchantHashedReq’ => ‘aasldfjlaksdjf;laksjdf;asdf--=====’,
‘autoRedirect’ => ‘0’,
‘paymentMethod’ => ‘OTC_PAYMENT_METHOD’,
‘emailAddr’ => ‘test.abcd@abcdomain.com’,
‘mobileNum’ => ‘03321020145’
}
response = http.request(request)
Page 25 of 29
For the second redirection:
require 'uri'
require 'net/http'
uri = URI.parse("https://easypay.easypaisa.com.pk/easypay/Confirm.jsf")
cgi = CGI.new
request = Net::HTTP::Post.new("/v1.1/auth")
request.add_field('Content-Type', 'application/json')
request.body = {
'auth_token' => auth_token,
'postBackURL' => 'http://www.my.online-store.com/transaction/MessageHandler1'
}
response = http.request(request)
Page 26 of 29
6.4 Sample Code Snippet for Python
host = 'https://easypay.easypaisa.com.pk'
url = '/easypay/Index.jsf'
values = {
'storeId' : '43',
'amount' : '10',
'postBackURL' : 'http://www.my.online-store.com/transaction/MessageHandler',
'orderRefNum' : '1101',
'expiryDate' : '20140606 201521',
‘merchantHashedReq’ => ‘aasldfjlaksdjf;laksjdf;asdf--=====’,
‘autoRedirect’ => ‘0’,
‘paymentMethod’ => ‘OTC_PAYMENT_METHOD’,
‘emailAddr’ => ‘test.abcd@domain.com’,
‘mobileNum’ => ‘03321041021’
}
headers = {
'User-Agent': 'python',
'Content-Type': 'application/x-www-form-urlencoded',
}
values = urllib.urlencode(values)
conn = httplib.HTTPSConnection(host)
conn.request("POST", url, values, headers)
response = conn.getresponse()
data = response.read()
Page 27 of 29
7. Sandbox Environment
For the ease of the merchants Easypay have exposed a testing environment which will be acting like a sandbox for the
merchants to integrate, test and monitor their transactions. The sand box is basically an environment which simulates
that of production, it is exposed over the internet. Merchants may use it to integrate for testing purposes and then
while taking the project live they can just change the URLs.
Page 28 of 29
8. Customized Header and Footer
Easypay Admin can also set customized headers and footers on the easypay checkout page upon the request of
Merchants aiming the better look and feel for their customers. Different header and footer can be applied for each
store.
Steps:
1) Login to ‘Easypay Admin Portal’
2) Go to ‘Manage Merchants’
3) Select merchant, list of stores will be displayed
4) Click action ‘Upload Header & Footer’ against any store
5) A dialog box will be opened to browse for images
6) Select the image and ‘Close’ the dialog box
Page 29 of 29