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.

ukgimp

1:24 pm on Aug 16, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



cbianchi

Are you going to post the gereric code code? :)

cbianchi

1:34 pm on Aug 16, 2004 (gmt 0)

10+ Year Member



I will as soon as I'm through :-)

Cheers, Cristiano

luigi_uk

7:03 pm on Aug 16, 2004 (gmt 0)

10+ Year Member



Hi Telumehtar

Thanks for your help and time in the matter.

I have got a bit further with running the TestHash.e file from the command line however it is saying 'Error generating hash!.

I have set both the permissions for TestHash.e and the libCcCpiTools.so to 755. Still no luck.

Your help appreciated...

Telumehtar

7:53 pm on Aug 16, 2004 (gmt 0)

10+ Year Member



Luigi: Hey! Ok - If you're getting the error "Error Generating Hash", then that means that the code is actually working... That's a good start ;) There's only really one thing I could think it could be - are you sure that you are entering your HashKey correctly (no quotes around it). Your call to the program should look like this. Only the mess in the middle should be your HashKey.

./TestHash.e 1234567890abcdef=/+1234567890abc "Monkey"

If it were having problems with libraries or permissions - you could get a more 'linux-y' error (File not Found, Cannot Load Library etc). As I said before - be VERY careful when typing your HashKey from the printed version - you really have to check the O's carefully (no dot inside them, and they're a capital letter - a dot inside means they are numeric). Hope this helps!

Everyone: Could someone please confirm that the libCcCpiTools.so file you have is 65536 bytes big? I'm pretty sure that the file is actually damaged - and I have a feeling that the file that HSBC have been sending out is damaged :(. On that note - I don't suppose anyone has an email address to contact the techy-people with? (Don't really wanna phone about insanely technical stuff like this and get 'regular phone people' that won't understand about linux programming ;))

crypto

8:47 am on Aug 17, 2004 (gmt 0)

10+ Year Member



Telumehtar,

Yes the size of libCcCpiTools.so is 65,536 bytes and you can contact the tech. guys of HSBC at secure-epayments@hsbc.com

Telumehtar

9:15 am on Aug 17, 2004 (gmt 0)

10+ Year Member



Crypto: Many thanks for confirming this - email just sent off to the address specified. Looking at it - I'm more convinced that it's truncated by the fact that, not only do all of the linux binary utility programs tell me that it is, but also that it's exactly the size of an 'unsigned short' (65536)...

I have uploaded the windows version of my php module, php_hsbccpi. Unfortunately, I cannot compile it from within linux because it will not link with the (apparently broken) file 'libCcCpiTools.so' - which means the linux version is kind of useless until it can ;). When I get it working under linux as well, I will publish the full source code (there's not much) - but it's a real mess at the moment as I've been hacking it to make it work under both OS'es (and didn't realise that error was down to a broken lib until after much playing...) Still - you can now generate an orderHash with 1 line of PHP :)

[edited by: jatar_k at 4:55 pm (utc) on Aug. 17, 2004]
[edit reason] removed url [/edit]

Telumehtar

2:55 pm on Aug 17, 2004 (gmt 0)

10+ Year Member



After a short rappor with the 'techy guys' over email, I was sent another version of the linux shared library libCcCpiTools.so. This time around - the file is around 85Kb, and more importantly, my bin-utils recognises it as a valid file!

So, 2 more updates for you guys. First of all, the linux version of the php module is now there for your downloading pleasure. At only a 5Kb download, why not give it a shot? It allows you to generate your orderHash with only 1 or 2 lines of PHP script - whoo! Comes with a detailed readme file on setting it up too! [angryrooster.co.uk ].

Also, I'm not entirely sure if I'm allowed to distribute this file (I can't see why not though), but I've uploaded the full (fixed) version of the libCcCpiTools.so file for those of you with the 64Kb version. I'm not going to publish a link on my site to it though, and I'll be removing it in a couple of weeks just incase it's not meant for prying eyes. You can find that one here: [angryrooster.co.uk ]. It's gzipped - so it's only 35Kb to download or so... Enjoy!

cbianchi

4:24 pm on Aug 17, 2004 (gmt 0)

10+ Year Member



You are an absolute star! Thanks for doing this, you'll help lots of people :-)

I tried yoru code (there is a minor parse error - missing semicolon on line 13), without loading your library at startup (through PHP). It might just be my Fedora system, but the second condition fails with the runtime download.

I modified your code slightly to take this possibility into account, by introducing a $loaded variable which is true if the library loads correctly at runtime.

This is how it looks.

<?php
/*
* This if-block is not required if you are loading the module from php.ini
*/

if (!extension_loaded("php_hsbccpi")){
$loaded = dl("php_hsbccpi.so");
}

if (extension_loaded("php_hsbccpi") &&!$loaded) {
echo "The module 'php_hsbccpi' could not be loaded - your order will not process through the HSBC CPI.";
} else {
$hashKey = "12345678901234567890123456789012"; /* Your 32-Digit Hash Key */
$variables = array( "Here", "Are", "Some", "Variables" );
$orderHash = _hsbccpi_generate_hash($variables, $hashKey);
}

if ( empty($orderHash) ) {
echo "Order Hash was not set! Please ensure that the hashKey supplied was correct!";
} else {
echo "Order Hash was generated: {$orderHash}";
}
?>

Thanks again, Cristiano

luigi_uk

7:12 pm on Aug 17, 2004 (gmt 0)

10+ Year Member



Telumehtar: Hi! Im sure all I need now is the correct HashKey to get it generating correctly. Im sure once I get this working I can move past this stage and face the next! Thanks for your help! Ive got your email in case I need your most valued help :)

Would any one be willing to a fake or a dummy Hash Key (I mean one that has the correct format but doesnt belong to anyone) - hope that made sense.

Oh by the way my libCcCpiTools.so file is 81kb if that helps.

Telumehtar

10:21 am on Aug 18, 2004 (gmt 0)

10+ Year Member



Cristiano: Ahh yes - There could well be problems with the sample code - I just wrote it up in Vi quickly so that I could provide a readme with the module. Ahhh - I've spotted it! The 'extension_loaded' is taking the wrong parameter... It should be as follows... (I have just uploaded new versions of both downloads - see the bottom of this post.)


if (!extension_loaded("hsbcCpi")){
$loaded = dl("php_hsbccpi.so");
}

if (extension_loaded("hsbcCpi")) {
die();
} else {
// Do Your Worst with the Hash!
}

If it's still not working - are you sure you have the 85Kb libCcCpiTools.so in '/usr/lib', and that php_hsbccpi.so is sitting in '/usr/lib/php4' (or your php extensions dir). If this doesn't work - what version of PHP are you using?

Luigi: Of course - just throw an email my way if you have any problems, and I'll help all I can! I'll usually respond pretty quick - if I'm at work. For some 'dummy' hash keys - I've just written a tiny php script to generate some, try these 'esfmrwwruiu6tk5lsfq6p/gu3sak2z/w', '1er3nfa6ks37xlq59orfj019kxpsb1t'. They should see you through until the end of testing.

Everyone: New versions of the modules are available for download. The Linux one just has an updated readme - I think the PHP should work this time (but can't test it on my windows box). However, I have made an Important Update to the Windows Module - in that, it now works on more than a tiny selection of machines (stupid bug - grr). Version 1.0.0 probably won't work - so if you've got it, overwrite it with this one. Also, the readme was updated (and tested) with working code. Enjoy!

This 92 message thread spans 10 pages: 92