1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25:
26:
27: class Mage_Paygate_Block_Authorizenet_Form_Cc extends Mage_Payment_Block_Form
28: {
29: 30: 31:
32: protected function _construct()
33: {
34: parent::_construct();
35: $this->setTemplate('paygate/form/cc.phtml');
36: }
37:
38: 39: 40: 41: 42:
43: public function getMethodFormBlock()
44: {
45: return $this->getLayout()->createBlock('payment/form_cc')
46: ->setMethod($this->getMethod());
47: }
48:
49: 50: 51: 52: 53:
54: public function getCardsBlock()
55: {
56: return $this->getLayout()->createBlock('paygate/authorizenet_info_cc')
57: ->setMethod($this->getMethod())
58: ->setInfo($this->getMethod()->getInfoInstance())
59: ->setCheckoutProgressBlock(false)
60: ->setHideTitle(true);
61: }
62:
63: 64: 65: 66: 67:
68: public function getCancelUrl()
69: {
70: return $this->getUrl('paygate/authorizenet_payment/cancel');
71: }
72:
73: 74: 75: 76: 77:
78: public function getAdminCancelUrl()
79: {
80: return Mage::getModel('adminhtml/url')->getUrl('adminhtml/paygate_authorizenet_payment/cancel');
81: }
82:
83: 84: 85: 86: 87:
88: protected function _toHtml()
89: {
90: $this->setChild('cards', $this->getCardsBlock());
91: $this->setChild('method_form_block', $this->getMethodFormBlock());
92: return parent::_toHtml();
93: }
94:
95: 96: 97: 98: 99:
100: public function showNoticeMessage($message)
101: {
102: return $this->getLayout()->getMessagesBlock()
103: ->addNotice($this->__($message))
104: ->getGroupedHtml();
105: }
106:
107: 108: 109: 110: 111:
112: public function getPartialAuthorizationConfirmationMessage()
113: {
114: $lastActionState = $this->getMethod()->getPartialAuthorizationLastActionState();
115: if ($lastActionState == Mage_Paygate_Model_Authorizenet::PARTIAL_AUTH_LAST_SUCCESS) {
116: $this->getMethod()->unsetPartialAuthorizationLastActionState();
117: return Mage::helper('paygate')->__('The amount on your credit card is insufficient to complete your purchase. The available amount has been put on hold. To complete your purchase click OK and specify additional credit card number. To cancel the purchase and release the amount on hold, click Cancel.');
118: } elseif ($lastActionState == Mage_Paygate_Model_Authorizenet::PARTIAL_AUTH_LAST_DECLINED) {
119: $this->getMethod()->unsetPartialAuthorizationLastActionState();
120: return Mage::helper('paygate')->__('Your credit card has been declined. Click OK to specify another credit card to complete your purchase. Click Cancel to release the amount on hold and select another payment method.');
121: }
122: return false;;
123: }
124:
125: 126: 127: 128: 129:
130: public function getPartialAuthorizationFormMessage()
131: {
132: $lastActionState = $this->getMethod()->getPartialAuthorizationLastActionState();
133: $message = false;
134: switch ($lastActionState) {
135: case Mage_Paygate_Model_Authorizenet::PARTIAL_AUTH_ALL_CANCELED:
136: $message = Mage::helper('paygate')->__('Your payment has been cancelled. All authorized amounts have been released.');
137: break;
138: case Mage_Paygate_Model_Authorizenet::PARTIAL_AUTH_CARDS_LIMIT_EXCEEDED:
139: $message = Mage::helper('paygate')->__('You have reached the maximum number of credit cards that can be used for one payment. The available amounts on all used cards were insufficient to complete payment. The payment has been cancelled and amounts on hold have been released.');
140: break;
141: case Mage_Paygate_Model_Authorizenet::PARTIAL_AUTH_DATA_CHANGED:
142: $message = Mage::helper('paygate')->__('Your order has not been placed, because contents of the shopping cart and/or address has been changed. Authorized amounts from your previous payment that were left pending are now released. Please go through the checkout process for your recent cart contents.');
143: break;
144: }
145: if ($message) {
146: $this->getMethod()->unsetPartialAuthorizationLastActionState();
147: }
148: return $message;
149: }
150:
151: 152: 153: 154: 155:
156: public function getCancelConfirmationMessage()
157: {
158: return $this->__('Are you sure you want to cancel your payment? Click OK to cancel your payment and release the amount on hold. Click Cancel to enter another credit card and continue with your payment.');
159: }
160:
161: 162: 163: 164: 165:
166: public function isPartialAuthorization()
167: {
168: return $this->getMethod()->isPartialAuthorization();
169: }
170:
171: 172: 173: 174: 175:
176: public function getCancelButtonHtml()
177: {
178: $cancelButton = $this->getLayout()->createBlock('adminhtml/widget_button')
179: ->setData(array(
180: 'id' => 'payment_cancel',
181: 'label' => Mage::helper('paygate')->__('Cancel'),
182: 'onclick' => 'cancelPaymentAuthorizations()'
183: ));
184: return $cancelButton->toHtml();
185: }
186: }
187: