/**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     if ($this->scenario === 'moderate') {
         $query = PaymentsTransaction::find();
     } else {
         $query = PaymentsTransaction::find()->asSalon();
     }
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'rentact_id' => $this->rentact_id, 'amount' => $this->amount, 'amount_all' => $this->amount_all, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at]);
     $query->andFilterWhere(['like', 'operation_id', $this->operation_id])->andFilterWhere(['like', 'datetime', $this->datetime])->andFilterWhere(['like', 'time', $this->time])->andFilterWhere(['like', 'sender', $this->sender])->andFilterWhere(['like', 'pay_out', $this->pay_out])->andFilterWhere(['like', 'data_log', $this->data_log]);
     return $dataProvider;
 }
 protected function findModel($id)
 {
     if (($model = PaymentsTransaction::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Esempio n. 3
0
 public function actionYandexPay()
 {
     //https://sp-money.yandex.ru/myservices/online.xml
     /*
     $_POST = array (
         'notification_type' => 'p2p-incoming',
         'amount' => '10.50',
         'withdraw_amount' => '10.50',
         'datetime' => '2015-11-03T14:50:54Z',
         'codepro' => 'false',
         'sender' => '41001000040',
         'sha1_hash' => 'd65c3ae9fd476450697552a7cbb842f660eba555',
         'test_notification' => 'true',
         'operation_label' => '',
         'operation_id' => 'test-notification',
         'currency' => '643',
         'label' => '',
     );
     
     $_POST['test_notification'] = true;
     */
     $secret_key = Yii::$app->params['yandexSecretKey'];
     $sha1 = '';
     if (!empty($_POST)) {
         $sha1 = sha1($_POST['notification_type'] . '&' . $_POST['operation_id'] . '&' . $_POST['amount'] . '&643&' . $_POST['datetime'] . '&' . $_POST['sender'] . '&' . $_POST['codepro'] . '&' . $secret_key . '&' . $_POST['label']);
         $rentactId = intval($_POST['label']);
         // Записываем номер брони Rentact
         if (isset($_POST['test_notification'])) {
             $_POST['currency'] = '643';
             $_POST['sha1_hash'] = $sha1;
             $rentactId = 119;
         }
         if ($_POST['currency'] !== '643') {
             exit;
         }
         if ($sha1 !== $_POST['sha1_hash'] or !$rentactId) {
             exit;
         } else {
             $Transaction = PaymentsTransaction::findOne(['rentact_id' => $rentactId]);
             if (!empty($Transaction)) {
                 exit;
                 //нашли оплату выходим
             }
             // тут код на случай, если проверка прошла успешно
             $Transaction = new PaymentsTransaction();
             // Модель транзакции оплаты
             $Transaction->rentact_id = $rentactId;
             // Записываем номер брони Rentact
             $Transaction->operation_id = $_POST['operation_id'];
             // Номер операции в системе Яндекса (varchar)
             $Transaction->amount = $_POST['amount'];
             // Сумма за вычетом комиссии (float)
             //                    $Transaction->amount_all = $_POST['withdraw_amount']; // Полный размер оплаты (float)
             $Transaction->amount_all = $_POST['withdraw_amount'];
             // Полный размер оплаты (float)
             $Transaction->sender = $_POST['sender'];
             // Полный размер оплаты (float)
             $Transaction->datetime = $_POST['datetime'];
             // дата транзакции в формате 2015-10-28T17:49:52Z (varchar)
             $Transaction->pay_out = '1';
             // Статус выплат владельцу 1 - не выплачено. 2 - выплачено
             $errors = $Transaction->createPaymentTransaction();
             if (!empty($errors)) {
                 $errors = var_export($errors, true);
                 SystemLogs::WriteAccessLog($errors);
             }
         }
         exit;
     }
 }