HBLPay Integration Guide V1.1
HBLPay Integration Guide V1.1
ABSTRACT
The purpose of this document is to guide the online
ecommerce merchant to integrate with HBL’s payment
gateway HBLPay. Started with a brief overview of the
service followed by the pre-requisites of the technical
Revisions
Version Issue Date Author Changes
1.0 10-June-2020 Shahid Rafique Draft
1.1 16-Sep-2020 Saad Rasheed Tokenization
Contents
HBLPay Overview .......................................................................................................................................... 2
Pre-Requisites ............................................................................................................................................... 2
Integration .................................................................................................................................................... 3
Step 1: Merchant Configuration to access HBLPay ................................................................................... 3
Step 2: RSA Key Generation Process ......................................................................................................... 3
XML Format........................................................................................................................................... 3
PEM Format .......................................................................................................................................... 4
Step 3: Calling HBLPAY API for Authentication ......................................................................................... 4
Tokenization................................................................................................................................................ 10
Step 4: HBLPay Page for Transaction Processing .................................................................................... 10
Plugin Support............................................................................................................................................. 19
Woo-Commerce Setup............................................................................................................................ 19
Magento Setup ....................................................................................................................................... 20
Annexures ................................................................................................................................................... 21
.Net Sample Code.................................................................................................................................... 21
PHP Sample Code .................................................................................................................................... 23
Test Accounts (for Direct Transfer) ** .................................................................................................... 24
Test Cards................................................................................................................................................ 24
Response Codes ...................................................................................................................................... 25
Pre-Requisites
Your web site must meet the following requirements:
It must have a shopping –cart, customer order creation software, or an application for initiating
disbursement to send funds to payment accounts.
The IT infrastructure must be Public Key infrastructure (PKI) enabled to use SSL-based form POST
submission.
The IT infrastructure must be capable of digitally signing customer data prior to submission to
HBLPAY.
HBL team will share the following detail with merchant in order to integrate with HBLPay.
Merchant MID
Merchant Password
HBL Public Key in XML/PEM format for Encryption (RSA 4096)
Merchant will share their public key (RSA 4096) with IPG team
Key generation process can be found in Step II
Note: A public key is a large value that is used to encrypt data. As per our system it must be RSA 4096.
Merchant can generate RSA Key using .net library Cryptography. Besides that, there are many online tool
available over the internet for RSA 4096 key generation and encryption assistance.
Sample Key Generation online tool URL: https://travistidwell.com/jsencrypt/demo/ (Please be noted that
it’s an example and there are many more available over the internet).
X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y2Mj
w6lWFwkzWRzWExHs7D26QH7OY04hGOd8mvJF71QbrNuCwtH7t7l2VYuljMssG3nH
xqJ5aZTnv0kWZUp7x9ioYB1RGUMfjFdQ32QUWPg2fUbg1Un0+y0GAD3Bx6CbSnqX
VwQQLoNDsXpVDgSEGkblxJNxl1rXLNcL4MPx//ep21UQU26kZdghkFUHaGt9+idd
W05vbt9gm9AUCximaRHf4S5W/anCp86FE8faSJqBZvbBNQnSNu4OWnVHN20Z9WGi
n8DSao4GKgHJG0TgE3iu+UrdLxbC0gF8G+zF/+doJP1n6cjO9K4foV4VAiFkRYZc
FUPOEmDUIWXU5Xcp+MXGiZNKoFrozG8V3IPHhYk4RBP7Ubwv+TCZgfvrq0a8vH7E
mLMQ28785qtEVNTWQn8BhtECAwEAAQ==
Sandbox Endpoint
https://testpaymentapi.hbl.com/hblpay/api/checkout
Production Endpoint
https://digitalbankingportal.hbl.com/hostedcheckout/api/checkout
HBLPAY support following scripting languages and you can download the sample script code for the
scripting language that you use:
Order Detail
Billing & Shipping Detail
Authentication ID is provided by dev team to IPG team which merchant integrates in to their script code
and request the required parameter including encrypted key in form of post.
Authentication Fields:
Fields Description Required / Optional
The authentication ID of merchant
USER_ID Required
provided by HBL
Password provided by HBL to
PASSWORD Required
authenticate Merchant profile
Merchant must provide a return URL
RETURN_URL which will be used to post back after Required
transaction processing
Cancel URL will be called from HBL
CANCEL_URL Pay if customer decides to cancel Required
during the transaction
CHANNEL Merchant Channel Required
Define channel specification (Union
TYPE_ID Required
Pay, Cybersource)
Order Summary
Fields Description Required / Optional
Discount offered on the total amount
DISCOUNT_ON_TOTAL Optional
charged by the merchant
Total amount of order placed by the
SUBTOTAL Required
customer
Shipping Detail
Fields Description Required / Optional
NAME Name of the shipper Optional
Number of Days required by the
DELIEVERY_DAYS Optional
merchant for delivery of the product
Sample Request – JSON (for reference only, in actual the value of parameters should be encrypted)
{
"USER_ID": "testmerchant",
"PASSWORD": "hbl@1234",
"RETURN_URL": "http://localhost:64149/Home/ThankYouPage",
"CANCEL_URL": "http://localhost:64149/Home/FailedPurchase",
"CHANNEL": "BOOKME_WEB",
"TYPE_ID": "0",
"ORDER": {
"DISCOUNT_ON_TOTAL": "20",
"SUBTOTAL": "600",
"OrderSummaryDescription": [
{
"ITEM_NAME": "COMPUTER BOOK",
"QUANTITY": "1",
"UNIT_PRICE": "180",
"OLD_PRICE": "210",
"CATEGORY": "Test_Category",
"SUB_CATEGORY": "Test sUB Category 1"
},
{
"ITEM_NAME": "GUITAR",
"QUANTITY": "2",
"UNIT_PRICE": "200",
"OLD_PRICE": null,
"CATEGORY": "Test_Category2",
"SUB_CATEGORY": "Test sUB Category2"
}
]
},
"SHIPPING_DETAIL": {
"NAME": "DHL SERVICE",
"ICON_PATH": null,
"DELIEVERY_DAYS": "7",
"SHIPPING_COST": "40"
},
All details will be validated on HBL Pay and return with Authorization ID to the merchant web
page.
For token-based payment, Merchant first ask HBL team for token enablement on Merchant’s
account. Please refer to tokenization section below for further details related to it.
Merchant can access the HBL Pay page URL using that Authorization ID returned by HBL Pay API.
Merchant will re-direct the user to following page
https://testpaymentapi.hbl.com/hblpay/site/index.html#/checkout?data=
https://digitalbankingportal.hbl.com/hostedcheckout/site/index.html#/checkout?data=
After getting landed on HBL Pay’s page merchant then now able to see the checkout page along
with details and multiple options of payments i-e Union Pay, Cybersource and Direct Transfer. All
three platforms i-e Cybersource, Direct Transfer & Union Pay are available for online collection
payments.
Card holder have the choice to pay the payment via following option.
Visa/Master Card
HBL Account
UnionPay Card
Put all the details (Card Type, Card number, Expiry date, CVN) on payment details page.
HBL Account.
If customer is the HBL account holder and wants to purchase the item via HBL Account, select the
option, put the details (i-e account number and CNIC number) and click the Proceed button.
verification call on registered number and after successful verification, OTP will send to customer via
SMS.
Payment Successful.
to Union pay.
Put the details (Card number, Expiry date, CVN and SMS Code) on payment details page.
Woo-Commerce Setup
1. HBL team will provide merchant HBLPAY plugin as .zip file
2. To install plugin use the following link to install. You may proceed
with the upload zip file step
https://www.wpbeginner.com/beginners-guide/step-by-step-
guide-to-install-a-wordpress-plugin-for-beginners/
3. After installation and activation of plugin go to woo commerce -> settings -> Payments
4. After enabling the payment option go to manage and add plugin settings and save.
2. After installation and execution of commands go to admin dashboard -> Stores -> Configuration -
> Sales -> Payments
3. You will find HBL Pay gateway in a list of payment methods. Enable gateway with the yes option
and fill complete settings to start using HBLPay gateway.
You will receive SESSION_ID in response from API call. Then open the URL from your .net code or
JAVASCRIPT code with session id.
For example:
window.location.href =
'https://testpaymentapi.hbl.com/HBLPay/Site/index.html#/checkout?data=' + sessionID;
For example:
window.location.href =
'https://testpaymentapi.hbl.com/HBLPay/Site/index.html#/checkout?data=' + sessionID;
** P.S. HBL Implementation team will provide Direct Transfer test data
https://testpaymentapi.hbl.com/OTPViewer/Home/Email
Test Cards
Given below or similar messages can be shown to the customer after successful or a failed transaction.
If transaction response / decision received as “Accept” or “Successful” please display massage like
below;
Dear Customer, thank you for your payment, your transaction has been received successfully
and your account will be updated accordingly.
If transaction response / decision received as “Declined” please display massage like below:
Dear Customer, your card transaction has been declined by your card issuing bank, Kindly
contact your card issuing bank for details.
If transaction response / decision received as “Reject” (with Reason Code 481) please display
massage like below.
Dear Customer, your card transaction has been received and under review, our representative
will contact you shortly for further process.