paypal / ipn-code-samples

Other
562 stars 486 forks source link

Not receiving any data from IPN post data #131

Closed amielantonio closed 6 years ago

amielantonio commented 6 years ago

General information

Issue description

Hi, I'm using the code samples for php and I was wondering why there is no data that is being sent by the IPN. i'm getting a green light using the simulator but I can't seem to receive any transaction data back from the IPN. I'm simply emailing the response back to my gmail account, I also tried saving the data to the database but still no response was saved.

<?php
//--------------------
$ipn = new PaypalIPN();
// Use the sandbox endpoint during testing.
$ipn->useSandbox();
$verified = $ipn->verifyIPN();

if ($verified) {

    $subject = 'Instant Payment Notification - Received Payment';
    $to = 'amielnicole.antonio@gmail.com';    //  your email
    $body = "An instant payment notification was successfully received\n";
    $body .= "from amielnicole.antonio@gmail.com " . date('m/d/Y');
    $body .= " at " . date('g:i A') . "\n\nDetails:\n";
    foreach ($_POST as $key => $value) {
        $body .= "\n$key: $value";
    }
    mail($to, $subject, $body);
    //Reply with an empty 200 response to indicate to paypal the IPN was received correctly.
    header("HTTP/1.1 200 OK");
}
overint commented 6 years ago

Can you check the server access/error logs to see if the paypal is correctly hitting the page without errors? It seems like something is blocking the request between your server & paypal.

amielantonio commented 6 years ago

173.0.82.126 - - [01/May/2018:09:09:37 -0500] "POST /paypal-processor HTTP/1.1" 200 808 "-" "PayPal IPN ( https://www.paypal.com/ipn )"

This is the log that I got from the access log.

no errors from the error log.

amielantonio commented 6 years ago

does the IPN only work for websites that are under https:// protocol? i'm currently using a non https for the testing website.

overint commented 6 years ago

Ok, then there is an issue with your script. The IPN should work fine on non https. Can you try something like this?

<?php
$ipn = new PaypalIPN();
// Use the sandbox endpoint during testing.
$ipn->useSandbox();
$verified = $ipn->verifyIPN();

file_put_contents('ipn.json', json_encode([
    'verified' => $verified,
    'post' => $_POST
]));

And then send us the content of ipn.json

amielantonio commented 6 years ago

Hi, i think I solved the problem...

I tried to do a Post request to my script using Advanced Rest Client. and found out that it was throwing a curl error[77]. I updated my Certs and now I'm receiving the email response. I'll try to do some more testing so that I can verify that this was causing the issue. Thanks for the help

overint commented 6 years ago

No worries, strange that the response was a 200 if there was an error.