Cardpay_PayeezyLevel3 - Version 1.0.0

Version Notes

Initial stable release

Download this release

Release Info

Developer Brian McGowan
Extension Cardpay_PayeezyLevel3
Version 1.0.0
Comparing to
See all releases


Version 1.0.0

Files changed (23) hide show
  1. app/code/community/Cardpay/PayeezyLevel3/Block/Creditcard.php +236 -0
  2. app/code/community/Cardpay/PayeezyLevel3/Block/Form.php +53 -0
  3. app/code/community/Cardpay/PayeezyLevel3/Block/Info.php +98 -0
  4. app/code/community/Cardpay/PayeezyLevel3/Helper/Data.php +113 -0
  5. app/code/community/Cardpay/PayeezyLevel3/Model/Creditcard.php +124 -0
  6. app/code/community/Cardpay/PayeezyLevel3/Model/PaymentMethod.php +601 -0
  7. app/code/community/Cardpay/PayeezyLevel3/Model/Resource/Creditcard.php +36 -0
  8. app/code/community/Cardpay/PayeezyLevel3/Model/Resource/Creditcard/Collection.php +36 -0
  9. app/code/community/Cardpay/PayeezyLevel3/Model/Source/Cctype.php +37 -0
  10. app/code/community/Cardpay/PayeezyLevel3/Model/Source/PaymentAction.php +46 -0
  11. app/code/community/Cardpay/PayeezyLevel3/controllers/CreditcardController.php +239 -0
  12. app/code/community/Cardpay/PayeezyLevel3/etc/config.xml +115 -0
  13. app/code/community/Cardpay/PayeezyLevel3/etc/system.xml +181 -0
  14. app/code/community/Cardpay/PayeezyLevel3/sql/payeezylevel3_setup/install-1.0.0.php +61 -0
  15. app/design/adminhtml/default/default/template/payeezylevel3/form.phtml +143 -0
  16. app/design/frontend/base/default/layout/payeezylevel3.xml +56 -0
  17. app/design/frontend/base/default/template/payeezylevel3/creditcard/delete.phtml +61 -0
  18. app/design/frontend/base/default/template/payeezylevel3/creditcard/edit.phtml +134 -0
  19. app/design/frontend/base/default/template/payeezylevel3/creditcard/index.phtml +64 -0
  20. app/design/frontend/base/default/template/payeezylevel3/form.phtml +167 -0
  21. app/etc/modules/Cardpay_PayeezyLevel3.xml +12 -0
  22. app/locale/en_US/Cardpay_PayeezyLevel3.csv +1 -0
  23. package.xml +18 -0
