Payment Status

// read the post from PayPal system and add 'cmd'
$req = 'cmd=_notify-synch';

$tx_token = $_GET['tx'];
$auth_token = "pPGdItDchYVHc-EJ3nnsi3yNFT9lsyEoQesiQeNZgbkFXEbKpmYt83_0iFe";
$req .= "&tx=$tx_token&at=$auth_token";

// post back to PayPal system to validate
$header .= "POST /cgi-bin/webscr HTTP/1.0\r\n";
$header .= "Content-Type: application/x-www-form-urlencoded\r\n";
$header .= "Content-Length: " . strlen($req) . "\r\n\r\n";
$fp = fsockopen ('www.paypal.com', 80, $errno, $errstr, 30);
// If possible, securely post back to paypal using HTTPS
// Your PHP server will need to be SSL enabled
// $fp = fsockopen ('ssl://www.paypal.com', 443, $errno, $errstr, 30);

if (!$fp) {
// HTTP ERROR
} else {
fputs ($fp, $header . $req);
// read the body data
$res = '';
$headerdone = false;
while (!feof($fp)) {
$line = fgets ($fp, 1024);
if (strcmp($line, "\r\n") == 0) {
// read the header
$headerdone = true;
}
else if ($headerdone)
{
// header has been read. now read the contents
$res .= $line;
}
}

// parse the data
$lines = explode("\n", $res);
$keyarray = array();
if (strcmp ($lines[0], "SUCCESS") == 0) {
for ($i=1; $i list($key,$val) = explode("=", $lines[$i]);
$keyarray[urldecode($key)] = urldecode($val);
}
// check the payment_status is Completed
// check that txn_id has not been previously processed
// check that receiver_email is your Primary PayPal email
// check that payment_amount/payment_currency are correct
// process payment

$firstname = $keyarray['first_name'];
$lastname = $keyarray['last_name'];
$itemname = $keyarray['item_name'];
$amount = $keyarray['payment_gross'];
$custom = $keyarray['custom'];

echo ("

Thank you for your Payment!

“);

echo (“Payment Details
\n”);
echo (“

  • Name: $firstname $lastname
  • \n”);
    echo (“

  • Item: $itemname
  • \n”);
    echo (“

  • Amount: $amount
  • \n”);
    echo (“

  • Custom Details: $custom
  • \n”);
    echo (“”);
    echo ‘

    Thanks! I got the Payment.
    A receipt for your payment has been emailed to you. You may log into your account at www.paypal.com to view details of this transaction.

    ‘;
    }
    else if (strcmp ($lines[0], “FAIL”) == 0) {
    // log for manual investigation

    echo ‘

    Sorry! Your transaction has been cancelled or Failed

    ‘;
    }

    }

    fclose ($fp);

    ?>


    Hi, I am Chief Executive Officer (CEO), Webchilly Infoways, India and a 4 years experienced Leading Software Developer from southern (Visakhapatnam) india. With key skills PHP, XHTML, CSS, MySql, Ms Msql, VB.NET, AJAX, SEO, Photoshop. I work as Web Designer, Developer, Software Application Developer and SEO as well. I am one of the best WordPress Developers, Joomla, PHPBB, DRUPAL, Magento Experts, PSD to XHTML,CSS Experts from India.

    Comments are closed.

    Need a website for your business?

    Wordpress Expert India, Web Expert India

    I am on SKYPE and Google+

    A.Niraj Kumar’s Present Address

    Siva Nagar
    Marripalem
    Visakhapatanam
    530018, (Vizag)
    Andhra Pradesh, India
    Photo of A.Niraj Kumar

    Call me USA: +1-(505)-404-6627 (Office)
    Call me UK (London): +44-020-8144-4086
    Call me India: +91-891-2722707 (Office)

    Where is Niraj now?

    Jobs in Visakhapatnam

    Needed Web Designers and Developers with atleast 6 months of experience in
    1. Photoshop, XHTML and CSS (Designer)
    2. or/and PHP/MySql and Open Source CMS (Developer)
    Send CVs to career@webchilly.in

    Wanna Pay me for project done?

    Enter Project URL
    Enter Agreed Amount
    Select Currency
    Wordpress Developers | No Corruption | Wordpress Expert | Joomla to Wordpress Expert

    Translate to your Language