XF 1.1 PayPal IPNs returning 500

Sumo

Active member
I figured it was XenForo setting the error based on the logs, but, is it doing that simply because it's not HTTPS?
Using HTTPS/SSL is what solved it for me. Can't hurt to try. If I remember correctly it was only 1 or 2 changes in the code.
 

Mopquill

Active member
Yeah, I believe we'll be trying that momentarily. I want to make sure I don't interrupt whatever Jake is doing, though.
 

Mopquill

Active member
Okay, I imagine Jake went to bed or something, but, I've got it working- though I don't think it was directly my changing of it to HTTPS that fixed it. The zip file I used for installation was called xenforo_1.1.2_<License #>_full.zip , just to clarify, this is indeed XenForo 1.1.2.

library/XenForo/UserUpgradeProcessor/Paypal.php:
Code:
            if ($this->_filtered['test_ipn'] && XenForo_Application::debugMode())
            {
                $validator = XenForo_Helper_Http::getClient('http://www.sandbox.paypal.com/cgi-bin/webscr');
            }
            else
            {
                $validator = XenForo_Helper_Http::getClient('http://www.paypal.com/cgi-bin/webscr');
            }
library/XenForo/ControllerPublic/Account.php:
Code:
        $viewParams = array(
            'available' => $upgradeModel->prepareUserUpgrades($purchaseList['available']),
            'purchased' => $upgradeModel->prepareUserUpgrades($purchaseList['purchased']),
            //'payPalUrl' => 'https://www.sandbox.paypal.com/cgi-bin/websrc',
            'payPalUrl' => 'https://www.paypal.com/cgi-bin/websrc',
        );
Take note of the HTTPS/HTTP and webscr/websrc in the PayPal URIs in the different files. I suspect it's this discrepancy between the two files leading to the issue- not to mention, near as my google searches can tell, /cgi-bin/websrc isn't a real paypal directory. Googling "PayPal /cgi-bin/websrc" without the quotes nets a bunch of pages, the first of which is PayPal's own /cgi-bin/webscr , the second XenForo (which I figured is no coincidence), and then some amateurish looking sites giving apparently incorrect instructions. I just re-downloaded 1.1.2 from XenForo's customer area, and verified that the same http/s webscr/websrc discrepancies are in those files. I'm not sure if 1.1.2 is the *newest* as I've let my license expire and haven't renewed it, but it's at the very least present in that version. I imagine Sumo copied the https link upon changing it, or that perhaps the websrc in Account.php doesn't matter. It's also possible that it does in fact need to be https- but either way, the problem is fixed on my end.

Thanks for all your help Jake, and thanks for what you've pointed out Sumo, which led to the solution. I didn't think you knew what you were talking about at first, so, I apologize if I came off a bit disbelieving.

EDIT: Just noticed the WYSIWYG Editor lied to me when it applied my bold/color tags inside the code tags. Post updated to remove plaintext BBCODE.
 

Mopquill

Active member
I've been tinkering with this more, and I figured I'd follow up on this. Near as I can tell, the URI in library/XenForo/ControllerPublic/Account.php *has* to be HTTPS, or the screen the user sees when directed to PayPal is just their account overview. The URIs in both Account.php *and* library/XenForo/UserUpgradeProcessor/Paypal.php seem to have to end with webscr , as websrc isn't an actual URI, as mentioned previously. The URI in PayPal.php has to be HTTPS as well, or validation of the IPN fails. My website does not need to be HTTPS, which is what I initially (mis?)understood Sumo to be saying. This has all only been tested with the PayPal sandbox, but considering that the sandbox is supposed to function just like real PayPal, I have no idea how anybody has upgrades working without edits.

For those that just want the fix, in library/XenForo/UserUpgradeProcessor/PayPal.php, find:
Code:
            if ($this->_filtered['test_ipn'] && XenForo_Application::debugMode())
            {
                $validator = XenForo_Helper_Http::getClient('http://www.sandbox.paypal.com/cgi-bin/webscr');
            }
            else
            {
                $validator = XenForo_Helper_Http::getClient('http://www.paypal.com/cgi-bin/webscr');
            }
and replace with:

Code:
            if ($this->_filtered['test_ipn'] && XenForo_Application::debugMode())
            {
                $validator = XenForo_Helper_Http::getClient('https://www.sandbox.paypal.com/cgi-bin/webscr');
            }
            else
            {
                $validator = XenForo_Helper_Http::getClient('https://www.paypal.com/cgi-bin/webscr');
            }

Next, in library/XenForo/Controller_Public/Account.php, find:
Code:
        $viewParams = array(
            'available' => $upgradeModel->prepareUserUpgrades($purchaseList['available']),
            'purchased' => $upgradeModel->prepareUserUpgrades($purchaseList['purchased']),
            //'payPalUrl' => 'https://www.sandbox.paypal.com/cgi-bin/websrc',
            'payPalUrl' => 'https://www.paypal.com/cgi-bin/websrc',
        );
and replace with:

Code:
        $viewParams = array(
            'available' => $upgradeModel->prepareUserUpgrades($purchaseList['available']),
            'purchased' => $upgradeModel->prepareUserUpgrades($purchaseList['purchased']),
            //'payPalUrl' => 'https://www.sandbox.paypal.com/cgi-bin/webscr',
            'payPalUrl' => 'https://www.paypal.com/cgi-bin/webscr',
        );
And that should fix upgrades, if they're not working.
 

lms

Well-known member
I've been tinkering with this more, and I figured I'd follow up on this. Near as I can tell, the URI in library/XenForo/ControllerPublic/Account.php *has* to be HTTPS, or the screen the user sees when directed to PayPal is just their account overview. ...

...

Next, in library/XenForo/Controller_Public/Account.php, find:
Rich (BB code):
        $viewParams = array(
            'available' => $upgradeModel->prepareUserUpgrades($purchaseList['available']),
            'purchased' => $upgradeModel->prepareUserUpgrades($purchaseList['purchased']),
            //'payPalUrl' => 'https://www.sandbox.paypal.com/cgi-bin/websrc',
            'payPalUrl' => 'https://www.paypal.com/cgi-bin/websrc',
        );
and replace with:

Rich (BB code):
        $viewParams = array(
            'available' => $upgradeModel->prepareUserUpgrades($purchaseList['available']),
            'purchased' => $upgradeModel->prepareUserUpgrades($purchaseList['purchased']),
            //'payPalUrl' => 'https://www.sandbox.paypal.com/cgi-bin/webscr',
            'payPalUrl' => 'https://www.paypal.com/cgi-bin/webscr',
        );
And that should fix upgrades, if they're not working.
This replacement is absurd. Are they the same or I do not see the difference? I see the same text.
EDIT: I see it.

Thanks and salud2
 
Top