VirtueMart Forum

VirtueMart Dev/Coding Central: VM1 (old version) => Development Projects, Modifications, Hacks & Tweaks. VM1.1 => Payment Modules => Topic started by: jon.hathaway on July 22, 2005, 19:28:56 PM

Title: HSBC CPI Integration
Post by: jon.hathaway on July 22, 2005, 19:28:56 PM
I realise that there are very few payment modules at the moment, and I am currently in the process of writing a payment module that will integrate with HSBC CPI gateway.

However, I am not the best coder going and would liek to know if anyone else is looking at doing this.

The problem with the CPI integration is that it uses a compiled library for the call back for the gateway after authenticating the order.....I have no idea how to do this. I know oscommerce have an HSBC integration and I was wondering if any one could migrate this from oscommerce to phpshop.

I have two interesting links with regards to this topic:

http://www.webmasterworld.com/forum88/3967-2-10.htm
http://forums.oscommerce.com/index.php?showtopic=76967&st=0

Thanks
Title: Re: HSBC CPI Integration
Post by: stovesy on July 29, 2005, 12:28:44 PM
I'm looking to do thet same, and have breifly looked at the os-commerce code. I'm struggling because I don't have any details of the HSBC api or protocols. Do you have such info ?
Title: Re: HSBC CPI Integration
Post by: jon.hathaway on August 01, 2005, 21:09:03 PM
We are still trying to get the info out of HSBC. Everytime we ask for it they seem to gorget as it never arrives. We have had quite a bit of success with using the Hash code and the libraries.

One thing to note on a shared server though is whether or not the server will allow you to set the LD_LIBRARY_PATH. If you are running php in safe_mode=on then you are very unlikely to get HSBC working as you will need to change the library path to point to the location of the libCCPITools.so library that HSBC give you.

We currently have got the point where the hash is being accepeted and is successfully being generated and we are now running into problems posting it to either https://www.cpi.hsbc.com/server or https://www.secure-epayments.api.hsbc.com.

I think our script is in error, but the error we are getting relates to the SSL session not being verified.

Keep in touch and we'll let you know how we get on. You are more than welcome to the code once we have it and we will be releasing it under GPL.

Jon
Title: Re: HSBC CPI Integration
Post by: husayt on August 08, 2005, 15:13:31 PM
Hi again,
I thought this might be useful. Please, find enclosed php port of hash generation procedure fom HSBC CPI.
sample for use:

$h=generateHash(array('1','3','2'),"3jmNetQZP/ZSIUe/cYIHMkB70Bha4RyJe7mOAMqOoH8=");
echo ("<br>h=$h<br>");

and here is the source code:


// helper class
class SecCrypto{
var $_fldif;
    var $a;
    function rot13(&$abyte0)
    {
        for($i = 0; $i < strlen($abyte0); $i++)
        {
            $c = ord($abyte0[$i]);
            if($c >= ord('a') && $c <= ord('m') || $c >= ord('A') && $c <= ord('M'))
                $abyte0[$i] = chr($c + 13);
            else
            if($c >= ord('n') && $c <= ord('z') || $c >= ord('N') && $c <= ord('Z'))
                $abyte0[$i] = chr($c - 13);
        }

    }

    function  encode($abyte0)
    {
        return base64_encode($abyte0);
    }

    function  decode($s)
    {
        return base64_decode($s);
    }

    function encrypt($abyte0, $abyte1)
    {
$td = mcrypt_module_open (MCRYPT_DES, '', MCRYPT_MODE_CBC, '');
$iv = $this->a;
$ks = mcrypt_enc_get_key_size ($td);
$key=substr($abyte1,0,$ks);
  /* Intialize encryption */
    mcrypt_generic_init ($td, $key, $iv);
return  mcrypt_generic ($td, $abyte0);
// old version
// return mcrypt_cbc(MCRYPT_DES,substr($abyte1,0,mcrypt_get_key_size ('des', 'cbc')),$abyte0, MCRYPT_ENCRYPT,$this->a);
    }

    function decrypt($abyte0, $abyte1)
    {
$td = mcrypt_module_open (MCRYPT_DES, '', MCRYPT_MODE_CBC, '');
$iv = $this->a;
$ks = mcrypt_enc_get_key_size ($td);
$key=substr($abyte1,0,$ks);
  /* Intialize encryption */
    mcrypt_generic_init ($td, $key, $iv);
$ret=mdecrypt_generic($td, $abyte0);

// $ret=mcrypt_cbc(MCRYPT_DES,substr($abyte1,0,mcrypt_get_key_size ('des', 'cbc')),$abyte0, MCRYPT_DECRYPT,$this->a);
// Bus fix
while($ret[strlen($ret)-1]=="\4" && strlen($ret)>0){
$ret=substr($ret,0,strlen($ret)-1);
}
return $ret;
    }

    function encryptEncode($abyte0, $abyte1)
    {
        return $this->encode($this->encrypt($abyte0, $abyte1));
    }

    function decodeDecrypt($s, $abyte0)
    {

        return $this->decrypt($this->decode($s),$abyte0);
    }

    function initKey($s, $s1, $s2)
    {
        $abyte0 =chr(0);
        $abyte1 = $s1;
        $abyte2 = $s2;
        $byte0 = 4;
        $i = $byte0 + 9;
        $j = rand(0,30);
$j = 0;
        if($j > $byte0 * $i)
            $j -= $byte0 * $i;
        $k = 0;
        for($l = 0; $l < $byte0 * $i; $l++){
            switch(($j + $l) % $i)
            {
            case 4: // '\004'
            case 6: // '\006'
            case 8: // '\b'
            case 9: // '\t'
            default:
                break;

            case 7: // '\007'
                if($k < 2){
                    $abyte0 = $this->encrypt($abyte1, $abyte2);
}
                break;

            case 5: // '\005'
                if($k < 2){
                    $abyte0 = $this->encrypt($abyte1, $abyte2);
}
                break;

            case 10: // '\n'
                if($k < 2){
                    $abyte0 = $this->encrypt($abyte1, $abyte2);
}
                break;

            case 3: // '\003'
                if($k == 3){
                    $k++;
}
                break;

            case 0: // '\0'
                if($k == 2)
                {
                    $abyte0 = $this->encrypt($abyte1, $abyte2);
                    $k++;
                }
                break;

            case 1: // '\001'
                if($k == 1)
                {
                    $abyte2 = $abyte1;
                    $this->rot13($abyte2);
                    $k++;
                }
                break;

            case 2: // '\002'
                if($k == 0)
                {
                    $i1 = 48 + (ord($abyte1[0]) + 10) % 10;
                    $abyte1[0] = chr($i1);
                    $k++;
                }
                break;
            }
}
        return $this->decodeDecrypt($s, $abyte0);
    }

    function SecCrypto()
    {
        $s = "KmJTwzVPwjoxQdWJb1BxbuhBSa2RuM05+/aUdgYoGdFWWf04CKIQTxtxLeKCp+5J";
        $s1 = "y8YhmjsAoMUW9RxfXBSos0A6LwGd+5pXv/MRAKCYFLG";
        $s2 = "BqRkPAG8DFFAdeN5SMAArktCYuUGXi2q88EDoOs3Ykw0k";
$this->a =chr(98).chr(84).chr(120).chr(114).chr(66).chr(87).chr(80).chr(112);
        $this->_fldif = $this->initKey($s, $s1, $s2);
$this->_fldif=substr($this->_fldif,0,44);
    }

    function encrypt1($s)
    {
        if($s == NULL)
            return NULL;
        else
            return $this->encryptEncode($s, $this->_fldif);
    }


    function decrypt1($s)
    {
        if($s == NULL)
            return NULL;
        else
            return $this->decodeDecrypt($s, $this->_fldif);
    }
function decryptToBinary($s){
        if($s == NULL)
            return NULL;
        else
            return $this->decodeDecrypt($s, $this->_fldif);
}


//echo "iv size=".mcrypt_get_iv_size ('des', 'cbc')."<br>";
//echo "key size=".mcrypt_get_key_size ('des', 'cbc')."<br>";
//$h=generateHash(array('1','3','2'),"3jmNetQZP/ZSIUe/cYIHMkB70Bha4RyJe7mOAMqOoH8=");
//echo ("<br>h=$h<br>");

function generateHash($vector, $s)
{
        $vector1 = array();
        for($i = 0; $i < sizeof($vector); $i++)
        {
            $flag = false;
            $s2 = $vector[$i];
            for($k = 0; $k < sizeof($vector1) && !$flag; $k++)
            {
                $s4 = $vector1[$k];
                $l = strcmp($s2,$s4);
                if($l <= 0)
                {
array_push($vector1,"");
for($r=sizeof($vector1)-2;$r>=$k;$r--){
$vector1[$r+1]=$vector1[$r];
}
                    $vector1[$k]=$s2;
                    $flag = true;
                }
            }

            if(!$flag)
array_push($vector1,$s2);

        }

        $s1 = "";
        for($j = 0; $j < sizeof($vector1); $j++)
        {
            $s3 = $vector1[$j];
            $s1 = $s1 . $s3;
        }
        $seccrypto = new SecCrypto();
        $abyte0 = $seccrypto->decryptToBinary($s);
$ret=base64_encode(mhash(MHASH_SHA1,$s1.$abyte0,$abyte0));
return $ret;
}
Title: Re: HSBC CPI Integration
Post by: stovesy on August 21, 2005, 21:31:45 PM
I'm sortof half way thru (up to exit(0)) but I've got the documentation CD from HSBC
Sadly I'm struggling to get the mcrypt library installed on apache-php under windows - I winder if there is a native PHP equivalent to the mcrypt functions used here ??

Anyway folks - let's keep chipping away at this.


[attachment deleted by admin]
Title: Re: HSBC CPI Integration
Post by: stovesy on August 21, 2005, 21:34:49 PM
This might help (HSBC integration guide - pdf)


[attachment deleted by admin]
Title: Re: HSBC CPI Integration
Post by: stovesy on August 22, 2005, 10:42:26 AM
I've actually got libmcrypt - but am struggling to find php_mcrypt.dll.

I've got linux at work so I'll set it up on that.
The only concern I have is we are putting more requirements on our hosts (to have mcrypt installed). Wouldn't it be nice if we could get this all done in native php ?
Title: Re: HSBC CPI Integration
Post by: stovesy on August 22, 2005, 11:30:58 AM
Just noticed we need another external library 'mhash' ???
Title: Re: HSBC CPI Integration
Post by: stovesy on August 22, 2005, 12:55:32 PM
Something else I've been reading.
http://www.webmasterworld.com/forum88/3967.htm

Title: Re: HSBC CPI Integration
Post by: husayt on August 22, 2005, 17:26:21 PM
It will be good if HSBC has test server.

But in any case I have got a cusomer account in test mode, we can do tests with.
So I can do tests if I got the module.

Thanks.
Title: Re: HSBC CPI Integration
Post by: stovesy on August 22, 2005, 20:13:43 PM
As soon as I get any joy, I'll post the module.
At work (via a linux based php & apache). I am getting something back from the server.
I'll let you know how far i'm getting.
Title: Re: HSBC CPI Integration
Post by: stovesy on August 23, 2005, 17:40:30 PM
I can't get my head around this.

The HSBC payment system works I think in 3 steps.

1. Various data is posted to the HSBC server to initiate the payment.
2. The HSBC server presents the user with a secure page to fill in payment options
3. With 2 complete, the HSBC server posts back various confirmatory data.

How can I handle this within the payment processor, as far as I can see, it's one peice of code which has no possibility of this. Any of the moderators help on this ??

Thankyou
Title: Re: HSBC CPI Integration
Post by: mitch_a on August 24, 2005, 01:11:19 AM
stovesy, husayt

I also have a requirement for a payment module for the HSBC CPI.
I am in the process of setting up a test account with HSBC and the site will be hosted on a dedicated Linux server.
It would be great to get some more information regarding your progress todate and I would be happy to help, where I can (I'm more PHP hacker rather than coder i'm afraid).

I note above that you are having difficulty setting up a test server - due to a clients sites being live - let me know if I can be of help here.

With regards to your question above re the payment processor being only one piece of code --
I have , in the past, used the paypal module for payment processing  - this is in 3 steps - not sure if this will help you in any way ??

1 - Various data posted to paypal (albeit some in hidden, unsecure form fields)
2 - Payment made on paypal
3 - Code returned to phpshop to confirm payment / change order staus etc.

I have yet to look at the payment processor code and HSBC process in any detail, but image that it it not a simple 'forms' type interface (ala paypal, protx forms etc) - hence the above will not be helpful.

If I can help with testing / any other way, just let me know.

Regards

Title: Re: HSBC CPI Integration
Post by: stovesy on August 24, 2005, 09:57:02 AM
Here's what I have so far.



[attachment deleted by admin]
Title: Re: HSBC CPI Integration
Post by: stovesy on August 24, 2005, 12:19:41 PM
I'm starting to get this after looking at a load of Soerens code.

We've gotta use the 'payment_extrainfo' field to pass our form to the CPI. I installed the ps_pbs payment processor. What happens is the order completes in the phpShop system, then the code in the 'extra_info' field gets evaluated and any output is displayed at the bottom of the 'ThankYou' page.

(This is a little wrong really - because the payment may not go through - so the order is not complete) CPI is also able to return a payment status.. but anyway.

What needs to happen, is instead of posting the CPI variable directly, we need to get all that info into a form which is defined in the 'extra_info' field.

Just have a look at the 'ps_pb.php' file in admin-components-com_phpshop-classes-payment.

Title: Re: HSBC CPI Integration
Post by: chikkensoop on August 30, 2005, 16:49:38 PM
Any more movement on this? I have a friend desperate to get himself setup with a shop but needs to use HSBC CPI. Also if theres anything I can do to help please dont hesitate to ask... :)
Title: Re: HSBC CPI Integration
Post by: stovesy on September 01, 2005, 10:14:28 AM
If anyone can now loan me the use of an HSBC CPI account for testing, this would be usefull.
Don't post the keys etc. here. PM or email.
Cheers.
Title: Re: HSBC CPI Integration
Post by: chikkensoop on September 02, 2005, 12:32:02 PM
Getting my bod to contact HSBC and get his account put into test mode... will get back to you when I have more info
Title: Re: HSBC CPI Integration
Post by: chikkensoop on September 05, 2005, 10:26:18 AM
Just a quick update, apparently HSBC are dragging their heels and the account wont be set up until near the end of september :(

Anyone else got an active account they can get put in test mode?
Title: Re: HSBC CPI Integration
Post by: stovesy on September 05, 2005, 17:14:59 PM
Think we've got one sorted.  I'll let you know.

At present, CPi is responding back with result code 10. The transaction failed because of invalid input data. I'll have a look tomorrow at this, and then post the code I have so far.
Title: Re: HSBC CPI Integration
Post by: stovesy on September 08, 2005, 11:39:17 AM
Here's what I've got so far.

From the archive, copy the files ps_hsbc.* into your mambo root/administrator/components/com_phpshop/classes/payment
and the file payment.hsbc_return.html into  mambo root/administrator/components/com_phpshop/html

Then, into phpshop admin, choose Add Payment Method.
Payment Method Name: HSBC
Code: HSBC
Payment class name: ps_hsbc
Turn on Use Payment Processor
Make sure that Active ? is checked
Save those changes. You should see it added to the Payment Method List
Go in again and edit the HSBC. Go into the Configuration tab.
Fill in your storefront ID and hash keys.
and alter the Result URL to point to your server.

Now the bad news.
All I'm getting back from the cPi is result code 10 - The transaction failed because of invalid input data
I've been over the data being sent to HSBC (view source on the ThankYou page) and it all looks OK. Maybe another fews sets of eyes will help. OR, it could be something to do with the account I'm testing on. Thanks to husayt for supplying an acocunt.

Anyway. Onwards.

[attachment cleanup by admin]
Title: Re: HSBC CPI Integration
Post by: stovesy on September 13, 2005, 09:42:28 AM
Ground to a halt.

I'm still gettting nothing back from the CPI other than result code 10.
The fields being sent to the CPI look good to me.

Looking on other forums - it seems that HSBC sometimes send out duuf hash keys ???
I'm not sure if this is the case with the account husayt has provided as the hash I'm generating in the return phase, matches the hash sent back by the CPI ?

I'm running out of ideas on this ?
Anyone in a position to help ??
Come on everyone, we are getting close.
Title: Re: HSBC CPI Integration
Post by: devkungfoo on September 13, 2005, 10:17:40 AM
Hi,

I should have been paying more attention to this forum  ;)

I've come to almost the same point as you have here.
I've spent some time on the phone with hsbc and learnt a few things:

when you speak to the support at hsbc, if you don't ask they
will only give you the first error they see in their console.
So ask them to give you a rundown of all errors they see.
This will save you countless callbacks  ::) and will usually
allow you to first sort out any errors that may have crept in
to your fields.


