Easypaisa Merchant Integration Guide
Easypaisa Merchant Integration Guide
Integration Guide
V.4.1
1|P a g e
Table of Contents
1. How to activate your sandbox test account: ................................................................................................................................. 3
2. Types of custom code Integration: ................................................................................................................................................ 3
3. Post Method Integration for Credit Card Transactions ................................................................................................................. 4
3.1 Post Method Sample Codes ........................................................................................................................................................ 5
3.2 Encryption Algorithm to get value of “merchantHashedReq” Parameter: ................................................................................. 6
3.3 Hash Encryption Sample Code:.................................................................................................................................................... 7
4. REST APIs ....................................................................................................................................................................................... 7
4.1 Purpose ........................................................................................................................................................................................ 7
4.2 Initiate OTC Transaction .............................................................................................................................................................. 7
4.3 Initiate MA Transaction ............................................................................................................................................................. 10
4.4 Inquire Transaction Status ......................................................................................................................................................... 13
4.5 Possible Reasons of API Response: ................................................................................................................................... 17
4.6 Optional Parameters ................................................................................................................................................................. 17
5. Instant Payment Notification: ..................................................................................................................................................... 17
5.1 What you need to do: ................................................................................................................................................................ 17
6. Testing Credentials for Sandbox (Test Account) .......................................................................................................................... 19
7. How to Go Live with your Easypaisa Account: ............................................................................................................................ 19
7.1 Live Account Activation ............................................................................................................................................................. 20
8. Hosted Checkout Integration ...................................................................................................................................................... 21
8.1 Hosted Fields: ............................................................................................................................................................................ 21
8.2 Checkout Form: ......................................................................................................................................................................... 21
8.3 Hash Parameter Generation ...................................................................................................................................................... 21
8.4 Encrypt Card Holder Information .............................................................................................................................................. 22
8.5 Hosted Checkout User Journey ................................................................................................................................................. 24
8.6 How to integrate ....................................................................................................................................................................... 27
8.7 Pre-requisites ............................................................................................................................................................................ 29
2|P a g e
1. How to activate your sandbox test account:
Your Sandbox (testing) account will be created by your designated Telenor POC. You will receive an email from
[Link]@[Link] on your provided email ID containing the link to your Sandbox account activation
along with the one time password sent on your registered number that you shared for sandbox creation.
Steps:
Enter your username. Your Username will be the email address provided by you for sandbox
Enter OTP (one time password). Sent to you on your number
Set a new password
You’re good to go!
Once you have successfully logged in to your Testing account. You will need two things in order to
start your integration.
1-Store ID: To find your store ID, login to the OPS Portal and click on the profile button on top right
2-Hashkey (Used only in Post Method for Credit Card Transactions): To generate your Hashkey. Go to Account
Settings>Generate Hashkey
3|P a g e
3. Post Method Integration for Credit Card Transactions
STEP 1: The merchant needs to POST below parameters in a form to Easypaisa on the f o l l o w i n g STAGING URL:
URL: [Link]
Parameters Below:
Post back URL M postBackURL The first post back URL for Character. This should be a
Confirmation public URL
Order M orderRefNum Merchant Generated order Character
Reference reference number
Number
Merchant M merchantHashedReq Hash value. Explained in detail in Character
Hashed section 3.3
Payment M paymentMethod Merchant will redirect their customers CC_PAYMENT_METHOD
Method to Easypaisa secure checkout for CC
Transactions
Expiry O expiryDate Merchant provided expiry date for the YYYYMMDD HHMMSS
Date particular transaction
4|P a g e
Bank O bankIdentifier If the merchant wants to pass the 6 digit alphanumeric value
Identifier customer’s selected Bank
(Identification Number) in order to
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
Easypaisa and merchant’s website. Then Easypaisa sends back a parameter named auth_token to
the postbackURL which is sent as a GET parameter. Now the merchant needs to post back below
two parameters again to the following URL:
URL: [Link]
Parameters:
auth_token
po stBackURL
After this redirection the Easypaisa authenticates the auth_token sent by merchant with t h e one it has
in the previous step, and upon successful authentication it will make customer land on the successful
checkout screen sending back following three variables to the second postBackURL:
status
desc
orderRefNumber
**Below are the only working codes that we have for post method integration. In case your platform is developed on
some other language then reference codes are available and will be provided on request, but you will have to
customize and develop them as per need.
[Link]
[Link]
5|P a g e
3.2 Encryption Algorithm to get value of “merchantHashedReq” Parameter:
In order to mitigate parameter tempering/modification while transfer and posting of data, merchant can encrypt
the request using the hash key generated from your sandbox account. In your request to our online payment system
you have to send ["merchantHashedReq"] parameter. Value for this parameter can be formed by encrypting your
other parameters. Kindly note that all the parameters you were sending previously will be used in generation of the
encrypted value. Moreover, correct sequence of parameters in the concatenated string should be like this:
amount=&autoRedirect=&emailAddr=&mobileNum=&orderRefNum=&paymentMethod=&postBackURL=&storeId=
The secret key to encrypt values can be obtained from Merchant Portal [Account Settings -> Generate Hash Key].
This encrypted request is sent along with the main request, which is 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:
[Link]("amount", "10.0");
[Link]("storeId", "28");
[Link]("orderRefNum", "11001");
[Link]("expiryDate", "20150101 151515");
[Link]("postBackURL", "[Link]
2. Get the list of field name from the map created in the first step
[Link](fieldNames)
4. Create a string in following format. Remember that Auto redirect is a mandatory parameter while creating
this string
6|P a g e
amount=10.0&autoredirect=0&expiryDate=20150101151515&orderRefNum=11001&postBackURL=
[Link] 81/local/[Link]&storeId=28
5. Use AES/ECB/PKCS5Padding algorithm to encrypt with the key and string produced in the previous step
Merchants can use the below given PHP code as a reference for encryption process in Post
Method. For any other language, please follow this reference code to create your own code as
per need
[Link]
4. REST APIs
4.1 Purpose
Payment Gateway provides the capability for B2B integrations by exposing core services to
external partners. This enables external partners to reuse their existing interfaces in order to
integrate with Easypaisa. There will be no re-direction to Easypaisa checkout page and external
partner’s system will directly invoke Easypaisa APIs for initiating and inquiring the transaction.
The communication protocol supported is REST over HTTPs. External Systems should have the
capability to perform SSL based communication with the Easypaisa Load Balancer.
The Initiate OTC Transaction method is used to create OTC transactions in OPS
Request URL:
7|P a g e
Staging:
[Link]
Production:
[Link]
Request Header:
Request Parameters:
8|P a g e
Response Parameters:
Code : Description
0000 = SUCCESS
0015 = INVALID_TOKEN_EXPIRY
Sample Request:
{
"orderId": "abc123",
"storeId": "43",
"transactionAmount": "1.23",
9|P a g e
"transactionType": "OTC",
"msisdn": "03458508726",
"emailAddress": "testEmail@[Link]",
"tokenExpiry": "20190723 232722"
}
Sample Response:
{
"orderId": "abc123",
"storeId": 43,
"paymentToken": "40933012",
"transactionDateTime": "11/08/2018 10:41 PM",
"paymentTokenExpiryDateTime": "23/07/2019 11:27 PM",
"responseCode": "0000",
"responseDesc": "SUCCESS"
}
Request URL:
Staging:
[Link]
Production:
[Link]
Request Header:
10 | P a g e
Request Parameters:
mobileAccountNo Format: M
03xxxxxxxxx (11 - digits)
emailAddress Format : abc@[Link] M String
optional1 O String
optional2 O String
optional3 O String
optional4 O String
optional5 O String
11 | P a g e
Response Parameters:
Code : Description
0000 = SUCCESS
0001 = SYSTEM ERROR
0002 = REQUIRED FIELD MISSING
0005 = MERCHANT ACCOUNT NOT ACTIVE
0006 = INVALID STORE ID
0007 = STORE NOT ACTIVE
0008 = PAYMENT METHOD NOT ENABLED
0010 = INVALID CREDENTIALS
0013 = LOW BALANCE
0014 = ACCOUNT DOES NOT EXIST
Sample Request:
{
"orderId": "abc123",
"storeId": "43",
"transactionAmount": "1.23",
"transactionType": "MA",
"mobileAccountNo": "03458508726",
"emailAddress": "testEnmail@[Link]"
12 | P a g e
}
Sample Response:
{
"orderId": "abc123",
"storeId": 43,
"transactionId": "253184",
"transactionDateTime": "11/08/2018 11:30 PM",
"responseCode": "0000",
"responseDesc": "SUCCESS"
}
The Inquire Transaction Status API is used to inquire transaction information of the referenced
transaction.
Request URL:
Staging:
[Link]
Production:
[Link]
Request Header:
13 | P a g e
Request Parameters:
14 | P a g e
Response Parameters:
Code : Description
0000 = SUCCESS
0001 = SYSTEM ERROR
0002 = REQUIRED FIELD MISSING
0003 = INVALID ORDER ID
0004 = INVALID MERCHANT ACCOUNT
NUMBER
0005 = MERCHANT ACCOUNT NOT ACTIVE
0006 = INVALID STORE ID
0007 = STORE NOT ACTIVE
0010 = INVALID CREDENTIALS
15 | P a g e
Sample Request:
{
"orderId " : "MS5007",
"storeId" : "43",
"accountNum" : "654123987"
}
Sample Response
{
"orderId”: "MS5007",
"accountNum" : "654123987",
"storeId" : 43,
"storeName" : "PG Store 1",
"paymentToken" : "40931912",
"transactionStatus" : "PENDING",
"transactionAmount" : 12,
"transactionDateTime" : "09/08/2018 10:04 PM",
"paymentTokenExpiryDateTime" : "09/07/2019 05:06 PM",
"msisdn" : "03458508726",
"paymentMode" : "OTC",
"responseCode " : "0000",
"responseDesc" : "SUCCESS"
}
16 | P a g e
4.5 Possible Reasons of API Response:
These parameters are present in the requests and responses of all three APIs mentioned above and are
optional in each case.
If these attributes are provided in the request, then OPS will save the values of these parameters in OPS database
against the transaction and return them in the response.
These parameters are available for selection in the ‘IPN Attribute Configurations’ screen in the Account Settings tab
of the Merchant Portal.
If selected, these optional parameters will also be sent in the merchants’ IPN to the configured URL.
Instant payment notification message is used to notify merchants about the details of any particular
transaction made by customers using Easypaisa channel. IPN message is self-configured in Easypaisa
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 Easypaisa
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 Easypaisa. IPN message will contain the selected parameters configured for merchant using
below mentioned screen in merchant portal.
1. Configure the listener URL on Easypaisa merchant portal by going to the account setting tab and
clicking on the IPN attributes configuration
2. Select desired IPN attributes from the Easypaisa merchant portal
3. Create a listener that will receive in GET request variable named ‘url’
4. The received URL would be that of REST API which will return the IPN attributes
**See reference screenshot below
17 | P a g e
Following is the format for URL:
For Example:
Merchant URL = [Link]
Rest API URL = [Link]
service/rest/v1/order- status Merchant Account ID =
00001 Order ID = 998877
18 | P a g e
6. Testing Credentials for Sandbox (Test Account)
Once the integration with Easypaisa is completed, merchants can test the payment flows using
the following Credentials for Mobile Account and Credit Card Transactions.
**Each case must be tested as per screenshot below. There are a total of seven cases that are must to be tested.
Without which merchant cannot go live.
1- Generate an order
2- Pay with Easypaisa (Shop payment method)
3- Fill details on Easypaisa payment page
4- Copy the token number that has been generated
5- On the same page where token number is displayed, you will see an option ‘Pay Token’, click that option and
paste the token number in it and click enter
6- Transaction should be marked as paid in Easypaisa portal
19 | P a g e
7.1 Live Account Activation
Your Live account will be created by your designated Telenor POC. You will receive an email from
[Link]@[Link] on your provided email ID containing the link to your live account activation
along with the one time password sent on your registered number that you shared for sandbox creation.
Steps:
Enter your username. Your Username will be the email address provided by you for live account
Once you have successfully logged in to your live account. You will need two things in order to move from
Staging to Live.
1-Store ID: To find your store ID, login to the OPS Portal and click on the profile button on top right
2-Hashkey (Used only in Post Method for Credit Card Transactions): To generate your Hashkey. Go to Account
Settings>Generate Hashkey
Kindly follow the below mentioned steps in order to move from testing to live Easypaisa environment if you are using
the POST method integration
Change your Store ID from staging with the one you will get in your live account
Generate Hashkey from your live account .To generates your Hashkey. Go to Account Settings>Generate
Hashkey and replace it with the one you used for hash encryption in staging environment.
Change the [Link] and [Link] URL’s with the one’s given below
[Link]
[Link]
Kindly follow the below mentioned steps in order to move from testing to live Easypaisa environment if you are using
the OPEN API integration method.
Simple change the SOAP based WSDL URL of API to the one provided below
([Link]
service/PartnerBusinessService/METAINF/wsdl/partner/transaction/[Link])
Your SOAP credentials for live account (Username & Password ) will be shared with you
by your Easy pay POC
20 | P a g e
8. Hosted Checkout Integration
Introduction
Easypay Online Payment System (OPS) is an electronic payment solution that enables internet users to make financial
transactions online. It seamlessly integrates with e-commerce web-sites, shopping carts or mobile apps and allows the
owners of these applications to collect payments from their customers. Easypay allows partner businesses to offer their
customers a variety of payment methods to pay for their transactions, which include Easypaisa Mobile Accounts,
Credit/Debit Card payments.
Hosted Checkout
Hosted Checkout is an extension offered by Mastercard Payment Gateway Services (MPGS) allowing online merchants
and e-commerce/webstores to offer customers to pay for their transactions through credit/debit cards directly from the
webstore using a payment gateway, without re-directing to the payment gateway’s web-page. Easypay OPS offers this
feature to merchants or web-stores using Easypay as their payment gateway.
Hosted Checkout allows online merchants to copy a pre-built form in their web-sites’ code, to collect payment
information from their customers. This form allows customers to input credit card information in the web-site without
exposing it to the merchant. Merchant webstores will never handle this information directly. The form will automatically
retrieve the information and forward it to Easypay payment gateway for processing..
After integration with the hosted checkout page, merchant can take credit card transaction input (Card Number, CVV,
Card Expiry etc.) on their website and send the transaction for processing to Easypay. The credit card details entered on
merchant website are secured and cannot be extracted or stored by the web-store’s server or database
Security
21 | P a g e
8.4 Encrypt Card Holder Information
According to PCI DSS regulations, card holders’ data must be protected from merchant applications that are not PCI DSS
compliant.
The card details in the hosted fields is extracted from customers’ browsers by the Hosted Checkout form and is
transmitted to OPS Server for payment processing in an encrypted form. The encryption prevents any merchant
interference and also protects sensitive information from leaking over the network layer.
OPS uses the process of Public Key Encryption to secure credit card and card holder information. When users submit their
card details via pay button in an e-commerce website, then the Hosted Checkout JavaScript requests the Easypay OPS
server for a Public key. This key will be used for transaction information encryption. OPS will encrypt the credit card
information using this key and send the encrypted string to OPS for further processing.
After receiving an encrypted request from hosted checkout form, OPS will decrypt the request using its’ private key. OPS
stores its’ private keys in AES encrypted form. These private keys are OPS’ own secret and are not shared with anyone or
any third party system.
22 | P a g e
How it works
The checkout page of a web-store, using Hosted Checkout form can be classified into four sections based on their
behavior when opened in a customer’s browser.
The customer details section contains input fields that collect customer details such as first and last name, address etc.
The information from this section is embedded and controlled by the merchants’ own web-sites and can be accessed by
their web-servers.
The Hosted Checkout URL is a link to the Easypay JavaScript file that must be linked with the merchants’ website. This file
is used by the Hosted Checkout form in the merchant web-site to secure payment details.
The Hosted Checkout form contains the input fields that collect credit card information i.e. Card number, CVV and Expiry
date etc. This form uses the JavaScript files mentioned above, to ensure that the information entered in the hosted fields
is only held by the payment gateway and cannot be accessed by merchants’ websites.
The payment processor iframe comes with the Hosted Checkout form and is used to display the payment processor’s
page, within the merchant web-site. The web-page displayed in this iframe is controlled by OPS. OPS in turn is connected
with the Mastercard and displays the resulting HTML from Mastercard in this iframe.
23 | P a g e
8.5 Hosted Checkout User Journey
Step1
The Hosted Checkout form appears on an online store and asks for payment information input from user.
Step2
User enters his/her card details in the Hosted Checkout form and clicks on pay button.
24 | P a g e
Step3
The card details form will be hidden and an iframe will appear in its place showing the payment facilitator’s processing
page.
25 | P a g e
Step4 (Conditional)
If the customer’s card is 3d Secured, then the 3DS enrollment check page appears within the iframe.
Step5
After all processing, it will automatically redirect to the merchants’ configured thank you page with a set of parameters as
shown below.
26 | P a g e
8.6 How to integrate
The following sequence of steps needs to be performed to integrate Easypay Hosted Checkout with a merchant website.
Step1
Include the Hosted Checkout form in the order checkout page of the web-store. The following code snippet can be used
within the html code body.
<div id="hosted-checkout-container">
<div id="opsMessagesSpan" class="error"></div>
<iframe id="easypay-iframe" name="easypay-iframe" style="display:none;" width="100%" height="430px"></iframe>
<form id="hosted-checkout-form">
<table class="table table-borderless">
<input type="hidden" id="storeId" value="<?php echo $storeId; ?>">
27 | P a g e
<input type="hidden" id="orderRefNumber" value="<?php echo $orderRefNum; ?>">
<input type="hidden" id="amount" value="<?php echo $amount; ?>">
<input type="hidden" id="bankIdentificationNumber" value="<?php echo $bankIdentificationNumber; ?>">
<input type="hidden" id="postBackURL" value="<?php echo $postBackURL; ?>">
<tr>
<td>Card Number</td>
<td>
<input type="text" id="ccNumber" required/>
</td>
</tr>
<tr>
<td>CVV Code</td>
<td>
<input type="text" id="cvv" required/>
</td>
</tr>
<tr>
<td>Expiry Month</td>
<td>
<select id="expMonth">
<option value="01">01</option>
<option value="02">02</option>
<option value="03">03</option>
<option value="04">04</option>
<option value="05">05</option>
<option value="06">06</option>
<option value="07">07</option>
<option value="08">08</option>
<option value="09">09</option>
<option value="10">10</option>
<option value="11">11</option>
<option value="12">12</option>
</select>
</td>
</tr>
<tr>
<td>Expiry Year</td>
<td>
<select id="expYear">
<option value="18">18</option>
<option value="19">19</option>
<option value="20">20</option>
<option value="21">21</option>
<option value="22">22</option>
<option value="23">23</option>
</select>
</td>
</tr>
<tr>
<td>Email</td>
<td>
<input type="text" id="email" value="" required/>
</td>
</tr>
<tr>
<td>Cell</td>
<td>
<input type="text" id="mobileNum" value="" required/>
</td>
</tr>
</table>
<div id="post">
<input type="submit" value="Pay" /><span id="validation-message"></span> </div>
</form>
</div>
28 | P a g e
The following input fields come pre-built in the Checkout form:
Card Number
CVV Code
Expiry Month
Expiry Year
Email
Cell
Pay
The element name and “id” attribute of every element/tag within the form must be kept the same as in the code snippet
above. These IDs are used by the Hosted Checkout JavaScript file to identify the input fields.
Styling of elements within the form can be customized as needed.
Step2
Include links to the following files towards the end of the body in script tags with the link in the “src” attributes and
“text/javascript” in the “type” attribute.
1- [Link]
2- [Link]
<script src="[Link] type="text/javascript"></script>
<script src="http:// [Link] /hosted-checkout/js/[Link]" type="text/javascript"></script>
Step3
Step4
Your web-site should now be integrated with the Hosted Checkout and should now successfully communicate with
Easypay OPS.
8.7 Pre-requisites
In order to use Easypay Hosted Checkout, an active online merchant account is required for your store in Easypay OPS
with the following configurations:
CC Payment method enabled
Hosted Checkout enabled
Valid merchant credentials
A valid hash-key for your account
Hosted Checkout form and JavaScript integrated successfully
29 | P a g e
30 | P a g e









