@@ -26,6 +26,18 @@ class Mage_Payment_Helper_Data extends Mage_Core_Helper_Abstract
26
26
27
27
protected $ _moduleName = 'Mage_Payment ' ;
28
28
29
+ /**
30
+ * Retrieve the class name of the payment method's model
31
+ *
32
+ * @param $code
33
+ * @return string|null
34
+ */
35
+ public function getMethodModelClassName ($ code )
36
+ {
37
+ $ key = self ::XML_PATH_PAYMENT_METHODS . '/ ' . $ code . '/model ' ;
38
+ return Mage::getStoreConfig ($ key );
39
+ }
40
+
29
41
/**
30
42
* Retrieve method model object
31
43
*
@@ -34,8 +46,7 @@ class Mage_Payment_Helper_Data extends Mage_Core_Helper_Abstract
34
46
*/
35
47
public function getMethodInstance ($ code )
36
48
{
37
- $ key = self ::XML_PATH_PAYMENT_METHODS . '/ ' . $ code . '/model ' ;
38
- $ class = Mage::getStoreConfig ($ key );
49
+ $ class = $ this ->getMethodModelClassName ($ code );
39
50
if (is_null ($ class )) {
40
51
Mage::logException (new Exception (sprintf ('Unknown payment method with code "%s" ' , $ code )));
41
52
return false ;
@@ -156,7 +167,13 @@ public function getRecurringProfileMethods($store = null)
156
167
{
157
168
$ result = [];
158
169
foreach ($ this ->getPaymentMethods ($ store ) as $ code => $ data ) {
159
- $ method = $ this ->getMethodInstance ($ code );
170
+ $ paymentMethodModelClassName = $ this ->getMethodModelClassName ($ code );
171
+ if (!$ paymentMethodModelClassName ) {
172
+ continue ;
173
+ }
174
+
175
+ /** @var Mage_Payment_Model_Method_Abstract $method */
176
+ $ method = Mage::getModel ($ paymentMethodModelClassName );
160
177
if ($ method && $ method ->canManageRecurringProfiles ()) {
161
178
$ result [] = $ method ;
162
179
}
@@ -207,8 +224,9 @@ public function getPaymentMethodList($sorted = true, $asLabelValue = false, $wit
207
224
if ((isset ($ data ['title ' ]))) {
208
225
$ methods [$ code ] = $ data ['title ' ];
209
226
} else {
210
- if ($ this ->getMethodInstance ($ code )) {
211
- $ methods [$ code ] = $ this ->getMethodInstance ($ code )->getConfigData ('title ' , $ store );
227
+ $ paymentMethodModelClassName = $ this ->getMethodModelClassName ($ code );
228
+ if ($ paymentMethodModelClassName ) {
229
+ $ methods [$ code ] = Mage::getModel ($ paymentMethodModelClassName )->getConfigData ('title ' , $ store );
212
230
}
213
231
}
214
232
if ($ asLabelValue && $ withGroups && isset ($ data ['group ' ])) {
0 commit comments