Author Topic: Paypal ERROR checkPaypalIps: Error with REMOTE IP ADDRESS  (Read 13250 times)

sean_nwfs

  • Beginner
  • *
  • Posts: 37
  • A beginner
    • SymptoPro Fertility Education
Re: Paypal ERROR checkPaypalIps: Error with REMOTE IP ADDRESS
« Reply #75 on: October 29, 2019, 17:49:42 pm »
Struggling with the same issue. I spoke with Paypal and they sent this list: https://www.paypal.com/us/smarthelp/article/what-are-the-ip-addresses-for-live-paypal-servers-ts1056. Not sure if this might be useful to the devs.

I also appreciate the new feature in 3.6.4 for adding extra IPs for IPN Check.

Joomla 3.9.12
VM 3.6.4.10187
Joomla 3.9.12
VM 3.6.4 10187

StefanSTS

  • Global Moderator
  • Full Member
  • *
  • Posts: 517
  • VirtueMart Version: VM 4.2 on Joomla 4.5
Re: Paypal ERROR checkPaypalIps: Error with REMOTE IP ADDRESS
« Reply #76 on: October 29, 2019, 18:08:38 pm »
The first sentence in the link says what VirtueMart should do:
"When you make API calls, PayPal strongly recommends that you use Domain Name Service (DNS) results with the default Time To Live (TTL) values, to determine the IP addresses of our servers."

VirtueMart does that, and there is the issue with Paypal. Not all addresses are returned. That is why the IPN is rejected.

We will see how it goes on.

Thanks for your effort in communicating with Paypal. The more the merrier, someone the right support person might actually be able to help.

Regards
Stefan
--
Stefan Schumacher
www.jooglies.com - VirtueMart Invoice Layouts

Please use only stable versions with even numbers for your live shop! Use Alpha versions only if you know what risk you are taking.

sean_nwfs

  • Beginner
  • *
  • Posts: 37
  • A beginner
    • SymptoPro Fertility Education
Re: Paypal ERROR checkPaypalIps: Error with REMOTE IP ADDRESS
« Reply #77 on: October 29, 2019, 19:20:19 pm »
Again, not sure if this is helpful but they wrote back.

"If plugin can do an nslookup against the IP address (not the host name), you'll see that it resolves to notify.paypal.com, and as such, can be trusted & know the IPN came from a valid PayPal IP."

Not sure if the plugin can do that or not.

Thanks!
Joomla 3.9.12
VM 3.6.4 10187

Jörgen

  • Global Moderator
  • Full Member
  • *
  • Posts: 2425
    • Kreativ Fotografi
  • VirtueMart Version: 3.4.x
Re: Paypal ERROR checkPaypalIps: Error with REMOTE IP ADDRESS
« Reply #78 on: October 29, 2019, 21:04:51 pm »
Again, not sure if this is helpful but they wrote back.

"If plugin can do an nslookup against the IP address (not the host name), you'll see that it resolves to notify.paypal.com, and as such, can be trusted & know the IPN came from a valid PayPal IP."

Not sure if the plugin can do that or not.

Thanks!


Looks like the solution studio42 suggested earlier.

Jörgen @ Kreativ Fotografi
Joomla 3.9.8
Virtuemart 3.4.x
Olympiantheme Hera (customized)

ssc3

  • 3rd party VirtueMart Developer
  • Jr. Member
  • *
  • Posts: 150
    • Online Store Plugins
Re: Paypal ERROR checkPaypalIps: Error with REMOTE IP ADDRESS
« Reply #79 on: October 30, 2019, 09:40:26 am »
"If plugin can do an nslookup against the IP address (not the host name), you'll see that it resolves to notify.paypal.com, and as such, can be trusted & know the IPN came from a valid PayPal IP."


WorldPay also recommend using Reverse DNS lookup, it does not seem to cause the same problems PayPal is having with with lists of IP addresses.
Virtuemart Payment Plugins

https://plugins.online-store.co.uk

Milbo

  • Virtuemart Projectleader
  • Administrator
  • Super Hero
  • *
  • Posts: 9973
  • VM3.2 Cached and Optimized
    • VM3 Extensions
  • VirtueMart Version: VirtueMart 3 on joomla 3
