public function executeCoursePurchase(sfWebRequest $request)
 {
     global $CFG;
     $this->authorizePurchaseOnEschool();
     if (!$request->isMethod(sfRequest::POST)) {
         $this->redirect($CFG->current_app->getUrl());
     }
     $form = $request->getPostParameters();
     if ($this->useChainedPayment($request)) {
         $current_user = $CFG->current_app->getCurrentUser();
         $user = $current_user->getUserOnInstitution();
         $purchase_transaction = new GCPurchasePaypalCourseChained($form, $user);
         $url = $purchase_transaction->attemptPaypalTransaction();
         if ($url) {
             $this->redirect($url);
         }
     }
     // If the chained payment failed for some reason, we default to standard the
     // Website Payment Pro method.
     $this->form = new GcrPurchaseForm();
     $current_user1 = $CFG->current_app->getCurrentUser();
     $user1 = $current_user1->getUserOnInstitution();
     $get_product_type_id = GcrProductsTable::getProductType($CFG->current_app->getShortName(), $user1->getApp()->getShortName());
     $this->form->setDefaults(array('purchase_type' => $form['type'], 'purchase_type_id' => $form['type_id'], 'purchase_type_eschool_id' => $CFG->current_app->getShortName(), 'product_short_name' => "", 'product_type_id' => $get_product_type_id, 'bill_cycle' => 'single', 'purchase_token' => $form['purchase_token']));
     // set up object which hold info about the purchase item to display on form
     $this->purchaseObject = new Object();
     $this->hydratePurchaseObject($this->purchaseObject, $form['type'], $form['type_id'], $CFG->current_app->getShortName());
     $this->getResponse()->setTitle('Course Purchase');
 }