Forum Moderators: coopster
When I execute,
$./TestHash.e arg1 arg2 from the command prompt,it works fine.
And when I run,
$TestHash.e arg1 arg2 I get a bad command error.
This means the OS isn't executing it or treating it as an executable. I have given execute permissions also to the file.
When I run exec("./TestHash.e arg1 arg2") through PHP I don't get any output.
Please help. This is really getting frustrating.
I cant seem to execute the TestHash.e file plus it doesnt report an error.
<?
$path='/home/virtual/site66/fst/var/www/cgi-bin';
$cmd="$path/TestHash.e CPIHASHKEY $str";
$ret=exec($cmd);
$ret=split(':',$ret);
//Returns the hash
$hash=trim($ret[1]);
return $hash;
?>
I have tested whether the file exists in its path and it does.
Please help.
I finally got the TestHash.e working. The problem was that I was passing a junk encrypted key as the argument. But I wasn't getting an error message either. I had to check the exit status with the system() function to get to the root of the problem. Anyway thanx everyone for the help. First hurdle is over, now moving onto the next one :)
libCcCpiTools.so has to be put in /usr/lib on the server.
And make sure "TestHash.e" has execute permissions(chmod 755) and it has to be uploaded in binary mode(via ftp)
Also I hope you are not making the same mistake as I did that is you need to pass the actual CPIHASHKEY to TestHash.e and not any junk value.
Has anyone come across this yet?
Ross
Just to check my process. I am calling my hash generation script from a php function within the OrderHash variable. Like this ..
<input type="hidden" name="OrderHash" value="<?php create_hash($str);?>">
Then my function is declared at the top of the page itself like this. My string looks like this when im passing it to TestHash.e OrderId=GBP\&TimeStamp=1092082969\& CpiReturnUrl=http://www.cpu-uk.com/confirm_process.php\& CpiDirectResultUrl=/home/virtual/site66/fst/var/www/cgi-bin/resultpost.cgi\& StorefrontId=12345678910GBP\& OrderDesc=Online purchase from www.cpu-uk.com\&PurchaseAmount=71.50\&PurchaseCurrency=826\&TransactionType=Auth\& UserId=User00000001\& Mode=T\&MerchantData=1b300dad0c100197b109058627d47251 Does this look correct? Thanks [1][edited by: jatar_k at 8:59 pm (utc) on Aug. 9, 2004]
<?
function create_hash($str){
$path='/home/virtual/site66/fst/var/www/cgi-bin';
$cmd="$path/TestHash.e eggandchips $str";
$ret=exec($cmd);
$ret2=split(':',$ret);
//Returns the hash
$hash=trim($ret2);
return $hash;
}
?>
[edit reason] fixed sidescroll [/edit]
But I can tell you how I passed the arguments. You need not pass them in a specific order. Only thing you have to do is pass the values in "". So the arguments in the example you gave would go like this:
"GBP" "1092082969" "https://www.cpu-
uk.com/confirm_process.php"
"https://www.cpu-uk.com/cgi-bin/resultpost.cgi"
"12345678910GBP" "Online purchase from www.cpu-uk.com" "7150" "826" "Auth" "User00000001" "T" "1b300dad0c1
00197b109058627d47251"
Some points to note here are:
1.) CpiDirectResultUrl has to be a complete web-url.
2.) Both CpiReturnUrl and CpiDirectResultUrl has to be secure ie HTTPS.
3.) PurchaseAmount=71.50 has to be in sent in pence and not pounds (ie 7150). Check the documentation regarding this.
dl("php_hsbccpi.dll");
$hash = _hsbccpi_generate_hash($vars, $hashKey);
I haven't had a chance to test it yet though, as I am still waiting for my client to receive their Hash Key. It requires the files php_hsbccpi.dll to be installed into the php/extensions directory and the CcCpi?.dll to be installed into System32/. I've not yet tried to compile in *nix, as I don't have it here at work.
Could someone tell me what format the hashKey takes (just a character count really - are we talking a small string, or a GPG type key)? I'm trying to program as much of it as I can before the Key arrives...
Namarie!
"GBP" "1092333315" "https://ensim.logicaldns.net/~admin66/confirm_process.php" "https://ensim.logicaldns.net/~admin66/returnpost.php" "UK********GBP" "Online purchase from www.cpuuk.com" "7100" "826" "Auth"
"User00000001" "T" "09426424e4c1e899873fd80b80624039"
It still doesnt generate a hash thought. Infact if I was to submit all the information to the CPI without generating a hash it goes straight to my CpiReturnUrl.
Whats going on? Please help :))
As for the page simply returning if it doesn't have the correct data - presumably it posts back the required CpiResultsCode to your CpiReturnUrl so that you can handle the error it receives. I think it's set to simply 'return with error' if it doesn't get all the required details (ie. the orderHash). Remember to ensure that all required fields have data, and that the data is of the right format (ie. The time is time() * 1000 etc.)
Good luck!