Exemplo n.º 1
0
 public function actionPaymentSave()
 {
     $id = Yii::$app->request->get('id');
     $model = null;
     if (!empty($id)) {
         $model = UserAuthorizeNet::findOne($id);
     }
     if (is_null($model)) {
         $model = new UserAuthorizeNet();
     }
     $form = new CreditCardForm();
     $model->user_id = $this->getLoggedUser()->id;
     if ($form->load(Yii::$app->request->get()) && $form->validate() && $model->sendToAuthorize($form) && $model->save()) {
         $this->getShoppingCart()->payment_method = $model->id;
         $form = null;
         $id = null;
     }
     return $this->renderPartial('_sc_payment', ['model' => $form, 'id' => $id]);
 }