Beispiel #1
0
 public function actionPaypal($order_id = null)
 {
     $model = new PayPalForm();
     if ($order_id !== null) {
         $model->order_id = $order_id;
     }
     $order = Order::model()->findByPk($model->order_id);
     if ($order->customer->user_id != Yii::app()->user->id) {
         throw new CHttpException(403);
     }
     if ($order->status != 'new') {
         Shop::setFlash('The order is already paid');
         $this->redirect('//shop/products/index');
     }
     if (isset($_POST['PayPalForm'])) {
         $model->attributes = $_POST['PayPalForm'];
         if ($model->validate()) {
             echo $model->handlePayPal($order);
         }
     }
     $this->render('/order/paypal_form', array('model' => $model));
 }