/** * 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 availability related with quote totals. * We have to recollect quote totals before checking */ $this->getQuote()->collectTotals(); if (!$method->isAvailable($this->getQuote()) || !$method->isApplicableToQuote($this->getQuote(), $data->getChecks())) { Mage::throwException(Mage::helper('sales')->__('The requested Payment Method is not available.')); } $method->assignData($data); /* * validating the payment data */ $method->validate(); return $this; }