Thursday 16 August 2012

integrate icici payment gateway php without JavaBridge/JDK



The Installation process for SFAClient.zip

 

1.     Unzip SFAClient.zip. This will create a folder called SFAClient
2.    SFAClient contains the following files and directory.
1.     Sfa – SFA Client library (contains the PHP Sfa library)
2.     Test Pages – Sample pages for transactions and a test page (test.php) for testing php.
3.     sfa.properties

PHP Web Application Directory Structure – Sample Example

·         Create the following  PHP Web application directory structure as given below
o   E.g. the Merchant website directory name is “Merchant_Site_Dir”.
·         Copy all the directory and files from unzipped SFAClient to Merchant_Site_Dir .



§  Place the directory Merchant_Site_Dir in C:/wamp/www/ as shown below.
·         Sfa, Test Pages and sfa.properties



Note:
§  Sfa folder should be copied to the folder where TestPages/Merchant pages are present.
§  The directory names are case sensitive. Create them as mention above.











Changes in Test Pages

  • Open the SFAResponse.php and made some changes

<?php
include("Sfa/EncryptionUtil.php");


                        $strMerchantId="00000001";
                        $astrFileName="c://key//sbi//00000001.key";
                        $astrClearData;
                        $ResponseCode = "";
                        $Message = "";
                        $TxnID = "";
                        $ePGTxnID = "";
                        $AuthIdCode = "";
                        $RRN = "";
                        $CVRespCode = "";
                        $Reserve1 = "";
                        $Reserve2 = "";
                        $Reserve3 = "";
                        $Reserve4 = "";
                        $Reserve5 = "";
                        $Reserve6 = "";
                        $Reserve7 = "";
                        $Reserve8 = "";
                        $Reserve9 = "";
                        $Reserve10 = "";


Note : Mercant ID must be same as the .key file name. e.g. if file is 00000001.key then Merchant ID must be 00000001.

  • According to merchant type i.e. SSL or MOTO change select the file and make the changes
    • e.g. if Merchant is SSL Merchant then change the TestSsl.php
<?php


include("Sfa/BillToAddress.php");
include("Sfa/CardInfo.php");
include("Sfa/Merchant.php");
include("Sfa/MPIData.php");
include("Sfa/ShipToAddress.php");
include("Sfa/PGResponse.php");
include("Sfa/PostLibPHP.php");
include("Sfa/PGReserveData.php");

 $oMPI                        =          new     MPIData();

 $oCI               =          new     CardInfo();

 $oPostLibphp =          new     PostLibPHP();

 $oMerchant    =          new     Merchant();

 $oBTA                       =          new     BillToAddress();

 $oSTA                        =          new     ShipToAddress();

 $oPGResp      =          new     PGResponse();

 $oPGReserveData = new PGReserveData();




 $oMerchant->setMerchantDetails("00000001","00001203","00001203","193.545.34.33",rand()."","Ord123","http://10.10.10.167/SFAResponse.php","POST","INR","INV123","req.Sale","100","","Ext1","true","Ext3","Ext4","Ext5");
?>
Put marchant id.


  • e.g. if Merchant is Moto Merchant then change the TestMoto.php



Set the key directory path


·         'Key.Directory' should contain the name of the folder, which contains the merchant key. A trailing slash has to be included at the end of this value. The name of the file (.key file) need not be set. Save the file after making other relevant changes.
§  Key.Directory=D://WAMP//WWW//key//
Note: Don’t include key in key directory path.
·         Enable the verbose parameter to “true” only when required to generate logs. These logs are to be used for debugging (while integration) and should not be set to “true” in production as it might lead to considerable amount of logs depending on the number of transactions.
·         To verify the success of the above operations open the jar file again and check if the properties file has the values set.

 

 

Enabling Curl extensions

 


The curl extension files are

  • libeay32.dll
  • ssleay32.dll

These files should be present in to C:\WINDOWS\system32 and Php installation directory.

Open the php.ini file from PHP installation directory remove the semicolon of extension=php_curl.dll.

 


