It’s My Story!

HSBC Payment CLASS with payer authentication service

September 6, 2009 · 8 Comments

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

→ 8 CommentsCategories: HSBC
Tagged:

Google Clouds Hack

August 19, 2009 · Leave a Comment

Run PHP in the Google Clouds

Google App Engine, Amazon Cloud and Azure are always engaged in continuous war. But these platforms are Programming Language specific. So they must have different performance and the combat will not end any more.

Anyways, Last night I was reading a interesting post to execute a PHP script in Google App Engine (GAE)! GAE is supported by Java and Python. A JAVA to PHP bridge that can help us. You can get it from here.

Here is few steps
1. Get a free account from here
2. Download the interpreter
3. Now update “php-java-bridge” definition file. Open war/WEB-INF/appengine-web.xml and edit application name.
4. Download “Google App Engine SDK for Java” and extract it.
5. Open command prompt and execute following command
[GAE SDK file path]/ bin/ appcfg.cmd update [php-java-bridge-file-path] \war
6. Browse you application.
7. :)

See an example.

→ Leave a CommentCategories: Azure · Cloud Computing · Google App Engine
Tagged:

OLE DB (MS Access) database connection problem in 64bit operating with C#

May 19, 2009 · 4 Comments

From last couple of weeks I am developing a desktop software called “TSF Core” built with C#. This software is replacement of a web (Apache, MySQL) admin panel based one web service (WSDL). I am using MS Access as a cash database to make the more process faster.

I was getting an exception with my database connection in 64bit vista ultimate bit it was working fine in XP 32bit, 2000 and VISTA 32 bit OS.

I am using Microsoft.Jet.OLEDB.4.0; to connect with .mdb. Connection string is something like that:

new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=tsf_barcode_reader.mdb");

I got a strange result when I Googled on it. There is no OLEDB version for 64Bit Operating system.

But there is a good solution for that at least it worked for my software. We can specify the software platform in project definition. To do this please open "my_project.csproj" in notepad or any other plain text editor and add the following code under "PropertyGroup" tag.

<PlatformTarget>x86</PlatformTarget>

Code will be some ting like that:

Previouse code:

<PropertyGroup Condition=" ‘$(Configuration)|$(Platform)’ == ‘Debug|AnyCPU’ ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" ‘$(Configuration)|$(Platform)’ == ‘Release|AnyCPU’ ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>

Edited Cdoe

<PropertyGroup Condition=" ‘$(Configuration)|$(Platform)’ == ‘Debug|AnyCPU’ ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<PlatformTarget>x86</PlatformTarget>
</PropertyGroup>
<PropertyGroup Condition=" ‘$(Configuration)|$(Platform)’ == ‘Release|AnyCPU’ ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<PlatformTarget>x86</PlatformTarget>
</PropertyGroup>

In this situation the operations system will call 32 bit compatible database connection provider for that software and the problem will be solved.

→ 4 CommentsCategories: 64 bit OS · C# · MS Access

Organize a C# project to customize it from outside of source code

April 1, 2009 · 5 Comments

For any project we feel to process some configuration variables so that we can customize the software from out of sources code. It is important to make those variables available in each part of the project minimizing the system load. We can put the values either in an xml or Database. In my last C# project I’ve followed an interesting process.

I used a Single Tone Pattern Class to process my variables and declare the constructor “private” so that we can’t create more than one instance with “new” keyword.

private Dictionary sconfig;

Dictionary is a fantastic element to store temporary data. Here I used it something like associative array.

private static BCReaderConfiguration _bcrConfigObj = null;
public static BCReaderConfiguration getObject()
{
if (_bcrConfigObj == null)
{
_bcrConfigObj = new BCReaderConfiguration();
_bcrConfigObj.setConfig();
return _bcrConfigObj;
}
else
{
return _bcrConfigObj;
}
}

This the most interesting part of my coding. getObject() is a static method so that I can call it from anywhere with the name of class. Like:

BCReaderConfiguration.getObject();

I have declared a private variable with the type of my configuration class (“BCReaderConfiguration”) and storing the first instance of this object. Each time I call the function form other part of my coding first I check if the object already created. If this object is not created (First time call) then it’s creating new object otherwise returning the previous one. This process will save my Physical Memory as well as time because we are using same object for thousands of calls.

Let’s consider an XML file where all configuration variables are saved. Here is the example XML file :

<sconfig>
<node><svalue soption="check_update_title">Wait Checking for update</svalue> </node> <node><svalue soption="bad_database_structure">Bad Database structure!</svalue> </node> <node><svalue soption="guest_success_msg">Welcome!</svalue> </node>
<node><svalue soption="guest_failed_msg">Sorry</svalue> </node>
<node><svalue soption="general_inconvenience_msg">Sorry! For inconvenience</svalue> </node> <node><svalue soption="about">Version 1.0</svalue></node>
</sconfig>

Each “node” tag preserving one configuration value inside the tag and attribute “svalue soption” containing the variable name.

private XmlDocument getConfigXML ()
{
XmlDocument document = new XmlDocument();
return document.Load(“xmls\\config.xml”);
}

getConfigXML() is a simple function to read the xml and return the Xml type object.

private void setConfig()
{
this.sconfig = new Dictionary();
// Collect the xml data

XmlDocument sconfigXmlDoc = this.getConfigXML ();

XmlNodeList list = null;
list = sconfigXmlDoc.GetElementsByTagName(“node”);

foreach (XmlNode val in list)
{
this.sconfig[val["svalue"].GetAttribute(“soption”)] = val["svalue"].InnerText;
}
}

This is a pretty easy section. Here I am populating all my data in a 2D Dictionary. XmlNodeList is a C# data type to process Xml node from XmlObject.

Well, we are all most done. Now we need a Public function that can return our desired configuration variable.

public String get_config(String soption)
{
try
{
return this.sconfig[soption];
}
catch
{
return “”;
}
}

I used “get_config()” method that accept a Configuration variable name as parameter and return the desired value and in case of any exception it will return an empty string.

Finally, to get any configuration variable we will call something like this:

BCReaderConfiguration.getObject().get_config(“guest_success_msg”)

Full source Code here:

using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Xml;
namespace barcodereader
{
class BCReaderConfiguration
{
private Dictionary sconfig;
private static BCReaderConfiguration _bcrConfigObj = null;

private BCReaderConfiguration()
{
}

// Single Tone object generator
public static BCReaderConfiguration getObject()
{
if (_bcrConfigObj == null)
{
_bcrConfigObj = new BCReaderConfiguration();
_bcrConfigObj.setConfig();
return _bcrConfigObj;
}
else
{
return _bcrConfigObj;
}
}

private XmlDocument getConfigXML ()
{
XmlDocument document = new XmlDocument();
return document.Load(“config.xml);
}

// Populate the configuration in to array
private void setConfig()
{
this.sconfig = new Dictionary();
XmlDocument sconfigXmlDoc = this.getConfigXML();
XmlNodeList list = null;
list = sconfigXmlDoc.GetElementsByTagName(“node”);

foreach (XmlNode val in list)
{
this.sconfig[val["svalue"].GetAttribute(“soption”)] = val["svalue"].InnerText;
}
}

// Return the Configuration value
public String get_config(String soption)
{
try
{
return this.sconfig[soption];
}
catch
{
return “”;
}
}
}
}

→ 5 CommentsCategories: C#

Azure Services Platform

December 28, 2008 · Leave a Comment

Microsoft’s web application development platform “AZURE” already released. They are calming it will be most powerful and scalable technology. AZURE will be based on .Net framework supported by different internet protocols including HTTP, SOAP and XML etc. It will also support Non-Microsoft language Like Purl, Ruby, PHP. Here is a brief that I have copy and paste from Microsoft Release notes

“The Azure™ Services Platform (Azure) is an internet-scale cloud services platform hosted in Microsoft data centers, which provides an operating system and a set of developer services that can be used individually or together. Azure’s flexible and interoperable platform can be used to build new applications to run from the cloud or enhance existing applications with cloud-based capabilities. Its open architecture gives developers the choice to build web applications, applications running on connected devices, PCs, servers, or hybrid solutions offering the best of online and on-premises.

