示例#1
0
 /**
  * Creates a new Paylog model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Paylog(['scenario' => 'admin']);
     if ($model->load(Yii::$app->request->post()) && $model->validate()) {
         $user = User::findOne(['email' => $model->email]);
         $model->type = Paylog::PAY_IN;
         $model->status = Paylog::STATUS_PENDING;
         $model->user_id = $user->id;
         if ($model->save()) {
             //$merchant = Yii::$app->robokassa;
             $model->addBalance();
             Yii::$app->session->setFlash('success', 'Баланс пополнен');
             return $this->redirect($this->goHome());
             //return $merchant->payment($model->sum, $model->id, 'Пополнение счета', null, Yii::$app->user->identity->email);
             //return $this->redirect(['view', 'id' => $model->id]);
         }
     }
     return $this->render('create', ['model' => $model]);
 }