Mage_Payment_Helper_Data Class Reference

Inheritance diagram for Mage_Payment_Helper_Data:

Mage_Core_Helper_Abstract

List of all members.

Public Member Functions

 getMethodInstance ($code)
 getStoreMethods ($store=null, $quote=null)
 getMethodFormBlock (Mage_Payment_Model_Method_Abstract $method)
 getInfoBlock (Mage_Payment_Model_Info $info)

Public Attributes

const XML_PATH_PAYMENT_METHODS = 'payment'

Protected Member Functions

 _sortMethods ($a, $b)


Detailed Description

Payment module base helper

Author:
Magento Core Team <core@magentocommerce.com>

Definition at line 32 of file Data.php.


Member Function Documentation

_sortMethods ( a,
b 
) [protected]

Definition at line 108 of file Data.php.

00109     {
00110        // var_dump($a);
00111         if (is_object($a)) {
00112             //var_dump($a->getData());
00113             //var_dump($a->sort_order);
00114             //die ();
00115 
00116             return (int)$a->sort_order < (int)$b->sort_order ? -1 : ((int)$a->sort_order > (int)$b->sort_order ? 1 : 0);
00117         }
00118         return 0;
00119     }

getInfoBlock ( Mage_Payment_Model_Info info  ) 

Retrieve payment information block

Parameters:
Mage_Payment_Model_Info $info
Returns:
Mage_Core_Block_Template

Definition at line 144 of file Data.php.

00145     {
00146         $blockType = $info->getMethodInstance()->getInfoBlockType();
00147         if ($this->getLayout()) {
00148             $block = $this->getLayout()->createBlock($blockType);
00149         }
00150         else {
00151             $className = Mage::getConfig()->getBlockClassName($blockType);
00152             $block = new $className;
00153         }
00154         $block->setInfo($info);
00155         return $block;
00156     }

getMethodFormBlock ( Mage_Payment_Model_Method_Abstract method  ) 

Retreive payment method form html

Parameters:
Mage_Payment_Model_Abstract $method
Returns:
Mage_Payment_Block_Form

Definition at line 127 of file Data.php.

00128     {
00129         $block = false;
00130         $blockType = $method->getFormBlockType();
00131         if ($this->getLayout()) {
00132             $block = $this->getLayout()->createBlock($blockType);
00133             $block->setMethod($method);
00134         }
00135         return $block;
00136     }

getMethodInstance ( code  ) 

Retrieve method model object

Parameters:
string $code
Returns:
Mage_Payment_Model_Method_Abstract

Definition at line 42 of file Data.php.

00043     {
00044         $key = self::XML_PATH_PAYMENT_METHODS.'/'.$code.'/model';
00045         $class = Mage::getStoreConfig($key);
00046         if (!$class) {
00047             Mage::throwException($this->__('Can not configuration for payment method with code: %s', $code));
00048         }
00049         return Mage::getModel($class);
00050     }

getStoreMethods ( store = null,
quote = null 
)

Retrieve available payment methods for store

array structure: $index => Varien_Simplexml_Element

Parameters:
mixed $store
Returns:
array

Definition at line 61 of file Data.php.

00062     {
00063         $methods = Mage::getStoreConfig(self::XML_PATH_PAYMENT_METHODS, $store);
00064         $res = array();
00065         foreach ($methods as $code => $methodConfig) {
00066             $prefix = self::XML_PATH_PAYMENT_METHODS.'/'.$code.'/';
00067 
00068             if (!Mage::getStoreConfigFlag($prefix.'active', $store)) {
00069                 continue;
00070             }
00071             if (!$model = Mage::getStoreConfig($prefix.'model', $store)) {
00072                 continue;
00073             }
00074 
00075             $methodInstance = Mage::getModel($model);
00076 
00077             if ($methodInstance instanceof Mage_Payment_Model_Method_Cc && !Mage::getStoreConfig($prefix.'cctypes')) {
00078                 /* if the payment method has credit card types configuration option
00079                    and no credit card type is enabled in configuration */
00080                 continue;
00081             }
00082 
00083             if ( !$methodInstance->isAvailable($quote) ) {
00084                 /* if the payment method can not be used at this time */
00085                 continue;
00086             }
00087 
00088             $sortOrder = (int)Mage::getStoreConfig($prefix.'sort_order', $store);
00089             $methodInstance->setSortOrder($sortOrder);
00090             $methodInstance->setStore($store);
00091 //            while (isset($res[$sortOrder])) {
00092 //                $sortOrder++;
00093 //            }
00094 //            $res[$sortOrder] = $methodInstance;
00095             $res[] = $methodInstance;
00096         }
00097 //        ksort($res);
00098         //die('!');
00099 
00100         //echo '<pre>';
00101         //var_dump( (array)$res);
00102         usort($res, array($this, '_sortMethods'));
00103         //var_dump((array)$res);
00104       //  echo '</pre>';
00105         return $res;
00106     }


Member Data Documentation

const XML_PATH_PAYMENT_METHODS = 'payment'

Definition at line 34 of file Data.php.


The documentation for this class was generated from the following file:

Generated on Sat Jul 4 17:24:32 2009 for Magento by  doxygen 1.5.8