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_Paygate
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: class Mage_Paygate_Block_Authorizenet_Info_Cc extends Mage_Payment_Block_Info_Cc
28: {
29: /**
30: * Checkout progress information block flag
31: *
32: * @var bool
33: */
34: protected $_isCheckoutProgressBlockFlag = true;
35: /**
36: * Set block template
37: */
38: protected function _construct()
39: {
40: parent::_construct();
41: $this->setTemplate('paygate/info/cc.phtml');
42: }
43:
44: /**
45: * Render as PDF
46: *
47: * @return string
48: */
49: public function toPdf()
50: {
51: $this->setTemplate('paygate/info/pdf.phtml');
52: return $this->toHtml();
53: }
54:
55: /**
56: * Retrieve card info object
57: *
58: * @return mixed
59: */
60: public function getInfo()
61: {
62: if ($this->hasCardInfoObject()) {
63: return $this->getCardInfoObject();
64: }
65: return parent::getInfo();
66: }
67:
68: /**
69: * Set checkout progress information block flag
70: * to avoid showing credit card information from payment quote
71: * in Previously used card information block
72: *
73: * @param bool $flag
74: * @return Mage_Paygate_Block_Authorizenet_Info_Cc
75: */
76: public function setCheckoutProgressBlock($flag)
77: {
78: $this->_isCheckoutProgressBlockFlag = $flag;
79: return $this;
80: }
81:
82: /**
83: * Retrieve credit cards info
84: *
85: * @return array
86: */
87: public function getCards()
88: {
89: $cardsData = $this->getMethod()->getCardsStorage()->getCards();
90: $cards = array();
91:
92: if (is_array($cardsData)) {
93: foreach ($cardsData as $cardInfo) {
94: $data = array();
95: if ($cardInfo->getProcessedAmount()) {
96: $amount = Mage::helper('core')->currency($cardInfo->getProcessedAmount(), true, false);
97: $data[Mage::helper('paygate')->__('Processed Amount')] = $amount;
98: }
99: if ($cardInfo->getBalanceOnCard() && is_numeric($cardInfo->getBalanceOnCard())) {
100: $balance = Mage::helper('core')->currency($cardInfo->getBalanceOnCard(), true, false);
101: $data[Mage::helper('paygate')->__('Remaining Balance')] = $balance;
102: }
103: $this->setCardInfoObject($cardInfo);
104: $cards[] = array_merge($this->getSpecificInformation(), $data);
105: $this->unsCardInfoObject();
106: $this->_paymentSpecificInformation = null;
107: }
108: }
109: if ($this->getInfo()->getCcType() && $this->_isCheckoutProgressBlockFlag) {
110: $cards[] = $this->getSpecificInformation();
111: }
112: return $cards;
113: }
114: }
115: