示例#1
0
 /**
  * Return additional paymet form
  * @return string
  * @param object|string $payment
  * @param string $template example: 'view', 'form', 'process' etc
  */
 public function paymentForm($paymentCode, $template)
 {
     if ($paymentCode instanceof Axis_Method_Payment_Model_Abstract) {
         $this->view->payment = $paymentCode;
         $paymentCode = $this->view->payment->getCode();
     } else {
         $this->view->payment = Axis_Payment::getMethod($paymentCode);
     }
     $shortPath = 'payment' . str_replace('_', '/', strtolower($paymentCode)) . '/' . $template . '.phtml';
     $fallbackList = array_unique(array($this->view->templateName, 'fallback', 'default'));
     foreach ($fallbackList as $fallback) {
         $templatePath = $this->view->path . '/app/design/' . $this->view->area . '/' . $fallback . '/templates';
         if (is_readable($templatePath . '/' . $shortPath)) {
             return $this->view->render($shortPath);
         }
     }
     return '';
 }
示例#2
0
 /**
  *
  * @param string $method
  * @param Axis_Sales_Model_Order_Row $order
  * @return mixed bool
  */
 protected function _paymentCallback($method, $order)
 {
     return Axis_Payment::getMethod($order->payment_method_code)->{$method}($order);
 }
示例#3
0
 /**
  *
  * @param $request shipping request
  * @return bool
  */
 public function isAllowed($request)
 {
     if (!empty($this->_config->minOrderTotal) && $request['price'] < $this->_config->minOrderTotal) {
         return false;
     }
     if (!empty($this->_config->maxOrderTotal) && $request['price'] > $this->_config->maxOrderTotal) {
         return false;
     }
     if (empty($this->_config->geozone) || !intval($this->_config->geozone)) {
         return true;
     }
     if (null !== $request['payment_method_code']) {
         $payment = Axis_Payment::getMethod($request['payment_method_code']);
         $disallowedShippingMethods = $payment->config()->shippings->toArray();
         if (in_array($this->getCode(), $disallowedShippingMethods)) {
             return false;
         }
     }
     if (empty($request['country']['id'])) {
         return true;
     }
     $zoneId = null;
     if (isset($request['zone']['id'])) {
         $zoneId = $request['zone']['id'];
     }
     return Axis::single('location/geozone_zone')->inGeozone($this->_config->geozone, $request['country']['id'], $zoneId);
 }
示例#4
0
 /**
  * Apply Payment method if possible
  *
  * @param mixed $data
  * @return void
  * @throws Axis_Exception
  */
 public function setPaymentMethod($data)
 {
     if (!is_array($data)) {
         $data = array('method' => $data);
     }
     if (empty($data['method'])) {
         return $this->setPaymentMethodCode(null);
     }
     if (!in_array($data['method'], Axis_Payment::getMethodNames())) {
         throw new Axis_Exception(Axis::translate('checkout')->__("'%s' method not found among installed modules", $data['method']));
     }
     $method = Axis_Payment::getMethod($data['method']);
     if (!$method instanceof Axis_Method_Payment_Model_Abstract || !$method->isEnabled() || !$method->isAllowed($this->getPaymentRequest())) {
         throw new Axis_Exception(Axis::translate('checkout')->__('Selected payment method is not allowed'));
     }
     $this->setPaymentMethodCode($data['method']);
     $this->_payment = $method;
     $this->payment()->saveData($data);
 }