Showing posts with label php problem solutions. Show all posts
Showing posts with label php problem solutions. Show all posts

Friday 19 December 2014

Wordpress title repeated two times in browser header [SOLVED]

Wordpress title repeated two times in browser header [SOLVED]

I add the post from wordpress admin section (http://www.example.com/wp-admin/), 
After publishing the post it start displaying in website.

In Post detail page, Every information like post title, post description and post date etc is correct except meta title.


Issue: Meta title have post name + website name + | website name.

Here meta title have website name two times at then end of page title.


Solution: 
  • Login into admin section.
  • Go to Plugins section. ( or use link: http://example.com/wp-admin/plugins.php).
  • Search for "All in One SEO Pack".
  • Click on deactivate, Now "All in One SEO Pack" is deactivated successfully.
  • Go to website and refresh the Frontend page, Now you will see two times website name in title is FIXED.

Thursday 18 December 2014

How can I prevent SQL-injection in PHP [SOLVED]

How can I prevent SQL-injection in PHP [SOLVED]

Following are different 3 ways to prevent from SQL Injection.
1. Using PHP inbuilt Functions.
$name = mysql_real_escape_string($_POST["name"]);
mysql_query("INSERT INTO users VALUES($name)");


2. Use MySqli instead of MySQL. MySqli is far better than MySql because is object oriented MySql.
$stmt = $dbConnection->prepare('INSERT INTO users VALUES(?)');
$name=$_POST["name"];
$stmt->bind_param('s', $name);
$stmt->execute();


3. Using PDO
$stmt = $conn->prepare("INSERT INTO users VALUES(:name)");
$stmt->bindValue(':name', $_POST["name"]);
$stmt->execute();



Wednesday 10 December 2014

Htaccess RewriteRule Flags by Code Example

Htaccess RewriteRule Flags by Code Example

A RewriteRule can be modified by flag. Flags are included in square brackets at the end of the rule. We can also and multiple flags are separated by commas.

For Example:
[Flag1] //for 1 flag
[Flag1,Flag2] //for 2 flags
[Flag1,Flag2,Flag3 ] //for multiple flags

Following are most commonly htaccess flag:
1. htacces B(escape backreferences) Flag
Escape non-alphanumeric characters before applying the transformation


2. htaccess C(Chain) Flag
First htaccess Rule will be applied to next htaccess rule. Means if the rule matches, then control moves on to the next rule.


3. htaccess CO(Cookie) Flag
you can set a cookie when a particular RewriteRule matches
RewriteRule ^search/(.*)$ /search.php?term=$1[CO=variable:variableValue]
Set the variable=variableValue in cookie


4. htaccess DPI(discardpath) Flag
PATH_INFO portion of the rewritten URI to be discarded.


5. htaccess E (env) Flag
You can set the value of an environment variable. For example:
RewriteRule ^search/(.*)$ /search.php?term=$1[E=variable:variableValue]
Set the variable=variableValue in environment variable.


6. htaccess END Flag
This flag terminates not only the current round of rewrite but also prevents any subsequent rewrite from occurring in per-directory.


7. htaccess F(forbidden) Flag
This flag causes the server to return a 403 Forbidden status code to the client. For Example
RewriteRule \.exe - [F]
If anyone trying to open any file with .exe, he will get Forbidden error.



8. htaccess G(gone) Flag
This flag causes the server to return a 410 Gone status with the response code to the client. For Example
RewriteRule old_url - [G]
If old_url called, 410 gone status will be shown in the browser.



9. htaccess H(handler) Flag
This flag causes Forces the request to be handled with the specified handler. For example
RewriteRule !\. - [H=application/x-httpd-php]
Force all files without a file extension to be parsed by the php handler.



10. htaccess L(Last) Flag
This flag causes to stop processing the rule set, if the rule matches, no further rules will be processed.
RewriteRule ^(.*) /index.php?req=$1 [L]



11. htaccess N(Next) Flag
This flag causes ruleset to start over again from the top.
RewriteRule ^(.*) /index.php?req=$1 [N]


12. htaccess NC(nocase) Flag
This flag causes RewriteRule to be matched in a case-insensitive manner.
RewriteRule ^(.*) /index.php?req=$1 [NC]



13. htaccess NE(noescape) Flag
By default, special characters, such as & and ?, are converted to their hexcode equivalent. By Using NE flag prevents we can prevent this.


14. htaccess NS(nosubreq) Flag
This flag causes prevents the rule from being used on subrequests.



15. htaccess P(proxy) Flag
This flag causes the request to be handled by proxy request. For example, if you wanted all image requests to be handled by a image server
RewriteRule /(.*)\.(jpg|gif|png)$ http://images.mysite.com/$1.$2 [P]
Extension having jpg, gif, and png will be handled by images.mysite.com



16. htaccess PT(passthrough) Flag
This flag causes the result of the RewriteRule to be passed back through URL mapping.



17. htaccess QSA(qsappend) Flag
When the replacement URI contains a query string, the default behavior of RewriteRule is to discard the existing query string, and replace it with the newly generated one. Using the [QSA] flag causes the query strings to be combined.

18. htaccess S(Skip) flag
htaccess S flag is used to skip rules that you don't want to run. The syntax of the skip flag is [S=N], where N means the number of rules to skip. For Example
# Does the file exist?
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# Create an if-then-else construct by skipping 3 lines if we meant to go to the "else" stanza.
RewriteRule .? - [S=3]

# IF the file exists, then:
    RewriteRule (.*\.gif) images.php?$1
    RewriteRule (.*\.html) docs.php?$1
    # Skip past the "else" stanza.
    RewriteRule .? - [S=1]
# ELSE...
    RewriteRule (.*) 404.php?file=$1
# END


19. htaccess T(type) flag
htaccess T flag cause sets the MIME type with which the resulting response will be sent. For Example
RewriteRule IMG - [T=image/jpg]


20. htaccess R(Redirect) flag
htacces R flag causes a HTTP redirect to be issued to the browser. Normally Redirect does not occur but if we use R Flag, then redirection will be happened to the browser. For Example
RewriteRule (.*\.gif) images.php?$1 [R]

Tuesday 9 December 2014

Multiple column ordering in Zend Framework

Multiple column ordering in Zend Framework

There are different ways to multiple column ordering in Zend. Following are two different ways to do multiple column ordering in Zend Framework. you can use either First way OR Second way.

First Way
->order(array('first_name asc','last_name desc'));

Second Way
->order('first_name asc')->order('last_name desc')


In above code snippet, First It will sort by first_name in ascending order then sort by last_name in descending order. you can also add more than two column in ordering.


Multiple column ordering in MySQL
select * from users order by first_name asc, last_name desc
First It will sort by first_name in ascending order then sort by last_name in descending order.


Monday 1 December 2014

Strtolower - Returns string with all alphabetic characters converted to lowercase

string strtolower ( string $str )
Make a string lowercase
Returns string with all alphabetic characters converted to lowercase.

<?php
$str 
"Mary Had A Little Lamb and She LOVED It So";$str strtolower($str);
echo 
$str// Prints mary had a little lamb and she loved it so?>


14.-Curso PHP-MySQL. Formatear, cortar y unir strings.

Friday 7 November 2014

Enabling the openssl in Wamp-Xampp

Enabling the openssl in Wamp-Xampp

If you have any of following issue, then you are on right page.

  • How to enable SSL
  • Enabling the openssl in WampServer/xampp
  • How to enable openssl support in XAMPP
  • Unable to Connect to ssl
  • Fatal error: Uncaught exception Zend_Http_Client_Adapter_Exception


Solution: enable the extension php_openssl from PHP Extension

Option 1 (If using Wamp-Server)

Enabling the openssl in Wamp










and Restart your wamp Server


Option 2 (Direct change in php.ini File)
You can do direct change
Just comment your php_openssl.dll in your php.ini file.
Search
;extension=php_openssl.dll
Replace with
extension=php_openssl.dll
Here we have just removed the semicolon.



Saturday 25 October 2014

How do I get a YouTube video thumbnail from the YouTube

How do I get a YouTube video thumbnail from the YouTube




How to get youtube video thumbnail
1. First Get the Video URL (Video URL is like https://www.youtube.com/v/J0Qu6eyyr4c)
2. Get the youtube video Id from Video URL (Video id is like J0Qu6eyyr4c)
3. Now video thumbnail is ready.


Small Video Image
How do I get a YouTube video thumbnail from the YouTube
http://img.youtube.com/vi/J0Qu6eyyr4c/default.jpg 



Bigger Video Thumbnail
How do I get a YouTube video thumbnail from the YouTube
http://img.youtube.com/vi/J0Qu6eyyr4c/mqdefault.jpg



Large Video Thumbnail
How do I get a YouTube video thumbnail from the YouTube
http://img.youtube.com/vi/J0Qu6eyyr4c/hqdefault.jpg



How to find day of week in php?

How to find day of week in php?

$timestamp = strtotime(date('2014-10-25'));
$dw = date( "w", $timestamp);// $dw will be 0 (for Sunday) through 6 (for Saturday) 
$days = array('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday');
echo "today is ".$days[$dw];

Output
today is Saturday


Friday 10 October 2014

Download Videos from Amazon S3 - PHP

Download Videos from Amazon S3 - PHP

            $newFileName = "download_filename.mp4";
            header('Content-Type: video/mp4');
            header('Content-Disposition: attachment; filename="' . $newFileName . '"');
            $my_aws_key = 'AWS_KEY';
            $my_aws_secret_key = 'AWS_SCRET_KEY';
            $s3 = new Zend_Service_Amazon_S3($my_aws_key, $my_aws_secret_key);
            $newFileName = "S3_download_filename.mp4";
            $response = $s3->getObjectStream("$newFileName");//download stream from s3
            readfile($response->getStreamName());
            

Monday 28 July 2014

Paypal Sandbox do-Directpayment, Authorization, Capture and Mass-payment - Example with Code Snippets

Paypal Sandbox do-Directpayment, Authorization, Capture and Mass-payment

Different Paypal Payment with API example (NVP Operation).
  1. DoDirect Payment - Sale
  2. Authorization - PayPal / Capture - PayPal
  3. Mass Pay
  4. Parallel Payment


Do-Direct Payment:
Direct Payment lets buyers pay using their credit cards and amount is directly transferred to merchant account.
https://developer.paypal.com/docs/classic/paypal-payments-pro/integration-guide/WPDirectPayment/


Payment Authorization:
In this case paypal will not charge immediately from the customer. We will hold the customer amount with the transaction-Id. Further with transaction-Id, we can decide whether charge the amount(Capture amount) OR return the amount to customer (Void Payment).
It have two parts
a. Authorization the customer money and store the transaction Id in our database.
b.  Capture Payment-  Charge the payment from hold amount with use of Transaction Id OR
     Void Payment – Cancel the payment (Return the payment to customer)
https://developer.paypal.com/docs/classic/admin/auth-capture/


MayPay Payment
In this case, One Merchant can send the money to his partner’s paypal email address (Paypal email address), mean each merchant must have paypal account.
https://developer.paypal.com/docs/classic/mass-pay/integration-guide/MassPayOverview/


Parallel Payment
In this case, We transfer the money between two or more partner instead of transferring all money in one merchant Account. This is possible with “Paypal Express Checkout” Method. In this method customer leave our website(like example.com) and redirect to paypal.com website, Here customer will see the all partner details and can pay by credit card/paypal Account. After paying the amount, customer will return back to our website(example.com).
https://developer.paypal.com/docs/classic/express-checkout/integration-guide/ECGettingStarted/#id084RM05055Z
https://developer.paypal.com/docs/classic/paypal-payments-pro/integration-guide/WPParallelPaymens/#id09ARE0F405Z




Following are Request and Response of paypal APIs (Please update User, Pwd and Signature, these are dummy)

Sr Operation Method Payment Action Request Sample Response Sample Introduction
1 DoDirectPayment DoDirectPayment Sale
Array
(
    [METHOD] => DoDirectPayment
    [USER] => testname_api1.no-spam.ws
    [PWD] => 55555526677
    [SIGNATURE] => Alsdfdsfafds.zYsROoDYkL2AigOq
    [VERSION] => 95
    [PAYMENTACTION] => Sale
    [IPADDRESS] => 127.0.0.1
    [CREDITCARDTYPE] => MasterCard
    [ACCT] => 5522340006063638
    [EXPDATE] => 092015
    [CVV2] => 123
    [FIRSTNAME] => Aman
    [LASTNAME] => Jaiswal
    [STREET] => Phase+7%2C+Mohali+
    [CITY] => Largo
    [STATE] => Punjab
    [COUNTRYCODE] => US
    [ZIP] => 160055
    [AMT] => 100
    [CURRENCYCODE] => USD
)
Array
(
    [TIMESTAMP] => 2014-07-29T06:24:35Z
    [CORRELATIONID] => 5866bc2f19ac7
    [ACK] => Success
    [VERSION] => 95
    [BUILD] => 11950065
    [AMT] => 100.00
    [CURRENCYCODE] => USD
    [AVSCODE] => X
    [CVV2MATCH] => M
    [TRANSACTIONID] => 4VT01737UB5183903
)
Get the Payment from Buyer to Merchant Account
2 MassPayment MassPay -NA-
Array
(
    [METHOD] => MassPay
    [USER] => testname_api1.no-spam.ws
    [PWD] => 55555526677
    [SIGNATURE] => Alsdfdsfafdsfs.zYsROoDYkL2AigOq
    [VERSION] => 95
    [RECEIVERTYPE] => EmailAddress
    [CURRENCYCODE] => USD
    [L_EMAIL0] => testnamel@no-spam.ws
    [L_AMT0] => 10.00
    [L_EMAIL1] => testname2@no-spam.ws
    [L_AMT1] => 10.00
)
Array
(
    [AUTHORIZATIONID] => 7FU87403AH3981018
    [TIMESTAMP] => 2014-07-29T05:39:09Z
    [CORRELATIONID] => c86dbba49cc4b
    [ACK] => Success
    [VERSION] => 95
    [BUILD] => 11950065
)
Distribute the Payment between 2 more partner
3 DoAuthorization DoDirectPayment authorization
Array
(
    [METHOD] => DoDirectPayment
    [USER] => testname_api1.no-spam.ws
    [PWD] => 55555526677
    [SIGNATURE] => Alsdfdsfafdsf.zYsROoDYkL2AigOq
    [VERSION] => 95
    [PAYMENTACTION] => authorization
    [IPADDRESS] => 127.0.0.1
    [CREDITCARDTYPE] => MasterCard
    [ACCT] => 5522340006063638
    [EXPDATE] => 102015
    [CVV2] => 123
    [FIRSTNAME] => Aman
    [LASTNAME] => Jaiswal
    [STREET] => Phase+8%2C+Mohali+
    [CITY] => Largo
    [STATE] => Punjab
    [COUNTRYCODE] => US
    [ZIP] => 160055
    [AMT] => 124.00
    [CURRENCYCODE] => USD
)
Array
(
    [TIMESTAMP] => 2014-07-29T06:26:30Z
    [CORRELATIONID] => 42ec9f542fc9f
    [ACK] => Success
    [VERSION] => 95
    [BUILD] => 11950065
    [AMT] => 124.00
    [CURRENCYCODE] => USD
    [AVSCODE] => X
    [CVV2MATCH] => M
    [TRANSACTIONID] => 2EY34762VW9685022
)
Authorize(Hold) the payment from Buyer
4 DoCapture DoCapture -NA-
Array
(
    [METHOD] => DoCapture
    [USER] => testname_api1.no-spam.ws
    [PWD] => 55555526677
    [SIGNATURE] => Alsdfdsfafdsf.zYsROoDYkL2AigOq
    [VERSION] => 95
    [AUTHORIZATIONID] => 2EY34762VW9685022
    [IPADDRESS] => 127.0.0.1
    [AMT] => 124
    [CURRENCYCODE] => USD
    [COMPLETETYPE] => Complete
)
Array
(
    [AUTHORIZATIONID] => 2EY34762VW9685022
    [TIMESTAMP] => 2014-07-29T06:28:02Z
    [CORRELATIONID] => 943ba369b948d
    [ACK] => Success
    [VERSION] => 95
    [BUILD] => 11950065
    [TRANSACTIONID] => 0U8601158C887733S
    [PARENTTRANSACTIONID] => 2EY34762VW9685022
    [RECEIPTID] => 3177-5474-1146-7724
    [TRANSACTIONTYPE] => webaccept
    [PAYMENTTYPE] => instant
    [ORDERTIME] => 2014-07-29T06:28:02Z
    [AMT] => 124.00
    [FEEAMT] => 3.90
    [TAXAMT] => 0.00
    [CURRENCYCODE] => USD
    [PAYMENTSTATUS] => Completed
    [PENDINGREASON] => None
    [REASONCODE] => None
    [PROTECTIONELIGIBILITY] => Ineligible
    
Capture money which we have Authorized(Hold)
5 DoVoid DoVoid -NA-
Array
(
    [METHOD] => DoVoid
    [USER] => testname_api1.no-spam.ws
    [PWD] => 55555526677
    [SIGNATURE] => Alsdfdsfafds.zYsROoDYkL2AigOq
    [VERSION] => 95
    [AUTHORIZATIONID] => 9VP549332Y830720W
    [IPADDRESS] => 127.0.0.1
    [AMT] => 124
    [CURRENCYCODE] => USD
    [COMPLETETYPE] => Complete
)
Array
(
    [AUTHORIZATIONID] => 9VP549332Y830720W
    [TIMESTAMP] => 2014-07-29T06:28:52Z
    [CORRELATIONID] => 8a5d49a877bad
    [ACK] => Success
    [VERSION] => 95
    [BUILD] => 11950065
)
Return the Authorized(Holded) Amount to buyer account





Include Paypal Library
class Global_Paypal {

    private $_api_version = '95';
    private $_api_username = 'test_api1.no-spam.ws';//this is dummpy plz update
    private $_api_password = '1406987677';//this is dummpy plz update
    private $_api_signature = 'ARDESpesJftWYRUVq94d7LvquBZIApzl9Jq3wuT.zYsROoDYkL2AigOq';//this is dummpy plz update
    private $_uri = 'https://api-3t.sandbox.paypal.com/nvp';

    
    /** DoDirect Payment - SALE* */
    function doDirectPayment(array $data) {
        $postData = array(
            'METHOD' => 'DoDirectPayment',
            'USER' => ($this->_api_username),
            'PWD' => ($this->_api_password),
            'SIGNATURE' => ($this->_api_signature),
            'VERSION' => ($this->_api_version),
            'PAYMENTACTION' => $data['paymentAction'],
            'IPADDRESS' => $data['ip'],
            'CREDITCARDTYPE' => $data['cctype'],
            'ACCT' => $data['ccno'],
            'EXPDATE' => $data['expdate'],
            'CVV2' => $data['cvv2'],
            'FIRSTNAME' => $data['fname'],
            'LASTNAME' => $data['lname'],
            'STREET' => $data['address'],
            'CITY' => $data['city'],
            'STATE' => $data['state'],
            'COUNTRYCODE' => $data['ccode'],
            'ZIP' => $data['zip'],
            'AMT' => $data['amt'],
            'CURRENCYCODE' => $data['currencycode'],
        );

        try {
            $client = new Zend_Http_Client($this->_uri);
            $postData = array_map('urlencode', $postData);
            $client->setParameterPost($postData);
            $response = $client->request('POST');
            $body = $response->getRawBody();
            parse_str($body, $nvpResponseArray);
            return $nvpResponseArray;
        } catch (Exception $e) {
            echo $e->getMessage();
            die;
        }
    }

    /** Transfer Money to number of peoples - MassPay **/
    function masspayment(array $receiverArray) {
        $postData = array(
            'METHOD' => 'MassPay',
            'USER' => ($this->_api_username),
            'PWD' => ($this->_api_password),
            'SIGNATURE' => ($this->_api_signature),
            'VERSION' => ($this->_api_version),
            'RECEIVERTYPE' => 'EmailAddress',
            'CURRENCYCODE' => 'USD',
        );
        $i = 0;
        foreach ($receiverArray as $emailAddress => $amt) {
            $postData["L_EMAIL{$i}"] = $emailAddress;
            $postData["L_AMT{$i}"] = $amt;
            $i++;
        }
        try {
            $client = new Zend_Http_Client($this->_uri);
            //$postData = array_map('urlencode', $postData);            
            pr($postData);
            $client->setParameterPost($postData);
            $response = $client->request('POST');
            $body = $response->getRawBody();
            parse_str($body, $nvpResponseArray);
            return $nvpResponseArray;
        } catch (Exception $e) {
            echo $e->getMessage();
            die;
        }
    }

    /** DoDirect Payment - Authorization* */
    function doauthPayment(array $data) {

        $postData = array(
            'METHOD' => 'DoDirectPayment',
            'USER' => ($this->_api_username),
            'PWD' => ($this->_api_password),
            'SIGNATURE' => ($this->_api_signature),
            'VERSION' => ($this->_api_version),
            'PAYMENTACTION' => $data['paymentAction'],
            'IPADDRESS' => $data['ip'],
            'CREDITCARDTYPE' => $data['cctype'],
            'ACCT' => $data['ccno'],
            'EXPDATE' => $data['expdate'],
            'CVV2' => $data['cvv2'],
            'FIRSTNAME' => $data['fname'],
            'LASTNAME' => $data['lname'],
            'STREET' => $data['address'],
            'CITY' => $data['city'],
            'STATE' => $data['state'],
            'COUNTRYCODE' => $data['ccode'],
            'ZIP' => $data['zip'],
            'AMT' => $data['amt'],
            'CURRENCYCODE' => $data['currencycode'],
        );

        try {
            /** Get the Transaction Id * */
            $client = new Zend_Http_Client($this->_uri);
            $postData = array_map('urlencode', $postData);
            $client->setParameterPost($postData);
            $response = $client->request('POST');
            $body = $response->getRawBody();
            parse_str($body, $nvpResponseArray);
            /** Get the Transaction Id * */
            if (!empty($nvpResponseArray['TRANSACTIONID'])) {
                return $nvpResponseArray;
            } else {
                pr($nvpResponseArray);
                die("TransactionId is empty");
            }

            return $nvpResponseArray;
        } catch (Exception $e) {
            echo $e->getMessage();
            die;
        }
    }

    /** DoCapture* */
    function doCapturePayment($data = array()) {
        $postData = array(
            'METHOD' => 'DoCapture',
            'USER' => ($this->_api_username),
            'PWD' => ($this->_api_password),
            'SIGNATURE' => ($this->_api_signature),
            'VERSION' => ($this->_api_version),
            'AUTHORIZATIONID' => $data['TransactionID'],
            'IPADDRESS' => $data['ip'],
            'AMT' => $data['amt'],
            'CURRENCYCODE' => $data['currencycode'],
            'COMPLETETYPE' => 'Complete'
        );
        try {
            pr($postData);
            /** Get the Transaction Id * */
            $client = new Zend_Http_Client($this->_uri);
            $postData = array_map('urlencode', $postData);
            $client->setParameterPost($postData);
            $response = $client->request('POST');
            $body = $response->getRawBody();
            parse_str($body, $nvpResponseArray);
            pr($nvpResponseArray);
            die;
            /** Get the Transaction Id * */
            if (!empty($nvpResponseArray['TRANSACTIONID'])) {
                return $nvpResponseArray;
            } else {
                pr($nvpResponseArray);
                die("TransactionId is empty");
            }

            return $nvpResponseArray;
        } catch (Exception $e) {
            echo $e->getMessage();
            die;
        }
    }

}



Following are different functions which you can used to achieve above actions


  1. doDirectPayment: DoDirect Payment - Sale
  2. masspayment: Mass Pay
  3. doauthPayment: Authorization - PayPal
  4. doCapturePayment: Capture - PayPal

class PaypalController extends Zend_Controller_Action {


    /** DoDirect Payment - SALE* */
    public function indexAction() {

        /** Sample Data* */
        /** set Data  * */
        $amount = 100.00;
        $creditCardType = 'MasterCard';
        $creditCardNumber = '5522340006063638';
        $expirationMonth = '09';
        $expirationYear = '2015';
        $cvv2 = '123';
        $firstName = 'Aman';
        $lastName = 'Jaiswal';
        $address1 = 'Phase 7, Mohali';
        $address2 = '';
        $city = 'Largo';
        $state = 'Punjab';
        $zip = '160055';
        $postData = array();
        $countryCode = 'US';
        $currencyCode = 'USD';
        $ipAddress = $_SERVER['REMOTE_ADDR'];
        /** set Data * */
        $postData = array(
            'paymentAction' => 'Sale',
            'ip' => $_SERVER['REMOTE_ADDR'],
            'cctype' => $creditCardType,
            'ccno' => $creditCardNumber,
            'expdate' => "{$expirationMonth}{$expirationYear}",
            'cvv2' => urlencode($cvv2),
            'fname' => $firstName,
            'lname' => $lastName,
            'address' => $address1 . ' ' . $address2,
            'city' => $city,
            'state' => $state,
            'ccode' => $countryCode,
            'zip' => $zip,
            'amt' => $amount,
            'currencycode' => $currencyCode,
            'DESC' => 'Testing Payments Pro'
        );

        $paypal = new Global_PayPal();
        $result = $paypal->doDirectPayment($postData);        
        print_r($result);
        die;        
        /** Sample Data* */        
        
    }

    /** Transfer Money to number of peoples - MassPay **/
    function masspayAction() {
        $paypal = new Global_PayPal();
        $receiverArray = array(
            'ajit@no-spam.ws' => '10.00',
            'ajit@no-spam.ws' => '10.00',
        );        

        $result = $paypal->masspayment($receiverArray);
        print_r($result);die;
        
    }
    
      /** DoDirect Payment - Authorization* */
    public function authAction() {
        
        /** set Data  * */
        $amount = '124.00';
        $creditCardType = 'MasterCard';
        $creditCardNumber = '5522340006063638';
        $expirationMonth = '10';
        $expirationYear = '2015';
        $cvv2 = '123';
        $firstName = 'Aman';
        $lastName = 'Jaiswal';
        $address1 = 'Phase 8, Mohali';
        $address2 = '';
        $city = 'Largo';
        $state = 'Punjab';
        $zip = '160055';
        $postData = array();
        $countryCode = 'US';
        $currencyCode = 'USD';
        $ipAddress = $_SERVER['REMOTE_ADDR'];
        $transActionId = '8f4de96650a85';
        /** set Data * */
        $postData = array(            
            'paymentAction' => 'authorization',
            'ip' => $_SERVER['REMOTE_ADDR'],
            'cctype' => $creditCardType,
            'ccno' => $creditCardNumber,
            'expdate' => "{$expirationMonth}{$expirationYear}",
            'cvv2' => urlencode($cvv2),
            'fname' => $firstName,
            'lname' => $lastName,
            'address' => $address1 . ' ' . $address2,
            'city' => $city,
            'state' => $state,
            'ccode' => $countryCode,
            'zip' => $zip,
            'amt' => $amount,
            'currencycode' => $currencyCode,            
        );

        $paypal = new Global_PayPal();
        $result = $paypal->doauthPayment($postData);        
        print_r($result);
        die;
        /** Sample Data* */        
        // action body
    }   
    
    /** DoCapture* */
    function captureAction(){
        $postData = array(            
            'paymentAction' => 'DoCapture',
            'ip' => $_SERVER['REMOTE_ADDR'],           
            'amt' => 124,
            'currencycode' => 'USD',            
            'TransactionID' => '49760658JE805135N',
        );

        $paypal = new Global_PayPal();
        $result = $paypal->doCapturePayment($postData);        
        print_r($result);
        die;
        
    }

}