Disabling mcrypt extensions (for PHP version <= 4.4.4)

 


  • Open the php.ini file from PHP installation directory add the semicolon on start of line  ;extension=php_mcrypt.dll (if semicolon not present).

 Checklist

 

·           Merchant should have access to ePG over https
·           Check connectivity between php
1.     Restart the IIS Server
2.     Browse the testjava.php page either from browser of from IIS as shown below
                                       i.    Url : http://localhost/Merchant_Site_Name/test.php



Transaction Testing

 

·         Restart the Apache
·         Open the PHP page either from browser or from Apache
·         If Merchant is SSL then open TestSsl.php else if Merchant is Moto then TestMoto.php
1.         From IIS

               2.  From Browser
·         Type the URL : http://localhost/Merchant_Site_name/TestSsl.php


Troubleshooting

 


Problem : In log file if you got SSL certificate problem….



Solution : Add the certificate CSR in \Sfa\cacerts.pem file. (Refer Adding Certificates in  Cacerts section).

Tuesday 7 August 2012

Basic Linux Commands

mkdir - make directories
Usage
mkdir [OPTION] DIRECTORY
Options
Create the DIRECTORY(ies), if they do not already exist.
 Mandatory arguments to long options are mandatory for short options too.
 -m, mode=MODE  set permission mode (as in chmod), not rwxrwxrwx - umask
 -p, parents  no error if existing, make parent directories as needed
 -v, verbose  print a message for each created directory
 -help display this help and exit
 -version output version information and exit
cd - change directories
Use cd to change directories. Type cd followed by the name of a directory to access that directory.Keep in mind that you are always in a directory and can navigate to directories hierarchically above or below.
mv- change the name of a directory
Type mv followed by the current name of a directory and the new name of the directory.
 Ex: mv testdir newnamedir
pwd - print working directory
will show you the full path to the directory you are currently in. This is very handy to use, especially when performing some of the other commands on this page
 rmdir - Remove an existing directory
 rm -r
Removes directories and files within the directories recursively.
chown - change file owner and group
Usage
chown [OPTION] OWNER[:[GROUP]] FILE
chown [OPTION] :GROUP FILE
chown [OPTION] --reference=RFILE FILE
Options
Change the owner and/or group of each FILE to OWNER and/or GROUP. With --reference, change the owner and group of each FILE to those of RFILE.
 -c, changes like verbose but report only when a change is made
 -dereference affect the referent of each symbolic link, rather than the symbolic link itself
 -h, no-dereference affect each symbolic link instead of any referenced file (useful only on systems that can         change the ownership of a symlink)
 -from=CURRENT_OWNER:CURRENT_GROUP
  change the owner and/or group of each file only if its current owner and/or group match those specified here.  Either  may  be  omitted,  in which case a match is not required for the omitted attribute.
-no-preserve-root do not treat `/' specially (the default)
-preserve-root fail to operate recursively on `/'
-f, -silent, -quiet  suppress most error messages
-reference=RFILE use RFILE's owner and group rather than the specifying OWNER:GROUP values
-R, -recursive operate on files and directories recursively
-v, -verbose output a diagnostic for every file processed
The  following options modify how a hierarchy is traversed when the -R option is also specified. If more than one is specified, only the final one  takes effect.
-H     if a command line argument is a symbolic link to a directory, traverse it
-L     traverse every symbolic link to a directory encountered
-P     do not traverse any symbolic links (default)
chmod - change file access permissions
Usage
chmod [-r] permissions filenames
 r  Change the permission on files that are in the subdirectories of the directory that you are currently in.        permission  Specifies the rights that are being granted. Below is the different rights that you can grant in an alpha  numeric format.filenames  File or directory that you are associating the rights with Permissions
u - User who owns the file.
g - Group that owns the file.
o - Other.
a - All.
r - Read the file.
w - Write or edit the file.
x - Execute or run the file as a program.
Numeric Permissions:
CHMOD can also to attributed by using Numeric Permissions:
400 read by owner
040 read by group
004 read by anybody (other)
200 write by owner
020 write by group
002 write by anybody
100 execute by owner
010 execute by group
001 execute by anybody
ls - Short listing of directory contents
-a        list hidden files
-d        list the name of the current directory
-F        show directories with a trailing '/'
            executable files with a trailing '*'
