Micael Sousa
Micael Sousa

Reputation: 1169

Paypal's IPN Simulator using Laravel 5

I'm about to go mental with this problem, I'm implementing an IPN system in my app and started doing tests now using Paypal's IPN Simulator.

When I try to send an IPN simulation, it just gives the following error:

We're sorry, but there's an HTTP error. Please try again.

First thought - Paypal's service was down - Tested wrong since if I create a blank page and send an IPN message to http://myDNS.com/blankpage.php it is able to send it.

Second thought - Problem with routes - which I think it's not the problem either:

Here's my IPN Listener at the PurchaseController.php:

public function completed()
{
    //FAHIM's Paypal IPN Listener

    $ipn = new PaypalIPNListener();
    $ipn->use_sandbox = true;

    $verified = $ipn->processIpn();

    $report = $ipn->getTextReport();

    Log::info("-----new payment-----");

    Log::info($report);

    if ($verified) {
        if($_POST['address_status'] == 'confirmed'){
            //sucess
        }
    }
}

In routes.php :

Route::post('purchase/completed/', array('as' => 'purchase.completed', 'uses' => 'PurchaseController@completed'));

Is there any known problems associated with IPN Simulator and Laravel?

Thank you in advance.

Upvotes: 2

Views: 1602

Answers (1)

Micael Sousa
Micael Sousa

Reputation: 1169

Looks like I found the answer! The problem was that a tokenMismatchException was being thrown whenever Paypal tried to send the POST information.

For people with the same problem, here's the solution:

Add an exception into the VerifyCsrfToken.php Middleware, so that the exception URI won't need the CsrfToken verification:

In my case, it looks something like this:

protected $except = [
    'purchase/completed'
];

I'm working with Laravel 5, so please keep in mind that it might be slightly different in lower versions.

Upvotes: 8

Related Questions