Quantcast
Channel: Live News for Yii Framework
Viewing all articles
Browse latest Browse all 2941

[Wiki] Using PayPal IPN with Yii2

$
0
0

I'm using PayPal's script from

https://github.com/paypal/ipn-code-samples/blob/master/paypal_ipn.php

To create IPN. I'm using Yii2 framework. In my sandbox account I'm trying to test IPN but I'm keep getting error:

We could not send an IPN due to an HTTP error: 400: Bad Request

It is not cookie problem because I tried to use different browsers.

I fixed it by adding:

public $enableCsrfValidation = false;

To my XYZController. It's not safe to do it, but it worked, I'm using different controllers just for IPN, so it's fine.

Or just add this code in your controller so you can easily disable CSRF

public function beforeAction($action) 
{
    if(Yii::$app->controller->action->id=="ipn")
        $this->enableCsrfValidation = false;
    return parent::beforeAction($action);
}

Read more here: Yii Forum


Viewing all articles
Browse latest Browse all 2941

Trending Articles