Virtuemart 3.0.16 - Joomla 3.5.1 PayPal - Error with REMOTE IP ADDRESS

Started by tdbaker1956, May 11, 2016, 08:10:02 AM

Previous topic - Next topic

tdbaker1956

I've tested on 3 separate websites - all have the same issue. (Virtuemart 3.0.16 - Joomla 3.5.1) PHP 5.4 or higher. Linux/Apache webservers

PayPal Payments will not complete correctly.

In the PayPal log file (same on all 3 sites):
53.2016-05-11 05:25:14 DEBUG PaymentNotification, order_number:: B43A07
54.2016-05-11 05:25:14 DEBUG PaymentNotification, virtuemart_paymentmethod_id:: 3
55.2016-05-11 05:25:14 DEBUG checkPaypalIps PRODUCTION:
56.2016-05-11 05:25:14 DEBUG checkPaypalIps REMOTE ADDRESS: 173.0.81.1
57.2016-05-11 05:25:14 ERROR checkPaypalIps: Error with REMOTE IP ADDRESS = 173.0.81.1.
58.                        The remote address of the script posting to this notify script does not match a valid PayPal IP address
59.
60.            These are the valid IP Addresses: The Order ID received was: B43A07

As a result - even though PayPal accepts the payment and returns a valid PayPal IP (173.0.81.1) - the script is unable to validate the IP address to the array in /plugins/vmpayment/paypal/paypal/helpers/paypal.php
The order status is not changed to Confirmed or no emails issued.
In older logs where the validation process worked the line in the log checkPaypalIps PRODUCTION:  is followed by the word Array and then a full list of valid PayPal IP Addresses.

It seems something is stopping this array of valid PayPal IP addresses from being populated.

I've checked the "Proxy Server Issue" - its not that because it gets a valid PayPal IP address.
I've checked the "PDF" creation issue and the issue with Errors changing the Order Status.

It appears to be a bug in the PayPal plugin.

AH

I have tested using sandbox and am receiving a very similar error - I have asked for this to be looked at - to see what has changed
Regards
A

Joomla 4.4.5
php 8.1


AH

My error had nothing to do with VM

Testing on local server - my router was forwarding and due to IPtable settings was replacing the REMOTE_ADDR with a local IP address

Adjusted and IPN works as expected
Regards
A

Joomla 4.4.5
php 8.1

tdbaker1956

Quote from: franzpeter on May 11, 2016, 14:20:36 PM
I recommend to read that http://forum.virtuemart.net/index.php?topic=128518.0

I have previously read that post and read again (as well as every other post regarding PayPal)
The only thing that maybe applicable is the Reverse Proxy. All three websites are hosted by the same company - CrazyDomains. I have seen the word ngnix a few times in error messages - eg Time Out etc. It could well be that the couple times the PayPal IPN finished was when I had "uncommented" the code "Get IP address in environment with reverse proxy" in the /plugins/vmpayment/paypal/paypal/helpers/paypal.php file. This would have been over written during subsequent upgrades.

It seems that the current solution is to add a "Rev. Proxy Header" in the VirtueMart configuration page (Shop Tab - near bottom)
There isn't much documentation for this - not even what you should ask your hosting provider.
From a phpinfo file I added to one site I see a record HTTP_X_FORWARDED_FOR  and HTTP_X_REAL_IP
The question is - what value do I add in "Rev. Proxy Header"    X_FORWARDED_FOR or HTTP_X_FORWARDED_FOR  ?


tdbaker1956

I thought I should come back and report SUCCESS.
It turns out that Reverse Proxy was the issue.

After adding X_FORWARDED_FOR,X_REAL_IP to the  "Rev. Proxy Header" in the VirtueMart configuration page - the PayPal verification is now working. Orders Confirmed - Emails sent.

Note: This works if your webserver is using ngnix. other Proxy Servers???

It seams earlier versions of the plugin did the reverse proxy check by default - new versions require a value in "Rev. Proxy Header" in the VirtueMart configuration page to validation check function.

AH

Regards
A

Joomla 4.4.5
php 8.1