FirstData Payment Gateway integration

This is a sample code for firtdata integration method using web serverice.

How to get the page load time using PHP

Posted by: ashu

Tagged in: Open Source

ashu

To get the page load time for a block of code you can do the following.

1. Add the code below before the block of code:
<?php
$starttime = microtime();
$startarray = explode(" ", $starttime);
$starttime = $startarray[1] + $startarray[0];
?>
Microtime is a function that returns a value giving the current time in seconds and milliseconds from the UNIX Epoch (internationally set as 0:00:00 January 1, 1970 GMT).   Explode then splits this value into its two component parts (seconds and milliseconds), and then inserts both values separately into a variable.

2. Insert the following code after the block of code:

<?php
$endtime = microtime();
$endarray = explode(" ", $endtime);
$endtime = $endarray[1] + $endarray[0];
$totaltime = $endtime – $starttime;
$totaltime = round($totaltime,5);
echo "This page loaded in $totaltime seconds.";
?>

This will show you the exact load time for a particular block of HTML code.

 


Wordpress site speed optimization

Posted by: ashu

Tagged in: Open Source

ashu

Wordpress is very popular cms that every one want to use. But the some sites in wordpress has very lower performance due to its speed(Time to load in the
browser). Whenever we create any site we want that the site should load very fast with less time no matter it is in wordpress/joomla/ or any other opens CMS
or your own custom CMS.

Here are the few checklist that everyone should follow:

1. Reduce the number of request in your site. This can be done by using only one css file instead of many different css files. Similarly is the case with .js
 files. In this way we can minimize the number of request.

2. Reduce the load time. This can be done if we compress the file or even gzip files(If your server support this feature). Secont you can mimize the image
size in bytes. FOr this there are many image optimizer available for free. One I prefer is "http://www.imageoptimizer.net/Pages/Home.aspx" which reduce image
size. The second is "http://refresh-sf.com/yui/" which reduces the css size.

3. There are some plugin available in the wordpress which also helps to increase the site speed. Some of which are "db-cache", "wp css", "hypercache" and
"Supercache".

4. If you are using some custome SQL queries you can also check the time of execution of each query so that if it can be modified you should modify them as
well. Lets take an example which I have taken from my wordpress script.

$x_column_query['Latest News'] = "SELECT DISTINCT posts.* FROM $wpdb->posts `posts`, $wpdb->term_relationships `relationships`, $wpdb->postmeta `meta` WHERE
`posts`.`ID` = `relationships`.`object_id` AND `relationships`.`term_taxonomy_id` IN($x_latest_cat_ids) AND !(`posts`.`ID` IN ($bpids)) AND
`posts`.`post_status` = 'publish' AND `posts`.`post_type` = 'post' $meta_condition ORDER BY `posts`.`post_date` DESC LIMIT $x_extended_limit";


I have replace the above script with the script as below:

$x_column_query['Latest News'] = "SELECT posts.* FROM $wpdb->posts `posts` WHERE `posts`.`ID` IN (SELECT `object_id` FROM $wpdb->term_relationships WHERE
term_taxonomy_id IN(".$x_latest_cat_ids.")) AND `posts`.`ID` IN (SELECT `post_id` FROM $wpdb->postmeta `meta` WHERE ".$meta_condition_one." ) AND
!(`posts`.`ID` IN (".$bpids.")) AND `posts`.`post_status` = 'publish' AND `posts`.`post_type` = 'post'   ORDER BY posts.`post_date` DESC LIMIT
".$x_extended_limit;

And I got very positive result in my query execution time. The only difference is that I have used sub-queries instead of one single query.

5. To check you site speed you can use FireFoz "Yslow plugin" or "Firebug" which gives you detail where the site is slow which part needs optimization to get better speed.


In continution to my wordpress blog post today I want to share my thoughts related to my experience while exploring the functionality of my plugin. I want to
develop the functionality to delete/trash posts similar to the default wordpress functions does. But when I created my own function to trash post it also
deleted my posts from trash, so I come to realize that when we add action to trash the post it also calls the wordpress trash function that's why on trashing
my post from my own custom function it then call trash fucntion (the default wordpresss function) which completely delete the post as it is already marked
"trashed".

Also I was not sure what add_action I have to use to call the trash/delete post. After some research I found what I actually need to do in my plugin. The
code is given below which solves my problem. Hope it will be beneficial to other users.

add_action('trash_post', 'trash_rows_setup'); //This is used to trash the post

add_action('delete_post', 'delete_rows_setup'); //this is used to delete the post


function trash_rows_setup()
{
    global $wpdb;
    if(is_array($_GET['post']))
    {
                foreach($_GET['post'] as $key =>$value)
        {
            $varPostID = $value;
            $id = $wpdb->get_var("SELECT `ID` FROM $wpdb->posts WHERE `plex_post_type` = 'duplicated" . $varPostID . "'");
            if(trim($id) != '')
            {
                $wpdb->query("UPDATE $wpdb->posts SET `post_status`='trash' WHERE `ID` = '".$id."'");
            }
        }
    }
    else
    {
        $id = $wpdb->get_var("SELECT `ID` FROM $wpdb->posts WHERE `plex_post_type` = 'duplicated" . $_GET['post'] . "'");
        if(trim($id) != '')
        {
            $wpdb->query("UPDATE $wpdb->posts SET `post_status`='trash' WHERE `ID` = '".$id."'");
        }     }
        return true;
}

function delete_rows_setup()
{
    global $wpdb;
    if(is_array($_GET['post']))
    {
        foreach($_GET['post'] as $key =>$value)
        {
            $varPostID = $value;
            $id = $wpdb->get_var("SELECT `ID` FROM $wpdb->posts WHERE `plex_post_type` = 'duplicated" . $varPostID . "'");
            if(trim($id) != '')
            {
                $wpdb->query("DELETE FROM $wpdb->posts WHERE `ID` = '".$id."'");
                $wpdb->query("DELETE FROM $wpdb->postmeta WHERE `post_id` = '".$id."'");
                $wpdb->query("DELETE FROM $wpdb->comments WHERE `comment_post_ID` = '".$id."'");
                            }
        }
    }
    else
    {
        $id = $wpdb->get_var("SELECT `ID` FROM $wpdb->posts WHERE `plex_post_type` = 'duplicated" . $_GET['post'] . "'");
        if(trim($id) != '')
        {
            $wpdb->query("DELETE FROM $wpdb->posts WHERE `ID` = '".$id."'");
            $wpdb->query("DELETE FROM $wpdb->postmeta WHERE `post_id` = '".$id."'");
            $wpdb->query("DELETE FROM $wpdb->comments WHERE `comment_post_ID` = '".$id."'");
        }     }
    return true;
}


Change HTML style via simple JS

Posted by: ashu

Tagged in: Open Source

ashu

Hi
Sometimes we want to change the page css either on any event let say "onclick" or "onchange". I have created one simple demo script of js that we can use to do so. Below is the sample code.&nbsp; I have called my script on pageload but you can call it in any of the event as you require.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>

<script type="text/javascript"><!--

function doSomething() {
    var aryClassElements = getElementsByClassName( 'testing', document.body );
    for ( var i = 0; i < aryClassElements.length; i++ ) {
       aryClassElements[i].style.fontWeight = 'bold';
       aryClassElements[i].style.color = '#FF0000';
       //aryClassElements[i].style.display = 'none'; //NOTE this will hide your content.
    }
}

function getElementsByClassName( strClassName, obj ) {
    var ar = arguments[2] || new Array();
    var re = new RegExp("b" + strClassName + "b", "g");

    if ( re.test(obj.className) ) {
        ar.push( obj );
    }
    for ( var i = 0; i < obj.childNodes.length; i++ )
        getElementsByClassName( strClassName, obj.childNodes[i], ar );
        return ar;
}

//--></script>
</head>
<body">
<div class="testing">
This is testing
</div>
<div class="testing123">
This is wresting
</div>
</body>
<script type="text/javascript">
doSomething();
</script>
</html>


Whenever you transfered a site from one server to another you have to wait until your domain get transfered to the new location. The server provider give you some temporary url to browse the site. But if your site depends on .htaccess files then you can't test the site functionality in the new server untill the domain get completely transfered. Sometime it takes long time more than a day and if you need to check your site funtionality in new server location then the alternative for this is to add the new site IP address to your windows/system32/drivers/etc/hosts

say for example

When I ping my site in cmd prompt with the command

"ping opensourceuniverse.com -t"

it gives the IP 68.172.11.112  which was my old serever IP to make it points to correct IP 68.175.11.122(new server location) I have added the new server IP at the bottom of the file in the following way ### below two lines you need to add in your file ###
68.175.11.122  www.mysite.com
68.175.11.122  mysite.com


File Location: "windows/system32/drivers/etc/hosts" I ping again, now this time it shows me the new server IP that is 68.175.11.122


Few days back I am facing a problem to convert a time zone from "America/Chicago" (which is my server default time zone) to Pacific Standard Time(PST). I did some googling and found that to make the time zone in PST we need to set the time zone to "America/Los_Angeles" by using the function date_default_timezone_set() but when I do this and do some database insertion to my site from front end it shows different result and when I tries to show the time zone along with my date it does not shows me exact PST time.

After some time I realize that the PHP server timezone and mysql server time zone are different and if we have to store the date in our database I should use PHP date function (that is date('Y-m-d H:i:s')) in my insert SQL query instead of MySql now() function.


To do this I modified my php.ini file instead of using "date_default_timezone_set()" function in every PHP page. The code that I have used in my php.ini file is as below:

date.timezone = "America/Los_Angeles";

and then I uploaded my php.ini file to the server root directory.

NOTE:This is the new feature that I have seen intead of modifying the server actual php.ini file I simply add my own php.ini file for the services to be  enable on the server. I think not all server support such functionality, but you can try it.


Second I replace all my date query from now() to PHP's date('Y-m-d H:i:s'). This is the solution which works for me.

Q. How to convert local time in php to GTM time?
A.
Similar to date() function which shows server local time there is another function named "gmdate()" which is used convert your server local time to GMT. The code is very simple see below.
echo 'Current Local Time : '.  date("H:i:s d-M-y"); echo '
GMT Time :   '.  gmdate("H:i:s d-M-y"); ?>

Q. How to convert a local Unix timestamp to GMT?
A.
This can be achieved by using the function gmtdate(). See the code below:

if ( ! function_exists('local_to_gmt'))
{
 function local_to_gmt($time = '')
 {
 if ($time == '')
 $time = time();
 return mktime( gmdate("H", $time), gmdate("i", $time), gmdate("s", $time), gmdate("m", $time), gmdate("d", $time), gmdate("Y", $time));
 }
}

?>

Q. From where I should compare my time has been converted to GMT or not?
A.
There are so many sites in available for comparison but I like the URL: http://wwp.greenwichmeantime.com/info/current-time/ which shows the GMT time.


Hello I want share something to all the developers who really want to integrate FirstData(formerly know as Link Point) webservice(which allows you to make payment via payment gateway but without going outside of your site) as there payment gateway.

I have search a lot for integration on it as I was novice to FirstData and I really want to integrate it in my sites http://www.nobcche.org/.

Before going live you need to create test account The test account can be created from the following URL: http://www.firstdata.com/gg/apply_test_account.htm. Once you register to the test account you will receive a tar.gz file of your certificate. This will be a list of files as below:
1. WS1909487962._.1.auth.txt
2. WS1909487962._.1.key
3. WS1909487962._.1.key.pw.txt
4. WS1909487962._.1.ks
5. WS1909487962._.1.ks.pw.txt
6. WS1909487962._.1.p12
7. WS1909487962._.1.p12.pw.txt
8. WS1909487962._.1.pem

The number 1909487962 would be different for your test store.

Then the next step is to create a script which will use this certificate and do some test payments.
Note: If you would try to execute the FirstData script it will not work as it require live server testing environment.

I have used PHP script with curl and the sample script is as below:

//php script sample code first data integration starts here


<?php
/*** code for new php file with named firstdata_cfg.php**/
//This file can be placed inside include folder /**
Config file for FirstData Payment Gateway
**/
define("FDAPI_URL","https://ws.merchanttest.firstdataglobalgateway.com/fdggwsapi/services/order.wsdl");// URL for test store test payment.
//############## OR ###############
define("FDAPI_URL", "https://ws.firstdataglobalgateway.com/fdggwsapi/services/order.wsdl");// URL for live store for actual payment.

define("FD_USERPWD", "WSXXXXXXXXX._.1:XXXXXXXX");//Replace WSXXXXXXXXX._.1:XXXXXXXX with actual username:password
define("FD_SSLCERT", "/home/105364/domains/yoursite.org/html/certificate/WSXXXXXXXX._.1.pem"); //replace WSXXXXXXXX._.1.pem with actual pem file define("FD_SSLKEY", "/home/105364/domains/yoursite.org/html/certificate/WSXXXXXXXXX._.1.key"); //replace WSXXXXXXXXX._.1.key with actual key file.
define("FD_SSLKEYPASSWD", "ckp_1284657964"); //Replace "ckp_1284657964" key with your store key . You can download all these from your store after loged into your account


/**** function to get Transacion ID ******/
function getFirstDataTransactionID($result)
{
    $varPos = strpos($result, '<fdggwsapi:TransactionID>');
    $varPos2 = strpos($result, '</fdggwsapi:TransactionID>');
    $varPos = $varPos + 25;
    $varLen = $varPos2 - $varPos;
    return substr($result,$varPos,$varLen);
}
/***** function to get Transaction Result ****/
/****** Return Type APPROVED /  FAILED    ****/
function getTransactionResult($result)
{
    $varPos = strpos($result, '<fdggwsapi:TransactionResult>');
    $varPos2 = strpos($result, '</fdggwsapi:TransactionResult>');
    if($varPos !== false)
    {
        $varPos = $varPos + 29;
        $varLen = $varPos2 - $varPos;
        return substr($result,$varPos,$varLen);
    }
    else
    {
        return 'FAILED';
    }
        }

/*** function to get the orderID ****/
/***###################
 This function is used in case of recurring billing as in case of  recurrring billing we get OrderID instead of Transaction ID
 #######################
***/
function getRecurrringOrderID($result)
{
    $varPos = strpos($result, '<fdggwsapi:OrderId>');
    $varPos2 = strpos($result, '</fdggwsapi:OrderId>');
    if($varPos !== false)
    {
        $varPos = $varPos + 19;
        $varLen = $varPos2 - $varPos;
        return substr($result,$varPos,$varLen);
    }
    else
    {
        return '';
    }
}
//end firstdata_cfg.php code
?>
<?php
// This is the code that you have to use to test your first data web service transactions.
// Set the fdggwsapi request - XML String-we have broken it down for viewing purposes
$body = "<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"><SOAP-ENV:Header/>

<SOAP-ENV:Body>
<fdggwsapi:FDGGWSApiOrderRequest xmlns:v1="http://secure.linkpt.net/fdggwsapi/schemas_us/v1" xmlns:v3="http://secure.linkpt.net/fdggwsapi/schemas_us/a1" xmlns:fdggwsapi="http://secure.linkpt.net/fdggwsapi/schemas_us/fdggwsapi">

<v1:Transaction>

<v1:CreditCardTxType>
<v1:Type>sale</v1:Type>
</v1:CreditCardTxType>

<v1:CreditCardData>
<v1:CardNumber>4012000033330026</v1:CardNumber>
<v1:ExpMonth>12</v1:ExpMonth>
<v1:ExpYear>12</v1:ExpYear>
</v1:CreditCardData>

<v1:Payment>
<v1:ChargeTotal>120.00</v1:ChargeTotal>
</v1:Payment>

</v1:Transaction>

</fdggwsapi:FDGGWSApiOrderRequest>

</SOAP-ENV:Body>
</SOAP-ENV:Envelope>";




// initializing cURL with the IPG API URL (OLD URL):
$ch = curl_init(FDAPI_URL);



// setting the request type to POST:
curl_setopt($ch, CURLOPT_POST, 1);

// setting the content type:
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: text/xml"));

// setting the authorization method to BASIC:
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);

// supplying your credentials:
curl_setopt($ch, CURLOPT_USERPWD, FD_USERPWD);

// filling the request body with your SOAP message:
curl_setopt($ch, CURLOPT_POSTFIELDS, $body);

// telling cURL to verify the server certificate:
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);

// setting the path where cURL can find the certificate to verify the
// Info directly from the API Manual Below:
 curl_setopt($ch, CURLOPT_SSLCERT, FD_SSLCERT);
 curl_setopt($ch, CURLOPT_SSLKEY, FD_SSLKEY);
 curl_setopt($ch, CURLOPT_SSLKEYPASSWD, FD_SSLKEYPASSWD);
// telling cURL to return the HTTP response body as operation result
// value when calling curl_exec:
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

// calling cURL and saving the SOAP response message in a variable which
// contains a string like "<SOAP-ENV:Envelope ...>...</SOAP-ENV:Envelope>":
$result = curl_exec($ch);  //if the curl executed successfully then it will return the <saop> XML response with getTransactionResult

if (getTransactionResult($result) == 'FAILED') {
        s$res = 2;
}
else{
      $res = 1 ;
}
curl_close($ch);
# end code
print("The response is $result");
if($res == 1)
{
   echo 'success';
}
else
{
  echo 'fail';
}
?>
//depending on the response we will do appropriate action as we need like database update or send email to customer etc.

//depending on the response we will do appropriate action as we need like database update or send email to customer etc.

//php script sample code ends here

This is my second post related to FirstData integration. Here I will discuss about the recurring billing and give you sample script of FirstData recurring billing integration in PHP .

If you want to learn from start please read my first article on FirstData. Before I show you the script I will make you about recurring billing.

Recurring billing is the process in which payment is deducted periodically from your account for n number of time where "n" can be "n" Year/Month/quarter etc. This type of billing is basically required for the people who sell services for which they want to deduct money every month/year depending on the subscription.

Recurring is an agreement between two parties one is payer and other is receiver. FirstData also provide such type of recurring billing process the sample script for this would be like as below:

//sample script starts here

<?php
/*** code for new php file with named firstdata_cfg.php**/
//This file can be placed inside inluce folder /**
Config file for FirstData Payment Gateway
**/
define("FDAPI_URL","https://ws.merchanttest.firstdataglobalgateway.com/fdggwsapi/services/order.wsdl");// URL for test store test payment.
//############## OR ###############
define("FDAPI_URL", "https://ws.firstdataglobalgateway.com/fdggwsapi/services/order.wsdl");// URL for live store for actual payment.

define("FD_USERPWD", "WSXXXXXXXXX._.1:XXXXXXXX");//Replace WSXXXXXXXXX._.1:XXXXXXXX with actual username:password
define("FD_SSLCERT", "/home/105364/domains/yoursite.org/html/certificate/WSXXXXXXXX._.1.pem"); //replace WSXXXXXXXX._.1.pem with actual pem file define("FD_SSLKEY", "/home/105364/domains/yoursite.org/html/certificate/WSXXXXXXXXX._.1.key"); //replace WSXXXXXXXXX._.1.key with actual key file.
define("FD_SSLKEYPASSWD", "ckp_1284657964"); //Replace "ckp_1284657964" key with your store key . You can download all these from your store after loged into your account


/**** function to get Transacion ID ******/
function getFirstDataTransactionID($result)
{
    $varPos = strpos($result, '<fdggwsapi:TransactionID>');
    $varPos2 = strpos($result, '</fdggwsapi:TransactionID>');
    $varPos = $varPos + 25;
    $varLen = $varPos2 - $varPos;
    return substr($result,$varPos,$varLen);
}
/***** function to get Transaction Result ****/
/****** Return Type APPROVED /  FAILED    ****/
function getTransactionResult($result)
{
    $varPos = strpos($result, '<fdggwsapi:TransactionResult>');
    $varPos2 = strpos($result, '</fdggwsapi:TransactionResult>');
    if($varPos !== false)
    {
        $varPos = $varPos + 29;
        $varLen = $varPos2 - $varPos;
        return substr($result,$varPos,$varLen);
    }
    else
    {
        return 'FAILED';
    }
        }

/*** function to get the orderID ****/
/***###################
 This function is used in case of recurring billing as in case of  recurrring billing we get OrderID instead of Transaction ID
 #######################
***/
function getRecurrringOrderID($result)
{
    $varPos = strpos($result, '<fdggwsapi:OrderId>');
    $varPos2 = strpos($result, '</fdggwsapi:OrderId>');
    if($varPos !== false)
    {
        $varPos = $varPos + 19;
        $varLen = $varPos2 - $varPos;
        return substr($result,$varPos,$varLen);
    }
    else
    {
        return '';
    }
}
//end firstdata_cfg.php code
?>


<?php
// set the fdggwsapi request - XML String-we have broken it down for viewing purposes
$body = "<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"><SOAP-ENV:Header/>

<SOAP-ENV:Body>
<fdggwsapi:FDGGWSApiActionRequest xmlns:v1="http://secure.linkpt.net/fdggwsapi/schemas_us/v1" xmlns:a1="http://secure.linkpt.net/fdggwsapi/schemas_us/a1" xmlns:fdggwsapi="http://secure.linkpt.net/fdggwsapi/schemas_us/fdggwsapi">

<a1:Action>

<a1:RecurringPayment>

<a1:RecurringPaymentInformation>
<a1:RecurringStartDate>20110616</a1:RecurringStartDate>
<a1:InstallmentCount>12</a1:InstallmentCount>
<a1:InstallmentFrequency>1</a1:InstallmentFrequency>
<a1:InstallmentPeriod>month</a1:InstallmentPeriod>
<a1:MaximumFailures>1</a1:MaximumFailures>
</a1:RecurringPaymentInformation>

<a1:TransactionDataType>
<a1:CreditCardData>
<v1:CardNumber>4012000033330026</v1:CardNumber>
<v1:ExpMonth>12</v1:ExpMonth>
<v1:ExpYear>12</v1:ExpYear>
</a1:CreditCardData>
</a1:TransactionDataType>

<v1:Payment>
<v1:ChargeTotal>10.00</v1:ChargeTotal>
<v1:SubTotal>10.00</v1:SubTotal>
</v1:Payment>

<v1:Shipping>
<v1:Address1>123 Test Street</v1:Address1>
<v1:Carrier>3</v1:Carrier>
<v1:City>Test</v1:City>
<v1:Country>United States</v1:Country>
<v1:Items>1</v1:Items>
<v1:State>Maryland</v1:State>
<v1:Total>1</v1:Total>
<v1:Weight>5</v1:Weight>
</v1:Shipping>

<v1:Billing>
<v1:Address1>234 Main Ave.</v1:Address1>
<v1:City>Brooklyn</v1:City>
<v1:Country>United States</v1:Country>
<v1:State>Maryland</v1:State>
<v1:Zip>21740</v1:Zip>
</v1:Billing>

<v1:TransactionDetails>
<v1:InvoiceNumber>12345</v1:InvoiceNumber>
<v1:TransactionOrigin>ECI</v1:TransactionOrigin>
<v1:UserID>WSAPI_Recurring</v1:UserID>
</v1:TransactionDetails>

<a1:Function>install</a1:Function>

</a1:RecurringPayment>

</a1:Action>

</fdggwsapi:FDGGWSApiActionRequest>

</SOAP-ENV:Body>
</SOAP-ENV:Envelope>";

// initializing cURL with the IPG API URL:
// $ch = curl_init("https://www.staging.linkpointcentral.com/fdggwsapi/services/order.wsdl");

// initializing cURL with the IPG API URL (OLD URL):
$ch = curl_init(FDAPI_URL);



// setting the request type to POST:
curl_setopt($ch, CURLOPT_POST, 1);

// setting the content type:
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: text/xml"));

// setting the authorization method to BASIC:
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);

// supplying your credentials:
curl_setopt($ch, CURLOPT_USERPWD, FD_USERPWD);

// filling the request body with your SOAP message:
curl_setopt($ch, CURLOPT_POSTFIELDS, $body);

// telling cURL to verify the server certificate:
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);

// setting the path where cURL can find the certificate to verify the
// Info directly from the API Manual Below:
 curl_setopt($ch, CURLOPT_SSLCERT, FD_SSLCERT);
 curl_setopt($ch, CURLOPT_SSLKEY, FD_SSLKEY);
 curl_setopt($ch, CURLOPT_SSLKEYPASSWD, FD_SSLKEYPASSWD);
// telling cURL to return the HTTP response body as operation result
// value when calling curl_exec:
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

// calling cURL and saving the SOAP response message in a variable which
// contains a string like "<SOAP-ENV:Envelope ...>...</SOAP-ENV:Envelope>":
$result = curl_exec($ch);  //if the curl executed successfully then it will return the <saop> XML response with getTransactionResult

if (getTransactionResult($result) == 'FAILED') {
        s$res = 2;
}
else{
      $res = 1 ;
   $varRecurringOrderID = getRecurrringOrderID($result);
}
curl_close($ch);
# end code
print("The response is $result");
if($res == 1)
{
   echo 'success';
}
else
{
  echo 'fail';
}
?>
 

//sample script ends here.

 //depending on the value return user may take appropriate action.


Free - Magazines

Like our work? Support Us

Chat

Please login to be able to chat.

Feed Subscription

Enter your email address:

Delivered by FeedBurner

Feedback Form