app/code/community/Cardpay/PayeezyLevel3/Block/Creditcard.php ADDED
@@ -0,0 +1,236 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Cardpay Solutions, Inc.
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is available through the world-wide-web at this URL:
9
+ * http://opensource.org/licenses/osl-3.0.php
10
+ *
11
+ * PHP version 5
12
+ *
13
+ * @category Cardpay
14
+ * @package Cardpay_PayeezyLevel3
15
+ * @copyright Copyright (c) 2015 Cardpay Solutions, Inc. (http://www.cardpaysolutions.com)
16
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
17
+ */
18
+
19
+ /**
20
+ * First Data PayeezyLevel3 credit card block.
21
+ *
22
+ * @category Cardpay
23
+ * @package Cardpay_PayeezyLevel3
24
+ * @author Cardpay Solutions, Inc. <sales@cardpaysolutions.com>
25
+ */
26
+ class Cardpay_PayeezyLevel3_Block_Creditcard extends Mage_Core_Block_Template
27
+ {
28
+ const TYPE_EDIT = 'edit';
29
+
30
+ /**
31
+ * Returns credit card
32
+ *
33
+ * @return Cardpay_PayeezyLevel3_Model_Creditcard credit card object
34
+ */
35
+ public function creditCard()
36
+ {
37
+ $id = Mage::app()->getRequest()->getParam('id');
38
+ $card = Mage::getModel('payeezylevel3/creditcard')->load($id);
39
+ return $card;
40
+ }
41
+
42
+ /**
43
+ * If existing card being edited
44
+ *
45
+ * @return bool if existing card edit
46
+ */
47
+ public function isEditMode()
48
+ {
49
+ if ($this->getType() == self::TYPE_EDIT) {
50
+ return true;
51
+ }
52
+ return false;
53
+ }
54
+
55
+ /**
56
+ * Returns url for add
57
+ *
58
+ * @return string add url
59
+ */
60
+ public function getAddUrl()
61
+ {
62
+ return $this->getUrl('customer/creditcard/new');
63
+ }
64
+
65
+ /**
66
+ * Returns url for edit
67
+ *
68
+ * @param int $id id of credit card
69
+ *
70
+ * @return string edit url
71
+ */
72
+ public function getEditUrl($id)
73
+ {
74
+ return $this->getUrl('customer/creditcard/edit', array('id' => $id));
75
+ }
76
+
77
+ /**
78
+ * Returns url for delete
79
+ *
80
+ * @param int $id id of credit card
81
+ *
82
+ * @return string delete url
83
+ */
84
+ public function getDeleteUrl($id)
85
+ {
86
+ return $this->getUrl('customer/creditcard/delete', array('id' => $id));
87
+ }
88
+
89
+ /**
90
+ * Returns url for delete confirm
91
+ *
92
+ * @param int $id id of credit card
93
+ *
94
+ * @return string delete confirm url
95
+ */
96
+ public function getDeleteConfirmUrl($id)
97
+ {
98
+ return $this->getUrl('customer/creditcard/deleteconfirm', array('id' => $id));
99
+ }
100
+
101
+ /**
102
+ * Returns url for new or edit form action
103
+ *
104
+ * @return string form action url
105
+ */
106
+ public function getFormAction()
107
+ {
108
+ if ($this->getType() == self::TYPE_EDIT) {
109
+ $url = $this->getUrl(
110
+ 'customer/creditcard/update',
111
+ array('id' => Mage::app()->getRequest()->getParam('id'))
112
+ );
113
+ } else {
114
+ $url = $this->getUrl('customer/creditcard/save');
115
+ }
116
+ return $url;
117
+ }
118
+
119
+ /**
120
+ * Returns page title
121
+ *
122
+ * @return string page title
123
+ */
124
+ public function getTitle()
125
+ {
126
+ $title = '';
127
+ if ($this->getType() == self::TYPE_EDIT) {
128
+ $title = 'Edit Credit Card';
129
+ } else {
130
+ $title = 'Add Credit Card';
131
+ }
132
+ return $this->__($title);
133
+ }
134
+
135
+ /**
136
+ * Returns url for back
137
+ *
138
+ * @return string back url
139
+ */
140
+ public function getBackUrl()
141
+ {
142
+ return $this->getUrl('customer/creditcard/index');
143
+ }
144
+
145
+ /**
146
+ * Returns credit card expire months
147
+ *
148
+ * @return array expiration months
149
+ */
150
+ public function getCcMonths()
151
+ {
152
+ $months = $this->getData('cc_months');
153
+ if (is_null($months)) {
154
+ $months[0] = $this->__('Month');
155
+ $months = array_merge($months, Mage::getSingleton('payment/config')->getMonths());
156
+ $this->setData('cc_months', $months);
157
+ }
158
+ return $months;
159
+ }
160
+
161
+ /**
162
+ * Returns credit card expire years
163
+ *
164
+ * @return array expiration years
165
+ */
166
+ public function getCcYears()
167
+ {
168
+ $years = $this->getData('cc_years');
169
+ if (is_null($years)) {
170
+ $years = Mage::getSingleton('payment/config')->getYears();
171
+ $years = array(0=>$this->__('Year'))+$years;
172
+ $this->setData('cc_years', $years);
173
+ }
174
+ return $years;
175
+ }
176
+
177
+ /**
178
+ * Returns available credit card types
179
+ *
180
+ * @return array card types
181
+ */
182
+ public function getCcAvailableTypes()
183
+ {
184
+ $types = Mage::getSingleton('payment/config')->getCcTypes();
185
+ if ($method = Mage::getModel('payeezylevel3/paymentmethod')) {
186
+ $availableTypes = $method->getConfigData('cctypes');
187
+ if ($availableTypes) {
188
+ $availableTypes = explode(',', $availableTypes);
189
+ foreach ($types as $code=>$name) {
190
+ if (!in_array($code, $availableTypes)) {
191
+ unset($types[$code]);
192
+ }
193
+ }
194
+ }
195
+ }
196
+ return $types;
197
+ }
198
+
199
+ /**
200
+ * If make default should be shown
201
+ *
202
+ * @return bool if can make default
203
+ */
204
+ public function canShowMakeDefault()
205
+ {
206
+ $model = Mage::getModel('payeezylevel3/creditcard');
207
+ $cardCount = count($model->currentCustomerCards());
208
+
209
+ if ($this->getType() == self::TYPE_EDIT) {
210
+ $cardId = $this->getRequest()->getParam('id');
211
+ $card = $model->load($cardId);
212
+ if ($card->getIsDefault()) {
213
+ return false;
214
+ } else {
215
+ return true;
216
+ }
217
+ } else {
218
+ if ($cardCount > 0) {
219
+ return true;
220
+ } else {
221
+ return false;
222
+ }
223
+ }
224
+ }
225
+
226
+ /**
227
+ * If cc cid should be shown
228
+ *
229
+ * @return bool if cid
230
+ */
231
+ public function hasVerification()
232
+ {
233
+ $method = Mage::getModel('payeezylevel3/paymentmethod');
234
+ return $method->getConfigData('useccv');
235
+ }
236
+ }
app/code/community/Cardpay/PayeezyLevel3/Block/Form.php ADDED
@@ -0,0 +1,53 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Cardpay Solutions, Inc.
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is available through the world-wide-web at this URL:
9
+ * http://opensource.org/licenses/osl-3.0.php
10
+ *
11
+ * PHP version 5
12
+ *
13
+ * @category Cardpay
14
+ * @package Cardpay_PayeezyLevel3
15
+ * @copyright Copyright (c) 2015 Cardpay Solutions, Inc. (http://www.cardpaysolutions.com)
16
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
17
+ */
18
+
19
+ /**
20
+ * First Data PayeezyLevel3 form block.
21
+ *
22
+ * @category Cardpay
23
+ * @package Cardpay_PayeezyLevel3
24
+ * @author Cardpay Solutions, Inc. <sales@cardpaysolutions.com>
25
+ */
26
+ class Cardpay_PayeezyLevel3_Block_Form extends Mage_Payment_Block_Form_Cc
27
+ {
28
+ /**
29
+ * Internal constructor. Set template.
30
+ */
31
+ protected function _construct()
32
+ {
33
+ parent::_construct();
34
+ $this->setTemplate('payeezylevel3/form.phtml');
35
+ }
36
+
37
+ /**
38
+ * If credit card can be saved
39
+ *
40
+ * @return bool if can save
41
+ */
42
+ public function canSaveCard()
43
+ {
44
+ $methodRegister = Mage_Checkout_Model_Type_Onepage::METHOD_REGISTER;
45
+ if (Mage::getModel('payeezylevel3/paymentmethod')->getConfigData('use_vault')
46
+ && (Mage::getSingleton('customer/session')->isLoggedIn()
47
+ || Mage::getSingleton('checkout/type_onepage')->getCheckoutMethod() == $methodRegister)
48
+ ) {
49
+ return true;
50
+ }
51
+ return false;
52
+ }
53
+ }
app/code/community/Cardpay/PayeezyLevel3/Block/Info.php ADDED
@@ -0,0 +1,98 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Cardpay Solutions, Inc.
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is available through the world-wide-web at this URL:
9
+ * http://opensource.org/licenses/osl-3.0.php.
10
+ *
11
+ * PHP version 5
12
+ *
13
+ * @category Cardpay
14
+ * @package Cardpay_PayeezyLevel3
15
+ * @copyright Copyright (c) 2015 Cardpay Solutions, Inc. (http://www.cardpaysolutions.com)
16
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
17
+ */
18
+
19
+ /**
20
+ * First Data PayeezyLevel3 info block.
21
+ *
22
+ * @category Cardpay
23
+ * @package Cardpay_PayeezyLevel3
24
+ * @author Cardpay Solutions, Inc. <sales@cardpaysolutions.com>
25
+ */
26
+ class Cardpay_PayeezyLevel3_Block_Info extends Mage_Payment_Block_Info
27
+ {
28
+ /**
29
+ * Return credit card type
30
+ *
31
+ * @return string card type name
32
+ */
33
+ public function getCcTypeName()
34
+ {
35
+ $types = Mage::getSingleton('payment/config')->getCcTypes();
36
+ $ccType = $this->getInfo()->getCcType();
37
+ if (isset($types[$ccType])) {
38
+ return $types[$ccType];
39
+ }
40
+ return (empty($ccType)) ? Mage::helper('payeezylevel3')->__('Stored Card') : $ccType;
41
+ }
42
+
43
+ /**
44
+ * If has expiration date
45
+ *
46
+ * @return bool if has expiration date
47
+ */
48
+ public function hasCcExpDate()
49
+ {
50
+ return (int)$this->getInfo()->getCcExpMonth() || (int)$this->getInfo()->getCcExpYear();
51
+ }
52
+
53
+ /**
54
+ * Return credit card expiration
55
+ *
56
+ * @return string formatted expiration date
57
+ */
58
+ public function getCcExpDate()
59
+ {
60
+ $month = $this->getInfo()->getCcExpMonth();
61
+ $year = $this->getInfo()->getCcExpYear();
62
+ return sprintf('%s/%s', sprintf('%02d', $month), $year);
63
+ }
64
+
65
+ /**
66
+ * Prepare information specific to current payment method
67
+ *
68
+ * @param null | array $transport
69
+ *
70
+ * @return Varien_Object specific information
71
+ */
72
+ protected function _prepareSpecificInformation($transport = null)
73
+ {
74
+ if (null !== $this->_paymentSpecificInformation) {
75
+ return $this->_paymentSpecificInformation;
76
+ }
77
+ $transport = parent::_prepareSpecificInformation($transport);
78
+ $data = array();
79
+ if ($ccType = $this->getCcTypeName()) {
80
+ $data[Mage::helper('payeezylevel3')->__('Credit Card Type')] = $ccType;
81
+ }
82
+ if ($ccLast = $this->getInfo()->getCcLast4()) {
83
+ $data[Mage::helper('payeezylevel3')->__('Credit Card Number')] = sprintf('xxxx-%s', $ccLast);
84
+ }
85
+ if ($this->hasCcExpDate()) {
86
+ $data[Mage::helper('payeezylevel3')->__('Expiration Date')] = $this->getCcExpDate();
87
+ }
88
+ if (Mage::app()->getStore()->isAdmin()) {
89
+ if ($this->getInfo()->getCcAvsStatus()) {
90
+ $data[Mage::helper('payeezylevel3')->__('AVS Response')] = $this->getInfo()->getCcAvsStatus();
91
+ }
92
+ if ($this->getInfo()->getCcCidStatus()) {
93
+ $data[Mage::helper('payeezylevel3')->__('CVV2 Response')] = $this->getInfo()->getCcCidStatus();
94
+ }
95
+ }
96
+ return $transport->setData(array_merge($data, $transport->getData()));
97
+ }
98
+ }
app/code/community/Cardpay/PayeezyLevel3/Helper/Data.php ADDED
@@ -0,0 +1,113 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Cardpay Solutions, Inc.
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is available through the world-wide-web at this URL:
9
+ * http://opensource.org/licenses/osl-3.0.php
10
+ *
11
+ * PHP version 5
12
+ *
13
+ * @category Cardpay
14
+ * @package Cardpay_PayeezyLevel3
15
+ * @copyright Copyright (c) 2015 Cardpay Solutions, Inc. (http://www.cardpaysolutions.com)
16
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
17
+ */
18
+
19
+ /**
20
+ * First Data PayeezyLevel3 data helper.
21
+ *
22
+ * @category Cardpay
23
+ * @package Cardpay_PayeezyLevel3
24
+ * @author Cardpay Solutions, Inc. <sales@cardpaysolutions.com>
25
+ */
26
+ class Cardpay_PayeezyLevel3_Helper_Data extends Mage_Core_Helper_Abstract
27
+ {
28
+ /**
29
+ * Returns credit card name
30
+ *
31
+ * @param $code credit card type code
32
+ *
33
+ * @return string card type name
34
+ */
35
+ public function getCcTypeName($code)
36
+ {
37
+ $ccTypes = array(
38
+ 'VI' => 'Visa',
39
+ 'MC' => 'MasterCard',
40
+ 'AE' => 'American Express',
41
+ 'DI' => 'Discover',
42
+ 'JCB' => 'JCB'
43
+ );
44
+ return $ccTypes[$code];
45
+ }
46
+
47
+ /**
48
+ * Returns avs response description
49
+ *
50
+ * @param $code avs response code
51
+ *
52
+ * @return string avs message
53
+ */
54
+ public function getAvsResponse($code)
55
+ {
56
+ $avsResponses = array(
57
+ 'X' => 'Exact match, 9 digit zip - Street Address, and 9 digit ZIP Code match',
58
+ 'Y' => 'Exact match, 5 digit zip - Street Address, and 5 digit ZIP Code match',
59
+ 'A' => 'Partial match - Street Address matches, ZIP Code does not',
60
+ 'W' => 'Partial match - ZIP Code matches, Street Address does not',
61
+ 'Z' => 'Partial match - 5 digit ZIP Code match only',
62
+ 'N' => 'No match - No Address or ZIP Code match',
63
+ 'U' => 'Unavailable - Address information is unavailable for that account number,
64
+ or the card issuer does not support',
65
+ 'G' => 'Service Not supported, non-US Issuer does not participate',
66
+ 'R' => 'Retry - Issuer system unavailable, retry later',
67
+ 'E' => 'Not a mail or phone order',
68
+ 'S' => 'Service not supported',
69
+ 'Q' => 'Bill to address did not pass edit checks',
70
+ 'D' => 'International street address and postal code match',
71
+ 'B' => 'International street address match',
72
+ 'C' => 'International street address and postal code not verified due to incompatable formats',
73
+ 'P' => 'International postal code match, street address not verified due to incompatable format',
74
+ '1' => 'Cardholder name matches',
75
+ '2' => 'Cardholder name, billing address, and postal code match',
76
+ '3' => 'Cardholder name and billing postal code match',
77
+ '4' => 'Cardholder name and billing address match',
78
+ '5' => 'Cardholder name incorrect, billing address and postal code match',
79
+ '6' => 'Cardholder name incorrect, billing postal code matches',
80
+ '7' => 'Cardholder name incorrect, billing address matches',
81
+ '8' => 'Cardholder name, billing address, and postal code are all incorrect'
82
+ );
83
+ if (array_key_exists($code, $avsResponses)) {
84
+ return $avsResponses[$code];
85
+ } else {
86
+ return '';
87
+ }
88
+ }
89
+
90
+ /**
91
+ * Returns cvv response description
92
+ *
93
+ * @param $code cvv response code
94
+ *
95
+ * @return string cvv message
96
+ */
97
+ public function getCvvResponse($code)
98
+ {
99
+ $cvvResponses = array(
100
+ 'M' => 'CVV2/CVC2 Match',
101
+ 'N' => 'CVV2 / CVC2 No Match',
102
+ 'P' => 'Not Processed',
103
+ 'S' => 'Merchant Has Indicated that CVV2 / CVC2 is not present on card',
104
+ 'U' => 'Issuer is not certified and/or has not provided visa encryption keys',
105
+ 'I' => 'CVV2 code is invalid or empty'
106
+ );
107
+ if (array_key_exists($code, $cvvResponses)) {
108
+ return $cvvResponses[$code];
109
+ } else {
110
+ return '';
111
+ }
112
+ }
113
+ }
app/code/community/Cardpay/PayeezyLevel3/Model/Creditcard.php ADDED
@@ -0,0 +1,124 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Cardpay Solutions, Inc.
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is available through the world-wide-web at this URL:
9
+ * http://opensource.org/licenses/osl-3.0.php
10
+ *
11
+ * PHP version 5
12
+ *
13
+ * @category Cardpay
14
+ * @package Cardpay_PayeezyLevel3
15
+ * @copyright Copyright (c) 2015 Cardpay Solutions, Inc. (http://www.cardpaysolutions.com)
16
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
17
+ */
18
+
19
+ /**
20
+ * First Data PayeezyLevel3 credit card model.
21
+ *
22
+ * @category Cardpay
23
+ * @package Cardpay_PayeezyLevel3
24
+ * @author Cardpay Solutions, Inc. <sales@cardpaysolutions.com>
25
+ */
26
+ class Cardpay_PayeezyLevel3_Model_Creditcard extends Mage_Core_Model_Abstract
27
+ {
28
+ /**
29
+ * Internal constructor.
30
+ */
31
+ public function _construct()
32
+ {
33
+ parent::_construct();
34
+ $this->_init('payeezylevel3/creditcard');
35
+ }
36
+
37
+ /**
38
+ * Returns current customer credit cards
39
+ *
40
+ * @return array customer cards
41
+ */
42
+ public function currentCustomerCards()
43
+ {
44
+ if ($this->useVault() && Mage::getSingleton('customer/session')->isLoggedIn()) {
45
+ $customerId = Mage::getSingleton('customer/session')->getCustomerId();
46
+ $cards = $this->getCollection()->addFieldToFilter('customer_id', $customerId);
47
+ return $cards;
48
+ }
49
+ return array();
50
+ }
51
+
52
+ /**
53
+ * Returns current customer credit cards
54
+ *
55
+ * @return array customer cards
56
+ */
57
+ public function adminCustomerCards()
58
+ {
59
+ if ($this->useVault()) {
60
+ $customerId = Mage::getSingleton('adminhtml/session_quote')->getCustomerId();
61
+ $cards = $this->getCollection()->addFieldToFilter('customer_id', $customerId);
62
+ return $cards;
63
+ }
64
+ return array();
65
+ }
66
+
67
+ /**
68
+ * If can use vault
69
+ *
70
+ * @return bool if can use vault
71
+ */
72
+ public function useVault()
73
+ {
74
+ $payeezylevel3 = Mage::getModel('payeezylevel3/paymentmethod');
75
+ return $payeezylevel3->getConfigData('use_vault');
76
+ }
77
+
78
+ /**
79
+ * Returns credit card type name
80
+ *
81
+ * @return string card type name
82
+ */
83
+ public function getCardTypeName()
84
+ {
85
+ $payeezylevel3 = Mage::getModel('payeezylevel3/paymentmethod');
86
+ return Mage::helper('payeezylevel3')->getCcTypeName($this->getCcType());
87
+ }
88
+
89
+ /**
90
+ * Returns masked credit card number
91
+ *
92
+ * @return string masked card number
93
+ */
94
+ public function getMaskedCardNum()
95
+ {
96
+ return '************' . substr($this->getToken(), -4);
97
+ }
98
+
99
+ /**
100
+ * Returns cardholder name
101
+ *
102
+ * @return string cardholder name
103
+ */
104
+ public function getCardholderName()
105
+ {
106
+ $customer = Mage::getSingleton('customer/session')->getCustomer();
107
+ $cardholderName = $customer->getName();
108
+ return $cardholderName;
109
+ }
110
+
111
+ /**
112
+ * Clears the current defualt credit card
113
+ */
114
+ public function clearDefault()
115
+ {
116
+ $cards = $this->currentCustomerCards();
117
+ foreach ($cards as $card) {
118
+ if ($card->getIsDefault()) {
119
+ $card->setIsDefault('0');
120
+ $card->save();
121
+ }
122
+ }
123
+ }
124
+ }
app/code/community/Cardpay/PayeezyLevel3/Model/PaymentMethod.php ADDED
@@ -0,0 +1,601 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Cardpay Solutions, Inc.
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is available through the world-wide-web at this URL:
9
+ * http://opensource.org/licenses/osl-3.0.php
10
+ *
11
+ * PHP version 5
12
+ *
13
+ * @category Cardpay
14
+ * @package Cardpay_PayeezyLevel3
15
+ * @copyright Copyright (c) 2015 Cardpay Solutions, Inc. (http://www.cardpaysolutions.com)
16
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
17
+ */
18
+
19
+ /**
20
+ * First Data PayeezyLevel3 payment method model.
21
+ *
22
+ * @category Cardpay
23
+ * @package Cardpay_PayeezyLevel3
24
+ * @author Cardpay Solutions, Inc. <sales@cardpaysolutions.com>
25
+ */
26
+ class Cardpay_PayeezyLevel3_Model_PaymentMethod extends Mage_Payment_Model_Method_Cc
27
+ {
28
+ protected $_code = 'payeezylevel3';
29
+ protected $_isGateway = true;
30
+ protected $_canAuthorize = true;
31
+ protected $_canCapture = true;
32
+ protected $_canCapturePartial = true;
33
+ protected $_canRefund = true;
34
+ protected $_canVoid = true;
35
+ protected $_canUseInternal = true;
36
+ protected $_canUseCheckout = true;
37
+ protected $_canUseForMultishipping = true;
38
+ protected $_canSaveCc = false;
39
+ protected $_canRefundInvoicePartial = true;
40
+
41
+ protected $_formBlockType = 'payeezylevel3/form';
42
+ protected $_infoBlockType = 'payeezylevel3/info';
43
+
44
+ private $_baseURL;
45
+ private $_url;
46
+ private $_merchantToken;
47
+
48
+ const API_KEY = 'tF92QqXikGklcppFBAfzZnDFghkjBXrN';
49
+ const API_SECRET = 'ab66d97bab5a4781c50fff107a1eb10e0bb40258385fb7a4da2fa5b320d128ec';
50
+
51
+ /**
52
+ * Validate data
53
+ *
54
+ * @return bool true
55
+ */
56
+ public function validate()
57
+ {
58
+ return true;
59
+ }
60
+
61
+ /**
62
+ * Authorizes specified amount
63
+ *
64
+ * @param Varien_Object $payment payment object
65
+ * @param decimal $amount amount in decimals
66
+ *
67
+ * @return Cardpay_PayeezyLevel3_Model_PaymentMethod payment method object
68
+ */
69
+ public function authorize(Varien_Object $payment, $amount)
70
+ {
71
+ $post = Mage::app()->getRequest()->getPost();
72
+ $payload = $this->getPayload($payment, $amount, "authorize");
73
+ $headerArray = $this->hmacAuthorizationToken($payload);
74
+ $response = json_decode($this->postTransaction($payload, $headerArray));
75
+ if ($response->transaction_status == "approved") {
76
+ $payment->setTransactionId($response->transaction_id)
77
+ ->setCcApproval($response->transaction_tag)
78
+ ->setCcTransId($response->transaction_id)
79
+ ->setIsTransactionClosed(0)
80
+ ->setParentTransactionId(null)
81
+ ->setCcAvsStatus(Mage::helper('payeezylevel3')->getAvsResponse($response->avs))
82
+ ->setCcCidStatus(Mage::helper('payeezylevel3')->getCvvResponse($response->cvv2));
83
+ if (isset($post['payment']['save_card'])) {
84
+ $this->saveCard($payment, $response->token->token_data->value);
85
+ }
86
+ return $this;
87
+ } else {
88
+ if ($response->bank_message) {
89
+ Mage::throwException('Transaction Declined: ' . $response->bank_message);
90
+ } else {
91
+ if ($response->Error->messages[0]->description == 'Access denied') {
92
+ Mage::throwException('Invalid Merchant Token: Call merchant support at (866) 588-0503 to obtain a new token');
93
+ } else {
94
+ Mage::throwException('Transaction Error: ' . $response->Error->messages[0]->description);
95
+ }
96
+
97
+ }
98
+
99
+ }
100
+ }
101
+
102
+ /**
103
+ * Captures specified amount
104
+ *
105
+ * @param Varien_Object $payment payment object
106
+ * @param decimal $amount amount in decimals
107
+ *
108
+ * @return Cardpay_PayeezyLevel3_Model_PaymentMethod payment method object
109
+ */
110
+ public function capture(Varien_Object $payment, $amount)
111
+ {
112
+ if ($payment->getParentTransactionId()) {
113
+ $payload = $this->getPayload($payment, $amount, "capture");
114
+ $headerArray = $this->hmacAuthorizationToken($payload);
115
+ $response = json_decode($this->postTransaction($payload, $headerArray));
116
+ if ($response->transaction_status == "approved") {
117
+ $payment->setTransactionId($response->transaction_id)
118
+ ->setCcApproval($response->transaction_tag)
119
+ ->setCcTransId($response->transaction_id)
120
+ ->setIsTransactionClosed(1)
121
+ ->setParentTransactionId($payment->getParentTransactionId());
122
+ return $this;
123
+ } else {
124
+ if ($response->bank_message) {
125
+ Mage::throwException('Capture Failed: ' . $response->bank_message);
126
+ } else {
127
+ Mage::throwException('Capture Error: ' . $response->Error->messages[0]->description);
128
+ }
129
+ }
130
+ } else {
131
+ return $this->purchase($payment, $amount);
132
+ }
133
+ }
134
+
135
+ /**
136
+ * Authoirzes and captures specified amount
137
+ *
138
+ * @param Varien_Object $payment payment object
139
+ * @param decimal $amount amount in decimals
140
+ *
141
+ * @return Cardpay_PayeezyLevel3_Model_PaymentMethod payment method object
142
+ */
143
+ public function purchase(Varien_Object $payment, $amount)
144
+ {
145
+ $post = Mage::app()->getRequest()->getPost();
146
+ $payload = $this->getPayload($payment, $amount, "purchase");
147
+ $headerArray = $this->hmacAuthorizationToken($payload);
148
+ $response = json_decode($this->postTransaction($payload, $headerArray));
149
+ if ($response->transaction_status == "approved") {
150
+ $payment->setTransactionId($response->transaction_id)
151
+ ->setCcApproval($response->transaction_tag)
152
+ ->setCcTransId($response->transaction_id)
153
+ ->setIsTransactionClosed(1)
154
+ ->setParentTransactionId(null)
155
+ ->setCcAvsStatus(Mage::helper('payeezylevel3')->getAvsResponse($response->avs))
156
+ ->setCcCidStatus(Mage::helper('payeezylevel3')->getCvvResponse($response->cvv2));
157
+ if (isset($post['payment']['save_card'])) {
158
+ $this->saveCard($payment, $response->token->token_data->value);
159
+ }
160
+ return $this;
161
+ } else {
162
+ if ($response->bank_message) {
163
+ Mage::throwException('Transaction Declined: ' . $response->bank_message);
164
+ } else {
165
+ if ($response->Error->messages[0]->description == 'Access denied') {
166
+ Mage::throwException('Invalid Merchant Token: Call merchant support at (866) 588-0503 to obtain a new token');
167
+ } else {
168
+ Mage::throwException('Transaction Error: ' . $response->Error->messages[0]->description);
169
+ }
170
+ }
171
+ }
172
+ }
173
+
174
+ /**
175
+ * Refunds specified amount
176
+ *
177
+ * @param Varien_Object $payment payment object
178
+ * @param decimal $amount amount in decimals
179
+ *
180
+ * @return Cardpay_PayeezyLevel3_Model_PaymentMethod payment method object
181
+ */
182
+ public function refund(Varien_Object $payment, $amount)
183
+ {
184
+ if ($payment->getParentTransactionId()) {
185
+ $payload = $this->getPayload($payment, $amount, "refund");
186
+ $headerArray = $this->hmacAuthorizationToken($payload);
187
+ $response = json_decode($this->postTransaction($payload, $headerArray));
188
+ if ($response->transaction_status == "approved") {
189
+ $payment->setTransactionId($response->transaction_id)
190
+ ->setCcApproval($response->transaction_tag)
191
+ ->setCcTransId($response->transaction_id)
192
+ ->setIsTransactionClosed(1)
193
+ ->setParentTransactionId($payment->getParentTransactionId());
194
+ return $this;
195
+ } else {
196
+ if ($response->bank_message) {
197
+ Mage::throwException('Refund Failed: ' . $response->bank_message);
198
+ } else {
199
+ Mage::throwException('Refund Error: ' . $response->Error->messages[0]->description);
200
+ }
201
+ }
202
+ } else {
203
+ Mage::throwException('Refund Failed: Invalid parent transaction ID.');
204
+ }
205
+ }
206
+
207
+ /**
208
+ * Voides authorized transaction
209
+ *
210
+ * @param Varien_Object $payment payment object
211
+ *
212
+ * @return Cardpay_PayeezyLevel3_Model_PaymentMethod payment method object
213
+ */
214
+ public function void(Varien_Object $payment)
215
+ {
216
+ if ($payment->getParentTransactionId()) {
217
+ $amount = $payment->getBaseAmountAuthorized();
218
+ $payload = $this->getPayload($payment, $amount, "void");
219
+ $headerArray = $this->hmacAuthorizationToken($payload);
220
+ $response = json_decode($this->postTransaction($payload, $headerArray));
221
+ if ($response->transaction_status == "approved") {
222
+ $payment->setTransactionId($response->transaction_id)
223
+ ->setCcApproval($response->transaction_tag)
224
+ ->setCcTransId($response->transaction_id)
225
+ ->setIsTransactionClosed(1)
226
+ ->setParentTransactionId($payment->getParentTransactionId());
227
+ return $this;
228
+ } else {
229
+ if ($response->bank_message) {
230
+ Mage::throwException('Void Failed: ' . $response->bank_message);
231
+ } else {
232
+ Mage::throwException('Void Error: ' . $response->Error->messages[0]->description);
233
+ }
234
+ }
235
+ } else {
236
+ Mage::throwException('Void Failed: Invalid parent transaction ID.');
237
+ }
238
+ }
239
+
240
+ /**
241
+ * Voides transaction on cancel action
242
+ *
243
+ * @param Varien_Object $payment payment object
244
+ *
245
+ * @return Cardpay_PayeezyLevel3_Model_PaymentMethod payment method object
246
+ */
247
+ public function cancel(Varien_Object $payment)
248
+ {
249
+ return $this->void($payment);
250
+ }
251
+
252
+ /**
253
+ * Requests token for card
254
+ *
255
+ * @param Cardpay_PayeezyLevel3_Model_Creditcard $card credit card object
256
+ *
257
+ * @return string token value
258
+ */
259
+ public function verify($card)
260
+ {
261
+ $payload = $this->getTokenPayload($card);
262
+ $headerArray = $this->hmacAuthorizationToken($payload);
263
+ $response = json_decode($this->postTransaction($payload, $headerArray));
264
+ if ($response->status == "success") {
265
+ return $response->token->value;
266
+ } else {
267
+ if ($response->status) {
268
+ Mage::throwException('Card Declined');
269
+ } else {
270
+ Mage::throwException($response->Error->messages[0]->description);
271
+ }
272
+ }
273
+ }
274
+
275
+ /**
276
+ * Saves card and transarmor token
277
+ *
278
+ * @param Varien_Object $payment payment object
279
+ * @param string $token token value
280
+ *
281
+ * @return Cardpay_PayeezyLevel3_Model_Creditcard credit card object
282
+ */
283
+ public function saveCard(Varien_Object $payment, $token)
284
+ {
285
+ if ($token) {
286
+ $customerId = $payment->getOrder()->getCustomerId();
287
+ $card = Mage::getModel('payeezylevel3/creditcard');
288
+ $card->setData('customer_id', $customerId);
289
+ $card->setData('token', $token);
290
+ $card->setData('cc_exp_month', $payment->getCcExpMonth());
291
+ $card->setData('cc_exp_year', $payment->getCcExpYear());
292
+ $card->setData('cc_type', $payment->getCcType());
293
+ if (count($card->currentCustomerCards()) || count($card->adminCustomerCards())) {
294
+ $card->setData('is_default', '0');
295
+ } else {
296
+ $card->setData('is_default', '1');
297
+ }
298
+ $card->save();
299
+ }
300
+ }
301
+
302
+ /**
303
+ * Returns a previously saved card
304
+ *
305
+ * @param string $token token value
306
+ *
307
+ * @return Cardpay_PayeezyLevel3_Model_Creditcard credit card object
308
+ */
309
+ public function getSavedCard($token)
310
+ {
311
+ $card = Mage::getModel('payeezylevel3/creditcard')->load($token);
312
+ return $card;
313
+ }
314
+
315
+ /**
316
+ * Returns payload for transaction
317
+ *
318
+ * @param Varien_Object $payment payment object
319
+ * @param decimal $amount amount in decimals
320
+ * @param string $transaction_type transaction type string
321
+ *
322
+ * @return array payload
323
+ */
324
+ public function getPayload(Varien_Object $payment, $amount, $transactionType)
325
+ {
326
+ $post = Mage::app()->getRequest()->getPost();
327
+ if (isset($post['payment']['token']) && !empty($post['payment']['token'])) {
328
+ $card = $this->getSavedCard($post['payment']['token']);
329
+ $payment->setCcExpYear($card->getCcExpYear())
330
+ ->setCcExpMonth($card->getCcExpMonth())
331
+ ->setCcType($card->getCcType())
332
+ ->setCcLast4(substr($card->getToken(), -4));
333
+ }
334
+ $order = $payment->getOrder();
335
+ $orderId = $order->getIncrementId();
336
+ $billing = $order->getBillingAddress();
337
+ $amountInCents = $amount * 100;
338
+ $yr = substr($payment->getCcExpYear(), -2);
339
+ $expDate = sprintf('%02d%02d', $payment->getCcExpMonth(), $yr);
340
+ $testMode = $this->getConfigData('test_mode');
341
+ $currency = $this->getConfigData('currency');
342
+ $ccType = Mage::helper('payeezylevel3')->getCcTypeName($payment->getCcType());
343
+ $data = '';
344
+
345
+ if ($testMode) {
346
+ $this->_baseURL = 'https://api-cert.payeezy.com/v1/transactions';
347
+ $this->_merchantToken = 'fdoa-a480ce8951daa73262734cf102641994c1e55e7cdf4c02b6';
348
+ } else {
349
+ $this->_baseURL = 'https://api.payeezy.com/v1/transactions';
350
+ $this->_merchantToken = $this->getConfigData('merchant_token');
351
+ }
352
+
353
+ if ($transactionType == "authorize" || $transactionType == "purchase") {
354
+ if (isset($card)) {
355
+ $data = array(
356
+ 'merchant_ref' => $this->processInput($orderId),
357
+ 'transaction_type' => $this->processInput($transactionType),
358
+ 'method' => 'token',
359
+ 'amount' => $this->processInput($amountInCents),
360
+ 'currency_code' => $this->processInput($currency),
361
+ 'token' => array(
362
+ 'token_type' => 'FDToken',
363
+ 'token_data' => array(
364
+ 'type' => $this->processInput($ccType),
365
+ 'value' => $this->processInput($card->getToken()),
366
+ 'cardholder_name' => $this->processInput($billing->getName()),
367
+ 'exp_date' => $this->processInput($expDate)
368
+ )
369
+ ),
370
+ 'billing_address' => array(
371
+ 'street' => $this->processInput(substr($billing->getStreet(1), 0, 30)),
372
+ 'zip_postal_code' => $this->processInput(substr($billing->getPostcode(), 0, 10))
373
+ ),
374
+ 'level2' => array(
375
+ 'tax1_amount' => number_format($order->getTaxAmount(), '2', '.', ''),
376
+ 'customer_ref' => $this->processInput($orderId)
377
+ ),
378
+ 'level3' => $this->getLevel3Data($payment)
379
+ );
380
+ } else {
381
+ $data = array(
382
+ 'merchant_ref' => $this->processInput($orderId),
383
+ 'transaction_type' => $this->processInput($transactionType),
384
+ 'method' => 'credit_card',
385
+ 'amount' => $this->processInput($amountInCents),
386
+ 'currency_code' => $this->processInput($currency),
387
+ 'credit_card' => array(
388
+ 'type' => $this->processInput(Mage::helper('payeezylevel3')->getCcTypeName($payment->getCcType())),
389
+ 'cardholder_name' => $this->processInput($billing->getName()),
390
+ 'card_number' => $this->processInput($payment->getCcNumber()),
391
+ 'exp_date' => $this->processInput($expDate),
392
+ 'cvv' => $this->processInput($payment->getCcCid())
393
+ ),
394
+ 'billing_address' => array(
395
+ 'street' => $this->processInput(substr($billing->getStreet(1), 0, 30)),
396
+ 'zip_postal_code' => $this->processInput(substr($billing->getPostcode(), 0, 10))
397
+ ),
398
+ 'level2' => array(
399
+ 'tax1_amount' => number_format($order->getTaxAmount(), '2', '.', ''),
400
+ 'customer_ref' => $this->processInput($orderId)
401
+ ),
402
+ 'level3' => $this->getLevel3Data($payment)
403
+ );
404
+ }
405
+ $this->_url = $this->_baseURL;
406
+ } else {
407
+ $this->_url = $this->_baseURL . '/' . $payment->getParentTransactionId();
408
+ $data = array(
409
+ 'merchant_ref' => $this->processInput($orderId),
410
+ 'transaction_type' => $this->processInput($transactionType),
411
+ 'method' => $this->processInput('credit_card'),
412
+ 'amount' => $this->processInput($amountInCents),
413
+ 'currency_code' => $this->processInput($currency),
414
+ 'transaction_tag' => $this->processInput($payment->getCcApproval())
415
+ );
416
+ }
417
+ return json_encode($data);
418
+ }
419
+
420
+ /**
421
+ * Returns Level 3 payment data for payload
422
+ *
423
+ * @param Varien_Object $payment payment object
424
+ *
425
+ * @return array level3
426
+ */
427
+ public function getLevel3Data(Varien_Object $payment)
428
+ {
429
+ $order = $payment->getOrder();
430
+ $order_items = $order->getAllVisibleItems();
431
+ $shipping_address = $order->getShippingAddress();
432
+ $shipping_phone = preg_replace('/[^0-9]/','', $shipping_address->getTelephone());
433
+ $commodity_code = $this->getConfigData('commodity_code');
434
+ $ship_from_zip = Mage::getStoreConfig('shipping/origin/postcode');
435
+ $line_items = array();
436
+ foreach ($order_items as $item) {
437
+ $line_items[] = array(
438
+ 'description' => $this->processInput(substr($item->getName(), 0, 26)),
439
+ 'quantity' => (int)$item->getQtyOrdered(),
440
+ 'commodity_code' => $this->processInput(substr($commodity_code, 0, 12)),
441
+ 'discount_amount' => number_format($item->getDiscountAmount(), '2', '.', ''),
442
+ 'discount_indicator' => $item->getDiscountAmount() > 0 ? '1' : '0',
443
+ 'gross_net_indicator' => '1',
444
+ 'line_item_total' => number_format($item->getRowTotal(), '2', '.', ''),
445
+ 'product_code' => $this->processInput(substr($item->getSku(), 0, 12)),
446
+ 'tax_amount' => number_format($item->getTaxAmount(), '2', '.', ''),
447
+ 'tax_rate' => number_format($item->getTaxPercent(), '2', '.', ''),
448
+ 'tax_type' => '2',
449
+ 'unit_cost' => number_format($item->getPrice(), '2', '.', ''),
450
+ 'unit_of_measure' => 'EA'
451
+ );
452
+ }
453
+
454
+ $level3 = array(
455
+ 'discount_amount' => number_format(abs($order->getDiscountAmount()), '2', '.', ''),
456
+ 'duty_amount' => '0.00',
457
+ 'freight_amount' => number_format($order->getShippingAmount(), '2', '.', ''),
458
+ 'ship_from_zip' => $this->processInput(substr($ship_from_zip, 0, 10)),
459
+ 'ship_to_address' => array(
460
+ 'address_1' => $this->processInput(substr($shipping_address->getStreetFull(), 0, 28)),
461
+ 'city' => $this->processInput(substr($shipping_address->getCity(), 0, 20)),
462
+ 'state' => $this->processInput(substr($shipping_address->getRegionCode(), 0, 2)),
463
+ 'zip' => $this->processInput(substr($shipping_address->getPostcode(), 0, 10)),
464
+ 'country' => $this->processInput($shipping_address->getCountry()),
465
+ 'customer_number' => $this->processInput($order->getIncrementId()),
466
+ 'email' => $this->processInput(substr($order->getCustomerEmail(), 0, 50)),
467
+ 'name' => $this->processInput(substr($shipping_address->getName(), 0, 28)),
468
+ 'phone' => $this->processInput(substr($shipping_phone, 0, 14))
469
+ ),
470
+ 'line_items' => $line_items
471
+ );
472
+ return $level3;
473
+ }
474
+
475
+ /**
476
+ * Returns payload for token request
477
+ *
478
+ * @param Cardpay_PayeezyLevel3_Model_Creditcard $card credit card object
479
+ *
480
+ * @return array payload
481
+ */
482
+ public function getTokenPayload($card)
483
+ {
484
+ $yr = substr($card->getCcExpYear(), -2);
485
+ $expDate = sprintf('%02d%02d', $card->getCcExpMonth(), $yr);
486
+ $testMode = $this->getConfigData('test_mode');
487
+ $data = '';
488
+
489
+ if ($testMode) {
490
+ $this->_baseURL = 'https://api-cert.payeezy.com/v1/transactions';
491
+ $this->_merchantToken = 'fdoa-a480ce8951daa73262734cf102641994c1e55e7cdf4c02b6';
492
+ $taToken = 'NOIW';
493
+ } else {
494
+ $this->_baseURL = 'https://api.payeezy.com/v1/transactions';
495
+ $this->_merchantToken = $this->getConfigData('merchant_token');
496
+ $taToken = $this->getConfigData('ta_token');
497
+ }
498
+
499
+ $data = array(
500
+ 'type' => 'FDToken',
501
+ 'auth' => 'false',
502
+ 'ta_token' => $this->processInput($taToken),
503
+ 'credit_card' => array(
504
+ 'type' => $this->processInput(Mage::helper('payeezylevel3')->getCcTypeName($card->getCcType())),
505
+ 'cardholder_name' => $this->processInput($card->getCardholderName()),
506
+ 'card_number' => $this->processInput($card->getCcNumber()),
507
+ 'exp_date' => $this->processInput($expDate),
508
+ 'cvv' => $this->processInput($card->getCcCid())
509
+ )
510
+ );
511
+ $this->_url = $this->_baseURL . '/tokens';
512
+ return json_encode($data, JSON_FORCE_OBJECT);
513
+ }
514
+
515
+ /**
516
+ * Returns HMAC authorization values
517
+ *
518
+ * @param array $payload payload
519
+ *
520
+ * @return array hmac values
521
+ */
522
+ public function hmacAuthorizationToken($payload)
523
+ {
524
+ $nonce = strval(hexdec(bin2hex(openssl_random_pseudo_bytes(4, $cstrong))));
525
+ $timestamp = strval(time() * 1000); //time stamp in milli seconds
526
+ $data = self::API_KEY . $nonce . $timestamp . $this->_merchantToken . $payload;
527
+ $hashAlgorithm = "sha256";
528
+ $hmac = hash_hmac($hashAlgorithm, $data, self::API_SECRET, false); // HMAC Hash in hex
529
+ $authorization = base64_encode($hmac);
530
+ return array(
531
+ 'authorization' => $authorization,
532
+ 'nonce' => $nonce,
533
+ 'timestamp' => $timestamp
534
+ );
535
+ }
536
+
537
+ /**
538
+ * Post transaction to gateway
539
+ *
540
+ * @param array $payload payload
541
+ * @param array $headers headers
542
+ *
543
+ * @return string json response
544
+ */
545
+ public function postTransaction($payload, $headers)
546
+ {
547
+ $request = curl_init();
548
+ curl_setopt($request, CURLOPT_URL, $this->_url);
549
+ curl_setopt($request, CURLOPT_POST, true);
550
+ curl_setopt($request, CURLOPT_POSTFIELDS, $payload);
551
+ curl_setopt($request, CURLOPT_RETURNTRANSFER, true);
552
+ curl_setopt($request, CURLOPT_HEADER, false);
553
+ //curl_setopt($request, CURLOPT_SSL_VERIFYPEER, false);
554
+ curl_setopt(
555
+ $request, CURLOPT_HTTPHEADER, array(
556
+ 'Content-Type: application/json',
557
+ 'apikey:' . strval(self::API_KEY),
558
+ 'token:' . strval($this->_merchantToken),
559
+ 'Authorization:' . $headers['authorization'],
560
+ 'nonce:' . $headers['nonce'],
561
+ 'timestamp:' . $headers['timestamp']
562
+ )
563
+ );
564
+ $response = curl_exec($request);
565
+ if (false === $response) {
566
+ Mage::throwException('Transaction Error: ' . curl_error($request));
567
+ }
568
+ curl_close($request);
569
+ return $response;
570
+ }
571
+
572
+ /**
573
+ * Returns processed input
574
+ *
575
+ * @param string $data input data
576
+ *
577
+ * @return string processed input
578
+ */
579
+ public function processInput($data)
580
+ {
581
+ $data = trim($data);
582
+ $data = stripslashes($data);
583
+ $data = htmlspecialchars($data);
584
+ return strval($data);
585
+ }
586
+
587
+ /**
588
+ * If payment method is available for currency
589
+ *
590
+ * @param string $currencyCode order currency
591
+ *
592
+ * @return bool available for currency or not
593
+ */
594
+ public function canUseForCurrency($currencyCode)
595
+ {
596
+ if ($currencyCode != $this->getConfigData('currency')) {
597
+ return false;
598
+ }
599
+ return true;
600
+ }
601
+ }
app/code/community/Cardpay/PayeezyLevel3/Model/Resource/Creditcard.php ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Cardpay Solutions, Inc.
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is available through the world-wide-web at this URL:
9
+ * http://opensource.org/licenses/osl-3.0.php
10
+ *
11
+ * PHP version 5
12
+ *
13
+ * @category Cardpay
14
+ * @package Cardpay_PayeezyLevel3
15
+ * @copyright Copyright (c) 2015 Cardpay Solutions, Inc. (http://www.cardpaysolutions.com)
16
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
17
+ */
18
+
19
+ /**
20
+ * First Data PayeezyLevel3 credit card resource model.
21
+ *
22
+ * @category Cardpay
23
+ * @package Cardpay_PayeezyLevel3
24
+ * @author Cardpay Solutions, Inc. <sales@cardpaysolutions.com>
25
+ */
26
+ class Cardpay_PayeezyLevel3_Model_Resource_Creditcard extends Mage_Core_Model_Resource_Db_Abstract
27
+ {
28
+ /**
29
+ * Internal constructor. Set template.
30
+ */
31
+ public function _construct()
32
+ {
33
+ // Note that the <module>_id refers to the key field in your database table.
34
+ $this->_init('payeezylevel3/creditcard', 'payeezylevel3_id');
35
+ }
36
+ }
app/code/community/Cardpay/PayeezyLevel3/Model/Resource/Creditcard/Collection.php ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Cardpay Solutions, Inc.
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is available through the world-wide-web at this URL:
9
+ * http://opensource.org/licenses/osl-3.0.php
10
+ *
11
+ * PHP version 5
12
+ *
13
+ * @category Cardpay
14
+ * @package Cardpay_PayeezyLevel3
15
+ * @copyright Copyright (c) 2015 Cardpay Solutions, Inc. (http://www.cardpaysolutions.com)
16
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
17
+ */
18
+
19
+ /**
20
+ * First Data PayeezyLevel3 credit card collection resource model.
21
+ *
22
+ * @category Cardpay
23
+ * @package Cardpay_PayeezyLevel3
24
+ * @author Cardpay Solutions, Inc. <sales@cardpaysolutions.com>
25
+ */
26
+ class Cardpay_PayeezyLevel3_Model_Resource_Creditcard_Collection extends Mage_Core_Model_Resource_Db_Collection_Abstract
27
+ {
28
+ /**
29
+ * Internal constructor.
30
+ */
31
+ public function _construct()
32
+ {
33
+ parent::_construct();
34
+ $this->_init('payeezylevel3/creditcard');
35
+ }
36
+ }
app/code/community/Cardpay/PayeezyLevel3/Model/Source/Cctype.php ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Cardpay Solutions, Inc.
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is available through the world-wide-web at this URL:
9
+ * http://opensource.org/licenses/osl-3.0.php
10
+ *
11
+ * PHP version 5
12
+ *
13
+ * @category Cardpay
14
+ * @package Cardpay_PayeezyLevel3
15
+ * @copyright Copyright (c) 2015 Cardpay Solutions, Inc. (http://www.cardpaysolutions.com)
16
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
17
+ */
18
+
19
+ /**
20
+ * First Data PayeezyLevel3 credit card type source model.
21
+ *
22
+ * @category Cardpay
23
+ * @package Cardpay_PayeezyLevel3
24
+ * @author Cardpay Solutions, Inc. <sales@cardpaysolutions.com>
25
+ */
26
+ class Cardpay_PayeezyLevel3_Model_Source_Cctype extends Mage_Payment_Model_Source_Cctype
27
+ {
28
+ /**
29
+ * Allowed credit card types
30
+ *
31
+ * @return array allowed card types
32
+ */
33
+ public function getAllowedTypes()
34
+ {
35
+ return array('VI', 'MC', 'AE', 'DI', 'JCB');
36
+ }
37
+ }
app/code/community/Cardpay/PayeezyLevel3/Model/Source/PaymentAction.php ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Cardpay Solutions, Inc.
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is available through the world-wide-web at this URL:
9
+ * http://opensource.org/licenses/osl-3.0.php
10
+ *
11
+ * PHP version 5
12
+ *
13
+ * @category Cardpay
14
+ * @package Cardpay_PayeezyLevel3
15
+ * @copyright Copyright (c) 2015 Cardpay Solutions, Inc. (http://www.cardpaysolutions.com)
16
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
17
+ */
18
+
19
+ /**
20
+ * First Data PayeezyLevel3 payment action source model.
21
+ *
22
+ * @category Cardpay
23
+ * @package Cardpay_PayeezyLevel3
24
+ * @author Cardpay Solutions, Inc. <sales@cardpaysolutions.com>
25
+ */
26
+ class Cardpay_PayeezyLevel3_Model_Source_PaymentAction
27
+ {
28
+ /**
29
+ * Possible actions on order place
30
+ *
31
+ * @return array payment actions
32
+ */
33
+ public function toOptionArray()
34
+ {
35
+ return array(
36
+ array(
37
+ 'value' => Mage_Payment_Model_Method_Abstract::ACTION_AUTHORIZE,
38
+ 'label' => 'Authorize'
39
+ ),
40
+ array(
41
+ 'value' => Mage_Payment_Model_Method_Abstract::ACTION_AUTHORIZE_CAPTURE,
42
+ 'label' => 'Authorize and Capture'
43
+ ),
44
+ );
45
+ }
46
+ }
app/code/community/Cardpay/PayeezyLevel3/controllers/CreditcardController.php ADDED
@@ -0,0 +1,239 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Cardpay Solutions, Inc.
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is available through the world-wide-web at this URL:
9
+ * http://opensource.org/licenses/osl-3.0.php
10
+ *
11
+ * PHP version 5
12
+ *
13
+ * @category Cardpay
14
+ * @package Cardpay_PayeezyLevel3
15
+ * @copyright Copyright (c) 2015 Cardpay Solutions, Inc. (http://www.cardpaysolutions.com)
16
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
17
+ */
18
+
19
+ require_once 'Mage/Customer/controllers/AccountController.php';
20
+
21
+ /**
22
+ * First Data PayeezyLevel3 credit card controller.
23
+ *
24
+ * @category Cardpay
25
+ * @package Cardpay_PayeezyLevel3
26
+ * @author Cardpay Solutions, Inc. <sales@cardpaysolutions.com>
27
+ */
28
+ class Cardpay_PayeezyLevel3_CreditCardController extends Mage_Customer_AccountController
29
+ {
30
+ /**
31
+ * Retrieve customer session object
32
+ *
33
+ * @return Mage_Customer_Model_Session
34
+ */
35
+ protected function _getSession()
36
+ {
37
+ return Mage::getSingleton('customer/session');
38
+ }
39
+
40
+ /**
41
+ * Action predispatch
42
+ *
43
+ * Check if extension and vault are enabled, otherwise no route
44
+ */
45
+ public function preDispatch()
46
+ {
47
+ parent::preDispatch();
48
+
49
+ if (!Mage::getSingleton('customer/session')->authenticate($this)
50
+ || !Mage::getStoreConfig('payment/payeezylevel3/use_vault')
51
+ || !Mage::getStoreConfig('payment/payeezylevel3/active')
52
+ ) {
53
+ $this->setFlag('', 'no-dispatch', true);
54
+ }
55
+ }
56
+
57
+ /**
58
+ * Customer credit card list
59
+ */
60
+ public function indexAction()
61
+ {
62
+ $this->loadLayout();
63
+ $this->_initMessages();
64
+ $this->renderLayout();
65
+ }
66
+
67
+ /**
68
+ * Customer new credit card
69
+ */
70
+ public function newAction()
71
+ {
72
+ $this->loadLayout();
73
+ $this->_initMessages();
74
+ $this->renderLayout();
75
+ }
76
+
77
+ /**
78
+ * Customer save credit card
79
+ */
80
+ public function saveAction()
81
+ {
82
+ if (!$this->_validateFormKey()) {
83
+ $this->_getSession()->addError($this->__('Error saving credit card'));
84
+ return $this->_redirect('customer/creditcard/index');
85
+ }
86
+ if ($this->getRequest()->isPost()) {
87
+ $customerId = $this->_getSession()->getCustomerId();
88
+ $cardholderName = $this->_getSession()->getCustomer()->getName();
89
+ $data = $this->getRequest()->getPost();
90
+
91
+ $card = Mage::getModel('payeezylevel3/creditcard');
92
+ $card->addData($data['payment']);
93
+ $card->setData('customer_id', $customerId);
94
+ $card->setData('cardholder_name', $cardholderName);
95
+ $payeezylevel3 = Mage::getModel('payeezylevel3/paymentmethod');
96
+ try {
97
+ $token = $payeezylevel3->verify($card);
98
+ } catch (Exception $e) {
99
+ $this->_getSession()->addError($e->getMessage());
100
+ return $this->_redirect('customer/creditcard/new');
101
+ }
102
+
103
+ $card->setData('token', $token);
104
+ if ($card->getIsDefault()) {
105
+ $card->clearDefault();
106
+ }
107
+ $card->save();
108
+ $this->_getSession()->addSuccess($this->__('The credit card has been saved.'));
109
+ }
110
+ $this->_redirect('customer/creditcard/index');
111
+ }
112
+
113
+ /**
114
+ * Customer update credit card
115
+ */
116
+ public function updateAction()
117
+ {
118
+ if (!$this->_validateFormKey()) {
119
+ $this->_getSession()->addError($this->__('Error updating credit card'));
120
+ return $this->_redirect('customer/creditcard/index');
121
+ }
122
+ if ($this->getRequest()->isPost()) {
123
+ $cardId = $this->getRequest()->getParam('id');
124
+ $customerId = $this->_getSession()->getCustomerId();
125
+ $cardholderName = $this->_getSession()->getCustomer()->getName();
126
+ $data = $this->getRequest()->getPost();
127
+ $card = Mage::getModel('payeezylevel3/creditcard')->load($cardId);
128
+
129
+ // Validate that card belongs to customer
130
+ if ($card->getCustomerId() != $customerId) {
131
+ $this->_getSession()->addError($this->__('The credit card does not belong to this customer.'));
132
+ return $this->_redirect('customer/creditcard/index');
133
+ }
134
+
135
+ $card->addData($data['payment']);
136
+ $card->setData('customer_id', $customerId);
137
+ $card->setData('cardholder_name', $cardholderName);
138
+ $payeezylevel3 = Mage::getModel('payeezylevel3/paymentmethod');
139
+ try {
140
+ $token = $payeezylevel3->verify($card);
141
+ } catch (Exception $e) {
142
+ $this->_getSession()->addError($e->getMessage());
143
+ return $this->_redirect('customer/creditcard/new');
144
+ }
145
+
146
+ $card->setData('token', $token);
147
+ if ($card->getIsDefault()) {
148
+ $card->clearDefault();
149
+ }
150
+ $card->save();
151
+ $this->_getSession()->addSuccess($this->__('The credit card has been updated.'));
152
+ }
153
+ $this->_redirect('customer/creditcard/index');
154
+ }
155
+
156
+ /**
157
+ * Customer edit credit card
158
+ */
159
+ public function editAction()
160
+ {
161
+ $cardId = $this->getRequest()->getParam('id');
162
+ if ($cardId) {
163
+ $card = Mage::getModel('payeezylevel3/creditcard')->load($cardId);
164
+
165
+ // Validate that card belongs to customer
166
+ if ($card->getCustomerId() != $this->_getSession()->getCustomerId()) {
167
+ $this->_getSession()->addError($this->__('The credit card does not belong to this customer.'));
168
+ return $this->_redirect('customer/creditcard/index');
169
+ }
170
+ $this->loadLayout();
171
+ $this->_initMessages();
172
+ $this->renderLayout();
173
+ } else {
174
+ $this->_getSession()->addError($this->__('Invalid credit card id.'));
175
+ return $this->_redirect('customer/creditcard/index');
176
+ }
177
+ }
178
+
179
+ /**
180
+ * Customer delete credit card
181
+ */
182
+ public function deleteAction()
183
+ {
184
+ $cardId = $this->getRequest()->getParam('id');
185
+ if ($cardId) {
186
+ $card = Mage::getModel('payeezylevel3/creditcard')->load($cardId);
187
+
188
+ // Validate that card belongs to customer
189
+ if ($card->getCustomerId() != $this->_getSession()->getCustomerId()) {
190
+ $this->_getSession()->addError($this->__('The credit card does not belong to this customer.'));
191
+ return $this->_redirect('customer/creditcard/index');
192
+ }
193
+ $this->loadLayout();
194
+ $this->_initMessages();
195
+ $this->renderLayout();
196
+ } else {
197
+ $this->_getSession()->addError($this->__('Invalid credit card id.'));
198
+ return $this->_redirect('customer/creditcard/index');
199
+ }
200
+ }
201
+
202
+ /**
203
+ * Customer confirm delete credit card
204
+ */
205
+ public function deleteConfirmAction()
206
+ {
207
+ $cardId = $this->getRequest()->getParam('id');
208
+ if ($cardId) {
209
+ $card = Mage::getModel('payeezylevel3/creditcard')->load($cardId);
210
+
211
+ // Validate that card belongs to customer
212
+ if ($card->getCustomerId() != $this->_getSession()->getCustomerId()) {
213
+ $this->_getSession()->addError($this->__('The credit card does not belong to this customer.'));
214
+ return $this->_redirect('customer/creditcard/index');
215
+ }
216
+
217
+ try {
218
+ $card->delete();
219
+ $this->_getSession()->addSuccess($this->__('The credit card has been deleted.'));
220
+ return $this->_redirect('customer/creditcard/index');
221
+ } catch (Exception $e){
222
+ $this->_getSession()->addError($this->__('An error occurred while deleting the credit card.'));
223
+ return $this->_redirect('customer/creditcard/index');
224
+ }
225
+ } else {
226
+ $this->_getSession()->addError($this->__('Invalid credit card id.'));
227
+ return $this->_redirect('customer/creditcard/index');
228
+ }
229
+ }
230
+
231
+ /**
232
+ * Init layout messages, add page title
233
+ */
234
+ protected function _initMessages()
235
+ {
236
+ $this->_initLayoutMessages('customer/session');
237
+ $this->getLayout()->getBlock('head')->setTitle($this->__('My Credit Cards'));
238
+ }
239
+ }
app/code/community/Cardpay/PayeezyLevel3/etc/config.xml ADDED
@@ -0,0 +1,115 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * Cardpay Solutions, Inc.
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ *
12
+ * PHP version 5
13
+ *
14
+ * @category Cardpay
15
+ * @package Cardpay_PayeezyLevel3
16
+ * @copyright Copyright (c) 2015 Cardpay Solutions, Inc. (http://www.cardpaysolutions.com)
17
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
18
+ */
19
+ -->
20
+ <congig>
21
+ <modules>
22
+ <Cardpay_PayeezyLevel3>
23
+ <version>1.0.0</version>
24
+ </Cardpay_PayeezyLevel3>
25
+ </modules>
26
+ <global>
27
+ <blocks>
28
+ <payeezylevel3>
29
+ <class>Cardpay_PayeezyLevel3_Block</class>
30
+ </payeezylevel3>
31
+ </blocks>
32
+ <models>
33
+ <payeezylevel3>
34
+ <class>Cardpay_PayeezyLevel3_Model</class>
35
+ <resourceModel>payeezylevel3_resource</resourceModel>
36
+ </payeezylevel3>
37
+ <payeezylevel3_resource>
38
+ <class>Cardpay_PayeezyLevel3_Model_Resource</class>
39
+ <entities>
40
+ <creditcard>
41
+ <table>payeezylevel3_credit_card</table>
42
+ </creditcard>
43
+ </entities>
44
+ </payeezylevel3_resource>
45
+ </models>
46
+ <resources>
47
+ <payeezylevel3_setup>
48
+ <setup>
49
+ <module>Cardpay_PayeezyLevel3</module>
50
+ </setup>
51
+ <connection>
52
+ <use>core_setup</use>
53
+ </connection>
54
+ </payeezylevel3_setup>
55
+ <payeezylevel3_write>
56
+ <connection>
57
+ <use>core_write</use>
58
+ </connection>
59
+ </payeezylevel3_write>
60
+ <payeezylevel3_read>
61
+ <connection>
62
+ <use>core_read</use>
63
+ </connection>
64
+ </payeezylevel3_read>
65
+ </resources>
66
+ <helpers>
67
+ <payeezylevel3>
68
+ <class>Cardpay_PayeezyLevel3_Helper</class>
69
+ </payeezylevel3>
70
+ </helpers>
71
+ </global>
72
+ <default>
73
+ <payment>
74
+ <payeezylevel3>
75
+ <active>0</active>
76
+ <model>payeezylevel3/paymentMethod</model>
77
+ <order_status>processing</order_status>
78
+ <title>Credit Card (Payeezy B2B)</title>
79
+ <cctypes>VI,MC,AE,DI,JCB</cctypes>
80
+ <payment_action>authorize</payment_action>
81
+ <allowspecific>0</allowspecific>
82
+ <currency>USD</currency>
83
+ <useccv>1</useccv>
84
+ <use_vault>1</use_vault>
85
+ </payeezylevel3>
86
+ </payment>
87
+ </default>
88
+ <frontend>
89
+ <layout>
90
+ <updates>
91
+ <payeezylevel3 module="Cardpay_PayeezyLevel3">
92
+ <file>payeezylevel3.xml</file>
93
+ </payeezylevel3>
94
+ </updates>
95
+ </layout>
96
+ <routers>
97
+ <customer>
98
+ <args>
99
+ <modules>
100
+ <Cardpay_PayeezyLevel3 after="Mage_Customer">Cardpay_PayeezyLevel3</Cardpay_PayeezyLevel3>
101
+ </modules>
102
+ </args>
103
+ </customer>
104
+ </routers>
105
+ <translate>
106
+ <modules>
107
+ <Cardpay_PayeezyLevel3>
108
+ <files>
109
+ <default>Cardpay_PayeezyLevel3.csv</default>
110
+ </files>
111
+ </Cardpay_PayeezyLevel3>
112
+ </modules>
113
+ </translate>
114
+ </frontend>
115
+ </congig>
app/code/community/Cardpay/PayeezyLevel3/etc/system.xml ADDED
@@ -0,0 +1,181 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * Cardpay Solutions, Inc.
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ *
12
+ * PHP version 5
13
+ *
14
+ * @category Cardpay
15
+ * @package Cardpay_PayeezyLevel3
16
+ * @copyright Copyright (c) 2015 Cardpay Solutions, Inc. (http://www.cardpaysolutions.com)
17
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
18
+ */
19
+ -->
20
+ <config>
21
+ <sections>
22
+ <payment>
23
+ <groups>
24
+ <payeezylevel3 translate="label" module="paygate">
25
+ <label>First Data Payeezy B2B Level 3</label>
26
+ <sort_order>700</sort_order>
27
+ <show_in_default>1</show_in_default>
28
+ <show_in_website>1</show_in_website>
29
+ <show_in_store>1</show_in_store>
30
+ <comment><![CDATA[<a href="http://www.pcardsystems.com/magento?pid=47d14a305e64a009" target="_blank">Click here to sign up for a Payeezy B2B merchant account</a>]]></comment>
31
+ <fields>
32
+ <active translate="label">
33
+ <label>Enabled</label>
34
+ <frontend_type>select</frontend_type>
35
+ <source_model>adminhtml/system_config_source_yesno</source_model>
36
+ <sort_order>1</sort_order>
37
+ <show_in_default>1</show_in_default>
38
+ <show_in_website>1</show_in_website>
39
+ <show_in_store>0</show_in_store>
40
+ </active>
41
+ <title translate="label">
42
+ <label>Title</label>
43
+ <frontend_type>text</frontend_type>
44
+ <sort_order>2</sort_order>
45
+ <show_in_default>1</show_in_default>
46
+ <show_in_website>1</show_in_website>
47
+ <show_in_store>1</show_in_store>
48
+ </title>
49
+ <test_mode translate="label">
50
+ <label>Test Mode</label>
51
+ <frontend_type>select</frontend_type>
52
+ <source_model>adminhtml/system_config_source_yesno</source_model>
53
+ <comment><![CDATA[If test mode is enabled, your transactions will be sent to a test merchant account.]]></comment>
54
+ <sort_order>3</sort_order>
55
+ <show_in_default>1</show_in_default>
56
+ <show_in_website>1</show_in_website>
57
+ <show_in_store>0</show_in_store>
58
+ </test_mode>
59
+ <merchant_token translate="label">
60
+ <label>Merchant Token</label>
61
+ <comment><![CDATA[Merchant Token provided by Payeezy after you establish your account. Contact sales at (866) 588-0503 to obtain your merchant token.]]></comment>
62
+ <frontend_type>text</frontend_type>
63
+ <sort_order>4</sort_order>
64
+ <show_in_default>1</show_in_default>
65
+ <show_in_website>1</show_in_website>
66
+ <show_in_store>0</show_in_store>
67
+ </merchant_token>
68
+ <commodity_code translate="label">
69
+ <label>Default Commodity Code</label>
70
+ <comment><![CDATA[Enter the 5 digit commodity code that best describes the type of products that you sell. <a href="https://a37186aa94a08d9086cb-3c54b90d7c788e49a2e99bea979bb225.ssl.cf1.rackcdn.com/commodity_codes.pdf">Click here to download the PDF list of valid commodity codes.</a> This value is required to obtain Level 3 Interchange rates.]]></comment>
71
+ <frontend_type>text</frontend_type>
72
+ <sort_order>5</sort_order>
73
+ <show_in_default>1</show_in_default>
74
+ <show_in_website>1</show_in_website>
75
+ <show_in_store>0</show_in_store>
76
+ <validate>validate-number validate-length minimum-length-5 maximum-length-5</validate>
77
+ </commodity_code>
78
+ <order_status translate="label">
79
+ <label>New order status</label>
80
+ <comment><![CDATA[The status of the order after the payment is successful.]]></comment>
81
+ <frontend_type>select</frontend_type>
82
+ <source_model>adminhtml/system_config_source_order_status</source_model>
83
+ <sort_order>6</sort_order>
84
+ <show_in_default>1</show_in_default>
85
+ <show_in_website>1</show_in_website>
86
+ <show_in_store>0</show_in_store>
87
+ </order_status>
88
+ <payment_action translate="label">
89
+ <label>Payment Action</label>
90
+ <frontend_type>select</frontend_type>
91
+ <source_model>payeezylevel3/source_paymentAction</source_model>
92
+ <sort_order>7</sort_order>
93
+ <show_in_default>1</show_in_default>
94
+ <show_in_website>1</show_in_website>
95
+ <show_in_store>0</show_in_store>
96
+ </payment_action>
97
+ <currency translate="label">
98
+ <label>Accepted Currency</label>
99
+ <comment><![CDATA[Account must be properly configured to process currencies other than USD. Contact sales for additional information: (866) 588-0503.]]></comment>
100
+ <frontend_type>select</frontend_type>
101
+ <source_model>adminhtml/system_config_source_currency</source_model>
102
+ <sort_order>8</sort_order>
103
+ <show_in_default>1</show_in_default>
104
+ <show_in_website>1</show_in_website>
105
+ <show_in_store>0</show_in_store>
106
+ </currency>
107
+ <cctypes translate="label">
108
+ <label>Credit Card Types</label>
109
+ <comment><![CDATA[Select which credit card types are accepted.]]></comment>
110
+ <frontend_type>multiselect</frontend_type>
111
+ <source_model>payeezylevel3/source_cctype</source_model>
112
+ <sort_order>9</sort_order>
113
+ <show_in_default>1</show_in_default>
114
+ <show_in_website>1</show_in_website>
115
+ <show_in_store>0</show_in_store>
116
+ </cctypes>
117
+ <useccv translate="label">
118
+ <label>Credit Card Verification</label>
119
+ <comment><![CDATA[Whether the 3 or 4 digit card security code is required.]]></comment>
120
+ <frontend_type>select</frontend_type>
121
+ <source_model>adminhtml/system_config_source_yesno</source_model>
122
+ <sort_order>10</sort_order>
123
+ <show_in_default>1</show_in_default>
124
+ <show_in_website>1</show_in_website>
125
+ <show_in_store>0</show_in_store>
126
+ </useccv>
127
+ <use_vault translate="label">
128
+ <label>Allow Stored Cards</label>
129
+ <comment><![CDATA[Allow a logged in customer to save credit cards for future use. PCI Compliant TransArmor Tokenization.]]></comment>
130
+ <frontend_type>select</frontend_type>
131
+ <source_model>adminhtml/system_config_source_yesno</source_model>
132
+ <sort_order>11</sort_order>
133
+ <show_in_default>1</show_in_default>
134
+ <show_in_website>1</show_in_website>
135
+ <show_in_store>0</show_in_store>
136
+ </use_vault>
137
+ <ta_token translate="label">
138
+ <label>TransArmor Token</label>
139
+ <comment><![CDATA[TransArmor token provided by Payeezy after you establish your account. Required for Stored Card functionality to work.]]></comment>
140
+ <frontend_type>text</frontend_type>
141
+ <sort_order>12</sort_order>
142
+ <show_in_default>1</show_in_default>
143
+ <show_in_website>1</show_in_website>
144
+ <show_in_store>0</show_in_store>
145
+ </ta_token>
146
+ <allowspecific translate="label">
147
+ <label><![CDATA[Payment from applicable countries:]]></label>
148
+ <comment><![CDATA[Set this to "Specific Countries" if you wish to limit what countries may place orders.]]></comment>
149
+ <frontend_type>allowspecific</frontend_type>
150
+ <sort_order>13</sort_order>
151
+ <source_model>adminhtml/system_config_source_payment_allspecificcountries</source_model>
152
+ <show_in_default>1</show_in_default>
153
+ <show_in_website>1</show_in_website>
154
+ <show_in_store>0</show_in_store>
155
+ </allowspecific>
156
+ <specificcountry translate="label">
157
+ <label><![CDATA[Payment from Specific countries:]]></label>
158
+ <comment><![CDATA[Which countries this payment method is available to. This becomes active if the setting above is set to "Specific Countries".]]></comment>
159
+ <frontend_type>multiselect</frontend_type>
160
+ <sort_order>14</sort_order>
161
+ <source_model>adminhtml/system_config_source_country</source_model>
162
+ <show_in_default>1</show_in_default>
163
+ <show_in_website>1</show_in_website>
164
+ <show_in_store>0</show_in_store>
165
+ </specificcountry>
166
+ <sort_order translate="label">
167
+ <label>Sort Order</label>
168
+ <comment><![CDATA[In which order this payment method will appear on the checkout page.]]></comment>
169
+ <frontend_type>text</frontend_type>
170
+ <sort_order>15</sort_order>
171
+ <show_in_default>1</show_in_default>
172
+ <show_in_website>1</show_in_website>
173
+ <show_in_store>0</show_in_store>
174
+ <frontend_class>validate-number</frontend_class>
175
+ </sort_order>
176
+ </fields>
177
+ </payeezylevel3>
178
+ </groups>
179
+ </payment>
180
+ </sections>
181
+ </config>
app/code/community/Cardpay/PayeezyLevel3/sql/payeezylevel3_setup/install-1.0.0.php ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Cardpay Solutions, Inc.
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is available through the world-wide-web at this URL:
9
+ * http://opensource.org/licenses/osl-3.0.php
10
+ *
11
+ * PHP version 5
12
+ *
13
+ * @category Cardpay
14
+ * @package Cardpay_PayeezyLevel3
15
+ * @copyright Copyright (c) 2015 Cardpay Solutions, Inc. (http://www.cardpaysolutions.com)
16
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
17
+ */
18
+
19
+
20
+ /* @var $installer Cardpay_PayeezyLevel3_Model_Resource_Creditcard */
21
+ $installer = $this;
22
+ $installer->startSetup();
23
+
24
+ /**
25
+ * Create table 'payeezylevel3_credit_card'
26
+ */
27
+ $table = $installer->getConnection()
28
+ ->newTable($installer->getTable('payeezylevel3_credit_card'))
29
+ ->addColumn('payeezylevel3_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
30
+ 'unsigned' => true,
31
+ 'identity' => true,
32
+ 'nullable' => false,
33
+ 'primary' => true,
34
+ ), 'PayeezyLevel3 Id')
35
+ ->addColumn('customer_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
36
+ 'unsigned' => true,
37
+ 'nullable' => false,
38
+ ), 'Customer Id')
39
+ ->addColumn('token', Varien_Db_Ddl_Table::TYPE_TEXT, 255, array(
40
+ 'nullable' => true,
41
+ ), 'Token')
42
+ ->addColumn('cc_exp_month', Varien_Db_Ddl_Table::TYPE_TEXT, 255, array(
43
+ 'nullable' => true,
44
+ ), 'Cc Exp Month')
45
+ ->addColumn('cc_exp_year', Varien_Db_Ddl_Table::TYPE_TEXT, 255, array(
46
+ 'nullable' => true,
47
+ ), 'Cc Exp Year')
48
+ ->addColumn('cc_type', Varien_Db_Ddl_Table::TYPE_TEXT, 255, array(
49
+ 'nullable' => true,
50
+ ), 'Cc Type')
51
+ ->addColumn('is_default', Varien_Db_Ddl_Table::TYPE_SMALLINT, null, array(
52
+ 'unsigned' => true,
53
+ 'nullable' => false,
54
+ 'default' => '0',
55
+ ), 'Is Default')
56
+ ->addIndex($installer->getIdxName('payeezylevel3_credit_card', array('customer_id')),
57
+ array('customer_id'))
58
+ ->setComment('PayeezyLevel3 Credit Card');
59
+
60
+ $installer->getConnection()->createTable($table);
61
+ $installer->endSetup();
app/design/adminhtml/default/default/template/payeezylevel3/form.phtml ADDED
@@ -0,0 +1,143 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Cardpay Solutions, Inc.
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is available through the world-wide-web at this URL:
9
+ * http://opensource.org/licenses/osl-3.0.php
10
+ *
11
+ * PHP version 5
12
+ *
13
+ * @category Cardpay
14
+ * @package Cardpay_PayeezyLevel3
15
+ * @copyright Copyright (c) 2015 Cardpay Solutions, Inc. (http://www.cardpaysolutions.com)
16
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
17
+ */
18
+ ?>
19
+ <?php
20
+ $_code = $this->getMethodCode();
21
+ $_model = Mage::getModel('payeezylevel3/creditcard');
22
+ $_savedCards = $_model->adminCustomerCards();
23
+ $_useVault = $_model->useVault() && count($_savedCards);
24
+ ?>
25
+ <ul id="payment_form_<?php echo $_code ?>" style="display:none">
26
+ <?php if ($_useVault): ?>
27
+ <li id="<?php echo $_code ?>_token_selector">
28
+ <label for="<?php echo $_code ?>_cc_token"><?php echo $this->__('Payment Information') ?></label>
29
+ <div class="input-box">
30
+ <select id="<?php echo $_code ?>_token" name="payment[token]">
31
+ <?php $_token = $this->getInfoData('token') ?>
32
+ <option value="">Select Saved Card</option>
33
+ <?php foreach ($_savedCards as $card): ?>
34
+ <option value="<?php echo $card->getId() ?>" <?php if($card->getId() == $_token): ?>selected="selected"<?php endif ?>>
35
+ <?php echo $card->getMaskedCardNum() . ' - ' . $card->getCardTypeName(); ?>
36
+ </option>
37
+ <?php endforeach; ?>
38
+ </select>
39
+ </div>
40
+ </li>
41
+ <li class="hide-if-token"><p>-- OR --</p></li>
42
+ <?php endif; ?>
43
+ <li class="hide-if-token">
44
+ <div class="input-box">
45
+ <label for="<?php echo $_code ?>_cc_type"><?php echo Mage::helper('payment')->__('Credit Card Type') ?> <span class="required">*</span></label><br/>
46
+ <select id="<?php echo $_code ?>_cc_type" name="payment[cc_type]" class="required-entry validate-cc-type-select">
47
+ <?php $_ccType = $this->getInfoData('cc_type') ?>
48
+ <option value=""></option>
49
+ <?php foreach ($this->getCcAvailableTypes() as $_typeCode => $_typeName): ?>
50
+ <option value="<?php echo $_typeCode ?>" <?php if($_typeCode==$_ccType): ?>selected="selected"<?php endif ?>><?php echo $_typeName ?></option>
51
+ <?php endforeach ?>
52
+ </select>
53
+ </div>
54
+ </li>
55
+ <li class="hide-if-token">
56
+ <div class="input-box">
57
+ <label for="<?php echo $_code ?>_cc_number"><?php echo Mage::helper('payment')->__('Credit Card Number') ?> <span class="required">*</span></label><br/>
58
+ <input type="text" id="<?php echo $_code ?>_cc_number" name="payment[cc_number]" title="<?php echo Mage::helper('payment')->__('Credit Card Number') ?>" class="input-text validate-cc-number" value="<?php echo $this->getInfoData('cc_number')?>"/>
59
+ </div>
60
+ </li>
61
+ <li class="hide-if-token">
62
+ <div class="input-box">
63
+ <label for="<?php echo $_code ?>_expiration"><?php echo Mage::helper('payment')->__('Expiration Date') ?> <span class="required">*</span></label><br/>
64
+ <select id="<?php echo $_code ?>_expiration" name="payment[cc_exp_month]" class="validate-cc-exp required-entry">
65
+ <?php $_ccExpMonth = $this->getInfoData('cc_exp_month') ?>
66
+ <?php foreach ($this->getCcMonths() as $k=>$v): ?>
67
+ <option value="<?php echo $k ?>" <?php if($k==$_ccExpMonth): ?>selected="selected"<?php endif ?>><?php echo $v ?></option>
68
+ <?php endforeach ?>
69
+ </select>
70
+ <?php $_ccExpYear = $this->getInfoData('cc_exp_year') ?>
71
+ <select id="<?php echo $_code ?>_expiration_yr" name="payment[cc_exp_year]" class="required-entry">
72
+ <?php foreach ($this->getCcYears() as $k=>$v): ?>
73
+ <option value="<?php echo $k ? $k : '' ?>" <?php if($k==$_ccExpYear): ?>selected="selected"<?php endif ?>><?php echo $v ?></option>
74
+ <?php endforeach ?>
75
+ </select>
76
+ </div>
77
+ </li>
78
+ <?php if($this->hasVerification()): ?>
79
+ <li class="hide-if-token">
80
+ <div class="input-box">
81
+ <label for="<?php echo $_code ?>_cc_cid"><?php echo Mage::helper('payment')->__('Card Verification Number') ?> <span class="required">*</span></label><br/>
82
+ <input type="text" title="<?php echo Mage::helper('payment')->__('Card Verification Number') ?>" class="required-entry input-text validate-cc-cvn" id="<?php echo $_code ?>_cc_cid" name="payment[cc_cid]" style="width:3em;" value="<?php echo $this->getInfoData('cc_cid')?>"/>
83
+ </div>
84
+ </li>
85
+ <?php endif; ?>
86
+ <?php if($_model->useVault()): ?>
87
+ <li class="hide-if-token" id="<?php echo $_code ?>_store_in_vault_div">
88
+ <input type="checkbox" title="<?php echo $this->__('Save this card for future use') ?>" class="input-checkbox" id="<?php echo $_code ?>_save_card" name="payment[save_card]" value="1" <?php if($this->getInfoData('save_card')): ?>checked="checked"<?php endif ?> />
89
+ <label for="<?php echo $_code ?>_save_card" style="float:none;"><?php echo $this->__('Save this card for future use') ?></label>
90
+ </li>
91
+ <?php endif; ?>
92
+ </ul>
93
+
94
+ <script type="text/javascript">
95
+ //<![CDATA[
96
+ (function() {
97
+ <?php if ($_useVault): ?>
98
+ var enableDisableFields = function(disabled) {
99
+ var code = "<?php echo $_code ?>";
100
+ <?php if($this->hasVerification()): ?>
101
+ var fields = ["_cc_type", "_cc_number", "_expiration", "_expiration_yr", "_cc_cid", "_save_card"];
102
+ <?php else: ?>
103
+ var fields = ["_cc_type", "_cc_number", "_expiration", "_expiration_yr", "_save_card"];
104
+ <?php endif; ?>
105
+ var id;
106
+ for (id = 0; id < fields.length; id++) {
107
+ $(code + fields[id]).disabled = disabled;
108
+ }
109
+ }
110
+
111
+ var selectBox = $('<?php echo $_code ?>_token');
112
+ var initToken = selectBox.getValue();
113
+
114
+ if (initToken)
115
+ {
116
+ $$('.hide-if-token').invoke('hide');
117
+ enableDisableFields("disabled");
118
+ }
119
+ $('<?php echo $_code ?>_token').observe('change', function (e) {
120
+ var selectBox = $(this);
121
+ var token = selectBox.getValue();
122
+ if (token)
123
+ {
124
+ $$('.hide-if-token').invoke('hide');
125
+ enableDisableFields("disabled");
126
+ }
127
+ else
128
+ {
129
+ $('<?php echo $_code ?>_cc_type').value = "";
130
+ $('<?php echo $_code ?>_cc_number').value = "";
131
+ $('<?php echo $_code ?>_expiration').value = "";
132
+ $('<?php echo $_code ?>_expiration_yr').value = "";
133
+ <?php if($this->hasVerification()): ?>
134
+ $('<?php echo $_code ?>_cc_cid').value = "";
135
+ <?php endif; ?>
136
+ $('<?php echo $_code ?>_save_card').checked = false;
137
+ $$('.hide-if-token').invoke('show');
138
+ enableDisableFields(false);
139
+ }
140
+ });
141
+ <?php endif; ?>
142
+ })();
143
+ //]]></script>
app/design/frontend/base/default/layout/payeezylevel3.xml ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * Cardpay Solutions, Inc.
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ *
12
+ * PHP version 5
13
+ *
14
+ * @category Cardpay
15
+ * @package Cardpay_PayeezyLevel3
16
+ * @copyright Copyright (c) 2015 Cardpay Solutions, Inc. (http://www.cardpaysolutions.com)
17
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
18
+ */
19
+ -->
20
+ <layout version="0.1.0">
21
+ <customer_account>
22
+ <reference name="customer_account_navigation">
23
+ <action method="addLink" translate="label" module="payeezylevel3" ifconfig="payment/payeezylevel3/use_vault">
24
+ <name>credit_card</name>
25
+ <path>customer/creditcard/</path>
26
+ <label>My Credit Cards</label>
27
+ </action>
28
+ </reference>
29
+ </customer_account>
30
+ <customer_creditcard_index>
31
+ <update handle="customer_account"/>
32
+ <reference name="my.account.wrapper">
33
+ <block type="payeezylevel3/creditcard" name="customer_creditcard" template="payeezylevel3/creditcard/index.phtml" />
34
+ </reference>
35
+ </customer_creditcard_index>
36
+ <customer_creditcard_new>
37
+ <update handle="customer_account"/>
38
+ <reference name="my.account.wrapper">
39
+ <block type="payeezylevel3/creditcard" name="customer_creditcard" template="payeezylevel3/creditcard/edit.phtml"/>
40
+ </reference>
41
+ </customer_creditcard_new>
42
+ <customer_creditcard_edit>
43
+ <update handle="customer_account"/>
44
+ <reference name="my.account.wrapper">
45
+ <block type="payeezylevel3/creditcard" name="customer_creditcard" template="payeezylevel3/creditcard/edit.phtml">
46
+ <action method="setType"><value>edit</value></action>
47
+ </block>
48
+ </reference>
49
+ </customer_creditcard_edit>
50
+ <customer_creditcard_delete>
51
+ <update handle="customer_account"/>
52
+ <reference name="my.account.wrapper">
53
+ <block type="payeezylevel3/creditcard" name="customer_creditcard" template="payeezylevel3/creditcard/delete.phtml" />
54
+ </reference>
55
+ </customer_creditcard_delete>
56
+ </layout>
app/design/frontend/base/default/template/payeezylevel3/creditcard/delete.phtml ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Cardpay Solutions, Inc.
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is available through the world-wide-web at this URL:
9
+ * http://opensource.org/licenses/osl-3.0.php
10
+ *
11
+ * PHP version 5
12
+ *
13
+ * @category Cardpay
14
+ * @package Cardpay_PayeezyLevel3
15
+ * @copyright Copyright (c) 2015 Cardpay Solutions, Inc. (http://www.cardpaysolutions.com)
16
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
17
+ */
18
+ ?>
19
+ <?php
20
+ $id = Mage::app()->getRequest()->getParam('id');
21
+ $card = Mage::getModel('payeezylevel3/creditcard')->load($id);
22
+ ?>
23
+ <div class="page-title">
24
+ <h1><?php echo $this->__('Delete Credit Card') ?></h1>
25
+ </div>
26
+ <?php echo $this->getMessagesBlock()->getGroupedHtml() ?>
27
+ <form action="<?php echo $this->getDeleteConfirmUrl($card->getId()) ?>" method="post" id="delete-form">
28
+ <div class="fieldset">
29
+ <h2 class="legend"><?php echo $this->__('Please confirm that you want to delete this credit card') ?></h2>
30
+ <ul class="form-list">
31
+ <li>
32
+ <b><?php echo $this->__('Credit Card Type'); ?></b>
33
+ </li>
34
+ <li>
35
+ <?php echo $card->getCardTypeName(); ?>
36
+ </li>
37
+ <li>
38
+ <b><?php echo $this->__('Credit Card Number'); ?></b>
39
+ </li>
40
+ <li>
41
+ <?php echo $card->getMaskedCardNum(); ?>
42
+ </li>
43
+ <li>
44
+ <b><?php echo $this->__('Expiration Date'); ?></b>
45
+ </li>
46
+ <li>
47
+ <?php echo $card->getCcExpMonth() . '/' . $card->getCcExpYear(); ?>
48
+ </li>
49
+ <li>
50
+ <b><?php echo $this->__('Cardholder Name'); ?></b>
51
+ </li>
52
+ <li>
53
+ <?php echo $card->getCardholderName(); ?>
54
+ </li>
55
+ </ul>
56
+ </div>
57
+ <div class="buttons-set">
58
+ <button type="submit" class="button" title="<?php echo $this->__('Delete') ?>"><span><span><?php echo $this->__('Delete') ?></span></span></button>
59
+ <p class="back-link"><a href="<?php echo $this->getBackUrl() ?>"><small>&laquo; </small><?php echo $this->__('Back') ?></a></p>
60
+ </div>
61
+ </form>
app/design/frontend/base/default/template/payeezylevel3/creditcard/edit.phtml ADDED
@@ -0,0 +1,134 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Cardpay Solutions, Inc.
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is available through the world-wide-web at this URL:
9
+ * http://opensource.org/licenses/osl-3.0.php
10
+ *
11
+ * PHP version 5
12
+ *
13
+ * @category Cardpay
14
+ * @package Cardpay_PayeezyLevel3
15
+ * @copyright Copyright (c) 2015 Cardpay Solutions, Inc. (http://www.cardpaysolutions.com)
16
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
17
+ */
18
+ ?>
19
+ <div class="page-title">
20
+ <h1><?php echo $this->getTitle() ?></h1>
21
+ </div>
22
+ <?php echo $this->getMessagesBlock()->getGroupedHtml() ?>
23
+ <?php
24
+ if ($this->isEditMode()) {
25
+ $creditCard = $this->creditCard();
26
+ $currentCcType = $creditCard->getCcType();
27
+ $currentCcExpMonth = $creditCard->getCcExpMonth();
28
+ $currentCcExpYear = $creditCard->getCcExpYear();
29
+ $isCcDefault = $creditCard->getIsDefault();
30
+ } else {
31
+ $currentCcType = '';
32
+ $currentCcExpMonth = '';
33
+ $currentCcExpYear = '';
34
+ }
35
+ ?>
36
+ <form action='<?php echo $this->getFormAction() ?>' method="post" id="cc-form-validate">
37
+ <div class="fieldset">
38
+ <?php echo $this->getBlockHtml('formkey')?>
39
+ <h2 class="legend"><?php echo $this->__('Credit Card') ?></h2>
40
+ <p class="required"><?php echo $this->__('* Required Fields') ?></p>
41
+
42
+ <ul class="form-list" id="payment_form_payeezylevel3">
43
+ <li>
44
+ <label for="payeezylevel3_cc_type" class="required"><em>*</em><?php echo $this->__('Credit Card Type') ?></label>
45
+ <div class="input-box">
46
+ <select id="payeezylevel3_cc_type" name="payment[cc_type]" class="required-entry validate-cc-type-select">
47
+ <option value=""><?php echo $this->__('--Please Select--')?></option>
48
+ <?php foreach ($this->getCcAvailableTypes() as $_typeCode => $_typeName): ?>
49
+ <option value="<?php echo $_typeCode ?>"<?php if($_typeCode==$currentCcType): ?> selected="selected"<?php endif ?>><?php echo $_typeName ?></option>
50
+ <?php endforeach ?>
51
+ </select>
52
+ </div>
53
+ </li>
54
+ <li>
55
+ <label for="payeezylevel3_cc_number" class="required"><em>*</em><?php echo $this->__('Credit Card Number') ?></label>
56
+ <div class="input-box">
57
+ <input type="text" id="payeezylevel3_cc_number" name="payment[cc_number]" title="<?php echo $this->__('Credit Card Number') ?>" class="input-text validate-cc-number validate-cc-type" value="" />
58
+ </div>
59
+ </li>
60
+ <li id="payeezylevel3_cc_type_exp_div" class="sp-methods">
61
+ <label for="payeezylevel3_expiration" class="required"><em>*</em><?php echo $this->__('Expiration Date') ?></label>
62
+ <div class="input-box">
63
+ <div class="v-fix">
64
+ <select id="payeezylevel3_expiration" name="payment[cc_exp_month]" class="month validate-cc-exp required-entry">
65
+ <?php foreach ($this->getCcMonths() as $k=>$v): ?>
66
+ <option value="<?php echo $k?$k:'' ?>"<?php if($k==$currentCcExpMonth): ?> selected="selected"<?php endif ?>><?php echo $v ?></option>
67
+ <?php endforeach ?>
68
+ </select>
69
+ </div>
70
+ <div class="v-fix">
71
+ <select id="payeezylevel3_expiration_yr" name="payment[cc_exp_year]" class="year required-entry">
72
+ <?php foreach ($this->getCcYears() as $k=>$v): ?>
73
+ <option value="<?php echo $k?$k:'' ?>"<?php if($k==$currentCcExpYear): ?> selected="selected"<?php endif ?>><?php echo $v ?></option>
74
+ <?php endforeach ?>
75
+ </select>
76
+ </div>
77
+ </div>
78
+ </li>
79
+ <?php if($this->hasVerification()): ?>
80
+ <li id="payeezylevel3_cc_type_cvv_div" class="sp-methods">
81
+ <label for="payeezylevel3_cc_cid" class="required"><em>*</em><?php echo $this->__('Card Verification Number') ?></label>
82
+ <div class="input-box">
83
+ <div class="v-fix">
84
+ <input type="text" title="<?php echo $this->__('Card Verification Number') ?>" class="input-text cvv required-entry validate-cc-cvn" id="payeezylevel3_cc_cid" name="payment[cc_cid]" value="" />
85
+ </div>
86
+ <a href="#" class="cvv-what-is-this"><?php echo $this->__('What is this?') ?></a>
87
+ </div>
88
+ </li>
89
+ <?php endif; ?>
90
+ <?php if ($this->canShowMakeDefault()): ?>
91
+ <li id="payeezylevel3_cc_make_default_div">
92
+ <label for="payeezylevel3_cc_make_default"><?php echo $this->__('Make Default') ?></label>
93
+ <div class="input-box">
94
+ <input type="checkbox" name="payment[is_default]" id="payeezylevel3_cc_make_default" value="1" />
95
+ </div>
96
+ </li>
97
+ <?php else: ?>
98
+ <input type="hidden" name="payment[is_default]" id="payeezylevel3_cc_make_default" value="1" />
99
+ <?php endif; ?>
100
+ </ul>
101
+ </div>
102
+ <div class="buttons-set">
103
+ <button type="submit" class="button" title="<?php echo $this->__('Submit') ?>"><span><span><?php echo $this->__('Submit') ?></span></span></button>
104
+ <p class="back-link"><a href="<?php echo $this->getBackUrl() ?>"><small>&laquo; </small><?php echo $this->__('Back') ?></a></p>
105
+ </div>
106
+ </form>
107
+ <div class="tool-tip" id="payment-tool-tip" style="display:none;">
108
+ <div class="btn-close"><a href="#" id="payment-tool-tip-close" title="<?php echo $this->__('Close') ?>"><?php echo $this->__('Close') ?></a></div>
109
+ <div class="tool-tip-content"><img src="<?php echo $this->getSkinUrl('images/cvv.gif') ?>" alt="<?php echo $this->__('Card Verification Number Visual Reference') ?>" title="<?php echo $this->__('Card Verification Number Visual Reference') ?>" /></div>
110
+ </div>
111
+ <script type="text/javascript">
112
+ //< ![CDATA[
113
+ var dataForm = new VarienForm('cc-form-validate', true);
114
+ //]]>
115
+ </script>
116
+ <script type="text/javascript">
117
+ function toggleToolTip(event){
118
+ if($('payment-tool-tip')){
119
+ $('payment-tool-tip').setStyle({
120
+ left: (Event.pointerX(event)-100)+'px',
121
+ top: (Event.pointerY(event)-200)+'px'
122
+ });
123
+ $('payment-tool-tip').toggle();
124
+ }
125
+ Event.stop(event);
126
+ }
127
+
128
+ $$('.cvv-what-is-this').each(function(element){
129
+ Event.observe(element, 'click', toggleToolTip);
130
+ });
131
+ if($('payment-tool-tip-close')){
132
+ Event.observe($('payment-tool-tip-close'), 'click', toggleToolTip);
133
+ }
134
+ </script>
app/design/frontend/base/default/template/payeezylevel3/creditcard/index.phtml ADDED
@@ -0,0 +1,64 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Cardpay Solutions, Inc.
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is available through the world-wide-web at this URL:
9
+ * http://opensource.org/licenses/osl-3.0.php
10
+ *
11
+ * PHP version 5
12
+ *
13
+ * @category Cardpay
14
+ * @package Cardpay_PayeezyLevel3
15
+ * @copyright Copyright (c) 2015 Cardpay Solutions, Inc. (http://www.cardpaysolutions.com)
16
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
17
+ */
18
+ ?>
19
+ <?php
20
+ $payeezylevel3 = Mage::getModel('payeezylevel3/creditcard');
21
+ $_savedCards = $payeezylevel3->currentCustomerCards();
22
+ ?>
23
+ <div class="page-title title-buttons">
24
+ <h1><?php echo $this->__('My Credit Cards') ?></h1>
25
+ <?php if ($payeezylevel3->useVault()): ?>
26
+ <button type="button" title="<?php echo $this->__('Add Credit Card') ?>" class="button" onclick="window.location='<?php echo $this->getAddUrl() ?>';"><span><span><?php echo $this->__('Add Credit Card') ?></span></span></button>
27
+ <?php endif ?>
28
+ </div>
29
+ <?php echo $this->getMessagesBlock()->getGroupedHtml() ?>
30
+ <?php if (count($_savedCards)): ?>
31
+ <table class="data-table" id="my-cards-table">
32
+ <col width="1" />
33
+ <col width="1" />
34
+ <col width="1" />
35
+ <col width="1" />
36
+ <col width="1" />
37
+ <col width="1" />
38
+ <thead>
39
+ <tr>
40
+ <th><?php echo $this->__('Type') ?></th>
41
+ <th><?php echo $this->__('Card Number') ?></th>
42
+ <th><?php echo $this->__('Expire Date') ?></th>
43
+ <th><?php echo $this->__('Is Default') ?></th>
44
+ <th colspan="2"><?php echo $this->__('Actions') ?></th>
45
+ </tr>
46
+ </thead>
47
+ <tbody>
48
+ <?php foreach ($_savedCards as $card): ?>
49
+ <tr>
50
+ <td><?php echo $card->getCardTypeName() ?></td>
51
+ <td><?php echo $card->getMaskedCardNum() ?></td>
52
+ <td><?php echo $card->getCcExpMonth() . '/' . $card->getCcExpYear() ?></td>
53
+ <td><?php echo ($card->getIsDefault()) ? $this->__('Yes') : $this->__('No') ?></td>
54
+ <td>
55
+ <a href="<?php echo $this->getEditUrl($card->getId()) ?>"><?php echo $this->__('Edit')?></a>
56
+ </td>
57
+ <td>
58
+ <a href="<?php echo $this->getDeleteUrl($card->getId()) ?>"><?php echo $this->__('Delete')?></a>
59
+ </td>
60
+ </tr>
61
+ <?php endforeach; ?>
62
+ </tbody>
63
+ </table>
64
+ <?php endif; ?>
app/design/frontend/base/default/template/payeezylevel3/form.phtml ADDED
@@ -0,0 +1,167 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Cardpay Solutions, Inc.
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is available through the world-wide-web at this URL:
9
+ * http://opensource.org/licenses/osl-3.0.php
10
+ *
11
+ * PHP version 5
12
+ *
13
+ * @category Cardpay
14
+ * @package Cardpay_PayeezyLevel3
15
+ * @copyright Copyright (c) 2015 Cardpay Solutions, Inc. (http://www.cardpaysolutions.com)
16
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
17
+ */
18
+ ?>
19
+ <?php
20
+ $_code = $this->getMethodCode();
21
+ $_model = Mage::getModel('payeezylevel3/creditcard');
22
+ $_loggedIn = Mage::getSingleton('customer/session')->isLoggedIn();
23
+ $_savedCards = $_model->currentCustomerCards();
24
+ $_useVault = $_loggedIn && $_model->useVault() && count($_savedCards);
25
+ ?>
26
+ <ul class="form-list" id="payment_form_<?php echo $_code ?>" style="display:none;">
27
+ <?php if ($_useVault): ?>
28
+ <li id="<?php echo $_code ?>_token_selector">
29
+ <label for="<?php echo $_code ?>_cc_token"><?php echo $this->__('Payment Information') ?></label>
30
+ <div class="input-box">
31
+ <select id="<?php echo $_code ?>_token" name="payment[token]">
32
+ <?php foreach ($_savedCards as $card): ?>
33
+ <option value="<?php echo $card->getId() ?>" <?php echo $card->getIsDefault() ? 'selected="selected"' : '' ?>>
34
+ <?php echo $card->getMaskedCardNum() . ' - ' . $card->getCardTypeName(); ?>
35
+ </option>
36
+ <?php endforeach; ?>
37
+ <option value=''><?php echo $this->__('Add new card') ?></option>
38
+ </select>
39
+ </div>
40
+ </li>
41
+ <?php endif; ?>
42
+ <li class="hide-if-token">
43
+ <label for="<?php echo $_code ?>_cc_type" class="required"><em>*</em><?php echo $this->__('Credit Card Type') ?></label>
44
+ <div class="input-box">
45
+ <select id="<?php echo $_code ?>_cc_type" name="payment[cc_type]" class="required-entry validate-cc-type-select">
46
+ <option value=""><?php echo $this->__('--Please Select--')?></option>
47
+ <?php $_ccType = $this->getInfoData('cc_type') ?>
48
+ <?php foreach ($this->getCcAvailableTypes() as $_typeCode => $_typeName): ?>
49
+ <option value="<?php echo $_typeCode ?>"<?php if($_typeCode==$_ccType): ?> selected="selected"<?php endif ?>><?php echo $_typeName ?></option>
50
+ <?php endforeach ?>
51
+ </select>
52
+ </div>
53
+ </li>
54
+ <li class="hide-if-token">
55
+ <label for="<?php echo $_code ?>_cc_number" class="required"><em>*</em><?php echo $this->__('Credit Card Number') ?></label>
56
+ <div class="input-box">
57
+ <input type="text" id="<?php echo $_code ?>_cc_number" name="payment[cc_number]" title="<?php echo $this->__('Credit Card Number') ?>" class="input-text validate-cc-number validate-cc-type" value="" />
58
+ </div>
59
+ </li>
60
+ <li class="hide-if-token" id="<?php echo $_code ?>_cc_type_exp_div">
61
+ <label for="<?php echo $_code ?>_expiration" class="required"><em>*</em><?php echo $this->__('Expiration Date') ?></label>
62
+ <div class="input-box">
63
+ <div class="v-fix">
64
+ <select id="<?php echo $_code ?>_expiration" name="payment[cc_exp_month]" class="month validate-cc-exp required-entry">
65
+ <?php $_ccExpMonth = $this->getInfoData('cc_exp_month') ?>
66
+ <?php foreach ($this->getCcMonths() as $k=>$v): ?>
67
+ <option value="<?php echo $k?$k:'' ?>"<?php if($k==$_ccExpMonth): ?> selected="selected"<?php endif ?>><?php echo $v ?></option>
68
+ <?php endforeach ?>
69
+ </select>
70
+ </div>
71
+ <div class="v-fix">
72
+ <?php $_ccExpYear = $this->getInfoData('cc_exp_year') ?>
73
+ <select id="<?php echo $_code ?>_expiration_yr" name="payment[cc_exp_year]" class="year required-entry">
74
+ <?php foreach ($this->getCcYears() as $k=>$v): ?>
75
+ <option value="<?php echo $k?$k:'' ?>"<?php if($k==$_ccExpYear): ?> selected="selected"<?php endif ?>><?php echo $v ?></option>
76
+ <?php endforeach ?>
77
+ </select>
78
+ </div>
79
+ </div>
80
+ </li>
81
+ <?php echo $this->getChildHtml() ?>
82
+ <?php if($this->hasVerification()): ?>
83
+ <li class="hide-if-token" id="<?php echo $_code ?>_cc_type_cvv_div">
84
+ <label for="<?php echo $_code ?>_cc_cid" class="required"><em>*</em><?php echo $this->__('Card Verification Number') ?></label>
85
+ <div class="input-box">
86
+ <div class="v-fix">
87
+ <input type="text" title="<?php echo $this->__('Card Verification Number') ?>" class="input-text cvv required-entry validate-cc-cvn" id="<?php echo $_code ?>_cc_cid" name="payment[cc_cid]" value="" />
88
+ </div>
89
+ <a href="#" class="cvv-what-is-this"><?php echo $this->__('What is this?') ?></a>
90
+ </div>
91
+ </li>
92
+ <?php endif; ?>
93
+ <?php if($this->canSaveCard()): ?>
94
+ <li class="hide-if-token" id="<?php echo $_code ?>_store_in_vault_div">
95
+ <input type="checkbox" title="<?php echo $this->__('Save this card for future use') ?>" class="input-checkbox" id="<?php echo $_code ?>_save_card" name="payment[save_card]" value="1" />
96
+ <label for="<?php echo $_code ?>_save_card" class="required" style="float:none;"><?php echo $this->__('Save this card for future use') ?></label>
97
+ </li>
98
+ <?php endif; ?>
99
+ </ul>
100
+
101
+ <script type="text/javascript">
102
+ //<![CDATA[
103
+ (function() {
104
+ <?php if ($_useVault): ?>
105
+ var selectBox = $('<?php echo $_code ?>_token');
106
+ var initToken = selectBox.getValue();
107
+ var cardsJson = [
108
+ <?php foreach ($_savedCards as $card): ?>
109
+ <?php echo Mage::helper('core')->jsonEncode($card->getData()) ?>,
110
+ <?php endforeach; ?>
111
+ ];
112
+
113
+ if (initToken)
114
+ {
115
+ var initialCard = objectFindByKey(cardsJson, 'payeezylevel3_id', initToken);
116
+ $('<?php echo $_code ?>_cc_type').value = initialCard.cc_type;
117
+ $('<?php echo $_code ?>_cc_number').value = initialCard.token;
118
+ $('<?php echo $_code ?>_expiration').value = initialCard.cc_exp_month;
119
+ $('<?php echo $_code ?>_expiration_yr').value = initialCard.cc_exp_year;
120
+ <?php if($this->hasVerification()): ?>
121
+ $('<?php echo $_code ?>_cc_cid').value = "";
122
+ <?php endif; ?>
123
+ $('<?php echo $_code ?>_save_card').checked = false;
124
+ $$('.hide-if-token').invoke('hide');
125
+ }
126
+ $('<?php echo $_code ?>_token').observe('change', function (e) {
127
+ var selectBox = $(this);
128
+ var token = selectBox.getValue();
129
+ if (token)
130
+ {
131
+ var selectedCard = objectFindByKey(cardsJson, 'payeezylevel3_id', token);
132
+ $('<?php echo $_code ?>_cc_type').value = selectedCard.cc_type;
133
+ $('<?php echo $_code ?>_cc_number').value = selectedCard.token;
134
+ $('<?php echo $_code ?>_expiration').value = selectedCard.cc_exp_month;
135
+ $('<?php echo $_code ?>_expiration_yr').value = selectedCard.cc_exp_year;
136
+ <?php if($this->hasVerification()): ?>
137
+ $('<?php echo $_code ?>_cc_cid').value = "";
138
+ <?php endif; ?>
139
+ $('<?php echo $_code ?>_save_card').checked = false;
140
+ $$('.hide-if-token').invoke('hide');
141
+ }
142
+ else
143
+ {
144
+ $('<?php echo $_code ?>_cc_type').value = "";
145
+ $('<?php echo $_code ?>_cc_number').value = "";
146
+ $('<?php echo $_code ?>_expiration').value = "";
147
+ $('<?php echo $_code ?>_expiration_yr').value = "";
148
+ <?php if($this->hasVerification()): ?>
149
+ $('<?php echo $_code ?>_cc_cid').value = "";
150
+ <?php endif; ?>
151
+ $('<?php echo $_code ?>_save_card').checked = false;
152
+ $$('.hide-if-token').invoke('show');
153
+ }
154
+ });
155
+
156
+ function objectFindByKey(array, key, value) {
157
+ for (var i = 0; i < array.length; i++) {
158
+ if (array[i][key] === value) {
159
+ return array[i];
160
+ }
161
+ }
162
+ return null;
163
+ }
164
+
165
+ <?php endif; ?>
166
+ })();
167
+ //]]></script>
app/etc/modules/Cardpay_PayeezyLevel3.xml ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Cardpay_PayeezyLevel3>
5
+ <active>true</active>
6
+ <codePool>community</codePool>
7
+ <depends>
8
+ <Mage_Payment />
9
+ </depends>
10
+ </Cardpay_PayeezyLevel3>
11
+ </modules>
12
+ </config>
app/locale/en_US/Cardpay_PayeezyLevel3.csv ADDED
@@ -0,0 +1 @@
 
1
+ """Save this card for future use""","""Save this card for future use"""
package.xml ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>Cardpay_PayeezyLevel3</name>
4
+ <version>1.0.0</version>
5
+ <stability>stable</stability>
6
+ <license uri="http://opensource.org/licenses/osl-3.0.php">Open Software License (OSL)</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>First Data Payeezy B2B Level 3 payment extension with TransArmor.</summary>
10
+ <description>The First Data Payeezy B2B payment extension allows you to securely accept credit cards through your Magento store with Level 3 transaction data to obtain the lowest possible interchange rates for Business, Corporate, and Purchase cards. In addition to processing one-time transactions, the extension also utilizes First Data TransArmor Tokenization to allow customers to securely store and manage credit card profiles for future use.</description>
11
+ <notes>Initial stable release</notes>
12
+ <authors><author><name>Brian McGowan</name><user>bmcgowan</user><email>bmcgowan@cardpaysolutions.com</email></author></authors>
13
+ <date>2015-09-24</date>
14
+ <time>21:34:50</time>
15
+ <contents><target name="magecommunity"><dir name="Cardpay"><dir name="PayeezyLevel3"><dir name="Block"><file name="Creditcard.php" hash="1eaa6e7510ff9c286b222996132197e6"/><file name="Form.php" hash="105c1a0cf35d68976aec95f43306c095"/><file name="Info.php" hash="1dd342a5127d7efc5b5ffe024474c80e"/></dir><dir name="Helper"><file name="Data.php" hash="ed90a311afeb22c569eee685898df857"/></dir><dir name="Model"><file name="Creditcard.php" hash="28d76d2492ba5a102b747943a0a75d0b"/><file name="PaymentMethod.php" hash="314d46842baa6392101b1c2ed798e762"/><dir name="Resource"><dir name="Creditcard"><file name="Collection.php" hash="6a9b5d47eaa40dcaa21e61c1ed908eb6"/></dir><file name="Creditcard.php" hash="e7d3bfb2eab308e2ddb1d9a927bc99e9"/></dir><dir name="Source"><file name="Cctype.php" hash="efc27b900cb34efcbaff8100e84ee306"/><file name="PaymentAction.php" hash="799cdb59f7d4a13b7193ccca4d33f78b"/></dir></dir><dir name="controllers"><file name="CreditcardController.php" hash="b4f3222897d52e2b06f860ce29cdb17e"/></dir><dir name="etc"><file name="config.xml" hash="726814d3d62e8f4ae6a54ead96ce6d13"/><file name="system.xml" hash="6fc495363d9031473b74928016f46903"/></dir><dir name="sql"><dir name="payeezylevel3_setup"><file name="install-1.0.0.php" hash="37a732780109ce25bdbcdca476d65d1b"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="template"><dir name="payeezylevel3"><file name="form.phtml" hash="df57d4b383cf02b420d168624f0659bf"/></dir></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="payeezylevel3.xml" hash="2b7b51e001ff2375224aded6d3358547"/></dir><dir name="template"><dir name="payeezylevel3"><dir name="creditcard"><file name="delete.phtml" hash="3330f6bf1b94299dc203d796aec51a0c"/><file name="edit.phtml" hash="c7d0c70f9fa4366419052119c16c78ad"/><file name="index.phtml" hash="db8cf141fd6add155177f9f6c7f8e3ed"/></dir><file name="form.phtml" hash="4ed133532f665016f2551b71e1619537"/></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Cardpay_PayeezyLevel3.xml" hash="ae44b2b97dd21cc51fb70642f51d0f04"/></dir></target><target name="magelocale"><dir name="en_US"><file name="Cardpay_PayeezyLevel3.csv" hash="1dad15e42befedbf24800f845bebb60c"/></dir></target></contents>
16
+ <compatible/>
17
+ <dependencies><required><php><min>5.3.29</min><max>5.6.10</max></php></required></dependencies>
18
+ </package>