A
A
Alexander Nevsky2018-11-28 10:26:14
Yii
Alexander Nevsky, 2018-11-28 10:26:14

How to connect notifications from Yandex money?

The site on yii2, made the usual form of payment through Yandex money. All rules pass. But you need to accept a notification via http about successful payment.
https://money.yandex.ru/myservices/online.xml here indicated the site " http://test.ru/balance/transaction/ya-create " indicated that it was necessary to notify. But after payment in general, nothing comes to this page. Did the usual check with a record in the database.

if ($_POST && $_POST['notification_type'])
            $sha1 = sha1( $_POST['notification_type'] . '&' .
                $_POST['operation_id']. '&' .
                $_POST['amount'] . '&643&' .
                $_POST['datetime'] . '&'.
                $_POST['sender'] . '&' .
                $_POST['codepro'] . '&' .
                $secret_key. '&' .
                $_POST['label'] );
else
            $sha1 = null;


if ($_POST && $_POST['sha1_hash'] && $sha1 == $_POST['sha1_hash']) {
            $model = new Transaction();
            $model->balance_id = Yii::$app->user->identity->id;
            $model->type = 'in';
            $model->amount = $_POST['amount'];
            $model->refill_type = '1';
            $model->comment = $_POST['comment'];
            $model->save;
} else {
            $model = new Transaction();
            $model->balance_id = 1;
            $model->type = 'out';
            $model->amount = 60;
            $model->refill_type = '1';
            $model->comment = 'Коммент';
            $model->save;
}

The joke is that even the lower else does not work, that is, nothing is written to the database at all. But when you just go to this page, then there is a record with else.
At the beginning of the controller, I put "public $enableCsrfValidation = false;", also nothing. Please help me to solve this issue.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question