I also used the secCrypto class supplied with the oscommerce hsbc module
and I'm not 100% certain yet but i think that the hash generated by this class
isn't the same as the hash generated by the hsbc supplied testhash.exe
(I'm currently testing this a bit further)

It's a bit vague regarding when to use " (quotes) around fields and this may
also be whats throwing us off??

I will be calling hsbc back tomorrow (as I'm off sick today  :'(  )
I'm looking forward to this call because it should clear things up completely!!

I'll pass on any info when I get some,
Title: Re: HSBC CPI Integration
Post by: stovesy on September 13, 2005, 13:22:21 PM
Can you post what you've got so far so that we may compare code ??
I too am using the has functions from osCommerce and as I've said before I'm getting a matching hash on the data presented in the Return phase, so this is encouraging.

Thanks for you input.
Title: Re: HSBC CPI Integration
Post by: stovesy on September 13, 2005, 14:51:08 PM
Here's another point I thought of.

Is there anything that can be configured from the Admin side of the CPI.
I've been reading through (countless) posts on the whole subject and get the impression that there may be some configuration items which can be switched on or off (Collecting shipping and billing addresses).
I haven't seen the administrator front end so I'm guessing.
If we are providing data which the CPi is not expecting, this may cause errors ???
Title: -
Post by: devkungfoo on September 13, 2005, 20:48:54 PM
OK, Since I couldn't get my code to generate a decent hash, I dumped it in place of the code provided here
and so far so good.

1. The field names are case sensitive, so replace:
         'UserID' => substr($dbbt->f("name"), 0, 32),
with
         'UserId' => substr($dbbt->f("name"), 0, 32),

i.e. UserId not UserID

2. if I block the billing details - everything is fine, it goes to hsbc and prompts
the user for his credit card details. As soon as I add the billing details back it
returns code 10.

I've checked the billing details and I'm 100% certain that all is good.
So that leaves the following possibilities:

1. Quotes around fields that contain spaces
2. Empty fields (in my case BillingCounty) - if empty should it be left out ??
3. I'm delusional and 100% certainty isn't good enough!!

the hsbc documentation is horribly lacking and it's a shame because decent integration
procedures would probably save them a truckload of cash in call centre costs  >:(

I'm gonna be on the phone with hsbc tomorrow, so I'm sure I'll sort out the billing detail problems.
And I'll let you guys know.

Some News
If the billing address details are sent in your post to hsbc then the shipping details
are required too!

And boom! once you provide both the billing and shipping its all fine and dandy.

I suggest that conditional you have on whether on not to provide shipping details should include the billing details
as well, so either just the bare minumum or all details.

Title: Re: HSBC CPI Integration
Post by: stovesy on September 14, 2005, 12:27:42 PM
!!! FINALLY !!!

It's working.
I've just managed to process my first transaction.
It needs polishing now.

I'll post the code later on today.
Title: Re: HSBC CPI Integration
Post by: stovesy on September 15, 2005, 15:04:18 PM
Give this a try then guys, and let me know how things go on.

Make sure that the 'Payment Method type' is 'bank debit'.

[attachment cleanup by admin]
Title: Re: HSBC CPI Integration
Post by: gwen on September 17, 2005, 20:31:24 PM
please could you participate to

http://mambo-phpshop.net/index.php?option=com_smf&Itemid=71&topic=12015.0

you seem to have a big experience on this matter now  :)
Title: Re: HSBC CPI Integration
Post by: chikkensoop on October 19, 2005, 12:09:21 PM
Just a note to stovesy to see if he's still around... I've not managed to get this working, once it gets to the confirm order stage where it should launch the user off to the CPI pages it just dumps me back to index.php... any ideas?
Title: Re: HSBC CPI Integration
Post by: chikkensoop on October 24, 2005, 11:51:36 AM
Nope, absolutely nothing thrown back... it goes through the checkout process asking the user for their billing and postal address, pick a postage type, then gets to a summary screen where I would guess it would launch the user over to the HSBC servers to enter payment details... but the form on that page simply has http://www.insertsitenamehere.com/index.php as the target of the form around the button they click to continue.

Any thoughts?
Title: Re: HSBC CPI Integration
Post by: ssm on October 24, 2005, 16:01:04 PM
Are HSBC still offering HSBC CPI Integration? I couldn't find any details on their site.

Man, its complicated trying to find a suitable online merchant account and an Online Payment Services Provider.

I just want to try and move from the less professional Worldpay.

Please help.
Title: Re: HSBC CPI Integration
Post by: stovesy on October 25, 2005, 10:21:33 AM
Quote from: chikkensoop on October 24, 2005, 11:51:36 AM
Nope, absolutely nothing thrown back... it goes through the checkout process asking the user for their billing and postal address, pick a postage type, then gets to a summary screen where I would guess it would launch the user over to the HSBC servers to enter payment details... but the form on that page simply has http://www.insertsitenamehere.com/index.php as the target of the form around the button they click to continue.

Any thoughts?
Check the configuration tab for the payment module.
You should have a whole host of code in the Payment Extra Info field.
This is where we generate a button to jump to the HSBC site.
If it's not there, click the Reset Extra Info button, to replace with default code.

Let me know how you get on.
On another note, I've started looking at the HSBC API. I'll post up another thread as I get it a little more working.
Title: Re: HSBC CPI Integration
Post by: chikkensoop on October 25, 2005, 13:05:01 PM
I've reset the extra info and the target of the confirm order form/submit button is still /index.php...

I've set the store's checkout process to standard (ie shipping address, billing address, payment, complete order), I've uploaded the hsbc files from this thread (the latest ones), set all the relevant keys, urls etc in the config, there's all the standard code in the payment extra info field and it still doesnt work :(
Title: Re: HSBC CPI Integration
Post by: stovesy on October 26, 2005, 13:25:44 PM
Just a though. Are you using the latest file ?

It's in Downloads Home » mambo-phpShop Files »  Payment Modules.
Title: Re: HSBC CPI Integration
Post by: husayt on October 29, 2005, 23:40:56 PM
I am not sure, but maybe the reason is that you are not using SSL.

Actually question: does it matter?? I have read in HSBC documentation that SSL connection is must. Did anybody manage to get it working on unsecure connection?

Thanks in advace.

Title: Re: HSBC CPI Integration
Post by: devkungfoo on October 30, 2005, 00:58:16 AM
in my experience ssl is a must...
Title: Re: HSBC CPI Integration
Post by: stovesy on October 30, 2005, 14:16:05 PM
Yep. HSBC need a secure connection
Title: Re: HSBC CPI Integration
Post by: devkungfoo on November 11, 2005, 21:02:02 PM
its proably best that you call the hsbc cpi support and ask them to give you a detailed list of the errors they are recieving. its the only really effective way of knowing where the problem lies
Title: Re: HSBC CPI Integration
Post by: devkungfoo on November 22, 2005, 18:44:54 PM
if its not getting to hsbc then double check your form action value to make sure its send it to right hsbc url

also try this :

create a test page that just dumps all post variable values to the screen and then point you form action to this page.
then try out a purchase and see exactly what post variables it is creating.
Title: Re: HSBC CPI Integration
Post by: husayt on December 16, 2005, 17:15:27 PM
chikkensoop,
did you manage to find the problem and solution?? if yes, please, share with us.
Title: Re: HSBC CPI Integration
Post by: jdlmarsh on December 19, 2005, 14:34:04 PM
Quote from: stovesy on September 14, 2005, 12:27:42 PM
!!! FINALLY !!!

It's working.
I've just managed to process my first transaction.
It needs polishing now.

I'll post the code later on today.

Hi there, I just wanted to thank you so much for making your solution available. I'm having to do an implementation using HSBC Secure ePayments and to be honest without your code I don't think I could have got the hash generation done. I haven't finished yet, but I HAVE managed to post successfullly to HSBC and get a test transaction authorised, which is 99% of the job (just need a server certificate now so that the notify & return will work properly). So - thanks again, brilliant!

P.S. In case anyone else has the following problem - if you post to HSBC without the CpiDirectResult & CpiReturnUrl fields starting https:// then HSBC doesn't respond at all, and it's difficult to identify the problem because when you phone HSBC support they say there are various problems (including the hash generation) when in fact it could be simply the lack of an 's'!

Title: Re: HSBC CPI Integration
Post by: husayt on December 22, 2005, 04:37:18 AM
Ok,
at last I started installing this module for my clients site which is on Virtuemart.
There are some changes needed to be done for it to work because, some table names has changed in VM.

And I have got question to Stovesy. I remember you were getting 10 error code from hsbc for long time.
Could you please, remind us what was the reason and how did you solve it.
Apparently I have got the same issue.

All the best.
Title: Re: HSBC CPI Integration erro 10
Post by: stovesy on January 06, 2006, 13:19:03 PM
You've got me scratching my head about the error 10 thing.
I'll have a trawl through my notes and see if I can dig something out about it.
Title: Re: HSBC CPI Integration
Post by: husayt on January 07, 2006, 13:42:12 PM
It is ok Stovesy,
everything is working fine now.
My fault it was, I missed a comma (!!!!) in parameters for hash key. Everything is working fine now. Excellent.

One more question. Billing and delivery details. How can i switch them off from appearing on HSBC website??
I don't need them.

Thanks.
Title: Re: HSBC CPI Integration
Post by: cmax on January 25, 2006, 00:25:45 AM
Hiya. This code looks excellent, but Im not having much joy getting this to work.. Ive downloaded the latest code, updated the config, tried selecting payment processor types of "use payment processor" and "bank debit" but still no joy.. With "use payment processor" everything happens on my site and nothing goes to hsbc at all.. (and I dont fancy taking credit card numbers on my site  :o )

Im sure its just a configuration / setting... Any advice?

Would really appreciate your help.   ;D Cheers.
Title: Re: HSBC CPI Integration
Post by: cmax on January 27, 2006, 23:22:48 PM
Anyone? pls help me  :'(
Title: Re: HSBC CPI Integration
Post by: terryd on February 14, 2006, 23:55:05 PM
Whats the latest regarding this module. I have the latest version installed from this topic. But i am a bit unsure what to put in the configuration part of it.
Cheers Terry
Title: Re: HSBC CPI Integration
Post by: dougal on May 03, 2006, 15:47:12 PM
Has anyone got this module working with HSBC bank in the UK? I need to use hsbc and i want to use virtuemart. i'm just wondering if it is a possibility or have people given up on this one?
Cheers
Title: Re: HSBC CPI Integration
Post by: devkungfoo on May 24, 2006, 12:41:18 PM
Hey All,

I haven't worked on HSBC payments for quite some time now and I'm not sure if anything
has changed since the last time I posted.

RE:
Quote from: stovesy on August 22, 2005, 10:42:26 AM
I've actually got libmcrypt - but am struggling to find php_mcrypt.dll.

I've got linux at work so I'll set it up on that.
The only concern I have is we are putting more requirements on our hosts (to have mcrypt installed). Wouldn't it be nice if we could get this all done in native php ?

mcrypt and mhash are fairly rarely provided by hosting co's and most will not install it - i came across this issue
and was forced to create a way of doing it in native php (no additional libraries.)

I have attached the script,
once this script is included you can get the hash as follows

generateHash($tmp, HSBC_CPI_HASH_KEY);

where $tmp is the array of values to calculate the hash on (this is a plain array not associative) and
HSBC_CPI_HASH_KEY would naturally be your hsbc provided hash key.

enjoy :)



P.S. Dougal it is possible, i have implemented it on 2 different sites successfully.

[attachment cleanup by admin]
Title: Re: HSBC CPI Integration
Post by: dougal on May 24, 2006, 12:48:04 PM
Thanks devkungfoo, i'll have a go at it. I also got a message from stovesy who said he has started to have another go at this so things are certainly looking up for this module.
Cheers
Title: Re: HSBC CPI Integration
Post by: dougal on June 12, 2006, 11:05:27 AM
Devkungfoo is there any chance you can share the working module with your alterations, or maybe just your code and where to place it, it would be greatly appreciated.
cheers
Title: Re: HSBC CPI Integration
Post by: devkungfoo on June 12, 2006, 17:53:42 PM
I have put it up to download at

http://www.devkungfoo.com/main/component/option,com_remository/Itemid,0/func,fileinfo/id,1/

no registration needed.
Title: Re: HSBC CPI Integration
Post by: Rachel on June 23, 2006, 18:03:30 PM
Hi

I am trying to integrate your files into virtuemart devkungfoo .  I have uploaded files into the correct virtuemart directories rather than com_phpshop, and altered a couple of sql calls due to virtuemart's slightly different structure.
However I am now completely bewildered (php not my strong point!).  Am I correct in saying this method doesn't need checkout.hsbc_return.php?
I am putting in card details, and it is saying that the payment has been processed, but I'm not sure it is even interacting with HSBC.
Can anyone enlighten me..  I am completely confused, been trying to integrate this for aaaaaaages!!!!

Thanks
Rachel
Title: Re: HSBC CPI Integration
Post by: Rachel on June 23, 2006, 19:06:47 PM
Do I need to put a submission button in the extra info field? ???
Thankx
Title: Re: HSBC CPI Integration
Post by: Rachel on June 23, 2006, 19:27:32 PM
For anyone as dumb as me.  For some reason, the config page for payment module didn't initially load the extrainfo.  I just spent all afternoon trawling through the code, to see that if I click the reset button, I will get the form required to submit the payment to the CPI. 
I'm now going to leave it until monday to do the rest - but this is a major breakthrough for me.  Although it didn't seem to call the payment.hsbc_return.php afterwards.

Thank you for code so far........

:)
Title: Re: HSBC CPI Integration
Post by: dougal on June 26, 2006, 14:22:59 PM
Thanks for the code devkungfoo, greatly appreciated. I have been getting a strange error when i test, i don't get asked to enter bank details but when i click "confirm order," i get this message "Error: You have actually not provided your bank account holder name." which is right since i haven't.
I didn't realise i had to change the sql calls so i will have a go at that and maybe i'll get somewhere. Could i see what you have changed Rachel because if you think you are dumb Rachel believe me i am in a league of my own.
Cheers

Title: Re: HSBC CPI Integration
Post by: Rachel on June 26, 2006, 14:26:57 PM
I spoke to HSBC this morning, and they have demanded that I remove the credit card input fields from my site before they will set the payment account to production from test.  I explained to the man that it was 128bit encrypted and details were not stored on our database, but he insisted it was company policy and to call him back once they were removed :(

Will dig out files for you.
Title: Re: HSBC CPI Integration
Post by: devkungfoo on June 26, 2006, 16:11:50 PM
Hey All,

I know that code defintely worked on php-shop, I have no clue regarding the differences between virtuemart and php-shop editions.

What I do know for a fact is that the hashing code still works 100% because I used that this week for a client using oscommerce.

I wish I had time to install virtuemart and test out the payment system because I know the struggle involved in working it out for php-shop, unfortunately I really don't have much time.

If I do get some time and manage to make some headway I'll let you guys know.
Title: Re: HSBC CPI Integration
Post by: Rachel on June 26, 2006, 17:05:19 PM
I'm not saying it works yet, but attached is the page that I altered the calls for.  Only changed 2 sql queries.

devkungfoo thanks for all your code so far  ;D

Now trying to do a version removing the payment method version for the mean man at HSBC.  devkungfoo can you point us towards one of your sites wher eit works, so I can see how it should look eventually?

Thanks

[attachment cleanup by admin]
Title: Re: HSBC CPI Integration
Post by: dougal on June 28, 2006, 11:56:48 AM
Thanks for your input guys. Am getting my php guru friend to have a blast in the next week so if he gets somewhere i will post up what we come up with.......hopefully a working version.
cheers
Title: Re: HSBC CPI Integration
Post by: Rachel on June 28, 2006, 12:13:36 PM
I took a few of your code.. mixed it in a pot, and came up with the attached for virtuemart.

You have to set the payment method, as "Paypal (or related)"
HSBC_CPI_RESULT_URL=https://www.something.co.uk/administrator/components/com_virtuemart/html/payment.hsbc_return.php
HSBC_CPI_RETURN_URL=https://www.something.co.uk/index.php?option=com_virtuemart&page=checkout.hsbc_return

As devkungfoo stated files should be:ps_hsbc.php - administrator\components\com_virtuemart\classes\payment
ps_hsbc_secCrypto.php - administrator\components\com_virtuemart\classes\payment
ps_hsbc.cfg.php - administrator\components\com_virtuemart\classes\payment
payment.hsbc_return.php - administrator\components\com_virtuemart\html
checkout.hsbc_return.php - administrator\components\com_virtuemart\html

Although my serious lack of knowledge means, I'm not sure if payment.hsbc_return.php is actually called!

Please note to us newbies out there, that after you have implemented the code, HSBC will want to check your site first before putting the account on their side into production.

Cheers

Rachel.






[attachment cleanup by admin]
Title: Re: HSBC CPI Integration
Post by: dougal on July 11, 2006, 12:46:01 PM
Finally my shop is working  ;D
I have attached the files below,
Once files are in place go to virtuemart/ list payment methods
select hsbc
In the general tab you should have
Active? = ticked
Payment method name = HSBC
Code = HSBC
Payment class name (e.g. ps_netbanx) :
default: ps_payment = ps_hsbc
Payment method type = select paypal or related
leave the rest

go to configuration
process in test mode = this depends on your hsbc account settings, it will be in test mode until the guys and gals at hsbc check your site and change it to live
Storefront ID = your client id supplied by hsbc
cpi hash = your hash key (case sensitive)
CPI result URL = https://yoursite.com/administrator/components/com_virtuemart/html/payment.hsbc_return.php
CPI Return URL = https://yoursite.com/index.php?option=com_virtuemart&page=checkout.hsbc_return
CPI Collect shipping address = no

I have a secure server (not a shared)and am hosted by siteground which is good value and works well. A php coder friend did this for me so i am not sure what exactly he has changed, but, we had it on a test  site first and then i transferred the 5 files across, changed the cpi file paths and it worked well. the only thing we can't quite figure is the collect shipping address function, but maybe we will get it done later.
Thanks to stovesy, devkungfoo and rachel for their input.


[attachment cleanup by admin]
Title: Re: HSBC CPI Integration
Post by: Rachel on July 11, 2006, 12:56:53 PM
Regarding shipping address. I haven't implemented it, but the  HSBC documentation does state that you must enter values for ALL CPI shipping fields, or it will not get included.
So we would have to put a check in on all field to ensure it is submitted.

Regds

Rachel
Title: Re: HSBC CPI Integration
Post by: gan_test on August 26, 2006, 07:41:23 AM
Hi,

I referred the CPI Integration Guide.. Quite difficult to find way out..
In the sample form they have provided the following:
form's action="servlet/Cpi"; 
CpiDirectResultUrl value="https://srvr:8443/cpi/result.jsp";
CpiReturnUrl value="https://srvr:8443/cpi/return.jsp"

when i submit the form with approppriate values, it asks for security alert and then
"The Page cannot displayed" error is displayed.

Can anyone help me the way out?

Rgds,
Ganesh

Quote from: stovesy on September 14, 2005, 12:27:42 PM
!!! FINALLY !!!

It's working.
I've just managed to process my first transaction.
It needs polishing now.

I'll post the code later on today.
Title: Re: HSBC CPI Integration
Post by: Andrew Hemming on October 19, 2006, 13:28:24 PM
Hi,

I have uploaded the files contained in the module pack to the locations as specified above, but when I list payment methods, I still see only the original 16; HSBC is not listed as an option.

I am sure there is something very simple behind this problem - any advice?

I have tried the packs from both Rachel and Dougal...

Regards

Andrew
Title: Re: HSBC CPI Integration
Post by: Andrew Hemming on October 19, 2006, 16:14:40 PM
It's OK, have figured it out now. I had to upload the files then add the HSBC service with out entering anything onto the configuration page. I was then able to list the payment methods and when I clicked on HSBC, all the necessary information had been imported...

:)
Title: Re: HSBC CPI Integration
Post by: jmds on November 16, 2006, 19:24:31 PM
Hi All,

I have just implemented the HSBC payment module on a site and got the billing and shipping address to be passed through.

I had to change this line(about line 340) in the 'ps_hsbc.php' file:

'ShopperEmail' => substr($dbbt->f("email"), 0, 30),

to

'ShopperEmail' => substr($dbbt->f("user_email"), 0, 30),

Title: Re: HSBC CPI Integration
Post by: da8iwr on December 14, 2006, 23:22:38 PM
I have got this HSBC payment gateway working perfect, and have added the files and a word document with a full step by step instructions to get it working.

Download the zip, and extract the files out (its not a standard Joomla installable zip file, you need to manually upload the files).

It has included

All the PHP files needed
An installation word document i made.
The full Spec from HSBC

Best of luck
Ian
www.newworlddesigns.co.uk

[attachment cleanup by admin]
Title: Re: HSBC CPI Integration
Post by: paul on December 15, 2006, 18:36:14 PM
has anybody installed the HSBC payment succesfully. If you have please can you post a link to your site so that i can veiw it thanks for the help
Title: Re: HSBC CPI Integration
Post by: David O'Sullivan on December 19, 2006, 01:31:44 AM
da8iwr,

Thanks so much for sharing your work here!

I am trying to set up a payment module for a client who uses HSBC. I can see that what you have here may be a solution. Although I don't mind customers going to HSBC to submit their card details, can you confirm whether or not they will have to enter their address details all over again with what you have designed (I see that in the 'CPI collect shipping address' it says 'no' and has a message saying 'this causes error'. )

Its just it looks like a fair old slog to get this working from this forum and before I go through with it (and before the client pays the set-up fee) I would like to know that the client does not have to enter their information all over again as we really don't want that.

Thanks

David
Title: Re: HSBC CPI Integration
Post by: jmds on December 19, 2006, 10:05:37 AM
da8iwr's version has the email amendment that I posted earlier in the thread included, so the customer address details should get posted to the HSBC system with no problems.
Title: Re: HSBC CPI Integration
Post by: Christopher on December 29, 2006, 17:21:19 PM
Quote from: da8iwr on December 14, 2006, 23:22:38 PM
I have got this HSBC payment gateway working perfect, and have added the files and a word document with a full step by step instructions to get it working.

Download the zip, and extract the files out (its not a standard Joomla installable zip file, you need to manually upload the files).

It has included

All the PHP files needed
An installation word document i made.
The full Spec from HSBC

Best of luck
Ian
www.newworlddesigns.co.uk

You're a star, Ian - thank you so much for this guide - you've saved me from a very dull New Year
fiddling around trying to fix this - my customer's site is now up-and-running and approved by HSBC.

This work should be picked up and indexed by the moderators of this forum to make it more easily
found by us poor newbies!

Cheers

Christopher
Title: Re: HSBC CPI Integration
Post by: Zobbster on January 15, 2007, 18:40:52 PM
Quote from: jmds on December 19, 2006, 10:05:37 AM
da8iwr's version has the email amendment that I posted earlier in the thread included, so the customer address details should get posted to the HSBC system with no problems.

It should, but... it doesn't.  At least not on my site (http://www.stalkiesshop.com/) anyway... and I'd really like to fix that :)

da8iwr, sir, thank you so much for your work on this script - I owe you huge amounts of thanks!

Also, after installing the processor first time around, it threw errors up at me.  checkout.hsbc_return.php's $message's didn't have any quotes around them - so one quick " " session later and it worked like a dream!
Title: Re: HSBC CPI Integration
Post by: da8iwr on February 14, 2007, 03:51:03 AM
Hey thanks for the great remarks guys and girls, sorry i haven't replied to any questions, I had the wrong email set in virtuemart, and hadn't received any of the emails to tell me i had people writing to me.

I'm having a problem with it for the return address just being a blank screen, after i upgraded to the newer VM 1.0.9 and Joomla 12 form version 10, so all I'm going to do for now is have the return address go to the a page which i made within the site
https://www.spot-ontv.co.uk/index.php?option=com_content&task=view&id=17&Itemid=26

/*define ('HSBC_CPI_RETURN_URL', 'https://www.spot-ontv.co.uk/index.php?option=com_virtuemart&page=checkout.hsbc_return');*/
define ('HSBC_CPI_RETURN_URL', 'https://www.spot-ontv.co.uk/index.php?option=com_content&task=view&id=17&Itemid=26');

I simply just commented the old return url out (yellow text), but kept it so i have it for the future, and replaced it with a page i made, so when the client comes back to the site, they goto the page i made and not what is originally in the old file i uploaded (the red text).

the file you alter is ps_hsbc.cfg.php on lines 8 and 9, its very self explanetry when you get there.

I will spend a little more time trying to find the error a little later on, but it is very small I'm sure, i just haven't the time at the moment (its 3.11am and I'm still working). I may just leave it as it is, as it gives you more ocntrol over what the client sees when they get back :)

I'm not sure it is a simple config problem, or a problem with the upgrade, and if it is the latter, which was it the VM or Joomla upgrade? lol

Oh the pleasures of Open source with zero support service.

As soon as i know anything new ill let you know
Ian

Ps
The site i have as working is
www.spot-ontv.co.uk
Title: Re: HSBC CPI Integration
Post by: da8iwr on February 14, 2007, 04:32:38 AM
Bollocks, just realised, the system wont recognise if the order was successfull or not, unless it comes back in the correct path. If it comes in the page url as i wrote above, it will say pending, crap i can feel another night of work coming.

Can anybody else help out here?
Ian
Title: Re: HSBC CPI Integration
Post by: jmds on February 14, 2007, 10:32:29 AM
Is it not the 'page=checkout.hsbc_return' part that causes the order status to be changed?


Maybe your could add a new parameter for a content item to display after the customer returns and use a 'mosRedirect' at the end of the file.
Title: Re: HSBC CPI Integration
Post by: da8iwr on February 14, 2007, 14:50:00 PM
Hmm i was thinking similar, so it would jump to another page.

Only problem is, i don't think its loading the files at all, which is why its bringing up the whit screen. As when i check the source code there is none at all, just a blank notepad. This is the bit that's confusing me more than anything else, as i would have thought it would have some source, even if not very much at all.

Which is leading me to believe there is some break and it cant find the files, but i checked all files and even refreshed them, to make sure they were there and as they should be (in case the upgrade flashed the files some how) and it still wont work.

What a bummer

I spoke to the client 2 Min's ago, and he said its not a huge issue the pending part, as he always has to check the HSBC panel has taken the money successfully any way before sending a £4K flat screen out, so whether it says pending or completed, it would still need to be checked, so its not much more work than it already is.

But if i do find any fix ill let you know on here
Ian
Title: Re: HSBC CPI Integration
Post by: jmds on February 14, 2007, 15:06:15 PM
Zobbster, for some reason I did not see you post. Did you get it working in the end. If not. Check with the HSBC. I think they are able to turn the address display feature on and off from their end. It may need switching on.

da8iwr, I have just been looking at a site with an HSBC CPI issue. It seems to be ok now and the return works fine on their site. This probably does not help, but it may be worth installing the files again.
Title: Re: HSBC CPI Integration
Post by: allstarone on February 19, 2007, 14:46:16 PM
I wrote this short HSBC installation guide, it's got no mention of virtuemart, but it might help someone out of trouble.


http://www.leadingedgewebsites.co.uk/help/hsbccreditcardslinux.html (http://www.leadingedgewebsites.co.uk/help/hsbccreditcardslinux.html)
Title: Re: HSBC CPI Integration
Post by: jason on February 28, 2007, 15:38:11 PM
Hi All,

Thanks for the installation guide on the CPI, however I can't get the shipping and billing address pass through the CPI page, and I'm getting this error:


Parse error: syntax error, unexpected T_STRING in /home/aircond/public_html/administrator/components/com_virtuemart/html/checkout.hsbc_return.php on line 72

Appreciate if anyone could help me out.

Thanks in advance.
Title: Re: HSBC CPI Integration
Post by: jmds on February 28, 2007, 15:48:50 PM
Hi Jason,

Can you post the contents of that line. I helped someone out a while ago on this and they had a different version of the file to me.
Title: Re: HSBC CPI Integration
Post by: jason on February 28, 2007, 16:04:02 PM
Hi jmds,

Thanks for your prompt reply, this is the code on checkout.hsbc_return.php

68 // The transaction was successful
69 switch($CpiResultsCode) {
70 case 0: {
71   $d['order_status'] = 'C';
72   $message = The transaction was approved;
73   break;
74   }

Thanks in advance.
Title: Re: HSBC CPI Integration
Post by: jmds on February 28, 2007, 16:18:38 PM
As I suspected

Quote72   $message = The transaction was approved;

Should be

Quote72   $message = "The transaction was approved";

This will probably need changing on various lines after this one as well. The message text needs to be in quotes.
Title: Re: HSBC CPI Integration
Post by: jason on February 28, 2007, 16:37:17 PM
Thanks jmds!! I will try it now.

Any idea on shipping and billing address not passing to CPI page?

Thanks a million!
Title: Re: HSBC CPI Integration
Post by: jason on February 28, 2007, 16:48:24 PM
Hi jmds,

Is not showing up this error:

Parse error: syntax error, unexpected T_STRING in /home/aircond/public_html/administrator/components/com_virtuemart/html/checkout.hsbc_return.php on line 135

I've replaced all the message with quote

131   case 12: {
132   $d['order_status'] = 'X';
133   $message =  "The transaction failed because the Storefront was configured incorrectly";
134   break;
135   }
136   case 13: {
137   $d['order_status'] = 'X';
138   $message =  "The connection timed out";
139   break;
140   }


Do you have a working copy so I can upload it to my server?
Thank you.
Title: Re: HSBC CPI Integration
Post by: jmds on February 28, 2007, 16:53:47 PM
With regards to the address issue.

Check that l;ine 341 in /administrator/components/com_virtuemart/classes/payment/ps_hsbc.php is

Quote'ShopperEmail' => substr($dbbt->f("user_email"), 0, 30),

and not

Quote'ShopperEmail' => substr($dbbt->f("email"), 0, 30),

You also need to ensure that the HSBC have got the address option turned on at their end.

I hope this helps.
Title: Re: HSBC CPI Integration
Post by: jmds on February 28, 2007, 16:56:29 PM
QuoteDo you have a working copy so I can upload it to my server?

I am afraid not, the version of the module I use has not got the message hard coded in this manner.
Title: Re: HSBC CPI Integration
Post by: jason on February 28, 2007, 18:08:17 PM
Quote from: jmds on February 28, 2007, 16:53:47 PM
With regards to the address issue.

Check that l;ine 341 in /administrator/components/com_virtuemart/classes/payment/ps_hsbc.php is

Quote'ShopperEmail' => substr($dbbt->f("user_email"), 0, 30),

and not

Quote'ShopperEmail' => substr($dbbt->f("email"), 0, 30),

You also need to ensure that the HSBC have got the address option turned on at their end.

I hope this helps.

Hi jmds,

I've check the code on line 641

                  'ShopperEmail' => substr($dbbt->f("user_email"), 0, 30),

Is is still having the same error:

Parse error: syntax error, unexpected T_STRING in /home/aircond/public_html/administrator/components/com_virtuemart/html/checkout.hsbc_return.php on line 135


As for the address, I called HSBC, and they say they have nothing to do with the shipping address, we should pass the data into HSBC.

Any ideas?

Thanks a lot.
Title: Re: HSBC CPI Integration
Post by: jason on March 01, 2007, 13:29:48 PM
At last I got it working now, but getting this error when returning to my merchant website:

Warning: fopen(HSBC_CPI_LOG_RETURNS) [function.fopen]: failed to open stream: Permission denied in /home/aircond/public_html/administrator/components/com_virtuemart/html/checkout.hsbc_return.php on line 42

Anyone can help me out?

Thanks in advance.
Title: Re: HSBC CPI Integration
Post by: jass on May 15, 2007, 18:41:58 PM
Hi all,

The HSBC module was working flawlessly for the past 2 months but it's stop working now and showing this error:

MODULE_PAYMENT_HSBC_TEXT_ERRORHASH

Does anyone have any idea on this error? Appreciate the help.

Thanks in advance.
Title: Re: HSBC CPI Integration
Post by: da8iwr on June 22, 2007, 03:56:38 AM
Hi Jass, this only shows on my system when i put in the wrong Hash Key (I found this out as i wrote the Hash Key down wrong as my hand writing is terrible lol), check with HSBC, and make sure they havent changed it without you realising.
Title: Re: HSBC CPI Integration
Post by: da8iwr on June 22, 2007, 14:22:26 PM
Quote from: jason on March 01, 2007, 13:29:48 PM
At last I got it working now, but getting this error when returning to my merchant website:

Warning: fopen(HSBC_CPI_LOG_RETURNS) [function.fopen]: failed to open stream: Permission denied in /home/aircond/public_html/administrator/components/com_virtuemart/html/checkout.hsbc_return.php on line 42

Anyone can help me out?

Thanks in advance.

Hi Jason
Im having the same trouble here about the billing address etc. HSBC use it for a fraud check, and if it is not there they cant do the check so just authorize the payment. How did you get it to transfer over the billing address?

I tried changing the line with the user-email in above, and it made no difference.

Many thanks
Ian
Title: Re: HSBC CPI Integration
Post by: desk2web on June 22, 2007, 23:19:01 PM
Thanks for all the advice and coding from all concerned.  I am having a little difficulty however, and am sure its something dead simple, but I just can't figure it out.

I'm looking at a site for a client, its in Mambo at present with phpShop, however, I have recreated the site at sitename.com/updated/ using Joomla and Virtuemart and have just tried to install the HSBC payment system and when I try to set the payment moduel as active I get ...

"Error: Function Not Registered. changePublishState is not a valid MOS_com_phpShop function"

Any ideas?

Thanks in advance
Title: Re: HSBC CPI Integration
Post by: desk2web on June 22, 2007, 23:57:53 PM
Ooops, should have searched a little harder, sorry folks...

http://virtuemart.net/index.php?option=com_smf&Itemid=71&topic=13870.0
Title: Re: HSBC CPI Integration
Post by: smitje on July 10, 2007, 12:59:23 PM
This looks brilliant has anyone got it working on live VirtueMart v1.0.12 the code posted by da8iwr is tested for VirtueMart v1.7. Also do you need to install an SSL?
Title: Re: HSBC CPI Integration
Post by: jmds on July 10, 2007, 14:16:52 PM
I have it working on a couple of sites using 1.0.10. Will be using it on 1.0.12 inthe next couple of days .

You do need to install an ssl certificate. This is a requirements of the HSBC.
Title: Re: HSBC CPI Integration
Post by: da8iwr on July 10, 2007, 14:47:59 PM
Hi Smitje
I have it working perfectly on Joomla 1.0.12 and Virtuemart 1.0.11

I haven't tested it on VM1.1 yet, but will be setting it up on my test server very soon so i can give it a go.

Also the certificate is a little annoying as its not really needed, but HSBC refuse to work with you until you have it working.

As far as I'm aware there is nothing personal transferred from the site to HSBC apart from cart contents, name and address.

All that information is easily found on the internet or local government means (voting register) anyway, so i fail to see why they need to use a certificate.

I cant get the postcode and billing address to transfer across to HSBC with the current version i uploaded, which is very annoying, as HSBC system does a fraud check on the post code against the account details they enter in the bank admin panel. This then flags up in the sellers control panel a problem if it fails and is then the sellers choice if to sell. But unfortunately HSBC don't really care, (as we have asked them) so if you get fraud, its your problem.

When we transferred one of the sites to a new server, we didn't have the certificate working for a while, and HSBC worked perfect, the only problem is when it transferred you back to your site again from the HSBC servers, it went to a dead page, as it was looking for https:// rather than http:// that we had.

If you change the return address to anything without the https, it shows errors as soon as you are transferred to HSBC.

So a long way round to answer, but yet, you need to have a certificate lol.

Also you maybe interested in this http://www.virtuemartfrooglefeed.com/
Its a component and module i have made that allows you to produce an RSS feed for your products and export them straight into Froogle.

I am making a free demo version right now, which will be available to download later on today. I'm just doing the bug checks with it now.
Title: Re: HSBC CPI Integration
Post by: jmds on July 10, 2007, 14:56:13 PM
Hi da8iwr,

I seem to recall  I had to change the shopper email address makes the billing address get sent through.

'ShopperEmail' => substr($dbbt->f("user_email"), 0, 30),


Title: Re: HSBC CPI Integration
Post by: smitje on July 10, 2007, 15:12:01 PM
Thanks for the input - really appreciated.

That's a real blow regarding the SSL our web hosts (fasthosts) only allow shared SSL upto 10mb and only on a windows box only! So much for the SEF URLs. Not really sure how I can proceed without changing web hosts or getting a dedicated server.
Title: Re: HSBC CPI Integration
Post by: jmds on July 10, 2007, 15:52:42 PM
Would you be able to get more ssl space if you have your own dedicated certificate?
Title: Re: HSBC CPI Integration
Post by: da8iwr on July 10, 2007, 16:00:10 PM
smitji

If you want a little space send me a message from the contact page on my new world designs site below and ill sort some out for you mate.

I have a bank of co located dedicated servers which I don't use all the space, they are in http://www.solidhost.com/ data centre who are excellent. They have amazing reviews and feedback on web hosting talk, which is the only reasons i used them. I was sick of going through the cheaper companies and being let down.

For a few beer tokens i can sort out a reseller account for you, and yes you can then use SEO URLs.

www.nutriculture.com and www.spot-ontv.co.uk are both on it, so you can see the speed.

Regards
Ian
www.newworlddesigns.co.uk
Title: Re: HSBC CPI Integration
Post by: da8iwr on July 10, 2007, 16:01:32 PM
Ohh my hosting company sells the cirts for about £60 per year i think it is, i can get you an exact quote if you like, but it works on the whole site, not just a portion of it.
Title: Re: HSBC CPI Integration
Post by: smitje on July 10, 2007, 16:59:48 PM
If we could have a dedicated certificate that would be one solution to the problem, but our hosting company does not provide this option at the moment! I was hoping that we could have the main site on one server and then launch the checkout on the 10mb shared SSL but I don't think this is possible either!

da8iwr - thanks for the info (will check that out).
Title: Re: HSBC CPI Integration
Post by: da8iwr on July 12, 2007, 02:43:11 AM
Just a general note for anybody

John Messingham and myself have been talking and have both agreed that for a cost of  approximately £50 we will install the HSBC payment gateway into your system and have it up and running for you.

Between us we now have the payment gateway working 100% perfect including the delivery address etc.

This is a note as we are both receiving emails etc asking for advice of why they have problems, and this is probably the simplest solution for everybody.

You can contact either of us by private message, and we can give you availability of time etc. We both charge the same, and have both done this many times before.

Many thanks
Ian
Title: Re: HSBC CPI Integration
Post by: da8iwr on July 19, 2007, 19:06:09 PM
Quote from: smitje on July 10, 2007, 12:59:23 PM
This looks brilliant has anyone got it working on live VirtueMart v1.0.12 the code posted by da8iwr is tested for VirtueMart v1.7. Also do you need to install an SSL?

Hi Smitji
Not sure if I'm too late here and you have already tried it, but as of last night I installed the HSBC payment gateway onto 2 Joomla 1.0.12 and VM 1.0.12 sites and it worked perfect.

Ive also upgraded another site last night that was built on Virtuemart 1.0.7 to 1.0.12 and the gateway works perfect still.

Regards
Ian
Title: Re: HSBC CPI Integration
Post by: smitje on July 23, 2007, 13:34:37 PM
I finally got a test version of the HSBC integration working with J1.0.12 and VM1.0.12 - thanks for all your help and offers of support!

I've been reading on the forums with great interest about the possibility of mod'ing the checkout process so that the order confirmation is only sent out once the payment details have been succesfully taken see the following posts:

http://virtuemart.net/index.php?option=com_smf&Itemid=71&topic=24147.0
http://virtuemart.net/index.php?option=com_smf&Itemid=71&topic=19132.0
http://virtuemart.net/index.php?option=com_smf&Itemid=71&topic=19823.0

The excellent posts above discuss Paypal and Wordlpay, now as the HSBC CPI payment method is PayPal related I guess that it would be possible to alter the checkout confirmation process.

What are your experiences? Does anyone have a live site running this? Have I missed an obvious setting in the config?

Smitje.
Title: Re: HSBC CPI Integration
Post by: smitje on July 27, 2007, 11:12:34 AM
Just remembered I also had to make a slight modification to the SQL statement in ps_hsbc.cfg.php to get things working. You will need to change all occurances of __pshop_ to __{vm}_ for example:

$qt = "SELECT * FROM #__pshop_country WHERE country_3_code='".$country_3."';";
to:
$qt = "SELECT * FROM #__{vm}_country WHERE country_3_code='".$country_3."';";

      
Should help a bit.
Title: Re: HSBC CPI Integration
Post by: Tony on August 13, 2007, 10:25:31 AM
I'm interested in you and John installing the HSBC CPI payments gateway for £50, can you please tell me what information you require to get started? Thanks, Tony

Quote from: da8iwr on July 12, 2007, 02:43:11 AM
Just a general note for anybody

John Messingham and myself have been talking and have both agreed that for a cost of  approximately £50 we will install the HSBC payment gateway into your system and have it up and running for you.

Between us we now have the payment gateway working 100% perfect including the delivery address etc.

This is a note as we are both receiving emails etc asking for advice of why they have problems, and this is probably the simplest solution for everybody.

You can contact either of us by private message, and we can give you availability of time etc. We both charge the same, and have both done this many times before.

Many thanks
Ian
Title: Re: HSBC CPI Integration
Post by: jass on September 08, 2007, 10:44:56 AM
Dear all,

We are looking for a good hosting company for our Virtuemart store with HSBC secure e-payment. We require dedicated IP, please let me know if you know of the hosting company already hosting such websites and if possible can I have a look on some sample working websites with HSBC.

Many thanks in advance.
Title: Re: HSBC CPI Integration
Post by: da8iwr on September 08, 2007, 13:04:56 PM
Jass
Of course most good hosting companies should be ok, but over the past few years now, i have moved around through 6 companies, all of which have been recommended, and all have let me down badly, which you can see here
http://www.webhostingtalk.com/showthread.php?t=625467
That was for my last hosting company, who some how or other won Hosting company of the year!!!

I then spent a lot of time on hosting forums and asking dozens of questions and asking "Has any body heard of these and had any problems or good stories to tell" and the wood worm came crawling out to tell me stuff.

Eventually once company http://www.solidhost.com/ had no negative feedback's, it wasn't the cheapest but i think hosting has much more important factors than cost.

I switched to them in Jan 2007, and haven't yet had any issues at all. I have three of their tech guys in MSN, so i can ask questions when ever i need. Their sales guy called John, is also on MSN and will help with any other stuff and they have a 15 min response time to support tickets, which they always are much quicker, usually a few Min's.

I pay an extra 10 Euros a month and have live watch, which sends a ping to many different parts of the server every min, such as Mail, HTTP, FTP etc, and if it doesn't respond, it automatically issues a support ticket.

When i was on hols in Greece 2 weeks ago, i received a text message saying there was a problem with the emails, so i jumped into a near by internet cafe, and logged onto MSN, the problem was solved in less than 3 Min's.

I cant recommend them highly enough, and for 59 Euros for 20GB of VPS and 10 Euros upgraded support which is about £46 per month, i cant believe the difference in confidence.

You can see this site here which runs on their servers
www.spot-ontv.co.uk

Oh and they do the SSL as well for 89 Euros, which is £59, my last host charged £100 each plus VAT.

Please let them know where you found the info from if you are going to go there :)

Regards
Ian
Title: Re: HSBC CPI Integration
Post by: Tony on October 15, 2007, 15:18:39 PM
I have the CPI integration working just fine, however I want to go straight to the HSBC screen when you click on 'confirm order'. In other words to automatically post the 'paymentform' without having to present the customer with another screen to 'submit'.

I'm sure this can't be too difficult a change to the 'payment extra info' but I have spent many days on this without success!!!

HELP!!!! I'm desperate!!!

Thanks, Tony
Title: Re: HSBC CPI Integration - AUTO REDIRECT - Solved!!
Post by: Tony on October 16, 2007, 12:50:15 PM
Here is the configuration code to put in the 'payment extra info' box to enable automatic redirection to HSBC secure e-payments. This bypasses the checkout.thankyou page so you might want to make suitable changes to your checkout.hsbc_return page to include 'thank you for your order' etc...

<?php
$sessionid = sprintf("%08d", $order_id). $_COOKIE['phpshop'].md5($_COOKIE['sessioncookie'].$_SERVER['REMOTE_ADDR']);
$sessionid .= md5( $sessionid . $mosConfig_secret . ENCODE_KEY);
$sessionid = base64_encode( $sessionid );
$formdata = $_SESSION['hsbc_formdata'];
$hsbc_host = $_SESSION['hsbc_host'];
echo '';

if( $page == "checkout.thankyou" ) {
echo '<form action="'.$hsbc_host.'" method="post" name="paymentform">';
    foreach ($formdata as $key => $value) {
    echo '<input type="hidden" name="'.$key.'" value="'.$value.'" />';
}

?>
   
<script language="JavaScript">
document.paymentform.submit();
</script>

<?php

else {
    echo '<form action="'.$hsbc_host.'" method="post" name="paymentform">';
    foreach ($formdata as $key => $value) {
    echo '<input type="hidden" name="'.$key.'" value="'.$value.'" />';
    }
    echo '<input type="submit" name="submit" value="submit" />';
}
?>

Hope this helps someone.

Tony
Title: Re: HSBC CPI Integration
Post by: Tony on November 02, 2007, 12:48:03 PM
HELP!!!

VM 1.0.12 & Joomla 1.0.12

I have successfully implemented the HSBC Secure ePayments CPI Integration with VM. Following checkout you are automatically directed to HSBC's secure site whereupon VM data is successfully transferred and then you enter your credit card detaisl etc., the return process is also all OK confirming the transaction details etc. Also if the transaction is aborted in anyway a suitable error message is returned and the transaction cancelled, again all OK. If you then wish to make a later payment via Account Maintenance by accessing the appropriate order via the file account.order_details.php, a submit button appears and you can make the payment, again all is OK.

The problem is when you log out and then log back in and wish to make a later payment on an order, an error message appears on account.order_details.php just prior to the submit button saying:

Warning: Invalid argument supplied for foreach() in /home/sites/diyhomefit.co.uk/public_html/administrator/components/com_virtuemart/html/account.order_details.php(114) : eval()'d code on line 27

However the weird thing is that if I then start the cart/checkout process again to place another order get redirected to HSBC then cancel out, all the previous orders that are pending awaiting payment all suddenly appear WITHOUT the error message and I can pay no problem !!

I have now spent 3 days on this and I cannot find where the problem is, please someone help!

Thanks, Tony
Title: Re: HSBC CPI Integration
Post by: baggiesmad on January 31, 2008, 16:00:42 PM
HI,

I have my store all setup and Ive just got my payment system facility from HSBC confirmed.

How do I go about building this into my store?

Any help would be great.

thanks
Title: Re: HSBC CPI Integration
Post by: da8iwr on January 31, 2008, 16:31:50 PM
Hi There
http://www.virtuemartfrooglefeed.com/download-area/virtuemart/hsbc-virtuemart-payment-gateway.html
My website isn't working at the moment as i upgraded it on Saturday after we had a few problems to find that virtuemart 1.0.13a doesnt work with Joomla 1.0.14 RC1

So it wont allow you login.

If you would like to buy it, please contact me through the contact form on that site.

The cost includes me setting it up, and working with the bank to have it tested and activated. I used to offer it for free, as did John Messingham, but we were both inundated with calls and emails asking for help when it got to the bank bit. So we added the small charge of about 2 hours labour so we do it all and then there is no problems.

If you need it doing, i can do it this afternoon for you, and it will then take the bank 24hrs to check it and activate it.

Regards
Ian
Title: Re: HSBC CPI Integration
Post by: baggiesmad on February 15, 2008, 17:51:30 PM
when I confirm payment I get the following error...


Parse error: syntax error, unexpected $end in /home/sites/mysite.com/public_html/administrator/components/com_virtuemart/html/checkout.thankyou.php(83) : eval()'d code on line 15

Error: The code of the payment method HSBC (HSBC) contains a Parse Error!
Please correct that first
Title: Re: HSBC CPI Integration
Post by: johnnybravo on February 20, 2008, 15:25:59 PM
hi,

I have managed to get this all workin i think but i was wondering how to accept multiple currencys? My client has signed up for a few, USD, AUD, EUR and GBP, how can i integrate these into virtuemart?

thanks
John
Title: Re: HSBC CPI Integration
Post by: baggiesmad on March 06, 2008, 12:41:15 PM
Quote from: johnnybravo on February 20, 2008, 15:25:59 PM
hi,

I have managed to get this all workin i think but i was wondering how to accept multiple currencys? My client has signed up for a few, USD, AUD, EUR and GBP, how can i integrate these into virtuemart?

thanks
John

is there any chance you could help me get it working :-(
Quote from: johnnybravo on February 20, 2008, 15:25:59 PM
hi,

I have managed to get this all workin i think but i was wondering how to accept multiple currencys? My client has signed up for a few, USD, AUD, EUR and GBP, how can i integrate these into virtuemart?

thanks
John
Title: Re: HSBC CPI Integration
Post by: da8iwr on March 06, 2008, 15:18:43 PM
At the moment we are testing my HSBC gateway with VM 1.1, which has the multiple currency options in there.
http://www.virtuemartfrooglefeed.com/download-area/virtuemart/hsbc-virtuemart-payment-gateway.html

I should know middle of next week, as we are waiting for the test site to be set up with a SSL cert.

Ill post on here what happens
Regards
Ian
Title: Re: HSBC CPI Integration
Post by: Jame on March 13, 2008, 07:36:23 AM
hi
can anyone tell me how to integrate HSBC CPI  integration into ofbiz project.
Title: Re: HSBC CPI Integration
Post by: badvoc on March 19, 2008, 11:04:59 AM
Hi,

I am trying to get HSBC integrated and not having much luck. Is there an idiots guide somewhere? I have searched quite a few sites and this one is the only one where claims are being made to have sorted it but no one is posting how.

The server I am working with is a dedicated one running Fedora OS. I have the files from hsbc.

CCOrderHas.e, CCResults.e and ss.txt are in the cgi-bim folder.

libCcCpiTools.so is located in the usr/lib folder. Now, the instructions state that this is to be installed. Does this mean more than just copying it to the folder? Am I required to execute this via a common prompt?

I keep getting a HTTP 500 error. I have checked the error log file and get the following

suexec policy violation: see suexec log for more details, referrer: http://www.mydomain.co.uk/sample.html
Premature end of script headers: CcOrderHash.e, referrer: http://www.mydomain.co.uk/sample.html

Any help will be very much appreciated.

Thanks
Title: Re: HSBC CPI Integration
Post by: badvoc on March 19, 2008, 11:07:02 AM
Sorry guys I have just realized that this forum is for VirtuMart. I use a custom built cart. I will take a look at this one and see if it can be integrated to our site.

Thanks anyway.
Title: Re: HSBC CPI Integration
Post by: afeiges on June 05, 2008, 20:25:40 PM
Dear All,

I've installed the payment module in virtuemart, using the files posted early on this forumn.

Actually, I was wondering if there is a payment module version which supports multiple currencies in VM 1.1 (I saw a previous message from Ian that was testing it)

Also, the module is not working so far, HSBC is returning a code 10, invalid input data. Any ideas of possible causes?

Best regards,
Alejandro
Title: Re: HSBC CPI Integration
Post by: jmds on June 05, 2008, 21:07:51 PM
Hi Alejandro,

If you give the HSBC e-payments tech support a call they will probably be able to tell you what data you are sending is incorrect.
Title: Re: HSBC CPI Integration
Post by: Christopher on June 26, 2008, 14:36:49 PM
If anyone is struggling with integrating the HSBC CPi code, I suggest you visit da8iwr's site, pay the fee and ask him nicely to carry out the integration work for you.

I had a problem with my second implementation of this code, that completely baffled me, especially as my first site had worked 'first time' and I couldn't see any differences in the programming.

In desperation, I contacted da8iwr and he solved the problem, revamped the site, tested it and kept me informed of every step he took.

Hats off to you Ian - you saved my bacon! - my client is very happy and I can relax! This service is worth every penny.

Cheers

Christopher
Title: Re: HSBC CPI Integration
Post by: da8iwr on June 26, 2008, 18:05:43 PM
I shouldn't have called myself da8iwr should i, i sound like a robot, when I'm really just a northern monkey scrabbling to make a living in the north east of England. :)

Christopher, thanks for that, if you ever need anything else, please let me know :).

Regards
"IAN"
Title: Re: HSBC CPI Integration
Post by: julien.b on December 15, 2008, 14:46:43 PM
Nice work !!! thanks a lot

Please notice that the
function generateHash($vector, $s) expect a NON associative array as $vector paramater

FIX : generateHash(array_value($vector), $s) or modify the source code
with a foreach loop ....
Title: Re: HSBC CPI Integration
Post by: Rachel on April 24, 2009, 11:33:37 AM
Hi All
I successfully implemented the HSBC payment module a few years ago, with support from this thread, and my client is happily plodding on with his site.
However, he is now being told that he must request a customers 3 digit verification pin by HSBC.... the HSBC cpi still doesn't provide this, and he couldn't be informed when the form will be updated by HSBC!?
The only suggestion HSBC had, was to move away from using the HSBC provided CPI to a fully integrated API payment method?!?!

Anyone done this with virtuemart?

I can't believe the idiocy of HSBS to state something is mandatory, but not provide the facilities to request it!?!?

Thanks

Rachel
Title: Re: HSBC CPI Integration
Post by: razor7 on December 29, 2009, 18:15:42 PM
Hi...is there a downlodable HSBC payment plugin for VirtueMart?

Thanks a lot!
Title: Re: HSBC CPI Integration
Post by: huhwhatwhere on March 07, 2010, 17:56:52 PM
Hi

I'm looking to integrate CPi payments on my website at some point

What im confused about it whether you can use shared hosting or do you have to have a dedicated server?

I'm currently with Heart Internet

Also what are the pros and cons of CPI /API? in terms of integrating with a website? which is easier?

Cheers
Title: Re: HSBC CPI Integration
Post by: Christopher on March 08, 2010, 15:53:12 PM
You'll need an SSL certificate and therefore, probably, a dedicated IP address for the cert. I've never bothered with shared hosting, but the clue could be in the name - you're trying to do something very secure on a *shared* server?

The choice of HSBC payment gateway will be down to the type of shop, your client's wishes and the kind of set up provided by HSBC. If I recall, they supply the client with a DVD containing the demos and explanations about the different kinds of account and integration, plus some scripting. Don't get too excited about the scripting - as you might be able to tell from this thread (now in its 10th page), there's plenty of work required to get HSBC CPi integrated and working with VM.

IMHO (and I've said this before) contact Ian (username da8iwr - see his posts throughout this thread) and pay him 50 quid for his solution then go to the pub and enjoy your evening, safe in the knowledge that you don't have to mess around for hours on end getting it to work properly because Ian's solution works.

As for Heart internet, best of luck to you - I've found them to be a complete PITA when dealing with them on behalf of clients who want to move away from them (because of Heart's poor service) but they could just be (several) isolated incidents.

:-)
Title: Re: HSBC CPI Integration
Post by: da8iwr on September 15, 2010, 13:41:26 PM
Sorry mate, im in Greece getting married and having a honney moon until next Friday :)
http://www.theimagefile.com/?skin=8407&Action=_VC&id=60377050&ppwd=60962nrn

