2
votes

I am using PayPal IPN Listener class which was working great for months, but recently (without any code changes) I received a weird issue.

The following code which validates the Instant Payment Notification throws an Exception: Invalid response status: 403

$listener = new IpnListener();
$listener->use_sandbox = PAYPAL_SANDBOX;

try {
    $listener->requirePostMethod();
    $verified = $listener->processIpn();
} catch (Exception $e) {
    error_log('Process IPN failed: ' . $e->getMessage() . " [".$_SERVER['REMOTE_ADDR']."] \n" . $listener->getResponse());
    exit(0);
}

The getResponse() method gives me this information:

HTTP/1.1 403 Forbidden
Server: AkamaiGHost
Mime-Version: 1.0
Content-Type: text/html
Content-Length: 284
Expires: Fri, 19 Sep 2014 08:06:58 GMT
Date: Fri, 19 Sep 2014 08:06:58 GMT
Connection: close
Strict-Transport-Security: max-age=63072000

<HTML><HEAD>
<TITLE>Access Denied</TITLE>
</HEAD><BODY>
<H1>Access Denied</H1>

You don't have permission to access "http://www.paypal.com/cgi-bin/webscr" on this server.<P>
Reference #18.682d1402.1411114018.180f58
</BODY>
</HTML>

I set the PayPal ExpressCheckout API calls with Angelleye library. It's not the most up-to-date version, but it was working just fine so far.

I am generating the link for Express Checkout payment and place it in the HTML. The user is going to PayPal (live and sandbox work the same) through the link, pays and successfully return to my "Thank you" page. The payment is received, but the IPN is failing.

Thanks in advance!

1
The error is pretty straight forward. PayPal's server simply does not have access to reach that URL...they're being denied. Have you setup an htaccess/htpasswd file or anything like that to protect your IPN directory by chance?Drew Angell
What is your action link on the <form>? It should be sandbox.paypal.com/cgi-bin/webscrMrD
Sounds like brain fart on Paypal's server to be honest. Have you tried resending the IPN through the account history? @AndrewAngell sounds more like his script is getting denied when access Paypal to validate the response.David Nguyen
Ah, I guess I read that backwards.Drew Angell
I have tried to send manually IPN from developer.paypal.com, but the result is the same. @Mr.M I am not using form. I am using Angelleye's library to generate the link for Express Checkout payment and place it as a link. The user is going to PayPal (live and sandbox work the same), pays and successfully return to my "Thank you" page. The payment is received, but the IPN is failing.Ivan Dokov

1 Answers

14
votes

Finally found the fix for this after speaking with PayPal Technical Support. It was an issue with something they have changed and are working to fix but to get it to work again you simply have to send a "User-Agent" HTTP Header with the Curl request, so something like:

curl_setopt($ch, CURLOPT_HTTPHEADER, array('Connection: Close', 'User-Agent: company-name'));

As for what the "User-Agent" should be set as, it just needs to be at least 5 characters, probably your company name as the example shows but it doesn't have to be.

The Technical Support agent also pointed me to: https://ppmts.custhelp.com/app/answers/detail/a_id/92 if the above fix does not work, but it did for me.

Access Denied on Paypal IPN verification