Note that there are some explanatory texts on larger screens.

plurals
  1. POPaypal: Invalid IPN problem
    primarykey
    data
    text
    <p>Hi I know that there are many questions already in SO related to my problem but I have not got solution from any of them. I have implemented paypal. It is working well. Now I want to implement ipn in my paypal implementation. I have searched through and found some code. I have implemented that but I am getting invalid ipn. I can get all details from paypal transaction but for ipn it is always invalid. I have used following code in DoExpressCheckoutPayment.php file</p> <pre><code>$req = 'cmd=_notify-validate'; foreach ($_POST as $key =&gt; $value) { $value = urlencode(stripslashes($value)); $req .= "&amp;$key=$value"; } // post back to PayPal system to validate $header = "POST /cgi-bin/webscr HTTP/1.0\r\n"; // If testing on Sandbox use: $header .= "Host: www.sandbox.paypal.com:443\r\n"; //$header .= "Host: www.paypal.com:443\r\n"; $header .= "Content-Type: application/x-www-form-urlencoded\r\n"; $header .= "Content-Length: " . strlen($req) . "\r\n\r\n"; // If testing on Sandbox use: //$fp = fsockopen ('ssl://www.sandbox.paypal.com', 443, $errno, $errstr, 30); $fp =fsockopen('ssl://www.sandbox.paypal.com',443,$err_num,$err_str,30); echo('&lt;br&gt;'.$req); // 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'];*/ if (!$fp) { echo(' HTTP ERROR'); } else { fputs ($fp, $header . $req); while (!feof($fp)) { $res = fgets ($fp, 1024); echo('&lt;br&gt; res is '.$res); if (strcmp ($res, "VERIFIED") == 0) { // 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 $mail_From = "From: me@mybiz.com"; $mail_To = "xxxx@gmail.com"; $mail_Subject = "VERIFIED IPN"; $mail_Body = $req; foreach ($_SESSION as $key =&gt; $value) { $emailtext .= $key . " = " .$value ."\n\n"; } if(mail($mail_To, $mail_Subject, $emailtext . "\n\n" . $mail_Body, $mail_From)) echo('&lt;br&gt;mail 1 sent'); else echo('&lt;br&gt;mail1 not sent'); } else if (strcmp ($res, "INVALID") == 0) { // log for manual investigation $mail_From = "From: me@mybiz.com"; $mail_To = "xxx@gmail.com"; $mail_Subject = "INVALID IPN"; $mail_Body = $req; foreach ($_SESSION as $key =&gt; $value) { $emailtext .= $key . " = " .$value ."\n\n"; } if(mail($mail_To, $mail_Subject, $emailtext . "\n\n" . $mail_Body, $mail_From)) echo('&lt;br&gt;mail sent'); else echo('&lt;br&gt;not sent'); } } fclose ($fp); } </code></pre> <p>I am setting notify_url in other file which is directing to this file like this</p> <pre><code>&amp;lt;input type="hidden" name="notify_url" value="http://www.mysite.com/paypal/DoExpressCheckoutPayment.php"/&gt; </code></pre> <p>I am getting the following email:</p> <pre><code>**notify_url = http://www.mysite.com/paypal/DoExpressCheckoutPayment.php cmd=_notify-validate&amp;notify_url=http%3A%2F%2Fwww.mysite.com%2Fpaypal%2FDoExpressCheckoutPayment.php** </code></pre> <p><strong>One thing that I have notice that I am not getting any thing from $_POST. My $_POST is empty.</strong> Please tell me where I am wrong. Thanks</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload