public function onBeforeWrite()
 {
     parent::onBeforeWrite();
     $this->CallBackSlug = !$this->CallBackSlug ? 'worldpay' : $this->CallBackSlug;
     if (!$this->Summary) {
         $this->Summary = "Pay with credit/debit card securely via WorldPay";
     }
 }
 public function onBeforeWrite()
 {
     parent::onBeforeWrite();
     $this->CallBackSlug = !$this->CallBackSlug ? 'sagepay' : Convert::raw2url($this->CallBackSlug);
     if (!$this->Summary) {
         $this->Summary = "Pay with credit/debit card securely via SagePay";
     }
     if (!$this->GatewayMessage) {
         $this->GatewayMessage = "Thank you for your order from: " . SiteConfig::current_site_config()->Title;
     }
 }
 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());
     }
 }