Search code examples
laraveltokenpaypal-ipnhttp-status-code-400

Laravel Paypal IPN with localtunnel randomly 400 Bad request


I use the PHP implementation found at Paypal.com.

I run php artisan serve to start the server.

Then i use localtunnel to make the server accessible through paypal.

The problem: I receive a ipn message, this message is sended back to paypal and than:

Sometimes the message gets VERIFIED and sometimes i receive a

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>400 Bad Request</title>
</head><body>
<h1>Bad Request</h1>
<p>Your browser sent a request that this server could not understand.<br />
</p>
</body></html>

If i resend the IPN from Paypal i receive nothing, only if i make payments the first time, i think the problem is that i receive the message via localtunnel and send it back from my laravel backend, so there are 2 different servers involved if i got it right.

How can i get it work 100% and why does it works even sometimes, if the approach is maybe wrong.


Solution

  • Does this 400 error occur when testing IPN in sandbox mode? If so, the issue is related to PayPal's recent sandbox migration to the cloud. For now, change the sandbox postback verification hostname from ipnpb to www:

    https://www.sandbox.paypal.com/cgi-bin/webscr