Integrating Himalayan Bank Payment Gateway

This is a payment gateway integration technique of Himalayan Bank Limited in your eCommerce sites. I successfully integrated it some days ago and I am sharing how I was able to do it.

The bank said its E-commerce Payment Gateway has been enhanced to include domestic cardholders in partnership with 2C2P Thailand, one of the most renowned E-Commerce payment service providers in Asia Pacific.

Before integrating, get your valid Merchant Id and Secret Key from bank itself. Also, ask them to set backend-url and front-end url of your site in their server. Backend-url is the url where you get the response of your payment from the server and front-end url is the url where the payer is redirected after successful payment is made.

First of all lets create a form that is to be submitted to the server.

$cost = //product_cost//;
$invoiceNo = str_pad(rand(100000, 99999999999999999999),20,"0",STR_PAD_LEFT);
$amount = str_pad($cost,12,"0",STR_PAD_LEFT);
$merchantId = //your_merchant_id//;
$currencyCode = //your_currency_code//;
$secretKey = //your_secret_key//;
$nonSecure = //nonce//;
$signatureString = $merchantId.$invoiceNo.$amount.$currencyCode.$nonSecure;

$signData = hash_hmac('SHA256', $signatureString, $secretKey, false);
$signData = strtoupper($signData);

<form action="" id="my-form">
<input type="hidden" id="paymentGatewayID" name="paymentGatewayID" value="{{$merchantId}}"/>
<input type="hidden" id="invoiceNo" name="invoiceNo" value="{{$invoiceNo}}"/>
<input type="hidden" id="productDesc" name="productDesc" value="{{$productdesc}}"/>
<input type="hidden" id="amount" name="amount" value="{{$amount}}"/>
<input type="hidden" id="currencyCode" name="currencyCode" value="//your_currency_code//;"/>
<input type="hidden" id="userDefined1" name="userDefined1" value="{{$userdefined_value}}"/>
<input type="hidden" id="nonSecure" name="nonSecure" value="{{$nonSecure}}"/>
<input type="hidden" id="hashValue" name="hashValue" value="{{$signData}}"/>
<input type="submit" id="submit" name="submit" value="{{$signData}}"/>

After successful payment on the server we get the following response from the server.

Status: $_POST['Status']
Invoice: $_POST['invoiceNo']
Rescode: $_POST['resCode']
Userdefined: $_POST['userDefined1']

Thats all. I hope you will understand it as it is not much of a hectic job to do.

If you have any confusion or query, please write in the comment below.

Leave comment

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