How to accept payments using Network Online – Payment gateway services?

Today, I am going to share an example of how you can integrate the Payment Gateway Service offered from Network Online (https://uat.timesofmoney.com/direcpay/niecom/home.jsp).

1. Create a PHP file with name “NetworkOnline.php” and the following code.

<?php

echo "<b>PHP ENCRYPTION KIT FOR NETWORK ONLINE</b>";
$enc = MCRYPT_RIJNDAEL_128;
$key = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";//enter secret key
$mode = MCRYPT_MODE_CBC;
$iv = "0123456789abcdef";
$rand = substr(hash('sha512',uniqid(rand(), true)), 0, 5);
$merchantId='xxxxxxxxxxxxxxx';  //enter your merchant id
$text = "order-".$rand."|AED|1100|http://example.com/paymentmerchant.php?result=ok|http://example.com/paymentmerchant.php?result=ok|01|INTERNET|||||||rohit|p|alquoz| |Dubai|Dubai|123456|AE|[email protected]||||||||||||||||||||||||FALSE|||||| ";


$text1 =$text; 

echo "<b>Request Parameter in Plain Text: </b>".$text1;
echo '<br/>';
echo '<br/>';
$size = mcrypt_get_block_size($enc, $mode);
$pad = $size - (strlen($text1) % $size);
$padtext = $text1 . str_repeat(chr($pad), $pad);

$crypt = mcrypt_encrypt($enc, base64_decode($key), $padtext, $mode, $iv);
echo '<b>After Encryption: </b>'.$requestParameter=base64_encode($crypt);
echo '<br/>';
echo '<br/>';
$padtext = mcrypt_decrypt($enc, base64_decode($key), $crypt, $mode, $iv);

$pad = ord($padtext{strlen($padtext) - 1});
if ($pad > strlen($padtext)) return false;
if (strspn($padtext, $padtext{strlen($padtext) - 1}, strlen($padtext) - $pad) != $pad) {
$text = "Error";
}
$text = substr($padtext, 0, -1 * $pad);

echo '<br/>';
echo '<br/>';
echo '<b>After Decryption:</b> '.$text;

echo'<form action="https://uat.timesofmoney.com/direcpay/secure/PaymentTransactionServlet" method="post" id="networkonline_checkout" name="networkonline_checkout">
<input type="hidden" name="requestParameter" value="'.$merchantId.'|'.$requestParameter.'">
<input type="submit" value="Pay via networkonline" name="suba" id="sub">
</form>';
?>

2. Create a PHP file with name “paymentmerchant.php” and the following code. This file will handle the response received from the payment gateway service provider.

<?php

$enc = MCRYPT_RIJNDAEL_128;
$key = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";  // Put Encryption Key //
$mode = MCRYPT_MODE_CBC;
$iv = "0123456789abcdef";
echo '<b>Encrypted Response:</b> '.$response = $_REQUEST['responseParameter'];
//$reponseParameters = explode("|",$_REQUEST['responseParameter']); 
$EncText=base64_decode($response);
$padtext = mcrypt_decrypt($enc, base64_decode($key), $EncText, $mode, $iv);

$pad = ord($padtext{strlen($padtext) - 1});
if ($pad > strlen($padtext)) return false;
if (strspn($padtext, $padtext{strlen($padtext) - 1}, strlen($padtext) - $pad) != $pad) {
	$text = "Error";
}
$text = substr($padtext, 0, -1 * $pad);

echo '<br/>';
echo '<br/>';
echo '<b>Decrypted Response:</b> '.$text;

?>

Hope this works for you.
For any other information or query please visit the following url: http://www.network.ae/contact/

Advertisements

Yuvraj has written 39 articles

"Learn & Share" - I believe in this. What about you?