Give me a shout when i get back, i will have no problem helping you then :)

Ian
Title: Re: HSBC CPI Integration
Post by: siddiqullah16 on September 16, 2010, 16:39:08 PM
Congrats mate have a nice honey moon. will contact you once you are back.

Take care

Quote from: da8iwr on September 15, 2010, 13:41:26 PM
Sorry mate, im in Greece getting married and having a honney moon until next Friday :)
http://www.theimagefile.com/?skin=8407&Action=_VC&id=60377050&ppwd=60962nrn

Give me a shout when i get back, i will have no problem helping you then :)

Ian
Title: Re: HSBC CPI Integration
Post by: siddiqullah16 on October 31, 2010, 15:58:33 PM
Hi Every one

Good news, I have been working with one of my Friend to develop API Integration for HSBC. We Have done it successfully and it is working very well.

We are planning to sell it for £35. This includes installation and the API integration.

Please contact me on siddiqullah16@gmail.com if you are interested.

Many thanks
Title: Re: HSBC CPI Integration
Post by: siddiqullah16 on March 29, 2011, 16:40:28 PM
We have gone a step further. Now we offer A Ready made module. Which can be installed with one click.
We currently sell HSBC API Integration only.

Many thanks 
Title: Re: HSBC CPI Integration
Post by: governer45 on June 12, 2011, 07:27:30 AM
hi
can anyone tell me how to integrate HSBC CPI  integration into ofbiz project
Title: Re: HSBC CPI Integration
Post by: Banzay on September 29, 2011, 15:26:38 PM
I will be happy to pay £50 if any one interesting in integrating it for me.

Email me if you are interesting please.
Title: Re: HSBC CPI Integration
Post by: topdestination on October 12, 2012, 13:18:25 PM
Looking for someone to help me out with the HSBC integration, willing to pay £50.