/** * Validate data before save * * @return Mage_Payment_Model_Billing_Agreement */ public function validate() { if (is_null($this->_paymentMethodInstance) || !$this->_paymentMethodInstance->getCode() || !$this->getCustomerId() || !$this->getReferenceId() || !$this->getStatus()) { throw new Mage_Core_Exception('Not enough data to save billing agreement instance.'); } return $this; }
/** * Return system config value by key for specified payment method * * @param string $key * @param Mage_Payment_Model_Method_Abstract $method * @param int $storeId * * @return string */ protected function _getMethodConfigData($key, Mage_Payment_Model_Method_Abstract $method, $storeId = null) { if (!$method->getCode()) { return null; } return Mage::getStoreConfig("payment/{$method->getCode()}/{$key}", $storeId); }
/** * Filter self data to make sure it can be validated properly * * @return Mage_Payment_Model_Recurring_Profile */ protected function _filterValues() { // determine payment method/code if ($this->_methodInstance) { $this->setMethodCode($this->_methodInstance->getCode()); } elseif ($this->getMethodCode()) { $this->getMethodInstance(); } // unset redundant values, if empty foreach (array('schedule_description', 'suspension_threshold', 'bill_failed_later', 'period_frequency', 'period_max_cycles', 'reference_id', 'trial_period_unit', 'trial_period_frequency', 'trial_period_max_cycles', 'init_may_fail') as $key) { if ($this->hasData($key) && (!$this->getData($key) || '0' == $this->getData($key))) { $this->unsetData($key); } } // cast amounts foreach (array('billing_amount', 'trial_billing_amount', 'shipping_amount', 'tax_amount', 'init_amount') as $key) { if ($this->hasData($key)) { if (!$this->getData($key) || 0 == $this->getData($key)) { $this->unsetData($key); } else { $this->setData($key, sprintf('%.4F', $this->getData($key))); } } } // automatically determine start date, if not set if ($this->getStartDatetime()) { $date = new Zend_Date($this->getStartDatetime(), Varien_Date::DATETIME_INTERNAL_FORMAT); $this->setNearestStartDatetime($date); } else { $this->setNearestStartDatetime(); } return $this; }
/** * Validate data before save * * @return bool */ public function isValid() { $this->_errors = array(); if (is_null($this->_paymentMethodInstance) || !$this->_paymentMethodInstance->getCode()) { $this->_errors[] = Mage::helper('payment')->__('Payment method code is not set.'); } if (!$this->getReferenceId()) { $this->_errors[] = Mage::helper('payment')->__('Reference ID is not set.'); } return empty($this->_errors); }
/** * Payment method additional label part getter * @param Mage_Payment_Model_Method_Abstract $method */ public function getMethodLabelAfterHtml(Mage_Payment_Model_Method_Abstract $method) { if ($form = $this->getChild('payment.method.' . $method->getCode())) { return $form->getMethodLabelAfterHtml(); } }
/** * Method code setter * * @param string|Mage_Payment_Model_Method_Abstract $method * @return Mage_Paypal_Model_Config */ public function setMethod($method) { if ($method instanceof Mage_Payment_Model_Method_Abstract) { $this->_methodCode = $method->getCode(); } elseif (is_string($method)) { $this->_methodCode = $method; } return $this; }
/** * Check whether the payment method can manage subscriptions. * * @param Mage_Payment_Model_Method_Abstract $paymentMethod * @return boolean */ public function canPaymentMethodManageSubscriptions(Mage_Payment_Model_Method_Abstract $paymentMethod) { return $paymentMethod instanceof Customweb_Payment_Authorization_IPaymentMethod || $paymentMethod instanceof Customweb_Subscription_Model_Payment_Abstract || in_array($paymentMethod->getCode(), array('IsrInvoice')); }
/** * Retreive payment method form html * * @param Mage_Payment_Model_Abstract $method * @return Mage_Payment_Block_Form */ public function getMethodFormBlock(Mage_Payment_Model_Method_Abstract $method) { $block = false; $blockType = $method->getFormBlockType(); if ($this->getLayout()) { $block = $this->getLayout()->createBlock($blockType, $method->getCode()); $block->setMethod($method); } return $block; }
/** * Retrieve dummy payment method code * * @return string */ public function getCode() { return Mage_Payment_Model_Method_Abstract::getCode(); }
/** * Payment method form html getter * @param Mage_Payment_Model_Method_Abstract $method */ public function getPaymentMethodFormHtml(Mage_Payment_Model_Method_Abstract $method) { return $this->getChildHtml('payment.method.' . $method->getCode()); }