Tag Archives: Add new tag

HSBC payment API method (Version 0.1.0)

28 Aug

HSBC Corporation generates some tricky documents for their payment method. Hopefully they will update those as soon as possible. I had to cry “HELP HELP!” when I got their manual. 😦
I tried to contact with HSBC help desk a number of times but got more upset. Forum and blog’s also made me frustrated. I was just bouncing around them.

Here i am going to explain the total  process,
First of all, HSBC have two systems for their payment integration method  API and CPI. I solved my problem using API (Application Programmable Interface) method.
Currently API interfaces is available in – C, Java and XML.

I don’t know how dumb those guys, who developed this manual and why  they did not provide the primary elements like “POST Action URL”. After  tried several times i got from their help desk.

We have to follow these simple process to complete the API integration using XML :
Post URL: https://www.secure-epayments.apixml.hsbc.com

Step -1: Prepare an XML document  with  the payment information according to HSBC conversions.
Step-2: Send the XML document to HSBC server and retrieve  the reply instantly
Step-3: Check the status. If status is ‘A’ then consider it as a  successfull transaction.
Step-4: Update your store

Here is the  XML that I prepared to send HSBC server.

<DocVersion DataType=”String”>1.0</DocVersion>
<ContentType DataType=”String”>OrderFormDoc</ContentType>
<Name DataType=”String”>HSBC_USER_NAME</Name>
<Password DataType=”String”>HSBC_USER_PWD</Password>
<ClientId DataType=”S32″>HSBC_USER_ID</ClientId>
<Pipeline DataType=”String”>Payment</Pipeline>
<Mode DataType=”String”>Y</Mode>
<Type DataType=”String”>CreditCard</Type>
<Number DataType=”String”>’ . $cradit_card_no .’</Number>
<Cvv2Val DataType=”String”>’ . $Cvv . ‘</Cvv2Val>
<Cvv2Indicator DataType=”String”>1</Cvv2Indicator>
<Expires DataType=”ExpirationDate”>’ . $exp .’</Expires>
<Type DataType=”String”>PreAuth</Type>
<Total DataType=”Money” Currency=”826″>17</Total>

One important issue is, Total amount always multiplied by 100. For example, If we send amount £3530 then it will represent £35.30.

About Sand Box/Testing Mode:
Another one thing, HSBC has no SandBox. So there is not opportunity to practice except actual user account. 😦
For testing we have set <Mode DataType=”String”>Y</Mode> in XML document and for Live Transaction we have to set <Mode DataType=”String”>P</Mode>

I used CURL to send the XML to HSBC network. See the following example:

$ch = curl_init();
$url = ‘https://www.secure-epayments.apixml.hsbc.com’;
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $xml_data_will_go_here);
$data = curl_exec($ch);
curl_close ($ch);

The return XML will available in ‘$data’ variable. There is a XML node ‘ TransactionStatus’ in return XML file from where we can determine the status of the last operation .

Now see the status of payment.

(A) Approved = Transaction was processed and accepted by the authoriser, but is not yet marked as ready for settlement
(C) Captured = Transaction is ready for settlement.
(D) Declined = Transaction was declined by the authoriser and it is unlikely that it would receive voice approval. This is also known as a hard decline.
(R) Referred = Transaction was declined by the authoriser, but it might receive voice approval. This is also known as a soft decline.
(V) Voided =Transaction has been voided.

That’s all to complate HSBC payment method. But only for proper documentation I had to suffer.

And I  thanks  MR. Paul who gave me support to do the experiment for his Finest Teddy Bear website.

Hope this post will help all of you guys.

Update September 7, 2009
Check my HSBC Paymen Class to make implement in easy way. I have implemented it with PASS(payer authentication service specification) validation.