Azure reduces the need for up-front technology purchases, and it enables developers to quickly and easily create applications running in the cloud by using their existing skills with the Microsoft Visual Studio development environment and the Microsoft .NET Framework. In addition to managed code languages supported by .NET, Azure will support more programming languages and development environments in the near future. Azure simplifies maintaining and operating applications by providing on-demand compute and storage to host, scale, and manage web and connected applications. Infrastructure management is automated with a platform that is designed for high availability and dynamic scaling to match usage needs with the option of a pay-as-you-go pricing model. Azure provides an open, standards-based and interoperable environment with support for multiple internet protocols, including HTTP, REST, SOAP, and XML.

Microsoft also offers cloud applications ready for consumption by customers such as Windows Live™, Microsoft Dynamics™, and other Microsoft Online Services for business such as Microsoft Exchange Online and SharePoint® Online. The Azure Services Platform lets developers provide their own unique customer offerings by offering the foundational components of compute, storage, and building block services to author and compose applications in the cloud.”

→ Leave a CommentCategories: Azure
Tagged:

To encrypt PHP soruce code

December 5, 2008 · Leave a Comment

Yesterday night I was looking for something to encrypt my PHP source code. Three years back I used one script to encrypt my PHP source code. Unfortunately I have lost the script.

Finally I got this service to get the job done.  They used same way that I did with the script that I lost. I am sharing with you… :)

rightscripts

www.rightscripts.com

→ Leave a CommentCategories: PHP
Tagged:

Our Q3 program 2008

November 25, 2008 · 10 Comments

Recently our Q3 program was celebrated. The most important part of this program is to award employees for their achievement.

Memtot Award

Mentor Award November/2008

I’m not too much older employee here but I could archive a faith from all of my colleagues.  I was really amazed when our CEO(SAM) announced my name from stage to receive my award. I was awarded with “Mentor Award“. In the stage I tried to visualize about my work that I did in last few months. I know, I have a habit to help my colleagues but it will bring me here I was not too much expected for it. I am thankful to the jury board that selected me and also remembering those people who appointed me here. i wish i could give return to these people by my work.

→ 10 CommentsCategories: Award
Tagged:

Some non-web based desktop softwares support CSS3 better then popular web browsers…. LOL

November 13, 2008 · 2 Comments

Majority of web communities are considering CSS3 is  powerful then all previous versions and also are dreaming to use it in near future with full featured. But problem is few browsers are supporting CSS3 selectors. www.css3.info is a fantastic website to study about this new tools.

Today I have grabbed interesting information when I was reading one of the articles from this site.
css3img
Opera is a browser that support some CSS3 selectors.:( But there is a desktops software called Prince Or PrinceXML that can convert a HTML file to PDF and it support few more CSS3 selectors where some popular web browsers failed. LOL……

→ 2 CommentsCategories: CSS3

Birth day party of JPT

October 13, 2008 · 3 Comments

Today I had an exciting moment. It was first birth day party of JPT (Junior Polar Traveler). This is my first assigned project released after joining SKYLARK team in bGlobal Sourcing.

Here I am sharing some pictures. I am sorry as I can not share the pictures from SKYLARK UK members because those are not appeared in my hand when I am wringing this post. They are Arthur Irving, Paul Wilson, Hayley Richardson and Zed Retief

→ 3 CommentsCategories: project Experience

OUR Q2 Program 2008

July 28, 2008 · 5 Comments

Recently we celebrate our b Global Sourcing Q2 offset program/2008 . Here i am sharing some picture….

Mr. Samuel D. Bretzfield( CEO)

Seminar view

Discussion on QA implementation

Discussion on QA implementation

Discussion on QA implementation

Discussion on QA implementation

Presentation on QA implementation

Presentation on QA implementation

…….

Go Cart

Raceing ….

… Takeing technical brief

shahed …on the race …

Moinul on his race…

Sam declaring the wining result…

………….

Winner award part

Wining team

Wining team

See more

→ 5 CommentsCategories: bGlobalSourcing
Tagged: