Example #1
0
 public function confirm()
 {
     access::verify_csrf();
     $form = $this->getCheckoutForm();
     $valid = $form->validate();
     if ($valid) {
         $basket = Session_Basket::get();
         if (!isset($basket->contents) || count($basket->contents) == 0) {
             self::view_basket();
             return;
         }
         /* changed order for nl_NL */
         $basket->title = $form->contact->title->value;
         $basket->initials = $form->contact->initials->value;
         $basket->insertion = $form->contact->insertion->value;
         $basket->name = $form->contact->fullname->value;
         $basket->street = $form->contact->street->value;
         $basket->house = $form->contact->house->value;
         $basket->postcode = $form->contact->postcode->value;
         $basket->town = $form->contact->town->value;
         $basket->suburb = $form->contact->suburb->value;
         $basket->email = $form->contact->email->value;
         $basket->phone = $form->contact->phone->value;
         $basket->childname = $form->contact->childname->value;
         $basket->childgroup = $form->contact->childgroup->value;
         $basket->comments = $form->contact->comments->value;
         $basket->agreeterms = $form->contact->agreeterms->value;
         $paypal = $form->contact->paypal->value == "true";
         $template = new Theme_View("page.html", "basket");
         // NOT USED ===============================
         if ($paypal) {
             // create a prelimary order
             $order = basket::createOrder($basket, Order_Model::PAYMENT_PAYPAL);
             $paypal = new Paypal();
             // create the order first
             $view = new View("paypal_redirect.html");
             $view->form = $paypal->process($basket, url::site("basket/paypal_complete/{$order->id}", "http"), url::site("basket/paypal_cancel/{$order->id}", "http"), url::site("basket/paypal_ipn/{$order->id}", "http"));
             $template->content = $view;
             print $template;
             // redirect to paypal
             // NOT USED END ===============================
         } else {
             $form = new Forge("basket/complete", "", "post", array("id" => "confirm", "name" => "confirm"));
             $view = new View("confirm_order.html");
             $view->basket = $basket;
             $template->content = $view;
             $view->form = $form;
             print $template;
         }
     } else {
         die("Invalid confirmation!");
     }
 }
 public function complete()
 {
     access::verify_csrf();
     $basket = Session_Basket::get();
     if (!isset($basket->contents) || count($basket->contents) == 0) {
         self::view_basket();
         return;
     }
     $paypal = $basket->paypal;
     if ($paypal) {
         //paypal payment
         $template = new Theme_View("page.html", "basket", "confirm");
         // create a preliminary order
         $order = basket_plus::createOrder($basket, Bp_Order_Model::PAYMENT_PAYPAL);
         bp_order_log::log($order, Bp_Order_Log_Model::ORDERED);
         // send e-mails to customer and internal order handling
         basket_plus::send_order($order);
         // paypal stuff
         $paypal_payment = new Paypal();
         $view = new View("paypal_redirect.html");
         // here the functions to call after paypal processing are defined;
         // function 'process' redirects to the PayPal site (see library Paypal)
         $view->form = $paypal_payment->process($basket, url::site("basket_plus/paypal_complete/{$order->id}", "http"), url::site("basket_plus/paypal_cancel/{$order->id}", "http"), url::site("basket_plus/paypal_ipn/{$order->id}", "http"));
         $template->content = $view;
         print $template;
     } else {
         //offline payment
         // create order
         $order = basket_plus::createOrder($basket, Bp_Order_Model::PAYMENT_OFFLINE);
         bp_order_log::log($order, Bp_Order_Log_Model::ORDERED);
         $basket->clear();
         // send e-mails to customer and internal order handling
         basket_plus::send_order($order);
         // show page Order completed
         $this->_complete($order);
     }
 }