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.

ajimenez

2:46 pm on Jul 29, 2004 (gmt 0)

10+ Year Member



Hi, Thanks for your reply.

The initial form is posted to a confirmation page. The confirmation page submits the info to hsbc.

On the confirmation page I am now generating the hash value with the following:

$fields=array('OrderId','OrderHash','TimeStamp','CpiReturnUrl',
'CpiDirectResultUrl','StorefrontId','OrderDesc','PurchaseAmount','PurchaseCurrency','TransactionType',
'UserId','Mode','MerchantData'
);

foreach($fields as $field){
$str.="$field=".$_POST[$field]."&";
}
$str=substr($str,0,-1);

$str = str_replace("&","\\&",$str);

Altho the hash values aren't matching up,,,

Is there something wrong with my string?

I also have now moved the hash key out of the web path. Thanks for noticing that.

ajimenez

2:58 pm on Jul 29, 2004 (gmt 0)

10+ Year Member



I just noticed 'OrderHash' shouldn't be in the array. I've taken that out. But still no joy :(

ajimenez

3:35 pm on Jul 29, 2004 (gmt 0)

10+ Year Member



Because the php set up is running in safe mode I don't need to escape the ampersands. So I've taken out:

$str = str_replace("&","\\&",$str);

Still doesn't work tho!

ajimenez

4:06 pm on Jul 29, 2004 (gmt 0)

10+ Year Member



Think I've cracked it. Any data in whitespace needs to be enclosed in double quotes.

The resultant string should look like:

8718386 1091115521000 [url...] [url...] shopid "Fine sample merchandise" 1995 826 Capture 1 T test

crypto

7:05 am on Jul 30, 2004 (gmt 0)

10+ Year Member



Hi Guys,

I also need to integrate HSBC with PHP for a UK Client. But after looking at the posts it seems integrating HSBC isn't that easy. So can anyone of you give me the details of the web hosts on which you were able to get HSBC running with PHP. I would prefer a Linux Host.

andeeh

9:46 am on Jul 30, 2004 (gmt 0)

10+ Year Member



I'm looking at the whole integration again and I'm working right now on moving the site to another isp.

[edited by: jatar_k at 3:45 pm (utc) on July 30, 2004]
[edit reason] removed url [/edit]

andeeh

9:51 am on Jul 30, 2004 (gmt 0)

10+ Year Member



Here's another gem that I found out - HSBC doesn't accept SSL Certificates with a postcode extension (X509 v3 extension). Only had to go back and get our SSL certificate re-issued! Took about a fortnight to sort that one out!

andeeh

9:53 am on Jul 30, 2004 (gmt 0)

10+ Year Member



ajimenez, I don't exactly know what paramaters you are passing and where to be honest. Did you compile your own code for generating the hash? Are you generating the merchant POST or validating the return POST?

ajimenez

12:42 pm on Jul 30, 2004 (gmt 0)

10+ Year Member



In that instance I was generating the merchant post.

I created a string of all the values I was going to post to HSBC (enclosed with quotes and separated by spaces).

Then I generated the has by sending the string to the testhash function using an exec call.

luigi_uk

9:09 am on Jul 31, 2004 (gmt 0)

10+ Year Member



Hi Guys,

Glad I have found some people who are experiencing problems with Integrating the HSBC CPI. First off does anyone know the address where the form should POST to reach the CPI server? Its not in the manual.

The samples are very poor.

Thanks

Anthony

This 92 message thread spans 10 pages: 92