Forum Moderators: coopster

Message Too Old, No Replies

HSBC CPI integration with PHP

Having a lot of trouble with this...

         

vincevincevince

12:55 pm on Jun 1, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi,

I've not had experience with HSBC CPI before, and am trying to integrate a shopping cart with it.

The server is Linux/Apache, and I have coded the cart in PHP. I'm desperately hoping that someone can give me a few pointers on what to do here, especially regarding the POST statements.

Telumehtar

3:18 pm on Aug 13, 2004 (gmt 0)

10+ Year Member



Luigi: It should generate a hash even if you just enter a test string such as...

testhash.e HASHKEY "Monkey"

Into the command line. However, I've just spent 20 minutes chasing a bug (yes - we just got our Hash Key - huzzah!)... I had entered a '0' instead of a 'O'. Note that, in the letter they send with the HashKey - if the 0 has no dot in the middle, it's a capital 'o'. If it has a dot in the middle, it's numeric. Something to check...

luigi_uk

3:38 pm on Aug 13, 2004 (gmt 0)

10+ Year Member



Hi Telumehtar,

Did you Telnet in or SSH to your domain and run the TestHash.e file from the command line?

Im using Putty and SSH'd in. I went to the directory the TestHash file was in and typed the command you entered in above. It then said TestHash.e command not found.

Something im doing wrong?!

Luigi

cbianchi

4:44 pm on Aug 13, 2004 (gmt 0)

10+ Year Member



Hi all,

I have been reading through these posts many times now, but I still cannot find a solution to the simple Order Hash generation problem.

Could someone be so kind to post the complete code to generate the Order Hash. Would you also please tell me where to put the libraries, either .e or .so?

We have a Linux Fedora 2 server, with Apache. Have copied (for now) the TestHash.e into the main www directory and ccLib.so into /lib. But if we execute the following code, nothing happens.

A complete example would be really appreciated.

Kind regards, Cristiano

$args = ('
"GBP" "1092082969" "https://www.mysite.com/confirm_process.php" "https://www. mysite.com/resultpost.cgi" "12345670000GBP" "Online purchase from mysite.com" "7150" "826" "Auth" "User00000001" "T" "1b300dad0c100197b109058627d47251"
');

$path='/var/www/html';
$cmd= $path.'/TestHash.e '.$args;

$ret=exec($cmd);
$ret=split(':',$ret);

Returns the hash
$hash=trim($ret[1]);
echo $hash;

ajimenez

9:07 am on Aug 16, 2004 (gmt 0)

10+ Year Member



Again, I think you need to try running it from the command line.

cbianchi

9:21 am on Aug 16, 2004 (gmt 0)

10+ Year Member



I did, and it tells 'not a command' or something like that.
I am at the point where I'll be asking my client to use WorldPay instead.

Some people managed to integrate it? I just cannot figure out how.

Thanks, Cristiano

Telumehtar

10:11 am on Aug 16, 2004 (gmt 0)

10+ Year Member



Luigi
I'm actually using a windows server here (stupid old pages still require ASP... grr). However, there are a few things to check on a Linux Box.

1./ Have you installed 'libCcCpiTools.so' into your '/lib' directory?

2./ After you have uploaded the file, you will need to 'chmod' it to make it executable. Just run 'chmod ug+x TestHash.e' from SSH when you're in the directory containing the file.

3./ You may have to access the command using './TestHash.e' instead of just 'TestHash.e'. You should then be able to run './TestHash.e HASHKEY "Monkey"' and it should produce a (useless) orderHash. (Obviously, putting your actual hashKey instead of HASHKEY).

.

Cristiano
I would suggest trying to get it to run as above before trying to integrate it with PHP. I would advise logging into your server with SSH, and getting it to run OK on the command line.

The .so file is the library, and should be installed into your lib directory (as you have done). The .e file is just the executable - so that can be anywhere you like - but you will need it somewhere 'handy' so you can call it from your scripts. '/var/www/bin' or anywhere will do.

Also - I think there is a problem with how you are sending the parameters to the file in your code. I don't see your hashKey being sent to the program...

$hashKey = "32DigitHashKey";
$cmd = "/var/www/bin/TestHash.e $hashKey $args";

.

The PHP Module...
...Seems to work fine! I've only compiled it on a windows machine at the moment though, and will try to compile it for Linux remotely on my production server so that you guys can use it. Naturally, full source will be supplied (and you would be advised to compile it for yourself)

cbianchi

10:33 am on Aug 16, 2004 (gmt 0)

10+ Year Member



Telumehtar,

thanks for the detailed reply :-) We are getting somewhere. I have done as you described, but if I run ./TestHash.e I now get this error message:

./TestHash.e: error while loading shared libraries: libstdc++-libc6.2-2.so.3: cannot open shared object file: No such file or directory

Now, what is this library. The other one (/lib/libCcCpiTools.so) is correctly installed and chmoded to ug+x

Any clue?

Thanks Cristiano

Telumehtar

11:22 am on Aug 16, 2004 (gmt 0)

10+ Year Member



Cristiano: Ahh, it looks like your system is missing the libstdc++ libraries. These aren't 'HSBC' libraries, but linux libraries - that quite a few programs require to run.

Fedora still uses 'rpm' and 'up2date' I presume? If so, then you might want to try running;

up2date compat-libstdc++
ldconfig

Be warned though - if your system still needs the standard C++ libraries installing, there could be a lot of packages that need installing as dependencies - so the process might take a while. It might also take up a lot of disk space (is it your server? / is your space limited?). Of course, it might not, but I have a feeling it will install a bunch of gcc/g++ stuff too.

After installing these libs, TestHash.e should be happy!

cbianchi

12:11 pm on Aug 16, 2004 (gmt 0)

10+ Year Member



Telumehtar

THANKS! That worked. I can now produce a Hash. Now I'll try to connect to HSBC. I suspect I'll be back with more questions :-)

Can I buy you a beer?

Cristiano

Telumehtar

12:56 pm on Aug 16, 2004 (gmt 0)

10+ Year Member



Cristiano: Fantastic! Quite a mission isn't it? Especially when compared to something that's nice like WorldPay. I can't see HSBC doing themselves any favours with this complex orderHash system. :( As for a beer - that's be great, would make the afternoon at work a bit nicer ;)

As for my own php_hsbccpi module - it's not compiling quite right under linux at the moment, so I'll have to have a play when I'm not at work. Still, hopefully soon!

This 92 message thread spans 10 pages: 92