Ejemplo n.º 1
0
 /**
  * Lists all models.
  */
 public function actionIndex()
 {
     $model = new PurchasedPlan();
     $form = new PurchasePlanForm();
     if (isset($_POST['PurchasedPlan'])) {
         $form->attributes = $_POST['PurchasedPlan'];
         if ($form->validate()) {
             if ($_POST['PurchasedPlan']['realPayment'] == 0) {
                 //$form->purchasePlan($this->getPlanType());
                 $this->redirect(array('index'));
             } else {
                 $wl = WhiteLabel::model()->findByPk(Yii::app()->user->getWhiteLabelId());
                 if ($wl == null) {
                     throw new Exception("Account doesn't exist");
                 }
                 $plan = Plan::model()->findByAttributes(array('plan_id' => $form->plan_id, 'wlabel_id' => Yii::app()->user->getWhiteLabelId(), 'type' => $this->getPlanType()));
                 if ($plan == null) {
                     throw new Exception("Plan doesn't exist");
                 }
                 if ($wl->payment_type == PaymentType::TYPE_PAYPAL) {
                     $this->processPayPalPayment($wl, $plan);
                 } else {
                     if ($wl->payment_type == PaymentType::TYPE_AUTHORIZENET) {
                         $this->processAuthnetPayment($wl, $plan);
                     }
                 }
                 exit;
             }
         }
     }
     if (isset($_GET['PurchasedPlan'])) {
         $model->attributes = $_GET['PurchasedPlan'];
     }
     $this->render('index', array('model' => $model, 'planType' => $this->getPlanType()));
 }
Ejemplo n.º 2
0
 /**
  * Lists all models.
  */
 public function actionIndex()
 {
     $model = new PurchasedPlan();
     $form = new PurchasePlanForm();
     if (isset($_POST['PurchasedPlan'])) {
         $form->attributes = $_POST['PurchasedPlan'];
         //echo "AP: ".$form->advertiser_id."|";
         ///print_r($_POST['PurchasedPlan']);
         //exit;
         if ($form->validate()) {
             //echo "AP: ".$form->advertiser_id."|";
             $form->purchasePlan($this->getPlanType(), $form->advertiser_id);
             $this->redirect(array('index'));
         }
     }
     if (isset($_GET['PurchasedPlan'])) {
         $model->attributes = $_GET['PurchasedPlan'];
     }
     $this->render('index', array('model' => $model, 'planType' => $this->getPlanType()));
 }