tags:

views:

50

answers:

0

The paypal ipn i set is sending the messsege in my site, which i get from paypal ipn history:

mc_gross=39.99&invoice=5f8907aea6ab76a1bc92c761211575a7&protection_eligibility=Eligible&address_status=confirmed&payer_id=EMQD7SB7STQQ2&tax=0.00&address_street=1 Main St&payment_date=13:11:02 May 12, 2010 PDT&payment_status=Completed&charset=windows-1252&address_zip=95131&first_name=Test&mc_fee=1.46&address_country_code=US&address_name=Test User&notify_version=2.9&custom=&payer_status=unverified&[email protected]&address_country=United States&address_city=San Jose&quantity=1&verify_sign=ACPvpPWeMel3jdWN99ADWnPipocoAVgkocAqXH.asro60DL.XX1gqX07&[email protected]&txn_id=1C617333CY4653325&payment_type=instant&last_name=User&address_state=CA&[email protected]&payment_fee=1.46&receiver_id=U5UQSB57XFX26&txn_type=web_accept&item_name=&mc_currency=USD&item_number=&residence_country=US&test_ipn=1&handling_amount=0.00&transaction_subject=&payment_gross=39.99&shipping=0.00

this is my code to track ipn(code igniter):

class Ipn_x2 extends Controller
{


    function Ipn_x2()
    {
    parent::Controller();
    }


    function XnPt2l()
    {
        $req = 'cmd=_notify-validate';
foreach ($_POST as $key => $value) {
$value = urlencode(stripslashes($value));
$req .= "&$key=$value";
}
// 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 ('ssl://www.sandbox.paypal.com', 443, $errno, $errstr, 30);


if (!$fp) {
// HTTP ERROR
} else {
fputs ($fp, $header . $req);
while (!feof($fp)) {
$res = fgets ($fp, 1024);
if (strcmp ($res, "VERIFIED") == 0) {

// PAYMENT VALIDATED & VERIFIED!

$email = $_POST['payer_email'];
$invoice = $_POST['invoice'];

$data = array(
               'active' => '1',
               'date_activated'=>date("Y-m-d")
            );

$this->db->where('invoice', $invoice);
$this->db->update('users', $data);

/*

$password = mt_rand(1000, 9999);

mysql_query("INSERT INTO users (email, password) VALUES('". mysql_escape_string($email) ."', '".md5($password)."' ) ") or die(mysql_error());
*/
$to      = '[email protected]';
$subject = 'Money added';
$message = '

Thank you for your purchase

Your account information
-------------------------
Email: '.$email.'
Invoice: '.$invoice.'
-------------------------

You can now login at http://yourwebsite.com/PayPal/';
$headers = 'From:[email protected]' . "\r\n";

mail($to, $subject, $message, $headers);



}

else if (strcmp ($res, "INVALID") == 0) {

// PAYMENT INVALID & INVESTIGATE MANUALY!

$to      = '[email protected]';
$subject = 'Invalid Payment';
$message = '

Dear Administrator,

A payment has been made but is flagged as INVALID.
Please verify the payment manualy and contact the buyer.

Buyer Email: '.$email.'
';
$headers = 'From:[email protected]' . "\r\n";

mail($to, $subject, $message, $headers);

}
}
fclose ($fp);
}

    }



}

but database is not updated, i can not understand why. ipn path is set