How to setup payments with paypal IPN - php

I am setting up paypal IPN with my website so that users who are logged in can purchase points. I already have session and login and $id variables and what not, I do not need help on any of that. I need help on the paypal IPN aspect of it. So, what I have so far is the notification URL which I also set on my paypal account. Here is the notification url:
$raw_post_data = file_get_contents('php://input');
$raw_post_array = explode('&', $raw_post_data);
$myPost = array();
foreach ($raw_post_array as $keyval) {
$keyval = explode ('=', $keyval);
if (count($keyval) == 2)
$myPost[$keyval[0]] = urldecode($keyval[1]);
}
// read the post from PayPal system and add 'cmd'
$req = 'cmd=_notify-validate';
if(function_exists('get_magic_quotes_gpc')) {
$get_magic_quotes_exists = true;
}
foreach ($myPost as $key => $value) {
if($get_magic_quotes_exists == true && get_magic_quotes_gpc() == 1) {
$value = urlencode(stripslashes($value));
} else {
$value = urlencode($value);
}
$req .= "&$key=$value";
}
// STEP 2: Post IPN data back to paypal to validate
$ch = curl_init('https://www.paypal.com/cgi-bin/webscr'); // change to [...]sandbox.paypal[...] when using sandbox to test
curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $req);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
curl_setopt($ch, CURLOPT_FORBID_REUSE, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Connection: Close'));
// In wamp like environments that do not come bundled with root authority certificates,
// please download 'cacert.pem' from "http://curl.haxx.se/docs/caextract.html" and set the directory path
// of the certificate as shown below.
// curl_setopt($ch, CURLOPT_CAINFO, dirname(__FILE__) . '/cacert.pem');
if( !($res = curl_exec($ch)) ) {
// error_log("Got " . curl_error($ch) . " when processing IPN data");
curl_close($ch);
exit;
}
curl_close($ch);
// STEP 3: Inspect IPN validation result and act accordingly
if (strcmp ($res, "VERIFIED") == 0) {
// check whether 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
// assign posted variables to local variables
$item_name = $_POST['item_name'];
$item_number = $_POST['item_number'];
$payment_status = $_POST['payment_status'];
if ($_POST['mc_gross'] != NULL)
$payment_amount = $_POST['mc_gross'];
else
$payment_amount = $_POST['mc_gross1'];
$payment_currency = $_POST['mc_currency'];
$txn_id = $_POST['txn_id'];
$receiver_email = $_POST['receiver_email'];
$payer_email = $_POST['payer_email'];
$custom = $_POST['custom'];
// Insert your actions here
if ($payment_status = "Completed")
{
// my sql statement to update the points will go here, I don't need help
// with that
}
if ($txn_id)
{
}
} else if (strcmp ($res, "INVALID") == 0) {
// log for manual investigation
}
So this seems to be setup properly, no errors, the SQL statements I'm going to add worked just fine when I tested them, etc. My only problem is the payments. I have no idea how to have the user pay. I know how to setup paypal API and integrate paypal payments with my website... is that what I have to do? If not, then how do I allow the user to enter a custom amount, have them pay for it, and then their payment will be automatically verified by the notification url? This question may seem pretty broad, but I'm not asking anyone to write free code for me. I'm just looking for someone to point me in the right direction on this because I've searched so long and hard for this information and I can't seem to find it. All help is greatly appreciated! Thank you :)

IPN is a post-transaction processing tool. It does not actually process transactions in itself (unless you happen to have your own API integration done within your IPN script that is doing so.)
So yes, you need to use Payments Standard, Express Checkout / Pro, or whatever you're comfortable with to actually tie the payment part into your site. Then once that payment is made it would trigger the IPN accordingly.

Related

Paypal IPN & updating database dilemma

So I have a problem and dont know what way to approach it. What I am trying to do so when the user verifies there email they are directed to a page where they select the membership plan and then they are directed to paypal to proceed with the payment - the payment field in the DB is then updated. They are then redirecting back to the website.
Problem 1: I have PayPal IPN PHP page witch is so-pose to handle the problem but that does not seem to be working or not even being called i dont know. I do have the ipn enabled and configured in the PayPal acount
<?php
// STEP 1: Read POST data
// reading posted data from directly from $_POST causes serialization
// issues with array data in POST
// reading raw POST data from input stream instead.
$raw_post_data = file_get_contents('php://input');
$raw_post_array = explode('&', $raw_post_data);
$myPost = array();
foreach ($raw_post_array as $keyval) {
$keyval = explode ('=', $keyval);
if (count($keyval) == 2)
$myPost[$keyval[0]] = urldecode($keyval[1]);
}
// read the post from PayPal system and add 'cmd'
$req = 'cmd=_notify-validate';
if(function_exists('get_magic_quotes_gpc')) {
$get_magic_quotes_exists = true;
}
foreach ($myPost as $key => $value) {
if($get_magic_quotes_exists == true && get_magic_quotes_gpc() == 1) {
$value = urlencode(stripslashes($value));
} else {
$value = urlencode($value);
}
$req .= "&$key=$value";
}
// STEP 2: Post IPN data back to paypal to validate
$ch = curl_init('https://www.paypal.com/cgi-bin/webscr'); // change to [...]sandbox.paypal[...] when using sandbox to test
curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $req);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
curl_setopt($ch, CURLOPT_FORBID_REUSE, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Connection: Close'));
// In wamp like environments that do not come bundled with root authority certificates,
// please download 'cacert.pem' from "http://curl.haxx.se/docs/caextract.html" and set the directory path
// of the certificate as shown below.
// curl_setopt($ch, CURLOPT_CAINFO, dirname(__FILE__) . '/cacert.pem');
if( !($res = curl_exec($ch)) ) {
// error_log("Got " . curl_error($ch) . " when processing IPN data");
curl_close($ch);
exit;
}
curl_close($ch);
// STEP 3: Inspect IPN validation result and act accordingly
// check whether 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
// assign posted variables to local variables
$item_name = $_POST['item_name'];
$item_number = $_POST['item_number'];
$payment_status = $_POST['payment_status'];
if ($_POST['mc_gross'] != NULL)
$payment_amount = $_POST['mc_gross'];
else
$payment_amount = $_POST['mc_gross1'];
$payment_currency = $_POST['mc_currency'];
$txn_id = $_POST['txn_id'];
$receiver_email = $_POST['receiver_email'];
$payer_email = $_POST['payer_email'];
$custom = $_POST['custom'];
// Insert your actions here
include 'base.php';
$q = "SELECT * FROM users WHERE EMAIL ='$email'";
//Run Query
$result = $link->query($q) or die(mysqli_error($mysqli));
//Numbers of rows that match
$num_rows = $result->num_rows;
if($num_rows > 0){
$query = "UPDATE 'users' SET 'payment' ='$payment_amount' WHERE EMAIL ='$payer_email'";
$link->query($query) or die(mysqli_error($mysqli));
if($link){
echo "<script>console.log( 'success '');</script>";
}
}else{
}
?>
Problem 2 Even if this wont there be a problem is the user used someone else account for a different email.
If any one had the patients to stick with me a read this far thanks, Any help would be great.
Regards
Amy

Why is my IPN Listener not receiving data sent from my paypal sandbox?

I have looked through all answers on google and this site - none have helped.
My code consists of the standard IPN Listener code:
$raw_post_data = file_get_contents('php://input');
$raw_post_array = explode('&', $raw_post_data);
$myPost = array();
foreach ($raw_post_array as $keyval) {
$keyval = explode ('=', $keyval);
if (count($keyval) == 2)
$myPost[$keyval[0]] = urldecode($keyval[1]);
}
// read the IPN message sent from PayPal and prepend 'cmd=_notify-validate'
$req = 'cmd=_notify-validate';
if(function_exists('get_magic_quotes_gpc')) {
$get_magic_quotes_exists = true;
}
foreach ($myPost as $key => $value) {
if($get_magic_quotes_exists == true && get_magic_quotes_gpc() == 1) {
$value = urlencode(stripslashes($value));
} else {
$value = urlencode($value);
}
$req .= "&$key=$value";
}
// STEP 2: POST IPN data back to PayPal to validate
$ch = curl_init('https://www.sandbox.paypal.com/cgi-bin/webscr');
curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $req);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
curl_setopt($ch, CURLOPT_FORBID_REUSE, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Connection: Close'));
// In wamp-like environments that do not come bundled with root authority certificates,
// please download 'cacert.pem' from "http://curl.haxx.se/docs/caextract.html" and set
// the directory path of the certificate as shown below:
// curl_setopt($ch, CURLOPT_CAINFO, dirname(__FILE__) . '/cacert.pem');
if( !($res = curl_exec($ch)) ) {
// error_log("Got " . curl_error($ch) . " when processing IPN data");
curl_close($ch);
exit;
}
curl_close($ch);
// STEP 3: Inspect IPN validation result and act accordingly
if (strcmp ($res, "VERIFIED") == 0) {
// The IPN is verified, process it:
// check whether 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 the notification
// assign posted variables to local variables
$item_name = $_POST['item_name'];
$item_number = $_POST['item_number'];
$payment_status = $_POST['payment_status'];
$payment_amount = $_POST['mc_gross'];
$payment_currency = $_POST['mc_currency'];
$txn_id = $_POST['txn_id'];
$receiver_email = $_POST['receiver_email'];
$payer_email = $_POST['payer_email'];
// IPN message values depend upon the type of notification sent.
// To loop through the &_POST array and print the NV pairs to the screen:
foreach($_POST as $key => $value) {
echo $key." = ". $value."<br>";
}
} else if (strcmp ($res, "INVALID") == 0) {
// IPN invalid, log for manual investigation
echo "The response from IPN was: <b>" .$res ."</b>";
}
?>
I have made sure the url in use is the sandbox one, not production. I send an IPN via the IPN simulator on PayPal and it says Successfully sent, and handshake verified. Which implies that my listener responded with a success. However, when I actually visit /ipn.php it simply says UNVERIFIED, and does not pick up any of the POST data sent from paypal. I test this at the moment by firstly sending the IPN, then refreshing my /ipn.php to see if it picked up the POST data, which it doesn't. What am I missing? Please do ask for any other details.
The POST data from PayPal sits in the $raw_post_data variable. If you don't do anything with it (such as store in a database, flat file, etc), it's simply list.
If you would want to see the IPN validation result when you do a GET /ipn.php HTTP request (which is what your browser does when you pull up ipn.php in your browser), you would need to add logic which returns the latest IPN validation status.
Which probably isn't what you'd want.
Instead, step through the sample script provided by PayPal and look at if (strcmp ($res, "VERIFIED") == 0) {: what this allows you to do, is add logic to, for example, write the results to a file. Or store it in a database and flip an order state to 'paid'.

Problems with PayPal IPN variables

Im using PayPal as main payment system, so I decided to add it inside my custom built script, however I have problems with IPN variables because when I try to echo any of those variables for example
$item_number
$txn_id
I get nothing from above variables. Everything is passed correctly to PayPal and the payment is received, but when user is redirected to my "Thank you" page where I need to grab that $item_number item number in order to update the database nothing is passed. Im doing testings using Sandbox for now.
This is the url values when redirected to my website:
http://example.com/thankyou.php?tx=8LT93279034418017&st=Completed&amt=20%2e00&cc=USD&cm=&item_number=29
this is my IPN code:
<?php
// STEP 1: Read POST data
// reading posted data from directly from $_POST causes serialization
// issues with array data in POST
// reading raw POST data from input stream instead.
$raw_post_data = file_get_contents('php://input');
$raw_post_array = explode('&', $raw_post_data);
$myPost = array();
foreach ($raw_post_array as $keyval) {
$keyval = explode ('=', $keyval);
if (count($keyval) == 2)
$myPost[$keyval[0]] = urldecode($keyval[1]);
}
// read the post from PayPal system and add 'cmd'
$req = 'cmd=_notify-validate';
if(function_exists('get_magic_quotes_gpc')) {
$get_magic_quotes_exists = true;
}
foreach ($myPost as $key => $value) {
if($get_magic_quotes_exists == true && get_magic_quotes_gpc() == 1) {
$value = urlencode(stripslashes($value));
} else {
$value = urlencode($value);
}
$req .= "&$key=$value";
}
// STEP 2: Post IPN data back to paypal to validate
$ch = curl_init('https://www.sandbox.paypal.com/cgi-bin/webscr');
curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $req);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
curl_setopt($ch, CURLOPT_FORBID_REUSE, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Connection: Close'));
// In wamp like environments that do not come bundled with root authority certificates,
// please download 'cacert.pem' from "http://curl.haxx.se/docs/caextract.html" and set the directory path
// of the certificate as shown below.
// curl_setopt($ch, CURLOPT_CAINFO, dirname(__FILE__) . '/cacert.pem');
if( !($res = curl_exec($ch)) ) {
// error_log("Got " . curl_error($ch) . " when processing IPN data");
curl_close($ch);
exit;
}
curl_close($ch);
// STEP 3: Inspect IPN validation result and act accordingly
if (strcmp ($res, "VERIFIED") == 0) {
// check whether 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
// assign posted variables to local variables
$custom_value = $_POST['custom'];
$item_name = $_POST['item_name'];
$item_number = $_POST['item_number'];
$payment_status = $_POST['payment_status'];
$payment_amount = $_POST['mc_gross'];
$payment_currency = $_POST['mc_currency'];
$txn_id = $_POST['txn_id'];
$receiver_email = $_POST['receiver_email'];
$payer_email = $_POST['payer_email'];
} else if (strcmp ($res, "INVALID") == 0) {
// log for manual investigation
}
?>
Thanks a lot for help!
You are confusing PDT and IPN. PDT is what would send data back to your return URL. IPN happens completely separate from your checkout flow and isn't something anybody sees on screen, so echoing data wouldn't be seen by anybody.
IPN is indeed the recommended way to handle database updates, email notifications, etc. because even with Auto-Return enabled there is no guarantee users would make it back to your ReturnURL (when using Payments Standard), in which case the code would never run for those orders.
It looks like you just pulled the IPN sample from PayPal, so you need to customize it to suit your needs, and again, keep in mind it's not anything you'll see on screen. You'll need to check PayPal's IPN History and your web server logs to see if it's getting hit and if any errors may be happening.
Of course, you'll need to make sure you have IPN configured in your PayPal profile, too, or that you've set notify_url in your payment code.
So your thank you page would really be nothing more than that, and then IPN would handle updating the db and notifying the user about anything they need to know.

PayPal IPN has stopped working

For several hours the script below worked very well and suddenly it has stopped working.
I have not changed anything.
Is there anything below that looks wrong that could prevent it from working properly?
<?php
// STEP 1: read POST data
// Reading POSTed data directly from $_POST causes serialization issues with array data in the POST.
// Instead, read raw POST data from the input stream.
$raw_post_data = file_get_contents('php://input');
$raw_post_array = explode('&', $raw_post_data);
$myPost = array();
foreach ($raw_post_array as $keyval) {
$keyval = explode ('=', $keyval);
if (count($keyval) == 2)
$myPost[$keyval[0]] = urldecode($keyval[1]);
}
// read the IPN message sent from PayPal and prepend 'cmd=_notify-validate'
$req = 'cmd=_notify-validate';
if(function_exists('get_magic_quotes_gpc')) {
$get_magic_quotes_exists = true;
}
foreach ($myPost as $key => $value) {
if($get_magic_quotes_exists == true && get_magic_quotes_gpc() == 1) {
$value = urlencode(stripslashes($value));
} else {
$value = urlencode($value);
}
$req .= "&$key=$value";
}
// Step 2: POST IPN data back to PayPal to validate
$ch = curl_init('https://www.sandbox.paypal.com/cgi-bin/webscr');
curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $req);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
curl_setopt($ch, CURLOPT_FORBID_REUSE, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Connection: Close'));
// In wamp-like environments that do not come bundled with root authority certificates,
// please download 'cacert.pem' from "http://curl.haxx.se/docs/caextract.html" and set
// the directory path of the certificate as shown below:
// curl_setopt($ch, CURLOPT_CAINFO, dirname(__FILE__) . '/cacert.pem');
if( !($res = curl_exec($ch)) ) {
// error_log("Got " . curl_error($ch) . " when processing IPN data");
curl_close($ch);
exit;
}
curl_close($ch);
if (strcmp ($res, "VERIFIED") == 0) {
// The IPN is verified, process it:
// check whether 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 the notification
// assign posted variables to local variables
$item_name = $_POST['item_name'];
$item_number = $_POST['item_number'];
$payment_status = $_POST['payment_status'];
$payment_amount = $_POST['mc_gross'];
$payment_currency = $_POST['mc_currency'];
$txn_id = $_POST['txn_id'];
$receiver_email = $_POST['receiver_email'];
$payer_email = $_POST['payer_email'];
// process payment
// Added pp_trans_id which is the unique Transaction ID provided by PayPal
// Added reg_date which is in UNIX_TIME()
// Set WHERE to be equal to $id for perfect match
mysql_connect('localhost', 'wgaxzhpl_registe', '****');
mysql_select_db('wgaxzhpl_register');
$id = $_POST['custom'];
$insert = mysql_query("INSERT INTO `log` (txn_id, active) VALUES ('".$txn_id."', 1);");
}
else if (strcmp ($res, "INVALID") == 0) {
// IPN invalid, log for manual investigation
}
?>
Check the IPN History in your PayPal account to see if IPN's are actually getting sent or not and what response is coming back. If it's showing that they're getting sent and including a 200 response then that means your script is getting hit and completing successfully. In such a case you would need to check the logic of your script to see why it's not doing what you think.
If it's not sending at all you would need to double check your IPN configuration in the PayPal account or the notify URL used on payment requests.
If it is showing that it's sending but getting something other than 200 response that means your IPN script is failing. You can check your web server logs for details on exactly what the error is and get it resolved.
See http://forums.oscommerce.com/topic/395932-paypal-ipns-have-stopped-working-for-us-yesterday/
It seems it is sending extraneous data
I was logging the paypal response to the verification and it sends something around the important bit I record as
Content-Type: text/html; charset=UTF-8
-blank line-
8
VERIFIED
0

Paypal Sandbox IPN Simulator - Not getting response

I have used exactly same code from paypal and try to get response from IPN simulator from Payapl Sandbox. I have set up ipn.php file on my website where I will get IPN response and it has below code. Still I am not getting any mail for either VERIFIED or INVALID status as I stated in below code. So please let me know what is missing or what is wrong in my code so I can correct it.
<?php
$raw_post_data = file_get_contents('php://input');
$raw_post_array = explode('&', $raw_post_data);
$myPost = array();
foreach ($raw_post_array as $keyval) {
$keyval = explode ('=', $keyval);
if (count($keyval) == 2)
$myPost[$keyval[0]] = urldecode($keyval[1]);
}
$req = 'cmd=_notify-validate';
if(function_exists('get_magic_quotes_gpc')) {
$get_magic_quotes_exists = true;
}
foreach ($myPost as $key => $value) {
if($get_magic_quotes_exists == true && get_magic_quotes_gpc() == 1) {
$value = urlencode(stripslashes($value));
} else {
$value = urlencode($value);
}
$req .= "&$key=$value";
}
$ch = curl_init('https://www.sandbox.paypal.com/cgi-bin/webscr');
curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $req);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
curl_setopt($ch, CURLOPT_FORBID_REUSE, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Connection: Close'));
if( !($res = curl_exec($ch)) ) {
// error_log("Got " . curl_error($ch) . " when processing IPN data");
curl_close($ch);
exit;
}
curl_close($ch);
if (strcmp ($res, "VERIFIED") == 0) {
$item_name = $_POST['item_name'];
$item_number = $_POST['item_number'];
$payment_status = $_POST['payment_status'];
$payment_amount = $_POST['mc_gross'];
$payment_currency = $_POST['mc_currency'];
$txn_id = $_POST['txn_id'];
$receiver_email = $_POST['receiver_email'];
$payer_email = $_POST['payer_email'];
mail('mymailid#yahoo.com', 'PayPal IPN', 'Working...');
}
else if (strcmp ($res, "INVALID") == 0)
{
// log for manual investigation
mail('kra_14_05#yahoo.co.in', 'PayPal IPN', 'NOT Working...');
}
?>
I have tried to test using test merchant and buyer accounts in paypal sandbox. I can see IPN history under test merchant account. There I can see HTTP response code = 200 so I guess my ipn script is accessed by Paypal. $0.25 amount is debited from buyer account and deposited into merchant account so I guess that part is also working fine.
Now I have passed 2 values in single variable like.
<input type="hidden" name="custom" value="mem001::mempass001">
Then I am trying to receive values of "custom" variable on my ipn.php (ipn script is on this page) page. Using php functions I have separated both values and stored in different variables.
For testing purpose, I am trying to store above values in database but values are not stored into database.
So finally what wrong I am doing so far? And how can i make sure that I am really getting "VERIFIED" status from IPN after all above processes? Please help.
I would first start by checking your access logs and error logs on your server. Make sure your access logs show that PayPal is actually attempting to POST the data to your script. If the access logs show PayPal posting to your script, then check your error logs to see if there are any errors being generated.
Make sure your server, is configured to all inbound and out bound connections and that you don't have anything that would be blocking access to your system. Another option, would be to set this up on a test sandbox seller account and go through and make a purchase with a test sandbox seller account instead of using the simulator. The one plus side to this is that, when you go through the account and make a payment you will have a record of the IPN in your IPN history. You can then check to verify that PayPal was sending it out. It will also tell you if your server responded back with a 200ok response, or if your server returned a different status other than 200ok.
I have used the same script example that you are which is based on the script at https://www.x.com/developers/PayPal/documentation-tools/code-sample/216623 and this has worked for me in the past. If this doesn't help, let me know and I can try testing it with your script and pulling up one of my PHP scripts that send out an email.

Categories