Re: Paypal ERROR checkPaypalIps: Error with REMOTE IP ADDRESS
« Reply #80 on: November 01, 2019, 11:30:56 am »
So the solution is perhaps to mix the 2 codes because in some case the returned domaine is the IP itself !

Like that?
Code: [Select]
if ($this->_method->sandbox) {
$paypalHosts = array('ipn.sandbox.paypal.com','ipnpb.sandbox.paypal.com');
} else {
$paypalHosts = array('ipnpb.paypal.com','notify.paypal.com');
}

$paypal_iplist = array();
foreach($paypalHosts as $host){
$ipList = gethostbynamel($host);
$paypal_iplist = array_merge($paypal_iplist,$ipList);
}
if (isset($this->_method->extra_ips)){
$extraIps = explode(',',$this->_method->extra_ips);
$paypal_iplist = array_merge($paypal_iplist,$extraIps);
}

$this->debugLog($paypal_iplist, 'checkPaypalIps $paypal_iplist', 'debug', false);

$remoteIPAddress = ShopFunctions::getClientIP();
$hostname = gethostbyaddr($remoteIPAddress);
$this->debugLog($remoteIPAddress, 'checkPaypalIps REMOTE ADDRESS', 'debug', false);

//  test if the remote IP connected here is a valid IP address
if (!in_array($remoteIPAddress, $paypal_iplist) and !in_array($hostname, $paypalHosts)) {

$text = "Error with REMOTE IP ADDRESS = " . $remoteIPAddress . ".\n
                        The remote address of the script posting to this notify script does not match a valid PayPal IP address\n
            These are the valid IP Addresses: " . implode(",", $paypal_iplist) . "The Order ID received was: " . $order_number;
$this->debugLog($text, 'checkPaypalIps', 'error', false);
return false;
}
I should fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

Studio 42

  • Contributing Developer
  • Sr. Member
  • *
  • Posts: 4046
  • Joomla & Virtuemart developper
    • Studio 42 - Virtuemart & Joomla extentions
  • VirtueMart Version: 2.6 & 3
Re: Paypal ERROR checkPaypalIps: Error with REMOTE IP ADDRESS
« Reply #81 on: November 04, 2019, 11:58:02 am »
Yes,
i don't tested, but it's what i mean
So the solution is perhaps to mix the 2 codes because in some case the returned domaine is the IP itself !

Like that?
Code: [Select]
      if ($this->_method->sandbox) {
         $paypalHosts = array('ipn.sandbox.paypal.com','ipnpb.sandbox.paypal.com');
      } else {
         $paypalHosts = array('ipnpb.paypal.com','notify.paypal.com');
      }

      $paypal_iplist = array();
      foreach($paypalHosts as $host){
         $ipList = gethostbynamel($host);
         $paypal_iplist = array_merge($paypal_iplist,$ipList);
      }
      if (isset($this->_method->extra_ips)){
         $extraIps = explode(',',$this->_method->extra_ips);
         $paypal_iplist = array_merge($paypal_iplist,$extraIps);
      }

      $this->debugLog($paypal_iplist, 'checkPaypalIps $paypal_iplist', 'debug', false);

      $remoteIPAddress = ShopFunctions::getClientIP();
      $hostname = gethostbyaddr($remoteIPAddress);
      $this->debugLog($remoteIPAddress, 'checkPaypalIps REMOTE ADDRESS', 'debug', false);

      //  test if the remote IP connected here is a valid IP address
      if (!in_array($remoteIPAddress, $paypal_iplist) and !in_array($hostname, $paypalHosts)) {

         $text = "Error with REMOTE IP ADDRESS = " . $remoteIPAddress . ".\n
                        The remote address of the script posting to this notify script does not match a valid PayPal IP address\n
            These are the valid IP Addresses: " . implode(",", $paypal_iplist) . "The Order ID received was: " . $order_number;
         $this->debugLog($text, 'checkPaypalIps', 'error', false);
         return false;
      }

hegbi

  • Beginner
  • *
  • Posts: 22
Re: Paypal ERROR checkPaypalIps: Error with REMOTE IP ADDRESS
« Reply #82 on: November 04, 2019, 21:48:54 pm »
tested, Revision 10195 works, thank you!!