HSBC Payment CLASS with payer authentication service

Friends! We already suffered enough with HSBC payment and also for PASS implementation.

Finally I have made the total implementation in a single class. Before going with the source code let me explain how the PASS and API works together. We have two separate processes to complete the payment.
1. Send Credit Card information to HSBC PASS server for validation. It will return some PASS parameters.
2. Construct API XML based on PASS response and send back to HSBC to complete the payment.

But no worries! I have made the process very easy with my HSBC class.

Step – 1: Execute PASS
First create object of the class and assign following parameters and execute PASS.

// Credit Card Number
$hsbc->add_pass_field('CardholderPan',"4055011111111111");

// Exipre Date with the format mm-yy
$hsbc->add_pass_field('CardExpiration',"02/11");

// HSBC Cardholderpan
$hsbc->add_pass_field('CcpaClientId',"UKXXXXXXXXGBP");

// Currency Exponent
$hsbc->add_pass_field('CurrencyExponent',"1");

// Amount with Pound symbol.
// For Test payment it must not grater then 1
$hsbc->add_pass_field('PurchaseAmount',"£1");

// Keep it same
$hsbc->add_pass_field('PurchaseAmountRaw',"100");

// Currency Code for Pound
$hsbc->add_pass_field('PurchaseCurrency',"826");

// Return URL to API Section
$hsbc->add_pass_field('ResultUrl',"http://www.example.com/hsbc/example.php");

// Execute PASS
$hsbc->send_pass();

Step – 2: Execute API
Assign the following variables and execute API payment section. If the payment process returns “A” as a response then considers it as a successful payment.
// Set Payment mode
// For test payment set 'Y'
$hsbc->payment_mode = 'P';

// Set true to see the return XML
$hsbc->debug = false;

// Set CcpaResultsCode from PASS responds
$hsbc->ccparesultscode = $_POST['CcpaResultsCode'];

// CAVV from PASS responds
$hsbc->cavv = $_POST['CAVV'];

// XID from PASS responds
$hsbc->xid = $_POST['XID'];

// Payment information for API XML
$hsbc->xmldata = array(
// HSBC Username
"name" =>"XXXXX",
// HSBC Password
"password"=>"XXXXXX",
// HSBC Client ID
"clientid"=>"XXXXX",
// HSBC Cardholderpan
"cardholderpan"=>"UKXXXXXXXXGBP",
// Credit Card No
"number"=>"4055011111111111",
// CVV code for Credit Card
"cvv2val"=>"345",
// Expire Date with format mm-yy
"expires"=>"02/11",
// Issue number only for SOLO and Debit Cards
"issuenum"=>"",
// Start date only for SOLO and Debit Cards
"startdate"=>"",
// Amount For test tranjection it must be 1
"total"=>"1",
// Customer Information
"email" =>"jon@yahoo.com",
"street1"=>"3/A 2nd floor",
"street2"=>"Dhaka Bangladesh",
"city"=>"Dhaka",
"stateprov"=>"BD",
"postalcode"=>"1209",
"country"=>"BD"
);

// Execute Payment
$result = $hsbc->execute_api();

if( $result == "A")
{
echo "Pyment success";
}
else
{
echo "Payment failed";
}

Test Payment:
To execute test payment set payment_mode to Y in API section. For each test transaction the payment amount can not grater then 1.

Debug:
Set $hsbc->debug = true to see the response XML to debug your integration

Download HSBC Payment Class