public function actionErrorDispositionNotification()
 {
     spl_autoload_unregister(array('YiiBase', 'autoload'));
     require_once Yii::getPathOfAlias('ext') . "/yandex-money-payout/lib/autoload.php";
     spl_autoload_register(array('YiiBase', 'autoload'));
     $settings = new \YandexMoney\Settings();
     $settings->host = Yii::app()->params['yandexPayout']['host'];
     $settings->cert = Yii::app()->params['yandexPayout']['cert'];
     $settings->certPassword = Yii::app()->params['yandexPayout']['certPassword'];
     $settings->privateKey = Yii::app()->params['yandexPayout']['privateKey'];
     $settings->yaCert = Yii::app()->params['yandexPayout']['yaCert'];
     $provider = new PKCS7RequestProvider($settings);
     $api = new PayoutAPI($provider, Yii::app()->params['yandexPayout']['cardSynonimUrl']);
     $api->errorDepositionNotification(function ($request) {
         $result = new \YandexMoney\ErrorDepositionParams($request['clientOrderId']);
         $deposition = PayoutDeposition::model()->findByAttributes(array('clientOrderId' => $request['clientOrderId']));
         if ($deposition) {
             $deposition->status = PayoutDeposition::STATUS_REJECTED;
             $deposition->errors = $request['error'];
             $deposition->save();
             /**
              * @var PayoutTask $task
              */
             $task = $deposition->payoutTask;
             $task->status = PayoutTask::STATUS_FAILED;
             $task->save();
         }
         return $result;
     });
 }
 protected function updateTaskStatus(PayoutTask $task)
 {
     $count = PayoutDeposition::model()->count("payoutTaskId = {$task->id} AND status = '" . PayoutDeposition::STATUS_REJECTED . '\'');
     if ($count > 0) {
         $task->status = PayoutTask::STATUS_FAILED;
         $task->save();
         return $task;
     }
     $count = PayoutDeposition::model()->count("payoutTaskId = {$task->id} AND status = '" . PayoutDeposition::STATUS_IN_PROGRESS . '\'');
     if ($count > 0) {
         $task->status = PayoutTask::STATUS_IN_PROGRESS;
         $task->save();
         return $task;
     }
     $count = PayoutDeposition::model()->count("payoutTaskId = {$task->id} AND status = '" . PayoutDeposition::STATUS_DONE . '\'');
     if ($count > 0) {
         $task->status = PayoutTask::STATUS_DONE;
         $task->save();
         return $task;
     }
 }