[ 'class' => VerbFilter::className(), 'actions' => [ ], ], 'access' => [ 'class' => AccessControl::className(), 'rules' => [ [ 'actions' => ['ipn'], 'allow' => true, 'roles' => ['?'], ], [ 'allow' => true, 'roles' => ['@'], 'matchCallback' => function ($rule, $action) { return Yii::$app->user->identity->status == USER::STATUS_ADMIN || Yii::$app->user->identity->status == USER::STATUS_BOULANGER; } ] ], ], ]; } /** * Lists all Produit models. * @return mixed */ public function actionIndex() { return $this->render('index', [ ]); } public function actionAnnuler() { return $this->render('annuler', [ ]); } public function actionSucces() { return $this->render('succes', [ ]); } public function beforeAction($action) { if(Yii::$app->controller->action->id=="ipn") $this->enableCsrfValidation = false; return parent::beforeAction($action); } public function actionIpn() { if (isset($_POST)) { $ipn = new PayPal_Ipn(false); if ($ipn->init()) { /* Get any key/value */ $custom = $ipn->getKeyValue('custom'); /* Add your code here */ $message = '' ; foreach($_POST as $key => $val) { $message .= $key.' : '.$val."\n" ; } mail('guillaume.bourgeois13@laposte.net','Données IPN', $message) ; } } /* Enable again if you use it */ Yii::$app->request->enableCsrfValidation = true; } }