/** * Check whether the object data is valid * Returns true if valid. * * @return bool */ public function isValid() { $this->_filterValues(); $this->_errors = array(); // start date, order ref ID, schedule description if (!$this->getStartDatetime()) { $this->_errors['start_datetime'][] = Mage::helper('payment')->__('Start date is undefined.'); } elseif (!Zend_Date::isDate($this->getStartDatetime(), Varien_Date::DATETIME_INTERNAL_FORMAT)) { $this->_errors['start_datetime'][] = Mage::helper('payment')->__('Start date has invalid format.'); } if (!$this->getScheduleDescription()) { $this->_errors['schedule_description'][] = Mage::helper('payment')->__('Schedule description must be not empty.'); } // period unit and frequency, trial period unit and trial frequency if (!$this->getPeriodUnit() || !in_array($this->getPeriodUnit(), $this->getAllPeriodUnits(false), true)) { $this->_errors['period_unit'][] = Mage::helper('payment')->__('Billing period unit is not defined or wrong.'); } elseif ($this->getPeriodFrequency()) { $this->_validatePeriodFrequency('period_unit', 'period_frequency'); } if ($this->getTrialPeriodUnit()) { if (!in_array($this->getTrialPeriodUnit(), $this->getAllPeriodUnits(false), true)) { $this->_errors['trial_period_unit'][] = Mage::helper('payment')->__('Trial billing period unit is wrong.'); } elseif ($this->getTrialPeriodFrequency()) { $this->_validatePeriodFrequency('trial_period_unit', 'trial_period_frequency'); } } // billing and other amounts if (!$this->getBillingAmount() || 0 >= $this->getBillingAmount()) { $this->_errors['billing_amount'][] = Mage::helper('payment')->__('Wrong or empty billing amount specified.'); } foreach (array('trial_billing_abount', 'shipping_amount', 'tax_amount', 'init_amount') as $key) { if ($this->hasData($key) && 0 >= $this->getData($key)) { $this->_errors[$key][] = Mage::helper('payment')->__('Wrong %s specified.', $this->getFieldLabel($key)); } } // currency code if (!$this->getCurrencyCode()) { $this->_errors['currency_code'][] = Mage::helper('payment')->__('Currency code is undefined.'); } // payment method if (!$this->_methodInstance || !$this->getMethodCode()) { $this->_errors['method_code'][] = Mage::helper('payment')->__('Payment method code is undefined.'); } if ($this->_methodInstance) { try { $this->_methodInstance->validateRecurringProfile($this); } catch (Mage_Core_Exception $e) { $this->_errors['payment_method'][] = $e->getMessage(); } } return empty($this->_errors); }