Location: PHPKode > scripts > HSBC > hsbc/example.php
<?php
/***************************************************************************************************
	Defination		: HSBC Payment CLASS Method With PASS And API
	Developed By	: Reazaul Karim - Rubel
	Emai			: hide@address.com
	Web				: http://www.apprain.com
	Blog			: http://reazulk.wordpress.com
	Terms			: This class is free for use. I request you not to remove the author information
	How to use
	----------
	I have tried to make the process as simple as possible. 
	1. We have to send all PASS values to HSBC network. See the PASS PROCESS in the code.
	2. In second step we have to set the CcpaResultsCode, CAVV, XID from PASS response
	3. We have to set necessary API information
	4. Finally we have to catch the result and if result is "A" then payment completed successfully.
***************************************************************************************************/

include("hsbc.php");

/* Example Payment */
$hsbc = new hsbc();

if(empty($_POST))
{
	/* --- PROCESS 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.teddybearspersonalised.co.uk/hsbc/hsbc.php");

	// Execute PASS
	$hsbc->send_pass();
}
else
{
	/* --- API PROCESS --- */
	// Set Payment mode
	// For test payment set 'Y'
	$hsbc->payment_mode = 'P';

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

	// Set CcpaResultsCode frin 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" =>"hide@address.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";
	}
}
?>
Return current item: HSBC