-g        show group ownership of file in long listing
-i        print the inode number of each file
-l        long listing giving details about files  and directories
-R        list all subdirectories encountered
-t        sort by time modified instead of name
cp - Copy files
cp  myfile yourfile
Copy the files "myfile" to the file "yourfile" in the current working directory. This command will create the file "yourfile" if it doesn't exist. It will normally overwrite it without warning if it exists.
cp -i myfile yourfile
With the "-i" option, if the file "yourfile" exists, you will be prompted before it is overwritten.
cp -i /data/myfile
Copy the file "/data/myfile" to the current working directory and name it "myfile". Prompt before overwriting the  file.
cp -dpr srcdir destdir
Copy all files from the directory "srcdir" to the directory "destdir" preserving links (-poption), file attributes (-p option), and copy recursively (-r option). With these options, a directory and all it contents can be copied to another dir
ln - Creates a symbolic link to a file.
ln -s test symlink
Creates a symbolic link named symlink that points to the file test Typing "ls -i test symlink" will show the two files are different with different inodes. Typing "ls -l test symlink" will show that symlink points to the file test.
locate - A fast database driven file locator.
slocate -u
This command builds the slocate database. It will take several minutes to complete this command.This command must be used before searching for files, however cron runs this command periodically  on most systems.locate whereis Lists all files whose names contain the string "whereis". directory.
more - Allows file contents or piped output to be sent to the screen one page at a time
less - Opposite of the more command
cat - Sends file contents to standard output. This is a way to list the contents of short files to the screen. It works well with piping.
whereis - Report all known instances of a command
wc - Print byte, word, and line counts
bg
bg jobs Places the current job (or, by using the alternative form, the specified jobs) in the background, suspending its execution so that a new user prompt appears immediately. Use the jobs command to discover the identities of background jobs.
cal month year - Prints a calendar for the specified month of the specified year.
cat files - Prints the contents of the specified files.
clear - Clears the terminal screen.
cmp file1 file2 - Compares two files, reporting all discrepancies. Similar to the diff command, though the output format differs.
diff file1 file2 - Compares two files, reporting all discrepancies. Similar to the cmp command, though the output format differs.
dmesg - Prints the messages resulting from the most recent system boot.
fg
fg jobs - Brings the current job (or the specified jobs) to the foreground.
file files - Determines and prints a description of the type of each specified file.
find path -name pattern -print
Searches the specified path for files with names matching the specified pattern (usually enclosed in single quotes) and prints their names. The find command has many other arguments and functions; see the online documentation.
finger users - Prints descriptions of the specified users.
free  - Displays the amount of used and free system memory.
ftp hostname
Opens an FTP connection to the specified host, allowing files to be transferred. The FTP program provides subcommands for accomplishing file transfers; see the online documentation.
head files - Prints the first several lines of each specified file.
ispell files - Checks the spelling of the contents of the specified files.
kill process_ids
kill - signal process_ids
kill -l
Kills the specified processes, sends the specified processes the specified signal (given as a number or name), or prints a list of available signals.
killall program
killall - signal program
Kills all processes that are instances of the specified program or sends the specified signal to all processes that are instances of the specified program.
mail - Launches a simple mail client that permits sending and receiving email messages.
man title
man section title - Prints the specified man page.
ping host - Sends an echo request via TCP/IP to the specified host. A response confirms that the host is operational.
reboot - Reboots the system (requires root privileges).
shutdown minutes
shutdown -r minutes
Shuts down the system after the specified number of minutes elapses (requires root privileges). The -r option causes the system to be rebooted once it has shut down.
sleep time - Causes the command interpreter to pause for the specified number of seconds.
sort files - Sorts the specified files. The command has many useful arguments; see the online documentation.
split file - Splits a file into several smaller files. The command has many arguments; see the online documentation
sync - Completes all pending input/output operations (requires root privileges).
telnet host - Opens a login session on the specified host.
top - Prints a display of system processes that's continually updated until the user presses the q key.
traceroute host - Uses echo requests to determine and print a network path to the host.
uptime - Prints the system uptime.
w - Prints the current system users.
wall - Prints a message to each user except those who've disabled message reception. Type Ctrl-D to end the message.


