Jump to content

Paypal IPN Help


Deepzone

Recommended Posts

I use the following IPN code from Paypal to trigger my database update.

 

if (!$fp) {

// HTTP ERROR

} else {

fputs ($fp, $header . $req);

while (!feof($fp)) {

$res = fgets ($fp, 1024);

// $res=stream_get_contents($fp, 1024);

 

$res = trim($res);

if (strcmp($res, "VERIFIED") == 0) {

if ($payment_status === 'Completed') {

$txn_id_check = mysql_query("SELECT txn_id FROM log WHERE txn_id = '".$txn_id."'");

if (mysql_num_rows($txn_id_check) != 1) {

if ($receiver_email=='[email protected]') {

if ($payment_amount == '0.09' && $payment_currency == 'CAD') {

// add txn to database

$log_query = mysql_query("INSERT INTO log (txn_id, email) VALUES ('".$txn_id."', '".$payer_email."')");

// update premium to 1

$update_premium = mysql_query("UPDATE users SET premium = 1 WHERE user_id = '".$user_id."' ");

}

}

}

}

}

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

// log for manual investigation

}

}

fclose ($fp);

}

 

The updating has never kicked in. I tried to debug it and found it has been blocked at if (strcmp($res, "VERIFIED") == 0) . From other post of this forum I learned to trace the IPN return script and found $res doesn't exist. Does anyone know how to fix it?

Link to comment
https://forums.phpfreaks.com/topic/273998-paypal-ipn-help/
Share on other sites

What, specifically, do you mean with "$res doesn't exist"?

 

Also, have you checked your error logs for errors/warnings that this snippet may be producing? I don't see any error handling in here, so it's quite possible that it silently fails at numerous points. Checking the error logs, or turning on error reporting, should give you some pointers.

Link to comment
https://forums.phpfreaks.com/topic/273998-paypal-ipn-help/#findComment-1410017
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.