Forum Moderators: coopster
I'm also trying to do this and can call the 'TestHash.e' from within my php script but when I run it I get:
TestHash.e: error while loading shared libraries: libCcCpiTools.so: cannot open shared object file: No such file or directory
Where do I put the 'libCcCpiTools.so' file so that it get picked up?
Thanks
Chris
I thought it was because of the data I was pushing through to it but I copied the example from the manual and still getting the error :( This is driving me crazy! :(
Do you have the email address for the tech support team, I can't find it anywhere?
Thanks
Chris
I think I have libCcCpiTools.so loaded, though I can't find any reference to it using phpinfo()... perhaps it is only loaded when required?
Can I access the library's function GenerateHash directly from PHP, and if so, do you have a PHP snippet that shows me how to do this?
Or must I go through a compiled binary such as testhash.e?
Regards,
Ian Tresman
Derby, UK
I have found this forum very helpful and am finally getting somewhere with this gateway.
I'm still a bit stuck though.
I can generate a hash using c:
function create_hash($str){
$path='/srv/www/htdocs';
$cmd="$path/TestHash.e HSBCHASHKEYHERE $str";
$ret=exec($cmd);
$ret=split(':',$ret);
//Returns the hash
$hash=trim($ret[1]);
return $hash;
}
But how do i build the $str?
Do I just implode the post?
Or do I have to put the fields in a certain order?
ie $str=$_POST['OrderID'].$_POST['TimeStamp'] etc.
Please help!
$strParam = str_replace(' ','+',$strParam);
$strParam = str_replace("&","\\&",$strParam);
only difference is that the ampersand must be escaped so it can pass to the script via exec().
I added in some different return codes throughout so that I could catch them with exec() if hash generation failed.
exec($strParam,$output,$returncode);
Not sure why you are imploding a POST, unless you are passing everything from another script in your purchase sequence. But you could do something like..
$keys = array_keys($_POST);
foreach ($keys as $key)
{
write your \&key=value stuff to a string in here
}
one other thing.. hard coding the CPI key in your php script is against the terms and conditions set by HSBC. You seem to be doing that in your exec() call?