Overview

Packages

  • currencysymbol
  • MAbout
  • Mage
    • Admin
    • Adminhtml
    • AdminNotification
    • Api
    • Api2
    • Authorizenet
    • Backup
    • Bundle
    • Captcha
    • Catalog
    • CatalogIndex
    • CatalogInventory
    • CatalogRule
    • CatalogSearch
    • Centinel
    • Checkout
    • Cms
    • Compiler
    • Connect
    • Contacts
    • Core
    • Cron
    • CurrencySymbol
    • Customer
    • Dataflow
    • Directory
    • DirtectPost
    • Downloadable
    • Eav
    • GiftMessage
    • GoogleAnalytics
    • GoogleBase
    • GoogleCheckout
    • ImportExport
    • Index
    • Install
    • Log
    • Media
    • Newsletter
    • Oauth
    • Page
    • PageCache
    • Paygate
    • Payment
    • Paypal
    • PaypalUk
    • Persistent
    • Poll
    • ProductAlert
    • Rating
    • Reports
    • Review
    • Rss
    • Rule
    • Sales
    • SalesRule
    • Sedfriend
    • Sendfriend
    • Shipping
    • Sitemap
    • Tag
    • Tax
    • Usa
    • Weee
    • Widget
    • Wishlist
    • XmlConnect
  • None
  • Phoenix
    • Moneybookers
  • PHP
  • Zend
    • Date
    • Mime
    • XmlRpc

Classes

  • Mage_Payment_Block_Catalog_Product_View_Profile
  • Mage_Payment_Block_Form
  • Mage_Payment_Block_Form_Banktransfer
  • Mage_Payment_Block_Form_Cashondelivery
  • Mage_Payment_Block_Form_Cc
  • Mage_Payment_Block_Form_Ccsave
  • Mage_Payment_Block_Form_Checkmo
  • Mage_Payment_Block_Form_Container
  • Mage_Payment_Block_Form_Purchaseorder
  • Mage_Payment_Block_Info
  • Mage_Payment_Block_Info_Banktransfer
  • Mage_Payment_Block_Info_Cc
  • Mage_Payment_Block_Info_Ccsave
  • Mage_Payment_Block_Info_Checkmo
  • Mage_Payment_Block_Info_Container
  • Mage_Payment_Block_Info_Purchaseorder
  • Mage_Payment_Helper_Data
  • Mage_Payment_Model_Billing_AgreementAbstract
  • Mage_Payment_Model_Config
  • Mage_Payment_Model_Info
  • Mage_Payment_Model_Method_Abstract
  • Mage_Payment_Model_Method_Banktransfer
  • Mage_Payment_Model_Method_Cashondelivery
  • Mage_Payment_Model_Method_Cc
  • Mage_Payment_Model_Method_Ccsave
  • Mage_Payment_Model_Method_Checkmo
  • Mage_Payment_Model_Method_Free
  • Mage_Payment_Model_Method_Purchaseorder
  • Mage_Payment_Model_Observer
  • Mage_Payment_Model_Paygate_Result
  • Mage_Payment_Model_Recurring_Profile
  • Mage_Payment_Model_Source_Cctype
  • Mage_Payment_Model_Source_Invoice

Interfaces

  • Mage_Payment_Model_Billing_Agreement_MethodInterface
  • Mage_Payment_Model_Recurring_Profile_MethodInterface

