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_Checkout
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: * One page checkout status
29: *
30: * @category Mage
31: * @category Mage
32: * @package Mage_Checkout
33: * @author Magento Core Team <core@magentocommerce.com>
34: */
35: class Mage_Checkout_Block_Onepage_Payment_Methods extends Mage_Payment_Block_Form_Container
36: {
37: public function getQuote()
38: {
39: return Mage::getSingleton('checkout/session')->getQuote();
40: }
41:
42: /**
43: * Check and prepare payment method model
44: *
45: * @return bool
46: */
47: protected function _canUseMethod($method)
48: {
49: if (!$method || !$method->canUseCheckout()) {
50: return false;
51: }
52: return parent::_canUseMethod($method);
53: }
54:
55: /**
56: * Retrieve code of current payment method
57: *
58: * @return mixed
59: */
60: public function getSelectedMethodCode()
61: {
62: if ($method = $this->getQuote()->getPayment()->getMethod()) {
63: return $method;
64: }
65: return false;
66: }
67:
68: /**
69: * Payment method form html getter
70: * @param Mage_Payment_Model_Method_Abstract $method
71: */
72: public function getPaymentMethodFormHtml(Mage_Payment_Model_Method_Abstract $method)
73: {
74: return $this->getChildHtml('payment.method.' . $method->getCode());
75: }
76:
77: /**
78: * Return method title for payment selection page
79: *
80: * @param Mage_Payment_Model_Method_Abstract $method
81: */
82: public function getMethodTitle(Mage_Payment_Model_Method_Abstract $method)
83: {
84: $form = $this->getChild('payment.method.' . $method->getCode());
85: if ($form && $form->hasMethodTitle()) {
86: return $form->getMethodTitle();
87: }
88: return $method->getTitle();
89: }
90:
91: /**
92: * Payment method additional label part getter
93: * @param Mage_Payment_Model_Method_Abstract $method
94: */
95: public function getMethodLabelAfterHtml(Mage_Payment_Model_Method_Abstract $method)
96: {
97: if ($form = $this->getChild('payment.method.' . $method->getCode())) {
98: return $form->getMethodLabelAfterHtml();
99: }
100: }
101: }
102: