ExpressCheckout IPN Invalid response status 403

一笑奈何 提交于 2021-02-08 05:30:08

问题


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:


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



来源:https://stackoverflow.com/questions/25934880/expresscheckout-ipn-invalid-response-status-403

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!