Forum Replies Created

Viewing 7 replies - 1 through 7 (of 7 total)
  • Sorry about the testing, but I need the code to come through OK.

    Anyway, the problem is solved. You will need to have compiled in curl support when you built PHP. I’m not sure if this will work on Windows or not.

    This solution assumes the following: That you are on a Linux or Unix system, and have access to the GNU version of the patch program.

    First, copy the following into a file called paypal.php.diff in your home directory on the server:

    *** stock/paypal.php	2009-10-23 20:17:17.000000000 -0700
    --- live/paypal.php	2009-10-23 20:17:17.000000000 -0700
    ***************
    *** 35,41 ****
      #the emails will be coming from
      $from_email = $dplus['ty_email'];
    
    -
      # Convert Super globals For backward compatibility
      if(phpversion() <= "4.0.6")  { $_POST = ($HTTP_POST_VARS);  }
    
    --- 35,40 ----
    ***************
    *** 62,72 ****
      ## Verify Mode 1: This will post the IPN variables to the Paypal Network for Validation
                  if     ($verifymode == 1)
                  {
    ! $port = fsockopen ("paypal.com", 80, $errno, $errstr, 30);
    ! $header = "POST /cgi-bin/webscr HTTP/1.0\r\n".
    ! "Host: www.paypal.com\r\n".
    ! "Content-Type: application/x-www-form-urlencoded\r\n".
    ! "Content-Length: " . strlen($postipn) . "\r\n\r\n";
                  }
      ## Verify Mode 2: This will post the IPN variables to Belahost Test Script for validation
      ## Located at www.belahost.com/pp/index.php
    --- 61,80 ----
      ## Verify Mode 1: This will post the IPN variables to the Paypal Network for Validation
                  if     ($verifymode == 1)
                  {
    !
    ! # Old PP code
    ! # $port = fsockopen ("paypal.com", 80, $errno, $errstr, 30);
    ! #$header = "POST /cgi-bin/webscr HTTP/1.0\r\n".
    ! #"Host: www.paypal.com\r\n".
    ! #"Content-Type: application/x-www-form-urlencoded\r\n".
    ! #"Content-Length: " . strlen($postipn) . "\r\n\r\n";
    !
    ! # New PP code
    ! # Still open the port, since there is error checking code around this
    ! # Although you can't actually do anything via 443 without encryption
    ! $port = fsockopen ("www.paypal.com", 443, $errno, $errstr, 30);
    ! $postURL = "https://www.paypal.com/cgi-bin/webscr";
    !
                  }
      ## Verify Mode 2: This will post the IPN variables to Belahost Test Script for validation
      ## Located at www.belahost.com/pp/index.php
    ***************
    *** 105,118 ****
    
      # If No Errors to this point then we proceed with the processing.
      # Open port to paypal or test site and post Varibles.
                  else
               {
    ! 			fputs ($port, $header . $postipn);
    !             while (!feof($port))
    ! 				    {
    !                    $reply = fgets ($port, 1024);
    !                    $reply = trim ($reply);
    !                     }
    
      # Prepare a Debug Report
      $ipnreport = $orgipn . "<br /><b>" . "IPN Reply: " . $reply . "</b>";
    --- 113,136 ----
    
      # If No Errors to this point then we proceed with the processing.
      # Open port to paypal or test site and post Varibles.
    +
    + # New PP code to deal with SSL
                  else
               {
    !             if     ($verifymode == 1)
    !             {
    !                 $reply = httpsPost($postURL, $postipn);
    !             }
    !
    !             else
    !             {
    ! 	        fputs ($port, $header . $postipn);
    !                 while (!feof($port))
    ! 		{
    !                   $reply = fgets ($port, 1024);
    !                   $reply = trim ($reply);
    !                 }
    !             }
    
      # Prepare a Debug Report
      $ipnreport = $orgipn . "<br /><b>" . "IPN Reply: " . $reply . "</b>";
    ***************
    *** 333,336 ****
      *   for you contact http://www.belahost.com/contact.php *
      ********************************************************/
    
    ! ?>
    \ No newline at end of file
    --- 351,377 ----
      *   for you contact http://www.belahost.com/contact.php *
      ********************************************************/
    
    ! # This is the added code for dealing with HTTPS posting to PayPal via curl
    ! # Posting via HTTP is no longer supported
    ! function httpsPost($Url, $strRequest)
    ! {
    !    // Initialization
    !    $ch=curl_init();
    !    // Set parameters
    !    curl_setopt($ch, CURLOPT_URL, $Url);
    !    // Return a variable instead of posting it directly
    !    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    !    // Active the POST method
    !    curl_setopt($ch, CURLOPT_POST, 1) ;
    !    // Request
    !    curl_setopt($ch, CURLOPT_POSTFIELDS, $strRequest);
    !    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
    !    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
    !    // execute the connection
    !    $result = curl_exec($ch);
    !    // Close it
    !    curl_close($ch);
    !    return $result;
    ! }
    !
    ! ?>

    Next, copy the following into a file called donate-plus.php.diff in your home directory on the server:

    *** stock/donate-plus.php	2009-10-23 20:20:53.000000000 -0700
    --- live/donate-plus.php	2009-10-23 20:20:53.000000000 -0700
    ***************
    *** 345,351 ****
      				$tyurl = $wall.'?thankyou=true';
      			else
      				$tyurl = $wall.'&thankyou=true';
    ! 			$output = '<form id="donateplusform" action="http://www.paypal.com/cgi-bin/webscr" method="post">';
      			//$output = '<form id="donateplusform" action="http://www.belahost.com/pp/" method="post">';
    
    --- 345,352 ----
      				$tyurl = $wall.'?thankyou=true';
      			else
      				$tyurl = $wall.'&thankyou=true';
    !                         $output = '<form id="donateplusform" action="https://www.paypal.com/cgi-bin/webscr" method="post">';
    ! 			//$output = '<form id="donateplusform" action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post">';
      			//$output = '<form id="donateplusform" action="http://www.belahost.com/pp/" method="post">';
    
    ***************
    *** 559,562 ****
      	global $donateplus;
      	echo $donateplus->DonateTotal();
      }
    ! ?>
    \ No newline at end of file
    --- 560,563 ----
      	global $donateplus;
      	echo $donateplus->DonateTotal();
      }
    ! ?>

    Now, assuming you are on Linux/Unix, and have the GNU version of the patch program (necessary), then cd to (WP install dir)/wp-content/plugins/donate-plus, and run the following commands:

    cp -p paypal.php paypal.php.bak
    cp -p donate-plus.php donate-plus.php.bak
    patch -p1 -i ~/paypal.php.diff paypal.php
    patch -p1 -i ~/donate-plus.php.diff donate-plus.php

    That’s it. You will probably want to verify that the live/testing settings in paypal.php are still what you want, and that the host to POST to in donate-plus.php is set properly as well.

    Sorry about the testing, but I need the code to come through OK.

    Anyway, the problem is solved. You will need to have compiled in curl support when you built PHP. I’m not sure if this will work on Windows or not.

    This solution assumes the following: That you are on a Linux or Unix system, and have access to the GNU version of the patch program.

    First, copy the following into a file called paypal.php.diff in your home directory on the server:

    *** stock/paypal.php	2009-10-23 20:17:17.000000000 -0700
    --- live/paypal.php	2009-10-23 20:17:17.000000000 -0700
    ***************
    *** 35,41 ****
      #the emails will be coming from
      $from_email = $dplus['ty_email'];
    
    -
      # Convert Super globals For backward compatibility
      if(phpversion() <= "4.0.6")  { $_POST = ($HTTP_POST_VARS);  }
    
    --- 35,40 ----
    ***************
    *** 62,72 ****
      ## Verify Mode 1: This will post the IPN variables to the Paypal Network for Validation
                  if     ($verifymode == 1)
                  {
    ! $port = fsockopen ("paypal.com", 80, $errno, $errstr, 30);
    ! $header = "POST /cgi-bin/webscr HTTP/1.0\r\n".
    ! "Host: www.paypal.com\r\n".
    ! "Content-Type: application/x-www-form-urlencoded\r\n".
    ! "Content-Length: " . strlen($postipn) . "\r\n\r\n";
                  }
      ## Verify Mode 2: This will post the IPN variables to Belahost Test Script for validation
      ## Located at www.belahost.com/pp/index.php
    --- 61,80 ----
      ## Verify Mode 1: This will post the IPN variables to the Paypal Network for Validation
                  if     ($verifymode == 1)
                  {
    !
    ! # Old PP code
    ! # $port = fsockopen ("paypal.com", 80, $errno, $errstr, 30);
    ! #$header = "POST /cgi-bin/webscr HTTP/1.0\r\n".
    ! #"Host: www.paypal.com\r\n".
    ! #"Content-Type: application/x-www-form-urlencoded\r\n".
    ! #"Content-Length: " . strlen($postipn) . "\r\n\r\n";
    !
    ! # New PP code
    ! # Still open the port, since there is error checking code around this
    ! # Although you can't actually do anything via 443 without encryption
    ! $port = fsockopen ("www.paypal.com", 443, $errno, $errstr, 30);
    ! $postURL = "https://www.paypal.com/cgi-bin/webscr";
    !
                  }
      ## Verify Mode 2: This will post the IPN variables to Belahost Test Script for validation
      ## Located at www.belahost.com/pp/index.php
    ***************
    *** 105,118 ****
    
      # If No Errors to this point then we proceed with the processing.
      # Open port to paypal or test site and post Varibles.
                  else
               {
    ! 			fputs ($port, $header . $postipn);
    !             while (!feof($port))
    ! 				    {
    !                    $reply = fgets ($port, 1024);
    !                    $reply = trim ($reply);
    !                     }
    
      # Prepare a Debug Report
      $ipnreport = $orgipn . "<br /><b>" . "IPN Reply: " . $reply . "</b>";
    --- 113,136 ----
    
      # If No Errors to this point then we proceed with the processing.
      # Open port to paypal or test site and post Varibles.
    +
    + # New PP code to deal with SSL
                  else
               {
    !             if     ($verifymode == 1)
    !             {
    !                 $reply = httpsPost($postURL, $postipn);
    !             }
    !
    !             else
    !             {
    ! 	        fputs ($port, $header . $postipn);
    !                 while (!feof($port))
    ! 		{
    !                   $reply = fgets ($port, 1024);
    !                   $reply = trim ($reply);
    !                 }
    !             }
    
      # Prepare a Debug Report
      $ipnreport = $orgipn . "<br /><b>" . "IPN Reply: " . $reply . "</b>";
    ***************
    *** 333,336 ****
      *   for you contact http://www.belahost.com/contact.php *
      ********************************************************/
    
    ! ?>
    \ No newline at end of file
    --- 351,377 ----
      *   for you contact http://www.belahost.com/contact.php *
      ********************************************************/
    
    ! # This is the added code for dealing with HTTPS posting to PayPal via curl
    ! # Posting via HTTP is no longer supported
    ! function httpsPost($Url, $strRequest)
    ! {
    !    // Initialization
    !    $ch=curl_init();
    !    // Set parameters
    !    curl_setopt($ch, CURLOPT_URL, $Url);
    !    // Return a variable instead of posting it directly
    !    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    !    // Active the POST method
    !    curl_setopt($ch, CURLOPT_POST, 1) ;
    !    // Request
    !    curl_setopt($ch, CURLOPT_POSTFIELDS, $strRequest);
    !    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
    !    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
    !    // execute the connection
    !    $result = curl_exec($ch);
    !    // Close it
    !    curl_close($ch);
    !    return $result;
    ! }
    !
    ! ?>

    Next, copy the following into a file called donate-plus.php.diff in your home directory on the server:

    *** stock/donate-plus.php	2009-10-23 20:20:53.000000000 -0700
    --- live/donate-plus.php	2009-10-23 20:20:53.000000000 -0700
    ***************
    *** 345,351 ****
      				$tyurl = $wall.'?thankyou=true';
      			else
      				$tyurl = $wall.'&thankyou=true';
    ! 			$output = '<form id="donateplusform" action="http://www.paypal.com/cgi-bin/webscr" method="post">';
      			//$output = '<form id="donateplusform" action="http://www.belahost.com/pp/" method="post">';
    
    --- 345,352 ----
      				$tyurl = $wall.'?thankyou=true';
      			else
      				$tyurl = $wall.'&thankyou=true';
    !                         $output = '<form id="donateplusform" action="https://www.paypal.com/cgi-bin/webscr" method="post">';
    ! 			//$output = '<form id="donateplusform" action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post">';
      			//$output = '<form id="donateplusform" action="http://www.belahost.com/pp/" method="post">';
    
    ***************
    *** 559,562 ****
      	global $donateplus;
      	echo $donateplus->DonateTotal();
      }
    ! ?>
    \ No newline at end of file
    --- 560,563 ----
      	global $donateplus;
      	echo $donateplus->DonateTotal();
      }
    ! ?>

    Now, assuming you are on Linux/Unix, and have the GNU version of the patch program (necessary), then cd to (WP install dir)/wp-content/plugins/donate-plus, and run the following commands:

    cp -p paypal.php paypal.php.bak
    cp -p donate-plus.php donate-plus.php.bak
    patch -p1 -i ~/paypal.php.diff paypal.php
    patch -p1 -i ~/donate-plus.php.diff donate-plus.php

    That’s it. You will probably want to verify that the live/testing settings in paypal.php are still what you want, and that the host to POST to in donate-plus.php is set properly as well.

    testing
    
    123456
    foo
    foo

    testing


    123456
    foo
    foo

    testing

    code
    123456
    foo
    foo
    /code

    I have found out that this problem is because PP has now put up a 301 redirect to https://www.paypal.com/cgi-bin/webscr from the http version.

    Since the script only posts via unencrypted http, it fails because it can’t submit to the redirect, and has no smarts to submit via SSL.

    I’m working on modifications to the paypal.php script that will use libcurl (linux/unix) to post the IPN reply via SSL.

    Ditto with problems.

    I was able to test to the Belahost.com site and veryfy IPN success with the PP sandbox, but I can’t get the real PP to give back a valid IPN.

    They must have changed something at PP.

    Help!

Viewing 7 replies - 1 through 7 (of 7 total)