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); } }