public function init() { parent::init(); // If no shopping cart doesn't exist, redirect to base if (!ShoppingCart::create()->getItems()->exists()) { return $this->redirect(ShoppingCart::config()->url_segment); } }
public function init() { parent::init(); // Check if payment slug is set and that corresponds to a payment if ($this->request->param('ID') && ($method = CommercePaymentMethod::get()->byID($this->request->param('ID')))) { $this->payment_method = $method; } elseif ($method = CommercePaymentMethod::get()->byID(Session::get('Commerce.PaymentMethodID'))) { $this->payment_method = $method; } // Setup payment handler if ($this->payment_method && $this->payment_method !== null) { $handler = $this->payment_method->ClassName; $handler = $handler::$handler; $this->payment_handler = $handler::create(); $this->payment_handler->setRequest($this->request); $this->payment_handler->setURLParams = $this->request->allParams(); $this->payment_handler->setPaymentGateway($this->getPaymentMethod()); } }