domenica 14 luglio 2013

Problema IPN PayPal, Magento ed eBay

Se si usa PayPal per ricevere pagamenti da ebay e dal proprio sito  ecommerce  le notifiche ebay inviate a magento vengono respinte e le notifiche vengono disabilitate.
Ecco la soluzione :
Copy everything between the <-start-> and <-end-> in order to create your null_ipn.php file.
Paste this text into a file named null_ipn.php in the root of your Magento web folder.
Go to PayPal and log in.  Next, select "My Account" on the tab.

Next, navigate to profile -> My Selling Tools -> Instant Payment Notifications -> Edit Settings.
For the "Notification URL", use the file that you just created http://iltuodominio.com/null_ipn.php
That's it.



IPNs received by Magento will be posted to your Magento orders and IPNs received by the null listener will send back a success message to PayPal.

No more disabled IPN every few days.

    <--------------start --------------------------="">
          // Revision Notes
          // 11/04/11 - changed post back url from https://www.paypal.com/cgi-bin/webscr to https://ipnpb.paypal.com/cgi-bin/webscr
          // For more info see below:
          // https://www.x.com/content/bulletin-ip-address-expansion-paypal-services
          // "ACTION REQUIRED: if you are using IPN (Instant Payment Notification) for Order Management and your IPN listener script is behind a firewall that uses ACL (Access Control List) rules which restrict outbound traffic to a limited number of IP addresses, then you may need to do one of the following:
          // To continue posting back to https://www.paypal.com  to perform IPN validation you will need to update your firewall ACL to allow outbound access to *any* IP address for the servers that host your IPN script
          // OR Alternatively, you will need to modify  your IPN script to post back IPNs to the newly created URL https://ipnpb.paypal.com using HTTPS (port 443) and update firewall ACL rules to allow outbound access to the ipnpb.paypal.com IP ranges (see end of message)."


          // read the post from PayPal system and add 'cmd'
          $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.1\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://ipnpb.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) {
          // 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
          // echo the response
          echo "The response from IPN was: " .$res ."

          ";

          //loop through the $_POST array and print all vars to the screen.

          foreach($_POST as $key => $value){
                  echo $key." = ". $value." ";
          }
          }
          else if (strcmp ($res, "INVALID") == 0) {
          // log for manual investigation

          // echo the response
          echo "The response from IPN was: " .$res ."";

            }

          }
          fclose ($fp);
          }


      <----------------end -----------------="">

    Nessun commento:

    Posta un commento