· 7 years ago · Dec 05, 2018, 05:26 AM
1following are the parameters that need to be forwarded to HBL IPG link that they have provided.
2
3
4<?php
5$params['access_key'] = $accessKey;
6 $params['profile_id'] = $profileId;
7 $params['transaction_uuid'] = $uuid;
8 $params['signed_field_names'] = "access_key,profile_id,transaction_uuid,signed_field_names,unsigned_field_names,signed_date_time,locale,transaction_type,reference_number,amount,currency,consumer_id,customer_ip_address,bill_to_address_city,bill_to_address_country,bill_to_address_line1,bill_to_address_postal_code,bill_to_address_state,bill_to_forename,bill_to_phone,bill_to_surname,bill_to_email,ship_to_address_city,ship_to_address_country,ship_to_address_line1,ship_to_address_postal_code,ship_to_address_state,ship_to_forename,ship_to_phone,ship_to_surname,ship_to_email,merchant_defined_data1,merchant_defined_data2,merchant_defined_data3,merchant_defined_data4,merchant_defined_data5,merchant_defined_data6,merchant_defined_data7,merchant_defined_data8,merchant_defined_data20";
9 $params['unsigned_field_names'] = "";
10 $params['signed_date_time'] = gmdate("Y-m-d\TH:i:s\Z");;
11 $params['locale'] = "en";
12 $params['transaction_type'] = "authorization";
13 $params['reference_number'] = $orderId;
14 $params['amount'] = $amount;
15 $params['currency'] = "PKR";
16 $params['consumer_id'] = is_null($customer_id) ? "" : $customer_id; //"156"
17 $params['customer_ip_address'] = $order->getRemoteIp();
18 $params['bill_to_address_city'] = $billingAddress->getCity();
19 $params['bill_to_address_country'] = $billingAddress->getCountryId();
20 $params['bill_to_address_line1'] = implode(" ",$billingAddress->getStreet());
21 $params['bill_to_address_postal_code'] = $billingAddress->getPostcode();
22 $params['bill_to_address_state'] = $billingAddress->getRegion();
23 $params['bill_to_forename'] = $billingAddress->getFirstname();
24 $params['bill_to_phone'] = $billingAddress->getTelephone();
25 $params['bill_to_surname'] = $billingAddress->getLastname();
26 $params['bill_to_email'] = $billingAddress->getEmail();
27 $params['ship_to_address_city'] = $shippingAddress->getCity();;
28 $params['ship_to_address_country'] = $shippingAddress->getCountryId();
29 $params['ship_to_address_line1'] = implode(" ",$shippingAddress->getStreet());
30 $params['ship_to_address_postal_code'] = $shippingAddress->getPostcode();
31 $params['ship_to_address_state'] = $shippingAddress->getRegion();
32 $params['ship_to_forename'] = $shippingAddress->getFirstname();
33 $params['ship_to_phone'] = $shippingAddress->getTelephone();
34 $params['ship_to_surname'] = $shippingAddress->getLastname();
35 $params['ship_to_email'] = $shippingAddress->getEmail();
36 $params['merchant_defined_data1'] = "WC"; //Channel of Operation
37 $params['merchant_defined_data2'] = "YES"; //3D Secure Registration
38 $params['merchant_defined_data3'] = addslashes($p_cates); //"Phones"; //product category
39 $params['merchant_defined_data4'] = addslashes($p_names); //"S9"; //product name
40 $params['merchant_defined_data5'] = "NO"; //previous customer?
41 $params['merchant_defined_data6'] = "Standard"; //shipping method?
42 $params['merchant_defined_data7'] = $p_count; //"1"; // number of items sold
43 $params['merchant_defined_data8'] = "Pakistan"; //Product Shipping Country Name
44 $params['merchant_defined_data20'] = "NO"; //VIP Customer
45
46?>
47basically just a form if its a site and not a web app. all the fields mentioned above need to be sent along with a hashed request.
48
49<form name="hblipgform" method="post" action="<?php echo $hblipgIndexUrl; ?>">
50<?php
51 foreach($params as $name => $value) {
52 echo "<input type=\"hidden\" id=\"" . $name . "\" name=\"" . $name . "\" value=\"" . $value . "\"/>\n";
53 }
54 echo "<input type=\"hidden\" id=\"signature\" name=\"signature\" value=\"" . $block->sign($params) . "\"/>\n";
55?>
56</form>
57
58Here is the procedure to create the hash request. This is all in php cause i made a php module for magento for HBL IPG. if you need any explanation just ask.
59
60<?php
61function sign ($params) {
62 return $this->signData($this->buildDataToSign($params), $this->getConfig('payment/hblipg/secretKey'));
63 }
64
65 function signData($data, $secretKey) {
66 return base64_encode(hash_hmac('sha256', $data, $secretKey, true));
67 }
68
69 function buildDataToSign($params) {
70 $signedFieldNames = explode(",",$params["signed_field_names"]);
71 foreach ($signedFieldNames as $field) {
72 $dataToSign[] = $field . "=" . $params[$field];
73 }
74 return $this->commaSeparate($dataToSign);
75 }
76
77 function commaSeparate ($dataToSign) {
78 return implode(",",$dataToSign);
79 }
80
81?>