How to Integrate CITI Bank Emi Payment Gateway in Linux Server

0

Today i am writing another simple steps to integrate the CITI Bank PG for advanced PHP Programmer.
The following steps will only work on Linux server as the linux server already have shell scripting enabled. I did not tried the below process on Windows.
I suggest you to first read the docs files sent by Citi Bank team. Although they are having a less technical guys sitting in there team and they can’t provide the program written in PHP not in other languages. They have a simple C program and nothing else. Don’t waste your time in calling them again and again and the output will be negative.

Step 1. Create a folder named citibank (name can be different as per your choice) on your Linux server. The location would be like this “/var/www/html/citibank”
Step 2. Copy the checksum.so.1 and prog.c or santest.c C program file provided by Citi Bank PG Support team in the folder.
Step 3. Then create a PHP program generate_checksum.php
<?php
shell_exec(‘gcc -rdynamic -o prog3 prog3.c -ldl’); // this shell command will create a prog3 compile file that will help to generate the checksum
?>
The above program will create the prog3 executable compile file on your server.
(* As the file will be created in the same citibank directory so the directory must have 0777 read write permission.)
If the executable compile file is not creating then there must be some problem and you can not proceed further without this file. Contact the Network Guy in your team or read the error log to resolve the issue.

Note: If you want to know that shell scripting is enabled on your Linux server is not then run the following php code.
<?php $output = shell_exec(‘ls -lart’); ?>
If the PHP Program shows some output then the shell scripting is enabled on your server.
If not then refer the log file at location “/var/log/httpd/error_log” (As i am using the Apache Server)

Step 4. If everything written above is working in a correct way then you may proceed further with the following PHP program.
Simple create a file form.php on your server and run the program.
<?php
function getChecksum($string ,$key)
{
$checksum_output = shell_exec(“./prog3 $string $key”);
$checksum_output = explode(‘=’,$checksum_output,2);
$checksum = $checksum_output[1];
$generatedChecksum = trim($checksum);
return $generatedChecksum;
}
$checksum = getChecksum(‘CITI’, ’9310341016vasim’); // 4 digit and 12 digit
$return_url =’http://www.YourWebsite.com/anyreturnfile.php’;
$d_m_y_his = gmdate(‘dmYhis’); // 182652
$merchant_code = ’44350912′;
$order_no = ’20811332′; // 20662730
$trace_no = ’662730′; // 662730
$amount = ’200.0′;
?>
<FORM name=”frm” action=”https://www.test.citibank.co.in/servlets/TransReq?” method=”post” >
<INPUT type=”text” size=”200″ NAME=”MalltoCiti” VALUE=”0100|<?php echo $return_url; ?>|1|<?php echo $checksum; ?>|<?php echo $d_m_y_his; ?>|<?php echo $merchant_code; ?>|<?php echo $order_no; ?>|<?php echo $trace_no; ?>|<?php echo $amount; ?>|”>
<input type=”submit” NAME=”Submit” value=”Pay Now”>
</form>

The C Program that will be used by above php program is

#include
#include
#include
#include

int main(int argc, char *argv[] )
{
void *handle;
char temp1[strlen(argv[1])+1];
char temp2[strlen(argv[2])+1];
strncpy(temp1,argv[1],strlen(argv[1]));
temp1[strlen(argv[1])+1] = ‘′;
strncpy(temp2,argv[2],strlen(argv[2]));
temp2[strlen(argv[2])+1] = ‘′;

char *str;

char* (*func)(char*,char*);
handle=dlopen(“/var/www/html/non-deploy/checksum.so.1″,RTLD_LAZY);
func=(char* (*)(char*,char*))dlsym(handle,”Transpo”) ;
str=(char*)malloc(sizeof(char) * 20);
str=(char *)((*func)(temp1,temp2));
printf(“STR = %s n”, str);
}

According to me everything will work fine and the Citibank url https://www.test.citibank.co.in/servlets/TransReq? will open successfully.
If there is something that you did not understand then you can Conact me.
Cheers and have fun!

Tags: , , , , ,

If you liked this post you may want to Subscribe to Latest CodeMasterz buzz about Tech Tips, Worpdress Tips and more updates in your inbox.

Enter your email address:     Delivered by FeedBurner

Post a comment