コード例 #1
0
 public function actionRecharge()
 {
     if (!Yii::app()->user->isGuest) {
         $error = "";
         if (!empty($_POST["recharge_submit"])) {
             $newPlantRequest = new OrderRequest();
             $price = (int) $_POST["price"];
             if ($price > 0) {
                 $newPlantRequest->user_id = Yii::app()->user->id;
                 $newPlantRequest->type_id = 2;
                 $newPlantRequest->status_id = 2;
                 $newPlantRequest->date = time();
                 $newPlantRequest->amount = $price;
                 if ($newPlantRequest->save()) {
                     $this->redirect(SiteHelper::createUrl("/merchant/index", array("id" => $newPlantRequest->id)));
                 }
             } else {
                 $error = "Вы ввели не верную сумму";
             }
         }
         Yii::app()->page->title = "Пополнения счета";
         $this->render("recharge", array("error" => $error));
     } else {
         $this->redirect(SiteHelper::createUrl("/"));
     }
 }
コード例 #2
0
 /**
  * This is the default 'index' action that is invoked
  * when an action is not explicitly requested by users.
  */
 public function actionIndex()
 {
     if (!Yii::app()->user->isGuest) {
         Yii::app()->page->title = "Оплата";
         /*
                     if( $_POST["register_submit_button"] )
                     {
                         $gateway = Yii::app()->getComponent('payment')->getGateway('PaypalExpress');
                         $response = $gateway->setupPurchase(100, array(
                             'return_url' => $this->createAbsoluteUrl(
                                 '/payment/callback', array('success' => 1, 'order_id' => 1)
                             ),
                             'cancel_return_url' => $this->createAbsoluteUrl(
                                 '/payment/callback', array('failed'  => 1, 'order_id'  => 1)
                             ),
                             'items' => array(
                                 array(
                                     'description' => 'Bla bla',
                                     'unit_price'  => 100,
                                     'quantity'    => 1,
                                     'id'              => 1
                                 )
                             )
                         ));
                         if ($response->success()) {
                             $this->redirect($gateway->urlForToken($response->token()));
                         }
         
                 // payment controller::callback action
                 // IPN
                         if (isset($_REQUEST['success'], $_GET['token'], $_GET['PayerID'])) {
                             $gateway = Yii::app()->getComponent('payment')->getGateway('PaypalExpress');
                             $response = $gateway->get_details_for($_GET['token'], $_GET['PayerID']);
                             $response = $gateway->purchase($response->amount());
                             if ($response->success()) {
                                 // success payment
                             } else {
                                 //error payment
                             }
                         }
                     }*/
         $id = Yii::app()->request->getParam("id", 0);
         if ($id > 0) {
             $order = OrderRequest::fetch($id);
             if ($order->id > 0 && $order->del == 0) {
                 $this->render('index', array("controller" => $this, "model" => $order));
             }
         } else {
             $this->redirect(SiteHelper::createUrl("/user/requsets"));
         }
     }
 }