Exceptions

  • Mage_Payment_Exception
  • Mage_Payment_Model_Info_Exception
  • Overview
  • Package
  • Class
  • Tree
  1: <?php
  2: /**
  3:  * Magento
  4:  *
  5:  * NOTICE OF LICENSE
  6:  *
  7:  * This source file is subject to the Open Software License (OSL 3.0)
  8:  * that is bundled with this package in the file LICENSE.txt.
  9:  * It is also available through the world-wide-web at this URL:
 10:  * http://opensource.org/licenses/osl-3.0.php
 11:  * If you did not receive a copy of the license and are unable to
 12:  * obtain it through the world-wide-web, please send an email
 13:  * to license@magentocommerce.com so we can send you a copy immediately.
 14:  *
 15:  * DISCLAIMER
 16:  *
 17:  * Do not edit or add to this file if you wish to upgrade Magento to newer
 18:  * versions in the future. If you wish to customize Magento for your
 19:  * needs please refer to http://www.magentocommerce.com for more information.
 20:  *
 21:  * @category    Mage
 22:  * @package     Mage_Payment
 23:  * @copyright   Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
 24:  * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
 25:  */
 26: 
 27: /**
 28:  * Payment configuration model
 29:  *
 30:  * Used for retrieving configuration data by payment models
 31:  *
 32:  * @category   Mage
 33:  * @package    Mage_Payment
 34:  * @author      Magento Core Team <core@magentocommerce.com>
 35:  */
 36: class Mage_Payment_Model_Config
 37: {
 38:     protected static $_methods;
 39: 
 40:     /**
 41:      * Retrieve active system payments
 42:      *
 43:      * @param   mixed $store
 44:      * @return  array
 45:      */
 46:     public function getActiveMethods($store=null)
 47:     {
 48:         $methods = array();
 49:         $config = Mage::getStoreConfig('payment', $store);
 50:         foreach ($config as $code => $methodConfig) {
 51:             if (Mage::getStoreConfigFlag('payment/'.$code.'/active', $store)) {
 52:                 if (array_key_exists('model', $methodConfig)) {
 53:                     $methodModel = Mage::getModel($methodConfig['model']);
 54:                     if ($methodModel && $methodModel->getConfigData('active', $store)) {
 55:                         $methods[$code] = $this->_getMethod($code, $methodConfig);
 56:                     }
 57:                 }
 58:             }
 59:         }
 60:         return $methods;
 61:     }
 62: 
 63:     /**
 64:      * Retrieve all system payments
 65:      *
 66:      * @param mixed $store
 67:      * @return array
 68:      */
 69:     public function getAllMethods($store=null)
 70:     {
 71:         $methods = array();
 72:         $config = Mage::getStoreConfig('payment', $store);
 73:         foreach ($config as $code => $methodConfig) {
 74:             $data = $this->_getMethod($code, $methodConfig);
 75:             if (false !== $data) {
 76:                 $methods[$code] = $data;
 77:             }
 78:         }
 79:         return $methods;
 80:     }
 81: 
 82:     protected function _getMethod($code, $config, $store=null)
 83:     {
 84:         if (isset(self::$_methods[$code])) {
 85:             return self::$_methods[$code];
 86:         }
 87:         if (empty($config['model'])) {
 88:             return false;
 89:         }
 90:         $modelName = $config['model'];
 91: 
 92:         $className = Mage::getConfig()->getModelClassName($modelName);
 93:         if (!mageFindClassFile($className)) {
 94:             return false;
 95:         }
 96: 
 97:         $method = Mage::getModel($modelName);
 98:         $method->setId($code)->setStore($store);
 99:         self::$_methods[$code] = $method;
100:         return self::$_methods[$code];
101:     }
102: 
103:     /**
104:      * Retrieve array of credit card types
105:      *
106:      * @return array
107:      */
108:     public function getCcTypes()
109:     {
110:         $_types = Mage::getConfig()->getNode('global/payment/cc/types')->asArray();
111: 
112:         uasort($_types, array('Mage_Payment_Model_Config', 'compareCcTypes'));
113: 
114:         $types = array();
115:         foreach ($_types as $data) {
116:             if (isset($data['code']) && isset($data['name'])) {
117:                 $types[$data['code']] = $data['name'];
118:             }
119:         }
120:         return $types;
121:     }
122: 
123:     /**
124:      * Retrieve list of months translation
125:      *
126:      * @return array
127:      */
128:     public function getMonths()
129:     {
130:         $data = Mage::app()->getLocale()->getTranslationList('month');
131:         foreach ($data as $key => $value) {
132:             $monthNum = ($key < 10) ? '0'.$key : $key;
133:             $data[$key] = $monthNum . ' - ' . $value;
134:         }
135:         return $data;
136:     }
137: 
138:     /**
139:      * Retrieve array of available years
140:      *
141:      * @return array
142:      */
143:     public function getYears()
144:     {
145:         $years = array();
146:         $first = date("Y");
147: 
148:         for ($index=0; $index <= 10; $index++) {
149:             $year = $first + $index;
150:             $years[$year] = $year;
151:         }
152:         return $years;
153:     }
154: 
155:     /**
156:      * Statis Method for compare sort order of CC Types
157:      *
158:      * @param array $a
159:      * @param array $b
160:      * @return int
161:      */
162:     static function compareCcTypes($a, $b)
163:     {
164:         if (!isset($a['order'])) {
165:             $a['order'] = 0;
166:         }
167: 
168:         if (!isset($b['order'])) {
169:             $b['order'] = 0;
170:         }
171: 
172:         if ($a['order'] == $b['order']) {
173:             return 0;
174:         } else if ($a['order'] > $b['order']) {
175:             return 1;
176:         } else {
177:             return -1;
178:         }
179: 
180:     }
181: }
182: 
Magento 1.7.0.2 API documentation generated by ApiGen 2.8.0