HSBC CPI Payment Gateway Integration

May 16th, 2006 | Tags:

I had a very interesting project this week, to integrate the HSBC online payment gateway into a custom built shopping store. I have never done this before and I admitted as much to my clients but I was adamant on learning it so I took up the project. The clients were very understanding and decided to go with me.

As always, I started off completely blank. I didn’t know where to begin really till I found an OsCommerce module for integrating HSBC gateway into an OsC store. After going through the code I was still quite lost because I couldn’t get the hash checking to work. No matter what I did or how many times I read the CPI specification, I couldn’t get it to work, something was wrong. It doesn’t help that HSBC provides no way of testing their payment method without a valid StoreFrontID and a HashKey.

This is where Webmaster World comes in. It’s a wonderful place that i’ve been visiting for a while not and i’m sure most of you know about it. This thread on WBM was really useful. On page 8 a user named Telumehtar provides the solution for generating OrderHash, a solution which unlike the HSBC CPI guide solutions, actually works. Telumehtar or John owns this site and is a professional web designer. He has also provided proper working libs for the HSBC gateway here. He was very helpful throughout the project in answering my little, and most of the time stupid, queries. Using his libraries I was finally able to generate proper OrderHash to test with.

Before I go any further here’s a little constructive criticism of the HSBC system. It’s painfully “secret”. There is no way of knowing what you’re doing wrong because HSBC doesn’t send you any decent error information. If your OrderHash itself is wrong, HSBC doesn’t say so, it simply disregards your transaction. It wouldn’t hurt to add an error code, it can’t possible be difficult. Secondly, the system only allows https or secure pages to postback and return too. Because of this, I had to go buy a Turbo SSL certificate off GoDaddy and then a hosting account off HostGator, who are by far the most helpful hosts i’ve encountered to even test my application. Last but possibly the most important point, not all of us are on good hosts like HostGator who will installs libs for us. How about providing a Zend or Ioncude encoded file with the implementation of the OrderHash…

The only real problem that I ran into was with the OrderHash, the rest of it is pretty straightforward and works just like the Paypal IPN. You post information to HSBC with a OrderHash. HSBC checks the validity of your information by generating it’s own OrderHash from your account access key and the data you posted. If the keys match your order is accepted. Upon payment completion/cancellation HSBC posts the details of the transaction to you with another OrderHash. Confirm that the transaction data is valid and you’re done.

There is absolutely no documentation to help you if you run into problems though. Your best bet is that thread on WBM but that’s about it.

If you’re looking for someone to integrate the solution into your site, contact me for a quote, my information is on the contact page. :)

  1. February 8th, 2008 at 18:40
    Quote | #1

    Might anyone have version of the file that Telumehtar created which works under PHP5?? The current one we have only works for PHP 4 and I don’t have the source code to modify. Any suggestions on how to get ahold of a PHP5 version?


  2. Gaurav Arora
    February 20th, 2008 at 12:47
    Quote | #2

    Hi Graham,
    Sorry for the late reply. I don’t think anyone has the source but Telu was quite quick in replying to my emails so you might want to email him. The PHP5 problem has been there since the start (about a year and a half) so I doubt its going to get solved unless you do it yourself.


  3. March 6th, 2008 at 23:01
    Quote | #3

    i went through the text that had been posted by you on HSBC merchant account.
    You can say that its the same that you had felt at the beginning.
    But in this case may i ask for the actual source to get code for payment gateway implementation?


  4. Gaurav Arora
    January 19th, 2009 at 14:45
    Quote | #4

    Hey Sagar,
    Sadly I do not own the source code (the work was done for a client) and hence cannot release it to you. Sorry.

  5. March 9th, 2009 at 14:49
    Quote | #5

    we want payment gateway for our web site

  6. Maya
    September 16th, 2009 at 12:30
    Quote | #6

    I neeed payment gateway

  7. Kiran
    September 22nd, 2009 at 16:08
    Quote | #7

    I have integrated a payment gateway but seems not working properly, i need your guidence to integrate it

  8. Deepak kaushik
    September 24th, 2009 at 12:27
    Quote | #8

    who i am send data from form to hsbc payment gate way in php. Please reply

  9. Thomas
    October 23rd, 2009 at 19:41
    Quote | #9

    Hi, need an expert in this matter to finish my payment gateway with HSBC?


  10. March 22nd, 2010 at 17:50

    Can any one help me,

    I need PHP Samples for HSBC CPI Integration, i have tried allot but nothing works.

    i have hosted the site in godaddy dedicated Linux server


  11. Arthur
    August 17th, 2010 at 19:34

    Hi guys,
    I was able successfully integrate HSBC payment gateway. Anyone who wishes to request professional help, I will be glad to help. just drop me an email: arthur_99 [ a t ]

  12. Ranjit
    April 4th, 2013 at 17:02

    I need java sample for payment gateway integration . Please help.

  13. hello! , I enjoy ones producing greatly! proportion we keep up a correspondence additional close to this page with AOL? We need a specialist with this space or room to be able to uncover my dilemma. It’s possible that may be you actually! Waiting for see you.

Comments are closed.