Board index   FAQ   Search  
Register  Login
Board index php forum :: php coding PHP coding => General

CitiBank Payment Gateway Integration

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

CitiBank Payment Gateway Integration

Postby nasirperwaiz » Wed Mar 30, 2011 11:41 pm

Dear All,

I am trying to integrate CitiBank payment gateway in my application developed in php. The steps CitiBank told us to follow are these.

copy checksum.so.1 in /usr/lib folder
check the bit of the server using 'uname -1' and it should be i386
then type 'ldconfig -n /usr/lib' or add the line "/usr/lib" in /etc/ld.so.conf then run ldconfig.
then create a C language program to call the checksum file, sample c file is attached
compile the C program using 'gcc -rdynamic -o prog3 prog3.c -ldl' where prog3.c is the c program name
this will create a executable name prog3
test run the executable using './prog3 test 1234567890abcdef'
finally create a php file and call the c executable, sample php program is attached


#########################################
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<dlfcn.h>
int main(int argc, char *argv[] )
{

void *handle;
char *str;

int len1, len2;
char *param1 , *param2;
len1=strlen(argv[1]);
param1=(char*)malloc(sizeof(char*)*(len1 +1));
strcpy(param1,argv[1]);
//printf("Argument1 - %s\n",param1);

len2=strlen(argv[2]);
param2=(char*)malloc(sizeof(char*)*(len2 +1));
strcpy(param2,argv[2]);
//printf("Argument2 - %s\n",param2);

/*
char temp1[strlen(argv[1]+1)];
char temp2[strlen(argv[2]+1)];
strncpy(temp1,argv[1],strlen(argv[1]));
temp1[strlen(argv[1])+1] = '\0';
strncpy(temp2,argv[2],strlen(argv[2]));
temp2[strlen(argv[2])+1] = '\0';
*/

char* (*func)(char*,char*);
handle=dlopen("/usr/lib/checksum.so.1",RTLD_LAZY);
func=(char* (*)(char*,char*))dlsym(handle,"Transpo");
str=(char*)malloc(sizeof(char) * 20);
str=(char *)((*func)(param1,param2));
//str=(char *)((*func)(temp1,temp2));
/*
printf("\n");
printf("%d",argc);
printf("\n");
printf("%s",argv[1]);
printf("\n");
printf("%s",argv[2]);
printf("\n");
*/
printf("STR = %s \n", str);
//return str;
//return 0;
}


---------------

###########################
PHP program
-----------
<?php
$output = shell_exec('./prog3 test 1234567890abcdef');
echo "$output";
?>

We followed all the above steps. But when we run the executable c program we get SEGMENTATION FAULT error.

Can anybody help us how to do it?

Thanks.

Nasir Perwaiz
nasirperwaiz
New php-forum User
New php-forum User
 
Posts: 6
Joined: Wed Jan 05, 2011 1:05 am

Re: CitiBank Payment Gateway Integration

Postby egami » Thu Mar 31, 2011 4:34 am

Sounds like a compilation problem.
I'm not sure why they would want you to change the libs.. they generally go hand in hand with other application libraries and could severly screw up your box.
User avatar
egami
php-forum GURU
php-forum GURU
 
Posts: 2197
Joined: Wed Oct 06, 2010 11:19 am
Location: Happy Valley, UT

Re: CitiBank Payment Gateway Integration

Postby johnj » Thu Mar 31, 2011 5:47 am

In your C code, I saw at least three uninitialized pointers - Is this the right way ?
I think segmentation fault happens when you try to access something (memory or storage) that you don't own (did not allocate or you deleted it etc)
johnj
php-forum Super User
php-forum Super User
 
Posts: 1805
Joined: Thu Mar 10, 2011 5:07 pm

Re: CitiBank Payment Gateway Integration

Postby tkdbb84 » Thu Mar 31, 2011 6:07 am

first i'm confused on why you are copying already allocated variables to new memory locations:
Code: Select all
char *str;

int len1, len2;
char *param1 , *param2;
len1=strlen(argv[1]); //why are we storing the lengths into an int,
                             //when they can be accessed via strlen,
                             //your code isn't long enough
                            // or processor heavy enough for it to be an "optimization"
param1=(char*)malloc(sizeof(char*)*(len1 +1));
strcpy(param1,argv[1]);  //why are you copying a char* to a different char*.... just use the original.
//printf("Argument1 - %s\n",param1);

len2=strlen(argv[2]);
param2=(char*)malloc(sizeof(char*)*(len2 +1));
strcpy(param2,argv[2]);
//printf("Argument2 - %s\n",param2);



to answer your question, Segmentation fault is caused by referencing memory thats already been freed, using pointers incorrectly, or trying to access some messed up hardware.

which in your case, is being kicked from your strcpy() calls, skip copying the variables into new locations and it should work. but i'm no C expert.
tkdbb84
New php-forum User
New php-forum User
 
Posts: 137
Joined: Tue Mar 08, 2011 9:25 am

Re: CitiBank Payment Gateway Integration

Postby mildredolson » Thu Oct 11, 2012 9:29 pm

Generally all the online payments made by the bank, there are a number of payment gateways are available for payment transactions. People want secure payment for online shopping is important, you can go to www.merchantinc.com for online payment which offers the best rate in the industry for the credit card processing.
mildredolson
New php-forum User
New php-forum User
 
Posts: 11
Joined: Thu Oct 11, 2012 9:21 pm


Return to PHP coding => General

Who is online

Users browsing this forum: No registered users and 3 guests

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.