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.

crypto

6:23 am on Aug 7, 2004 (gmt 0)

10+ Year Member



Same here guys. Never felt so happy after getting a code to run :)

luigi_uk

6:39 pm on Aug 8, 2004 (gmt 0)

10+ Year Member



Should I be able to see anything in phpinfo(); when libCcCpiTools.so is loaded?

crypto

9:38 am on Aug 9, 2004 (gmt 0)

10+ Year Member



"Should I be able to see anything in phpinfo(); when libCcCpiTools.so is loaded?"

Nope. "libCcCpiTools.so" has nothing to do with PHP. Its a C shared object.

luigi_uk

8:40 pm on Aug 9, 2004 (gmt 0)

10+ Year Member



Im waiting for my client to send me his Hash Key, obviously this needs to be correct before I can go any further.

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.
<?
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;
}
?>

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]
[edit reason] fixed sidescroll [/edit]

crypto

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

10+ Year Member



I'm not sure if it works this way:
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

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.

ajimenez

11:01 am on Aug 11, 2004 (gmt 0)

10+ Year Member



It would only work for me that way as well. Note that you only have to put the value in quotes if it contains spaces.

Telumehtar

3:39 pm on Aug 12, 2004 (gmt 0)

10+ Year Member



I have written a PHP Module that simply piggybacks on the .dll (and theoretically the .so file), so I can just call the Hashing function thusly...

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!

luigi_uk

6:09 pm on Aug 12, 2004 (gmt 0)

10+ Year Member



I have now revised my passing data.

"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 :))

Telumehtar

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

10+ Year Member



Do you have your Hash key yet? If not, then presumably the call to create the Hash will simply fail.

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!

crypto

2:28 pm on Aug 13, 2004 (gmt 0)

10+ Year Member



luigi_uk,

It seems you are not generating the timestamp correctly.

Use this:

$TimeStamp=time()*1000;

This 92 message thread spans 10 pages: 92