Monday, 12 September 2011

HSBC cpi Linux

What an effort!!!!

I eventually got HSBC CPI thang working on Centos 5.6 linux through the below guide:


Thought I would contribute some more notes that you might find helpfull:

below from: http://forums.fedoraforum.org/showthread.php?t=77772

1.) use < .bashrc > file in your home directory (instead of .bash_profile)
2.) add the following line to this file :

LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib ; export LD_LIBRARY_PATH

DO ONE MORE THING : also add this line to < /etc/ld.so.conf > file

run /sbin/ldconfig after /etc/ld.so.conf changing

You will need to install some more goodness to get it all running, check the errors spat out in /var/log/http for more info.

yum install compat-libstdc++-296-2.96-138.i386

If you are using php have a good look at:

http://www.leadingedgescripts.co.uk/downloads/hsbc_php.zip

Code beast!

In the below example we are selling registrations.

Sorry the formatting on the below code has gone pear shaped, would fix it but I've got a deadline to meet.


if ($onlinepayment == 'hsbc') {

echo '';

// OrderId random number

$randombeast = substr(md5(crypt(rand(0,10))),0,20);


//TimeStamp varibale

$hippytime = time();
$hippytime = $hippytime*1000;

// OrderDesc variable setting to $_REQUEST['RegNumber']

$OrderDesc = 'Your Registation number: ';
$OrderDesc .= $_REQUEST['RegNumber'];

// PurchaseAmount variable

//if we don't have a decimal place times by 10, PurchaseAmount must be a positive integer.

$numberOfDots = substr_count($_REQUEST['Amount'], '.');

if ($numberOfDots == 0) {

$hsbcAmount = preg_replace('/\D/', '', $_REQUEST['Amount']);
$hsbcAmount = $hsbcAmount . '00';
//echo $hsbcAmount;
}

if ($numberOfDots == 1) {

$hsbcAmount = preg_replace('/\D/', '', $_REQUEST['Amount']);
//echo $hsbcAmount;
}

//Encode all form values into one MerchantData variable, this comes back from HSBC. Using 'xxxDDDxxx' string as variable separator.

$merchdatabck = 'xxxDDDxxx' . urlencode($_REQUEST['RegNumber']) . 'xxxDDDxxx' . urlencode($_REQUEST['EmailAddress']) . 'xxxDDDxxx' . urlencode($_REQUEST['TelephoneNumber']) . 'xxxDDDxxx' . urlencode($_REQUEST['Amount']) . 'xxxDDDxxx';
//echo $merchdatabck;

/*******************************
|$postdata was created seperately using the array2String function in
|the following file http://www.leadingedgescripts.co.uk/downloads/hsbc_php.zip
|most of the below code is from this file
*******************************/

$postdata = 'submitButton=Submit&CpiUrl=https%3A%2F%2Fwww.cpi.hsbc.com%2Fservlet&OrderId=' . $randombeast . '&TimeStamp=' . $hippytime . '&CpiDirectResultUrl=https%3A%2F%2Fclients.somedomain.com%2FHsbcmail.php&CpiReturnUrl=https%3A%2F%2Fclients.somedomain.com%2Fhsbcback.php&StorefrontId=UKYourMerchantNumberGBP&OrderDesc=' . $OrderDesc . '&PurchaseAmount=' . $hsbcAmount . '&PurchaseCurrency=826&TransactionType=Capture&UserId=&Mode=T&MerchantData=' . $merchdatabck . '&';
/*******************************
|Strips out all the raw text we don't want
*******************************/
function strip_text($a)
{
$i = -1;
$n = '';
$ok = 1;
while(isset($a{++$i}))
{
if($ok&&$a{$i} != '<')
{
continue;
}
elseif($a{$i} == '>')
{
$ok = 1;
$n .= '>';
continue;
}
elseif($a{$i} == '<')
{
$ok = 0;
}
if(!$ok)
{
$n .= $a{$i};
}
}
return $n;
}

/*********************************
|Open the connection to the url
*********************************/
$fp = fsockopen("clients.somedomain.com", 80);
if (!$fp)
{
echo "There was an error connecting using fsockopen()\n";
}
else
{
/***************************
|lets build our post request
|these variables may change depending on your server
***************************/
$out = "POST /cgi-bin/OrderHash.e HTTP/1.1\r\n";
$out .= "Host: www.yourwebsite.com\r\n";
//Don't modify any of this unless you need to
$out .= "Accept:text/xml,application/xml,application/zhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5\r\n";
$out .= "Accept-Language: en\r\n";
$out .= "Accept-Encoding: gzip,deflate\r\n";
$out .= "Accept-Charset:ISO-8859-1,utf-8;q=0.7,*;q=0.7\r\n";
$out .= "Keep-Alive: 300\r\n";
$out .= "Content-Type:application/x-www-form-urlencoded\r\n";
$out .= "Content-Length: ". strlen($postdata) ."\r\n";
$out .= "Connection: close\r\n\r\n";
$out .= $postdata;
/*****************************
|This passes our POST headers
|to the OrderHash.e form
*****************************/
fwrite($fp, $out);
/****************************
|Here is where we get the result from OrderHash.e
|then strip out all the stuff we don't need
|This is the really clever bit
****************************/
while (!feof($fp))
{
$output = fgets($fp, 500);
$output = strip_text($output);
$output = strip_tags($output, ',
');
//Change the form elements from 'text' to 'hidden'
$output = str_replace('type="text"', 'type="hidden"', $output);
$output = str_replace('onSubmit="singleSubmit(this)"', '', $output);
$output = trim($output);
$persist .= $output;
}
//Remove some more stuff we don't want and change the text on the submit button.
$persist = str_replace('method="POST" >', 'method="POST" >', $persist);
$persist = str_replace('', '', $persist);
/******************************
|This echo statement should output a nice simple form
|which can be submitted directly to the HSBC
|I've hidden all the form elements so all that is visible at this stage
|is a simple submit button.
*****************************/
echo $persist;
fclose($fp);
}


echo '';

}


?>

Saturday, 6 December 2008

A green way to clear caustic soda from a drain.

Two methods to clear caustic soda from a drain (in a environmentally sound way) are:

(1) Hot water

(2) Strong vinegar (nasty chip vinegar). The safe but strong acidic properties of vinegar will partly neutralize the strong alkaline properties of caustic soda, producing a soapy solution.

PLEASE DON'T ASSUME THE RESULTING SOLUTION FROM THE MIX OF CAUSTIC SODA AND VINEGAR IS SAFE! IT MIGHT STILL BE A STRONG ALKALINE!

I hope you find this post useful.

John

Sunday, 30 March 2008

Boycott Creative Labs

Creative Labs has recently been getting some bad press from it's user base for threatening legal action against a developer who provided unofficial drivers for Windows Vista.

The unofficial driver provided the ability to use older Creative graphics cards under Vista - a service not presently provided by Creative.

Creative's business logic behind the lack of drivers was to force existing customers using Vista into purchasing a new graphics cards (Vista drivers provided), thus dramatically increasing new sales.

A very strong handed approach indeed!

My wife has her own gripe with Creative and this time it's their inability to provide a battery for a mp3 player that was purchased only 2 years ago!

Please see an email below from Creative detailing why they can't provide a battery for the original Creative Zen 20gb.


> Date: Tue, 1 Jan 2008 04:45:12 +0000
> From: support@europe.creative.com
> To: xxxxxx(hidden for obvious reasons)xxx@hotmail.com
> Subject: Re: CLE - Technical Support Request (KMM15741557I110L0KM)
>
>
>
>
> Dear Wendy,
>
> With regard to reply, I am sorry to inform you that your player is
> already out of warranty and we do not have any out of warranty
> repair/replacement service for your player.
>
> As your Creative product is no longer covered by a hardware warranty, I
> can offer you to purchase a new player of your choice at a discounted
> rate by calling our Technical Phone Support
>
> You could consider to get a new Creative Zen 8GB, http://uk.europe.creative.com/products/product.asp?category=213&subcategory=214&product=16999.
> The price we can offer you for Creative Zen 8GB is £116.99 including
> postage and VAT charges. This price only applies to you with out of
> warranty player. Or you can check out our other range of MP3 players at http://uk.europe.creative.com/products/welcome.asp?category=213
>
> If you are interested with our offer, you could call our Technical Phone
> Support colleagues situated in Ireland , Dublin at 00 353 1 4333200,
> and the operating hours is Mon-Fri : 09:30 - 18:00 (GMT) Sat-Sun &
> Public Holidays : Closed
>
> I apologize for any inconvenience caused, any inconvenience caused is
> regretted. If you have any other questions or clarifications in this
> regard, please do feel free to mail me.
>
> Please retain all the previous correspondence when replying to this
> email.
> Best Regards
> Chin
> Creative Customer Support Services
> Creative Labs Europe

Hopefully this blog will make you think twice about purchasing any products from a business that forces obsolescence.

John

Sunday, 24 February 2008

Workable business idea

My motivation behind writing this blog is to draw on all the creative business minds out on the Internet to help me solve an ethical business idea that's been bugging me for the last few years.

Background:

"
An unfortunate by-product of today's fast-moving digital age is the obsolescent equipment that gets discarded in its wake.."

Dealing with toxic computer waste (BBC News Article)

Opportunity:

All major cities like London have literally millions of old computers destined for the land fill. These machines are seen to be useless by their owners as they don't have the ability to run a secure & responsive modern operating system.

The vast majority of these machines will be thrown out at the dump or street side over the next few years. I know there are good organizations like Computer Aid International that are willing for individuals to drop off their machines in person or via courier. The cost of couriering invariably putting off most good doers.

Known:

I know it's possible to get my hands on literally thousands of older machines in a densely populated city like London at no cost except the time spent networking on sites like freecycle & gumtree e.t.c.

I know it's possible to load a totally free modern operating system like Linux (DSL / Gentoo / Arch / Vector / eLive / Xubuntu...) that will allow older machines to operate relatively quickly and securely while on the Internet.

The Crunch:

How does one take the above two freebies and convert it into a viable & ethical business idea?

Please post a comment.