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_Centinel
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: * Config centinel model
29: */
30: class Mage_Centinel_Model_Config
31: {
32: /**
33: * Store id or store model
34: *
35: * @var int|Mage_Core_Model_Store
36: */
37: protected $_store = false;
38:
39: /**
40: * Path of centinel config
41: *
42: * @var string
43: */
44: protected $_serviceConfigPath = 'payment_services/centinel';
45:
46: /**
47: * Path of cards config
48: *
49: * @var string
50: */
51: protected $_cardTypesConfigPath = 'global/payment/cc/types';
52:
53: /**
54: * Set store to congif model
55: *
56: * @param int|Mage_Core_Model_Store $store
57: * @return Mage_Centinel_Model_Config
58: */
59: public function setStore($store)
60: {
61: $this->_store = $store;
62: return $this;
63: }
64:
65: /**
66: * Return store
67: *
68: * @return int|Mage_Core_Model_Store
69: */
70: public function getStore()
71: {
72: return $this->_store;
73: }
74:
75: /**
76: * Return validation state class for card with type $cardType
77: *
78: * @param string $cardType
79: * @return string
80: */
81: public function getStateModelClass($cardType)
82: {
83: $node = Mage::getConfig()->getNode($this->_cardTypesConfigPath . '/' . $cardType . '/validator/centinel/state');
84: if (!$node) {
85: return false;
86: }
87: return $node->asArray();
88: }
89:
90: /**
91: * Return centinel processorId
92: *
93: * @return string
94: */
95: public function getProcessorId()
96: {
97: return $this->_getServiceConfigValue('processor_id');
98: }
99:
100: /**
101: * Return centinel merchantId
102: *
103: * @return string
104: */
105: public function getMerchantId()
106: {
107: return $this->_getServiceConfigValue('merchant_id');
108: }
109:
110: /**
111: * Return centinel transactionPwd
112: *
113: * @return string
114: */
115: public function getTransactionPwd()
116: {
117: return Mage::helper('core')->decrypt($this->_getServiceConfigValue('password'));
118: }
119:
120: /**
121: * Return flag - is centinel mode test
122: *
123: * @return bool
124: */
125: public function getIsTestMode()
126: {
127: return (bool)(int)$this->_getServiceConfigValue('test_mode');
128: }
129:
130: /**
131: * Return value of node of centinel config section
132: *
133: * @param string $key
134: * @return string
135: */
136: private function _getServiceConfigValue($key)
137: {
138: return Mage::getStoreConfig($this->_serviceConfigPath . '/' . $key, $this->getStore());
139: }
140:
141: /**
142: * Define if debugging is enabled
143: *
144: * @return bool
145: */
146: public function getDebugFlag()
147: {
148: return $this->_getServiceConfigValue('debug');
149: }
150: }
151: