Example #1
0
 public function getPaymentHtml(Varien_Object $payment)
 {
     if ($block = $this->getPaymentRenderer($payment->getMethod())) {
         $block->setPayment($payment);
         return $block->toHtml();
     }
     return '';
 }
Example #2
0
 /**
  * Import data
  *
  * @param   array $data
  * @return  Mage_Sales_Model_Quote_Payment
  */
 public function importData(array $data)
 {
     $data = new Varien_Object($data);
     $this->setMethod($data->getMethod());
     $method = $this->getMethodInstance();
     $method->assignData($data);
     /*
      * validating the payment data
      */
     $method->validate();
     return $this;
 }
Example #3
0
 /**
  * Import data
  *
  * @param   array $data
  * @return  Mage_Sales_Model_Quote_Payment
  */
 public function importData(array $data)
 {
     $data = new Varien_Object($data);
     Mage::dispatchEvent($this->_eventPrefix . '_import_data_before', array($this->_eventObject => $this, 'input' => $data));
     $this->setMethod($data->getMethod());
     $method = $this->getMethodInstance();
     $method->assignData($data);
     /*
      * validating the payment data
      */
     $method->validate();
     return $this;
 }
Example #4
0
 /**
  * Import data
  *
  * @param array $data
  * @throws Mage_Core_Exception
  * @return Mage_Sales_Model_Quote_Payment
  */
 public function importData(array $data)
 {
     $data = new Varien_Object($data);
     Mage::dispatchEvent($this->_eventPrefix . '_import_data_before', array($this->_eventObject => $this, 'input' => $data));
     $this->setMethod($data->getMethod());
     $method = $this->getMethodInstance();
     if (!$method->isAvailable($this->getOrder())) {
         Mage::throwException(Mage::helper('sales')->__('Requested Payment Method is not available'));
     }
     $method->assignData($data);
     /**
      * validating the payment data
      */
     $method->validate();
     return $this;
 }
Example #5
0
 /**
  * Import data array to payment method object,
  * Method calls quote totals collect because payment method availability
  * can be related to quote totals
  *
  * @param   array $data
  * @throws  Mage_Core_Exception
  * @return  Mage_Sales_Model_Quote_Payment
  */
 public function importData(array $data)
 {
     $data = new Varien_Object($data);
     Mage::dispatchEvent($this->_eventPrefix . '_import_data_before', array($this->_eventObject => $this, 'input' => $data));
     $this->setMethod($data->getMethod());
     $method = $this->getMethodInstance();
     /**
      * Payment avalability related with quote totals.
      * We have recollect quote totals before checking
      */
     $this->getQuote()->collectTotals();
     if (!$method->isAvailable($this->getQuote())) {
         Mage::throwException(Mage::helper('sales')->__('The requested Payment Method is not available.'));
     }
     $method->assignData($data);
     /*
      * validating the payment data
      */
     $method->validate();
     return $this;
 }
Example #6
0
 public function getShippingRates($order)
 {
     $request = $this->prepareShippingRequest($order);
     $shipping = Mage::getModel('shipping/shipping');
     $result = $shipping->collectRates($request)->getResult();
     if ($result) {
         $rates = array();
         foreach ($result->getAllRates() as $_rate) {
             $rate = new Varien_Object();
             $rate->setData($_rate->getData());
             $carrier = $rate->getCarrier();
             if (!isset($rates[$carrier])) {
                 $rates[$carrier] = array();
             }
             $rate->setCode($carrier . '_' . $rate->getMethod());
             $rates[$carrier][$rate->getCode()] = $rate;
         }
         return $rates;
     }
     return null;
 }
Example #7
0
 /**
  * Get allowed containers of carrier
  *
  * @param Varien_Object|null $params
  * @return array|bool
  */
 protected function _getAllowedContainers(Varien_Object $params = null)
 {
     $containersAll = $this->getContainerTypesAll();
     if (empty($containersAll)) {
         return array();
     }
     if (empty($params)) {
         return $containersAll;
     }
     $containersFilter = $this->getContainerTypesFilter();
     $containersFiltered = array();
     $method = $params->getMethod();
     $countryShipper = $params->getCountryShipper();
     $countryRecipient = $params->getCountryRecipient();
     if (empty($containersFilter)) {
         return $containersAll;
     }
     if (!$params || !$method || !$countryShipper || !$countryRecipient) {
         return $containersAll;
     }
     if ($countryShipper == self::USA_COUNTRY_ID && $countryRecipient == self::USA_COUNTRY_ID) {
         $direction = 'within_us';
     } else {
         if ($countryShipper == self::USA_COUNTRY_ID && $countryRecipient != self::USA_COUNTRY_ID) {
             $direction = 'from_us';
         } else {
             return $containersAll;
         }
     }
     foreach ($containersFilter as $dataItem) {
         $containers = $dataItem['containers'];
         $filters = $dataItem['filters'];
         if (!empty($filters[$direction]['method']) && in_array($method, $filters[$direction]['method'])) {
             foreach ($containers as $container) {
                 if (!empty($containersAll[$container])) {
                     $containersFiltered[$container] = $containersAll[$container];
                 }
             }
         }
     }
     return !empty($containersFiltered) ? $containersFiltered : $containersAll;
 }
Example #8
0
 /**
  * Return container types of carrier
  *
  * @param Varien_Object|null $params
  * @return array
  */
 public function getContainerTypes(Varien_Object $params = null)
 {
     $method = $params->getMethod();
     $countryRecipient = $params->getCountryRecipient();
     $serviceLevel = $this->getDeliveryServiceLevel($countryRecipient);
     if (!$this->getCode('method', $method)) {
         $method = Mage::getStoreConfig('carriers/wsaendicia/default_domestic');
     }
     $allContainers = $this->getCode('container');
     $allowedContainers = $allContainers['All'];
     if ($serviceLevel) {
         if (array_key_exists($method, $allContainers[$serviceLevel])) {
             $allowedContainers = $allContainers[$serviceLevel][$method];
         }
     }
     return $allowedContainers;
 }
 /**
  * Prepare and set to quote reward balance instance,
  * set zero subtotal checkout payment if need
  *
  * @param Mage_Sales_Model_Quote $quote
  * @param Varien_Object $payment
  * @param boolean $useRewardPoints
  * @return Enterprise_Reward_Model_Observer
  */
 protected function _paymentDataImport($quote, $payment, $useRewardPoints)
 {
     if (!$quote || !$quote->getCustomerId() || $quote->getBaseGrandTotal() + $quote->getBaseRewardCurrencyAmount() <= 0) {
         return $this;
     }
     $quote->setUseRewardPoints((bool) $useRewardPoints);
     if ($quote->getUseRewardPoints()) {
         /* @var $reward Enterprise_Reward_Model_Reward */
         $reward = Mage::getModel('enterprise_reward/reward')->setCustomer($quote->getCustomer())->setWebsiteId($quote->getStore()->getWebsiteId())->loadByCustomer();
         $minPointsBalance = (int) Mage::getStoreConfig(Enterprise_Reward_Model_Reward::XML_PATH_MIN_POINTS_BALANCE, $quote->getStoreId());
         if ($reward->getId() && $reward->getPointsBalance() >= $minPointsBalance) {
             $quote->setRewardInstance($reward);
             if (!$payment->getMethod()) {
                 $payment->setMethod('free');
             }
         } else {
             $quote->setUseRewardPoints(false);
         }
     }
     return $this;
 }
Example #10
0
 /**
  * Return CashOnDelivery Surcharge Value
  *
  * @param Varien_Object
  *
  * @return float
  */
 public function getCashOnDeliverySurcharge(Varien_Object $request)
 {
     $adapter = $this->_getReadAdapter();
     $bind = array(':website_id' => (int) $request->getWebsiteId(), ':country_id' => $request->getDestCountryId(), ':region_id' => $request->getDestRegionId(), ':postcode' => $request->getDestPostcode(), ':weight' => (double) $request->getPackageWeight(), ':price' => (double) $request->getData('zitec_table_price'), ':method' => $request->getMethod());
     $select = $adapter->select()->from($this->getMainTable(), array('cashondelivery_surcharge', 'cod_min_surcharge'))->where('website_id=:website_id')->order(array('dest_country_id DESC', 'dest_region_id DESC', 'dest_zip DESC', 'method DESC', 'price_vs_dest DESC', 'weight DESC'));
     // render destination condition
     $orWhere = '(' . implode(') OR (', array("dest_country_id = :country_id AND dest_region_id = :region_id AND dest_zip = :postcode", "dest_country_id = :country_id AND dest_region_id = :region_id AND dest_zip = ''", "dest_country_id = :country_id AND dest_region_id = 0 AND dest_zip = ''", "dest_country_id = :country_id AND dest_region_id = 0 AND dest_zip = :postcode", "dest_country_id = '0' AND dest_region_id = 0 AND dest_zip = ''")) . ')';
     $select->where($orWhere);
     $select->where('((weight <= :weight and price_vs_dest = 0) or (weight <= :price and price_vs_dest = 1))');
     $select->where('method = :method');
     $rate = $adapter->fetchRow($select, $bind);
     if (empty($rate) && $this->isRateDefinedForMethod($request)) {
         $rate = null;
     }
     return $rate;
 }
Example #11
0
 private function _paymentImportData($data)
 {
     $payment = $this->getQuote()->getPayment();
     $data = new Varien_Object($data);
     // magento does not re-instanciate
     // payment method if it was already set
     // and changed
     if ($data->getMethod() != $payment->getMethod()) {
         $payment->unsMethodInstance();
     }
     $payment->setMethod($data->getMethod());
     $method = $payment->getMethodInstance();
     $this->getQuote()->collectTotals();
     if (!$method->isAvailable($this->getQuote())) {
         Mage::throwException(Mage::helper('sales')->__('The requested Payment Method is not available.'));
     }
     $method->assignData($data);
 }
Example #12
0
 /**
  * Assign data to info model instance
  *
  * @param   mixed $data
  * @return  Mage_Payment_Model_Info
  */
 public function assignData($data)
 {
     if (!$data instanceof Varien_Object) {
         $data = new Varien_Object($data);
     }
     $info = $this->getInfoInstance();
     if (!$this->_isBackendOrder && $this->_connectionType === Eway_Rapid31_Model_Config::CONNECTION_SHARED_PAGE) {
         //Mage::getSingleton('core/session')->setData('sharedpagePaypal', $data->getSharedpageNotsaved());
         Mage::getSingleton('core/session')->setData('sharedpagePaypal', 'paypal');
     } elseif (!$this->_isBackendOrder && $this->_connectionType === Eway_Rapid31_Model_Config::CONNECTION_TRANSPARENT) {
         $info->setTransparentNotsaved($data->getTransparentNotsaved());
         //Option choice
         if ($data->getMethod() == 'ewayrapid_saved' && !$data->getTransparentSaved()) {
             Mage::throwException(Mage::helper('payment')->__('Please select an option payment for eWay saved'));
         } elseif ($data->getMethod() == 'ewayrapid_notsaved' && !$data->getTransparentNotsaved()) {
             Mage::throwException(Mage::helper('payment')->__('Please select an option payment for eWay not saved'));
         }
         //New Token
         if ($data->getMethod() == 'ewayrapid_saved' && $data->getTransparentSaved() == Eway_Rapid31_Model_Config::PAYPAL_STANDARD_METHOD && $data->getSavedToken() == Eway_Rapid31_Model_Config::TOKEN_NEW && Mage::helper('ewayrapid/customer')->checkTokenListByType(Eway_Rapid31_Model_Config::PAYPAL_STANDARD_METHOD)) {
             Mage::throwException(Mage::helper('payment')->__('You could only save one PayPal account, please select PayPal account existed to payent.'));
         }
         if ($data->getTransparentNotsaved()) {
             Mage::getSingleton('core/session')->setTransparentNotsaved($data->getTransparentNotsaved());
         }
         if ($data->getTransparentSaved()) {
             Mage::getSingleton('core/session')->setTransparentSaved($data->getTransparentSaved());
         }
         if ($data->getMethod()) {
             Mage::getSingleton('core/session')->setMethod($data->getMethod());
         }
         if ($data->getSavedToken()) {
             Mage::getSingleton('core/session')->setSavedToken($data->getSavedToken());
             if (is_numeric($data->getSavedToken())) {
                 $token = Mage::helper('ewayrapid/customer')->getTokenById($data->getSavedToken());
                 /* @var Eway_Rapid31_Model_Request_Token $model */
                 $model = Mage::getModel('ewayrapid/request_token');
                 $type = $model->checkCardName($token);
                 Mage::getSingleton('core/session')->setTransparentSaved($type);
                 unset($model);
                 unset($token);
             }
         }
         $infoCard = new Varien_Object();
         Mage::getSingleton('core/session')->setInfoCard($infoCard->setCcType($data->getCcType())->setOwner($data->getCcOwner())->setLast4($this->_isClientSideEncrypted($data->getCcNumber()) ? 'encrypted' : substr($data->getCcNumber(), -4))->setCard($data->getCcNumber())->setNumber($data->getCcNumber())->setCid($data->getCcCid())->setExpMonth($data->getCcExpMonth())->setExpYear($data->getCcExpYear()));
     } else {
         $info->setCcType($data->getCcType())->setCcOwner($data->getCcOwner())->setCcLast4($this->_isClientSideEncrypted($data->getCcNumber()) ? 'encrypted' : substr($data->getCcNumber(), -4))->setCcNumber($data->getCcNumber())->setCcCid($data->getCcCid())->setCcExpMonth($data->getCcExpMonth())->setCcExpYear($data->getCcExpYear());
     }
     return $this;
 }
Example #13
0
 /**
  * Prepare and set to quote reward balance instance,
  * set zero subtotal checkout payment if need
  *
  * @param Mage_Sales_Model_Quote $quote
  * @param Varien_Object $payment
  * @param boolean $useRewardPoints
  * @return Enterprise_Reward_Model_Observer
  */
 protected function _paymentDataImport($quote, $payment, $useRewardPoints)
 {
     if (!$quote || !$quote->getCustomerId()) {
         return $this;
     }
     $quote->setUseRewardPoints((bool) $useRewardPoints);
     if ($quote->getUseRewardPoints()) {
         /* @var $reward Enterprise_Reward_Model_Reward */
         $reward = Mage::getModel('enterprise_reward/reward')->setCustomer($quote->getCustomer())->setWebsiteId($quote->getStore()->getWebsiteId())->loadByCustomer();
         if ($reward->getId()) {
             $quote->setRewardInstance($reward);
             if (!$payment->getMethod()) {
                 $payment->setMethod('free');
             }
         } else {
             $quote->setUseRewardPoints(false);
         }
     }
     return $this;
 }
 /**
  * Analyze payment data for quote and set free shipping if grand total is covered by balance
  *
  * @param Mage_Sales_Model_Quote $quote
  * @param Varien_Object|Mage_Sales_Model_Quote_Payment $payment
  * @param bool $shouldUseBalance
  */
 protected function _importPaymentData($quote, $payment, $shouldUseBalance)
 {
     $store = Mage::app()->getStore($quote->getStoreId());
     if (!$quote || !$quote->getCustomerId() || $quote->getBaseGrandTotal() + $quote->getBaseCustomerBalanceAmountUsed() <= 0) {
         return;
     }
     $quote->setUseCustomerBalance($shouldUseBalance);
     if ($shouldUseBalance) {
         $balance = Mage::getModel('enterprise_customerbalance/balance')->setCustomerId($quote->getCustomerId())->setWebsiteId($store->getWebsiteId())->loadByCustomer();
         if ($balance) {
             $quote->setCustomerBalanceInstance($balance);
             if (!$payment->getMethod()) {
                 $payment->setMethod('free');
             }
         } else {
             $quote->setUseCustomerBalance(false);
         }
     }
 }
 public function paymentImportData(&$payment, array $data)
 {
     $data = new Varien_Object($data);
     //COMMENTED OUT FOR 1.11.x EE or any EE with customer balance solves
     //Fatal error: Call to a member function getQuote() on a non-object in app/code/core/Enterprise/CustomerBalance/Model/Observer.php on line 89
     /*
             Mage::dispatchEvent(
                 'sales_quote_payment_import_data_before',
                 array(
                     $payment->_eventObject=>$payment,
                     'input'=>$payment,
                 )
             );
     */
     $payment->setMethod($data->getMethod());
     $method = $payment->getMethodInstance();
     $method->assignData($data);
     return $payment;
 }
Example #16
0
 public function assignData($data)
 {
     if (!$data instanceof Varien_Object) {
         $data = new Varien_Object($data);
     }
     $info = $this->getInfoInstance();
     if (!$data->getSagepayTokenCcId() && $this->getSageSuiteSession()->getLastSavedTokenccid()) {
         $data->setSagepayTokenCcId($this->getSageSuiteSession()->getLastSavedTokenccid());
     } else {
         if ($data->getSagepayTokenCcId()) {
             //This check is because OSC set_methods_separate posts data and its not complete sometimes
             //Attention: Server with OSC will still have this problem since cv2 is asked on iframe
             if ($data->getMethod() == 'sagepayserver' || $data->getMethod() == 'sagepayserver_moto' || $data->getTokenCvv()) {
                 $this->getSageSuiteSession()->setLastSavedTokenccid($data->getSagepayTokenCcId());
             }
         }
     }
     //$this->getSageSuiteSession()->setTokenCvv($data->getTokenCvv());
     if ($this->isMobile()) {
         $cct = Mage::getSingleton('sagepaysuite/config')->getTranslateCc();
         if (in_array($data->getCcType(), $cct)) {
             $cctF = array_flip($cct);
             $data->setCcType($cctF[$data->getCcType()]);
         }
     }
     //Direct GiftAidPayment flag
     $dgift = !is_null($data->getCcGiftaid()) ? 1 : NULL;
     //Remember token
     $info->setRemembertoken(!is_null($data->getRemembertoken()) ? 1 : 0);
     $info->setCcType($data->getCcType())->setCcOwner($data->getCcOwner())->setCcLast4(substr($data->getCcNumber(), -4))->setCcNumber($data->getCcNumber())->setCcCid($data->getCcCid())->setSagepayTokenCcId($data->getSagepayTokenCcId())->setCcExpMonth($data->getCcExpMonth())->setCcExpYear($data->getCcExpYear())->setCcIssue($data->getCcIssue())->setSaveTokenCc($data->getSavecc())->setTokenCvv($data->getTokenCvv())->setCcStartMonth($data->getCcStartMonth())->setCcStartYear($data->getCcStartYear())->setCcNickname($data->getCcNickname())->setCcGiftaid($dgift);
     return $this;
 }
 public function importData(array $data)
 {
     $data = new Varien_Object($data);
     $this->setMethod($data->getMethod());
     $method = $this->getMethodInstance();
     $method->assignData($data);
     $method->validate();
     if ($data->getMethod() == 'checkmo') {
         if ($data->getPoNumber()) {
             $this->setPoNumber($data->getPoNumber());
         }
     }
     return $this;
 }