Saturday 4 August 2012

Demo/About/Documentation geolocation API , IP address based Geolocation


Demo/About/Documentation geolocation API

The geolocation-feature implements the navigator.geolocation API. The following methods are available:

    navigator.getCurrentPosition: successCallback, errorCallback and options ({timeout: number}) are supported
    navigator.watchPosition: in shim identical to getCurrentPosition, except it returns an useless ID
    navigator.clearWatch: is noop in shim

The shim uses the geolocation information provided by http://freegeoip.net and/or googles API-Loader
Options for geolocation

    confirmText (string): confirm text for requesting access to geo data.

$.webshims.setOptions('geolocation', { confirmText: '{location} wants to know your position. It is Ok to press Ok.' }); navigator.geolocation.getCurrentPosition(function(pos){ alert("Thx, you are @ latitude: "+ pos.coords.latitude +"/longitude: " + pos.coords.longitude); });

The following code extracts illustrate how to obtain basic location information:

Example of a "one-shot" position request.

    function showMap(position) {
      // Show a map centered at (position.coords.latitude, position.coords.longitude).
    }

    // One-shot position request.
    navigator.geolocation.getCurrentPosition(showMap);
   

Example of requesting repeated position updates.

    function scrollMap(position) {
      // Scrolls the map so that it is centered at (position.coords.latitude, position.coords.longitude).
    }

    // Request repeated updates.
    var watchId = navigator.geolocation.watchPosition(scrollMap);

    function buttonClickHandler() {
      // Cancel the updates when the user clicks a button.
      navigator.geolocation.clearWatch(watchId);
    }
   

Example of requesting repeated position updates and handling errors.

    function scrollMap(position) {
      // Scrolls the map so that it is centered at (position.coords.latitude, position.coords.longitude).
    }

    function handleError(error) {
      // Update a div element with error.message.
    }

    // Request repeated updates.
    var watchId = navigator.geolocation.watchPosition(scrollMap, handleError);

    function buttonClickHandler() {
      // Cancel the updates when the user clicks a button.
      navigator.geolocation.clearWatch(watchId);
    }
   

Example of requesting a potentially cached position.

    // Request a position. We accept positions whose age is not
    // greater than 10 minutes. If the user agent does not have a
    // fresh enough cached position object, it will automatically
    // acquire a new one.
    navigator.geolocation.getCurrentPosition(successCallback,
                                             errorCallback,
                                             {maximumAge:600000});

    function successCallback(position) {
      // By using the 'maximumAge' option above, the position
      // object is guaranteed to be at most 10 minutes old.
    }

    function errorCallback(error) {
      // Update a div element with error.message.
    }

   

Forcing the user agent to return a fresh cached position.

    // Request a position. We only accept cached positions whose age is not
    // greater than 10 minutes. If the user agent does not have a fresh
    // enough cached position object, it will immediately invoke the error
    // callback.
    navigator.geolocation.getCurrentPosition(successCallback,
                                             errorCallback,
                                             {maximumAge:600000, timeout:0});

    function successCallback(position) {
      // By using the 'maximumAge' option above, the position
      // object is guaranteed to be at most 10 minutes old.
      // By using a 'timeout' of 0 milliseconds, if there is
      // no suitable cached position available, the user agent
      // will asynchronously invoke the error callback with code
      // TIMEOUT and will not initiate a new position
      // acquisition process.
    }

    function errorCallback(error) {
      switch(error.code) {
        case error.TIMEOUT:
          // Quick fallback when no suitable cached position exists.
          doFallback();
          // Acquire a new position object.
          navigator.geolocation.getCurrentPosition(successCallback, errorCallback);
          break;
        case ... // treat the other error cases.
      };
    }

    function doFallback() {
      // No fresh enough cached position available.
      // Fallback to a default position.
    }
   

Forcing the user agent to return any available cached position.

    // Request a position. We only accept cached positions, no matter what
    // their age is. If the user agent does not have a cached position at
    // all, it will immediately invoke the error callback.
    navigator.geolocation.getCurrentPosition(successCallback,
                                             errorCallback,
                                             {maximumAge:Infinity, timeout:0});

    function successCallback(position) {
      // By setting the 'maximumAge' to Infinity, the position
      // object is guaranteed to be a cached one.
      // By using a 'timeout' of 0 milliseconds, if there is
      // no cached position available at all, the user agent
      // will immediately invoke the error callback with code
      // TIMEOUT and will not initiate a new position
      // acquisition process.
      if (position.timestamp < freshness_threshold &&
          position.coords.accuracy < accuracy_threshold) {
        // The position is relatively fresh and accurate.
      } else {
        // The position is quite old and/or inaccurate.
      }
    }

    function errorCallback(error) {
      switch(error.code) {
        case error.TIMEOUT:
          // Quick fallback when no cached position exists at all.
          doFallback();
          // Acquire a new position object.
          navigator.geolocation.getCurrentPosition(successCallback, errorCallback);
          break;
        case ... // treat the other error cases.
      };
    }

    function doFallback() {
      // No cached position available at all.
      // Fallback to a default position.
    }
   
IP address based Geolocation

So now the obvious question is what about those browsers that don’t support geolocation at all? The answer is that we must use an external geolocation service. These services do their best to map the IP address of a device to geographic locations using large geolocation databases. Usually they do a good job, but at times they may suffer from the following issues:

    IP addresses may be associated with the wrong location (e.g., the wrong postal code, city or suburb within a metropolitan area).
    Addresses may be associated only with a very broad geographic area (e.g., a large city, or a state). Many addresses are associated only with a city, not with a street address or latitude/longitude location.
    Some addresses will not appear in the database and therefore cannot be mapped (often true for IP numbers not commonly used on the Internet).

The important thing to remember is that when an external geolocation service is used, the accuracy is not as good as geolocation native to the device, and in some scenarios it may be completely off. Additionally, such services do not provide any information regarding the altitude, speed or heading of the device. Regardless, when GPS or triangulation are not available, they are a good fallback.

YQL Geo Library is a dedicated and lightweight library that lets you perform geolocation using good old Yahoo services. This library can do other things which I’ll leave to you to discover, but for now let’s look at how we should modify our code to successfully detect the location on both supporting and non-supporting browsers:
view plaincopy to clipboardprint?

    <!DOCTYPE html>
    <html>
     
      <head>
      <script src="js/jquery-1.4.2.min.js"></script>
      <script src="js/yqlgeo.js"></script>
      <script>
        jQuery(window).ready(function(){
            jQuery("#btnInit").click(initiate_geolocation);
        })
     
        function initiate_geolocation() {
            if (navigator.geolocation)
            {
                navigator.geolocation.getCurrentPosition(handle_geolocation_query, handle_errors);
            }
            else
            {
                yqlgeo.get('visitor', normalize_yql_response);
            }
        }
     
        function handle_errors(error)
        {
            switch(error.code)
            {
                case error.PERMISSION_DENIED: alert("user did not share geolocation data");
                break;
     
                case error.POSITION_UNAVAILABLE: alert("could not detect current position");
                break;
     
                case error.TIMEOUT: alert("retrieving position timedout");
                break;
     
                default: alert("unknown error");
                break;
            }
        }
     
        function normalize_yql_response(response)
        {
            if (response.error)
            {
                var error = { code : 0 };
                handle_error(error);
                return;
            }
     
            var position = {
                coords :
                {
                    latitude: response.place.centroid.latitude,
                    longitude: response.place.centroid.longitude
                },
                address :
                {
                    city: response.place.locality2.content,
                    region: response.place.admin1.content,
                    country: response.place.country.content
                }
            };
     
            handle_geolocation_query(position);
        }
     
        function handle_geolocation_query(position){
            alert('Lat: ' + position.coords.latitude + ' ' +
                  'Lon: ' + position.coords.longitude);
            }
        </script>
     
      </head>
      <body>
        <div>
          <button id="btnInit" >Find my location</button>
        </div>
     
      </body>
    </html>