/** * Load recurring profile * * @return Mage_Sales_Model_Recurring_Profile * @throws Exception */ protected function _getRecurringProfile() { if (empty($this->_recurringProfile)) { // get proper recurring profile $internalReferenceId = $this->_request['rp_invoice_id']; $this->_recurringProfile = Mage::getModel('sales/recurring_profile')->loadByInternalReferenceId($internalReferenceId); if (!$this->_recurringProfile->getId()) { throw new Exception(sprintf('Wrong recurring profile INTERNAL_REFERENCE_ID: "%s".', $internalReferenceId)); } // re-initialize config with the method code and store id $methodCode = $this->_recurringProfile->getMethodCode(); $this->_config = Mage::getModel('paypal/config', array($methodCode, $this->_recurringProfile->getStoreId())); if (!$this->_config->isMethodActive($methodCode) || !$this->_config->isMethodAvailable()) { throw new Exception(sprintf('Method "%s" is not available.', $methodCode)); } } return $this->_recurringProfile; }
/** * Check whether method available for checkout or not * Logic based on merchant country, methods dependence * * @param string $methodCode * @return bool */ public function isMethodAvailable($methodCode = null) { $result = parent::isMethodAvailable($methodCode); if (!$result) { return false; } // Additionally check parent method if ($methodCode === null) { $methodCode = $this->getMethodCode(); } switch ($methodCode) { case self::METHOD_PAYPAL_DIRECT_CUSTOMERSTORED: case self::METHOD_PAYPAL_DIRECT_ORDERSTORED: if (!$this->isMethodActive(self::METHOD_WPP_DIRECT)) { $result = false; } break; case self::METHOD_PAYPAL_PAYFLOWADVANCED_CUSTOMERSTORED: case self::METHOD_PAYPAL_PAYFLOWADVANCED_ORDERSTORED: if (!$this->isMethodActive(self::METHOD_PAYFLOWADVANCED)) { $result = false; } break; case self::METHOD_PAYPAL_PAYFLOWLINK_CUSTOMERSTORED: case self::METHOD_PAYPAL_PAYFLOWLINK_ORDERSTORED: if (!$this->isMethodActive(self::METHOD_PAYFLOWLINK)) { $result = false; } break; case self::METHOD_PAYPAL_PAYFLOWPRO_CUSTOMERSTORED: case self::METHOD_PAYPAL_PAYFLOWPRO_ORDERSTORED: if (!$this->isMethodActive(self::METHOD_PAYFLOWPRO)) { $result = false; } break; } return $result; }