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 ENCRYPTION KIT FOR NETWORK ONLINE";
$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 "Request Parameter in Plain Text: ".$text1;
echo '
'; echo '
'; $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 'After Encryption: '.$requestParameter=base64_encode($crypt); echo '
'; echo '
'; $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 '
'; echo '
'; echo 'After Decryption: '.$text; echo'
'; ?>

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.

Encrypted Response: '.$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 '
'; echo '
'; echo 'Decrypted Response: '.$text; ?>

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