Cardpay_GlobalGatewaye4 - Version 1.0.0

Version Notes

Initial stable release

Download this release

Release Info

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


Version 1.0.0

Files changed (23) hide show
  1. app/code/community/Cardpay/GlobalGatewaye4/Block/Creditcard.php +236 -0
  2. app/code/community/Cardpay/GlobalGatewaye4/Block/Form.php +53 -0
  3. app/code/community/Cardpay/GlobalGatewaye4/Block/Info.php +98 -0
  4. app/code/community/Cardpay/GlobalGatewaye4/Helper/Data.php +113 -0
  5. app/code/community/Cardpay/GlobalGatewaye4/Model/Creditcard.php +124 -0
  6. app/code/community/Cardpay/GlobalGatewaye4/Model/PaymentMethod.php +544 -0
  7. app/code/community/Cardpay/GlobalGatewaye4/Model/Resource/Creditcard.php +36 -0
  8. app/code/community/Cardpay/GlobalGatewaye4/Model/Resource/Creditcard/Collection.php +36 -0
  9. app/code/community/Cardpay/GlobalGatewaye4/Model/Source/Cctype.php +37 -0
  10. app/code/community/Cardpay/GlobalGatewaye4/Model/Source/PaymentAction.php +46 -0
  11. app/code/community/Cardpay/GlobalGatewaye4/controllers/CreditcardController.php +239 -0
  12. app/code/community/Cardpay/GlobalGatewaye4/etc/config.xml +115 -0
  13. app/code/community/Cardpay/GlobalGatewaye4/etc/system.xml +171 -0
  14. app/code/community/Cardpay/GlobalGatewaye4/sql/globalgatewaye4_setup/install-1.0.0.php +61 -0
  15. app/design/adminhtml/default/default/template/globalgatewaye4/form.phtml +143 -0
  16. app/design/frontend/base/default/layout/globalgatewaye4.xml +56 -0
  17. app/design/frontend/base/default/template/globalgatewaye4/creditcard/delete.phtml +61 -0
  18. app/design/frontend/base/default/template/globalgatewaye4/creditcard/edit.phtml +134 -0
  19. app/design/frontend/base/default/template/globalgatewaye4/creditcard/index.phtml +64 -0
  20. app/design/frontend/base/default/template/globalgatewaye4/form.phtml +167 -0
  21. app/etc/modules/Cardpay_GlobalGatewaye4.xml +12 -0
  22. app/locale/en_US/Cardpay_GlobalGatewaye4.csv +1 -0
  23. package.xml +18 -0
app/code/community/Cardpay/GlobalGatewaye4/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_GlobalGatewaye4
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 Global Gateway e4 credit card block.
21
+ *
22
+ * @category Cardpay
23
+ * @package Cardpay_GlobalGatewaye4
24
+ * @author Cardpay Solutions, Inc. <sales@cardpaysolutions.com>
25
+ */
26
+ class Cardpay_GlobalGatewaye4_Block_Creditcard extends Mage_Core_Block_Template
27
+ {
28
+ const TYPE_EDIT = 'edit';
29
+
30
+ /**
31
+ * Returns credit card
32
+ *
33
+ * @return Cardpay_GlobalGatewaye4_Model_Creditcard credit card object
34
+ */
35
+ public function creditCard()
36
+ {
37
+ $id = Mage::app()->getRequest()->getParam('id');
38
+ $card = Mage::getModel('globalgatewaye4/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('globalgatewaye4/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('globalgatewaye4/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('globalgatewaye4/paymentmethod');
234
+ return $method->getConfigData('useccv');
235
+ }
236
+ }
app/code/community/Cardpay/GlobalGatewaye4/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_GlobalGatewaye4
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 Global Gateway e4 form block.
21
+ *
22
+ * @category Cardpay
23
+ * @package Cardpay_GlobalGatewaye4
24
+ * @author Cardpay Solutions, Inc. <sales@cardpaysolutions.com>
25
+ */
26
+ class Cardpay_GlobalGatewaye4_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('globalgatewaye4/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('globalgatewaye4/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/GlobalGatewaye4/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_GlobalGatewaye4
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 Global Gateway e4 info block.
21
+ *
22
+ * @category Cardpay
23
+ * @package Cardpay_GlobalGatewaye4
24
+ * @author Cardpay Solutions, Inc. <sales@cardpaysolutions.com>
25
+ */
26
+ class Cardpay_GlobalGatewaye4_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('globalgatewaye4')->__('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('globalgatewaye4')->__('Credit Card Type')] = $ccType;
81
+ }
82
+ if ($ccLast = $this->getInfo()->getCcLast4()) {
83
+ $data[Mage::helper('globalgatewaye4')->__('Credit Card Number')] = sprintf('xxxx-%s', $ccLast);
84
+ }
85
+ if ($this->hasCcExpDate()) {
86
+ $data[Mage::helper('globalgatewaye4')->__('Expiration Date')] = $this->getCcExpDate();
87
+ }
88
+ if (Mage::app()->getStore()->isAdmin()) {
89
+ if ($this->getInfo()->getCcAvsStatus()) {
90
+ $data[Mage::helper('globalgatewaye4')->__('AVS Response')] = $this->getInfo()->getCcAvsStatus();
91
+ }
92
+ if ($this->getInfo()->getCcCidStatus()) {
93
+ $data[Mage::helper('globalgatewaye4')->__('CVV2 Response')] = $this->getInfo()->getCcCidStatus();
94
+ }
95
+ }
96
+ return $transport->setData(array_merge($data, $transport->getData()));
97
+ }
98
+ }
app/code/community/Cardpay/GlobalGatewaye4/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_GlobalGatewaye4
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 Global Gateway e4 data helper.
21
+ *
22
+ * @category Cardpay
23
+ * @package Cardpay_GlobalGatewaye4
24
+ * @author Cardpay Solutions, Inc. <sales@cardpaysolutions.com>
25
+ */
26
+ class Cardpay_GlobalGatewaye4_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/GlobalGatewaye4/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_GlobalGatewaye4
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 Global Gateway e4 credit card model.
21
+ *
22
+ * @category Cardpay
23
+ * @package Cardpay_GlobalGatewaye4
24
+ * @author Cardpay Solutions, Inc. <sales@cardpaysolutions.com>
25
+ */
26
+ class Cardpay_GlobalGatewaye4_Model_Creditcard extends Mage_Core_Model_Abstract
27
+ {
28
+ /**
29
+ * Internal constructor.
30
+ */
31
+ public function _construct()
32
+ {
33
+ parent::_construct();
34
+ $this->_init('globalgatewaye4/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
+ $globalgatewaye4 = Mage::getModel('globalgatewaye4/paymentmethod');
75
+ return $globalgatewaye4->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
+ $globalgatewaye4 = Mage::getModel('globalgatewaye4/paymentmethod');
86
+ return Mage::helper('globalgatewaye4')->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/GlobalGatewaye4/Model/PaymentMethod.php ADDED
@@ -0,0 +1,544 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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_GlobalGatewaye4
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 Global Gateway e4 payment method model.
21
+ *
22
+ * @category Cardpay
23
+ * @package Cardpay_GlobalGatewaye4
24
+ * @author Cardpay Solutions, Inc. <sales@cardpaysolutions.com>
25
+ */
26
+ class Cardpay_GlobalGatewaye4_Model_PaymentMethod extends Mage_Payment_Model_Method_Cc
27
+ {
28
+ protected $_code = 'globalgatewaye4';
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 = 'globalgatewaye4/form';
42
+ protected $_infoBlockType = 'globalgatewaye4/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_GlobalGatewaye4_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('globalgatewaye4')->getAvsResponse($response->avs))
82
+ ->setCcCidStatus(Mage::helper('globalgatewaye4')->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_GlobalGatewaye4_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_GlobalGatewaye4_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('globalgatewaye4')->getAvsResponse($response->avs))
156
+ ->setCcCidStatus(Mage::helper('globalgatewaye4')->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_GlobalGatewaye4_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_GlobalGatewaye4_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_GlobalGatewaye4_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_GlobalGatewaye4_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_GlobalGatewaye4_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('globalgatewaye4/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_GlobalGatewaye4_Model_Creditcard credit card object
308
+ */
309
+ public function getSavedCard($token)
310
+ {
311
+ $card = Mage::getModel('globalgatewaye4/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('globalgatewaye4')->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
+ );
379
+ } else {
380
+ $data = array(
381
+ 'merchant_ref' => $this->processInput($orderId),
382
+ 'transaction_type' => $this->processInput($transactionType),
383
+ 'method' => 'credit_card',
384
+ 'amount' => $this->processInput($amountInCents),
385
+ 'currency_code' => $this->processInput($currency),
386
+ 'credit_card' => array(
387
+ 'type' => $this->processInput(Mage::helper('globalgatewaye4')->getCcTypeName($payment->getCcType())),
388
+ 'cardholder_name' => $this->processInput($billing->getName()),
389
+ 'card_number' => $this->processInput($payment->getCcNumber()),
390
+ 'exp_date' => $this->processInput($expDate),
391
+ 'cvv' => $this->processInput($payment->getCcCid())
392
+ ),
393
+ 'billing_address' => array(
394
+ 'street' => $this->processInput(substr($billing->getStreet(1), 0, 30)),
395
+ 'zip_postal_code' => $this->processInput(substr($billing->getPostcode(), 0, 10))
396
+ ),
397
+ 'level2' => array(
398
+ 'tax1_amount' => number_format($order->getTaxAmount(), '2', '.', ''),
399
+ 'customer_ref' => $this->processInput($orderId)
400
+ )
401
+ );
402
+ }
403
+ $this->_url = $this->_baseURL;
404
+ } else {
405
+ $this->_url = $this->_baseURL . '/' . $payment->getParentTransactionId();
406
+ $data = array(
407
+ 'merchant_ref' => $this->processInput($orderId),
408
+ 'transaction_type' => $this->processInput($transactionType),
409
+ 'method' => $this->processInput('credit_card'),
410
+ 'amount' => $this->processInput($amountInCents),
411
+ 'currency_code' => $this->processInput($currency),
412
+ 'transaction_tag' => $this->processInput($payment->getCcApproval())
413
+ );
414
+ }
415
+ return json_encode($data, JSON_FORCE_OBJECT);
416
+ }
417
+
418
+ /**
419
+ * Returns payload for token request
420
+ *
421
+ * @param Cardpay_GlobalGatewaye4_Model_Creditcard $card credit card object
422
+ *
423
+ * @return array payload
424
+ */
425
+ public function getTokenPayload($card)
426
+ {
427
+ $yr = substr($card->getCcExpYear(), -2);
428
+ $expDate = sprintf('%02d%02d', $card->getCcExpMonth(), $yr);
429
+ $testMode = $this->getConfigData('test_mode');
430
+ $data = '';
431
+
432
+ if ($testMode) {
433
+ $this->_baseURL = 'https://api-cert.payeezy.com/v1/transactions';
434
+ $this->_merchantToken = 'fdoa-a480ce8951daa73262734cf102641994c1e55e7cdf4c02b6';
435
+ $taToken = 'NOIW';
436
+ } else {
437
+ $this->_baseURL = 'https://api.payeezy.com/v1/transactions';
438
+ $this->_merchantToken = $this->getConfigData('merchant_token');
439
+ $taToken = $this->getConfigData('ta_token');
440
+ }
441
+
442
+ $data = array(
443
+ 'type' => 'FDToken',
444
+ 'auth' => 'false',
445
+ 'ta_token' => $this->processInput($taToken),
446
+ 'credit_card' => array(
447
+ 'type' => $this->processInput(Mage::helper('globalgatewaye4')->getCcTypeName($card->getCcType())),
448
+ 'cardholder_name' => $this->processInput($card->getCardholderName()),
449
+ 'card_number' => $this->processInput($card->getCcNumber()),
450
+ 'exp_date' => $this->processInput($expDate),
451
+ 'cvv' => $this->processInput($card->getCcCid())
452
+ )
453
+ );
454
+ $this->_url = $this->_baseURL . '/tokens';
455
+ return json_encode($data, JSON_FORCE_OBJECT);
456
+ }
457
+
458
+ /**
459
+ * Returns HMAC authorization values
460
+ *
461
+ * @param array $payload payload
462
+ *
463
+ * @return array hmac values
464
+ */
465
+ public function hmacAuthorizationToken($payload)
466
+ {
467
+ $nonce = strval(hexdec(bin2hex(openssl_random_pseudo_bytes(4, $cstrong))));
468
+ $timestamp = strval(time() * 1000); //time stamp in milli seconds
469
+ $data = self::API_KEY . $nonce . $timestamp . $this->_merchantToken . $payload;
470
+ $hashAlgorithm = "sha256";
471
+ $hmac = hash_hmac($hashAlgorithm, $data, self::API_SECRET, false); // HMAC Hash in hex
472
+ $authorization = base64_encode($hmac);
473
+ return array(
474
+ 'authorization' => $authorization,
475
+ 'nonce' => $nonce,
476
+ 'timestamp' => $timestamp
477
+ );
478
+ }
479
+
480
+ /**
481
+ * Post transaction to gateway
482
+ *
483
+ * @param array $payload payload
484
+ * @param array $headers headers
485
+ *
486
+ * @return string json response
487
+ */
488
+ public function postTransaction($payload, $headers)
489
+ {
490
+ $request = curl_init();
491
+ curl_setopt($request, CURLOPT_URL, $this->_url);
492
+ curl_setopt($request, CURLOPT_POST, true);
493
+ curl_setopt($request, CURLOPT_POSTFIELDS, $payload);
494
+ curl_setopt($request, CURLOPT_RETURNTRANSFER, true);
495
+ curl_setopt($request, CURLOPT_HEADER, false);
496
+ //curl_setopt($request, CURLOPT_SSL_VERIFYPEER, false);
497
+ curl_setopt(
498
+ $request, CURLOPT_HTTPHEADER, array(
499
+ 'Content-Type: application/json',
500
+ 'apikey:' . strval(self::API_KEY),
501
+ 'token:' . strval($this->_merchantToken),
502
+ 'Authorization:' . $headers['authorization'],
503
+ 'nonce:' . $headers['nonce'],
504
+ 'timestamp:' . $headers['timestamp']
505
+ )
506
+ );
507
+ $response = curl_exec($request);
508
+ if (false === $response) {
509
+ Mage::throwException('Transaction Error: ' . curl_error($request));
510
+ }
511
+ curl_close($request);
512
+ return $response;
513
+ }
514
+
515
+ /**
516
+ * Returns processed input
517
+ *
518
+ * @param string $data input data
519
+ *
520
+ * @return string processed input
521
+ */
522
+ public function processInput($data)
523
+ {
524
+ $data = trim($data);
525
+ $data = stripslashes($data);
526
+ $data = htmlspecialchars($data);
527
+ return strval($data);
528
+ }
529
+
530
+ /**
531
+ * If payment method is available for currency
532
+ *
533
+ * @param string $currencyCode order currency
534
+ *
535
+ * @return bool available for currency or not
536
+ */
537
+ public function canUseForCurrency($currencyCode)
538
+ {
539
+ if ($currencyCode != $this->getConfigData('currency')) {
540
+ return false;
541
+ }
542
+ return true;
543
+ }
544
+ }
app/code/community/Cardpay/GlobalGatewaye4/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_GlobalGatewaye4
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 Global Gateway e4 credit card resource model.
21
+ *
22
+ * @category Cardpay
23
+ * @package Cardpay_GlobalGatewaye4
24
+ * @author Cardpay Solutions, Inc. <sales@cardpaysolutions.com>
25
+ */
26
+ class Cardpay_GlobalGatewaye4_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('globalgatewaye4/creditcard', 'globalgatewaye4_id');
35
+ }
36
+ }
app/code/community/Cardpay/GlobalGatewaye4/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_GlobalGatewaye4
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 Global Gateway e4 credit card collection resource model.
21
+ *
22
+ * @category Cardpay
23
+ * @package Cardpay_GlobalGatewaye4
24
+ * @author Cardpay Solutions, Inc. <sales@cardpaysolutions.com>
25
+ */
26
+ class Cardpay_GlobalGatewaye4_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('globalgatewaye4/creditcard');
35
+ }
36
+ }
app/code/community/Cardpay/GlobalGatewaye4/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_GlobalGatewaye4
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 Global Gateway e4 credit card type source model.
21
+ *
22
+ * @category Cardpay
23
+ * @package Cardpay_GlobalGatewaye4
24
+ * @author Cardpay Solutions, Inc. <sales@cardpaysolutions.com>
25
+ */
26
+ class Cardpay_GlobalGatewaye4_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/GlobalGatewaye4/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_GlobalGatewaye4
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 GlobalGatewaye4 payment action source model.
21
+ *
22
+ * @category Cardpay
23
+ * @package Cardpay_GlobalGatewaye4
24
+ * @author Cardpay Solutions, Inc. <sales@cardpaysolutions.com>
25
+ */
26
+ class Cardpay_GlobalGatewaye4_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/GlobalGatewaye4/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_GlobalGatewaye4
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 Global Gateway e4 credit card controller.
23
+ *
24
+ * @category Cardpay
25
+ * @package Cardpay_GlobalGatewaye4
26
+ * @author Cardpay Solutions, Inc. <sales@cardpaysolutions.com>
27
+ */
28
+ class Cardpay_GlobalGatewaye4_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/globalgatewaye4/use_vault')
51
+ || !Mage::getStoreConfig('payment/globalgatewaye4/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('globalgatewaye4/creditcard');
92
+ $card->addData($data['payment']);
93
+ $card->setData('customer_id', $customerId);
94
+ $card->setData('cardholder_name', $cardholderName);
95
+ $globalgatewaye4 = Mage::getModel('globalgatewaye4/paymentmethod');
96
+ try {
97
+ $token = $globalgatewaye4->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('globalgatewaye4/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
+ $globalgatewaye4 = Mage::getModel('globalgatewaye4/paymentmethod');
139
+ try {
140
+ $token = $globalgatewaye4->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('globalgatewaye4/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('globalgatewaye4/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('globalgatewaye4/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/GlobalGatewaye4/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_GlobalGatewaye4
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_GlobalGatewaye4>
23
+ <version>1.0.0</version>
24
+ </Cardpay_GlobalGatewaye4>
25
+ </modules>
26
+ <global>
27
+ <blocks>
28
+ <globalgatewaye4>
29
+ <class>Cardpay_GlobalGatewaye4_Block</class>
30
+ </globalgatewaye4>
31
+ </blocks>
32
+ <models>
33
+ <globalgatewaye4>
34
+ <class>Cardpay_GlobalGatewaye4_Model</class>
35
+ <resourceModel>globalgatewaye4_resource</resourceModel>
36
+ </globalgatewaye4>
37
+ <globalgatewaye4_resource>
38
+ <class>Cardpay_GlobalGatewaye4_Model_Resource</class>
39
+ <entities>
40
+ <creditcard>
41
+ <table>globalgatewaye4_credit_card</table>
42
+ </creditcard>
43
+ </entities>
44
+ </globalgatewaye4_resource>
45
+ </models>
46
+ <resources>
47
+ <globalgatewaye4_setup>
48
+ <setup>
49
+ <module>Cardpay_GlobalGatewaye4</module>
50
+ </setup>
51
+ <connection>
52
+ <use>core_setup</use>
53
+ </connection>
54
+ </globalgatewaye4_setup>
55
+ <globalgatewaye4_write>
56
+ <connection>
57
+ <use>core_write</use>
58
+ </connection>
59
+ </globalgatewaye4_write>
60
+ <globalgatewaye4_read>
61
+ <connection>
62
+ <use>core_read</use>
63
+ </connection>
64
+ </globalgatewaye4_read>
65
+ </resources>
66
+ <helpers>
67
+ <globalgatewaye4>
68
+ <class>Cardpay_GlobalGatewaye4_Helper</class>
69
+ </globalgatewaye4>
70
+ </helpers>
71
+ </global>
72
+ <default>
73
+ <payment>
74
+ <globalgatewaye4>
75
+ <active>0</active>
76
+ <model>globalgatewaye4/paymentMethod</model>
77
+ <order_status>processing</order_status>
78
+ <title>Credit Card (Global Gateway e4)</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
+ </globalgatewaye4>
86
+ </payment>
87
+ </default>
88
+ <frontend>
89
+ <layout>
90
+ <updates>
91
+ <globalgatewaye4 module="Cardpay_GlobalGatewaye4">
92
+ <file>globalgatewaye4.xml</file>
93
+ </globalgatewaye4>
94
+ </updates>
95
+ </layout>
96
+ <routers>
97
+ <customer>
98
+ <args>
99
+ <modules>
100
+ <Cardpay_GlobalGatewaye4 after="Mage_Customer">Cardpay_GlobalGatewaye4</Cardpay_GlobalGatewaye4>
101
+ </modules>
102
+ </args>
103
+ </customer>
104
+ </routers>
105
+ <translate>
106
+ <modules>
107
+ <Cardpay_GlobalGatewaye4>
108
+ <files>
109
+ <default>Cardpay_GlobalGatewaye4.csv</default>
110
+ </files>
111
+ </Cardpay_GlobalGatewaye4>
112
+ </modules>
113
+ </translate>
114
+ </frontend>
115
+ </congig>
app/code/community/Cardpay/GlobalGatewaye4/etc/system.xml ADDED
@@ -0,0 +1,171 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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_GlobalGatewaye4
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
+ <globalgatewaye4 translate="label" module="paygate">
25
+ <label>First Data Global Gateway e4</label>
26
+ <sort_order>690</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.freeglobalgateway.com/magento?pid=b22a2a0c27e71cea" target="_blank">Click here to sign up for a Global Gateway e4 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 Global Gateway e4 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
+ <order_status translate="label">
69
+ <label>New order status</label>
70
+ <comment><![CDATA[The status of the order after the payment is successful.]]></comment>
71
+ <frontend_type>select</frontend_type>
72
+ <source_model>adminhtml/system_config_source_order_status</source_model>
73
+ <sort_order>5</sort_order>
74
+ <show_in_default>1</show_in_default>
75
+ <show_in_website>1</show_in_website>
76
+ <show_in_store>0</show_in_store>
77
+ </order_status>
78
+ <payment_action translate="label">
79
+ <label>Payment Action</label>
80
+ <frontend_type>select</frontend_type>
81
+ <source_model>globalgatewaye4/source_paymentAction</source_model>
82
+ <sort_order>6</sort_order>
83
+ <show_in_default>1</show_in_default>
84
+ <show_in_website>1</show_in_website>
85
+ <show_in_store>0</show_in_store>
86
+ </payment_action>
87
+ <currency translate="label">
88
+ <label>Accepted Currency</label>
89
+ <comment><![CDATA[Account must be properly configured to process currencies other than USD. Contact sales for additional information: (866) 588-0503.]]></comment>
90
+ <frontend_type>select</frontend_type>
91
+ <source_model>adminhtml/system_config_source_currency</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
+ </currency>
97
+ <cctypes translate="label">
98
+ <label>Credit Card Types</label>
99
+ <comment><![CDATA[Select which credit card types are accepted.]]></comment>
100
+ <frontend_type>multiselect</frontend_type>
101
+ <source_model>globalgatewaye4/source_cctype</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
+ </cctypes>
107
+ <useccv translate="label">
108
+ <label>Credit Card Verification</label>
109
+ <comment><![CDATA[Whether the 3 or 4 digit card security code is required.]]></comment>
110
+ <frontend_type>select</frontend_type>
111
+ <source_model>adminhtml/system_config_source_yesno</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
+ </useccv>
117
+ <use_vault translate="label">
118
+ <label>Allow Stored Cards</label>
119
+ <comment><![CDATA[Allow a logged in customer to save credit cards for future use. PCI Compliant TransArmor Tokenization.]]></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
+ </use_vault>
127
+ <ta_token translate="label">
128
+ <label>TransArmor Token</label>
129
+ <comment><![CDATA[TransArmor token provided by Global Gateway e4 after you establish your account. Required for Stored Card functionality to work.]]></comment>
130
+ <frontend_type>text</frontend_type>
131
+ <sort_order>11</sort_order>
132
+ <show_in_default>1</show_in_default>
133
+ <show_in_website>1</show_in_website>
134
+ <show_in_store>0</show_in_store>
135
+ </ta_token>
136
+ <allowspecific translate="label">
137
+ <label><![CDATA[Payment from applicable countries:]]></label>
138
+ <comment><![CDATA[Set this to "Specific Countries" if you wish to limit what countries may place orders.]]></comment>
139
+ <frontend_type>allowspecific</frontend_type>
140
+ <sort_order>12</sort_order>
141
+ <source_model>adminhtml/system_config_source_payment_allspecificcountries</source_model>
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
+ </allowspecific>
146
+ <specificcountry translate="label">
147
+ <label><![CDATA[Payment from Specific countries:]]></label>
148
+ <comment><![CDATA[Which countries this payment method is available to. This becomes active if the setting above is set to "Specific Countries".]]></comment>
149
+ <frontend_type>multiselect</frontend_type>
150
+ <sort_order>13</sort_order>
151
+ <source_model>adminhtml/system_config_source_country</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
+ </specificcountry>
156
+ <sort_order translate="label">
157
+ <label>Sort Order</label>
158
+ <comment><![CDATA[In which order this payment method will appear on the checkout page.]]></comment>
159
+ <frontend_type>text</frontend_type>
160
+ <sort_order>14</sort_order>
161
+ <show_in_default>1</show_in_default>
162
+ <show_in_website>1</show_in_website>
163
+ <show_in_store>0</show_in_store>
164
+ <frontend_class>validate-number</frontend_class>
165
+ </sort_order>
166
+ </fields>
167
+ </globalgatewaye4>
168
+ </groups>
169
+ </payment>
170
+ </sections>
171
+ </config>
app/code/community/Cardpay/GlobalGatewaye4/sql/globalgatewaye4_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_GlobalGatewaye4
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_GlobalGatewaye4_Model_Resource_Creditcard */
21
+ $installer = $this;
22
+ $installer->startSetup();
23
+
24
+ /**
25
+ * Create table 'globalgatewaye4_credit_card'
26
+ */
27
+ $table = $installer->getConnection()
28
+ ->newTable($installer->getTable('globalgatewaye4_credit_card'))
29
+ ->addColumn('globalgatewaye4_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
30
+ 'unsigned' => true,
31
+ 'identity' => true,
32
+ 'nullable' => false,
33
+ 'primary' => true,
34
+ ), 'Globalgateway4 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('globalgatewaye4_credit_card', array('customer_id')),
57
+ array('customer_id'))
58
+ ->setComment('GlobalGatewaye4 Credit Card');
59
+
60
+ $installer->getConnection()->createTable($table);
61
+ $installer->endSetup();
app/design/adminhtml/default/default/template/globalgatewaye4/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_GlobalGatewaye4
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('globalgatewaye4/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/globalgatewaye4.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_GlobalGatewaye4
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="globalgatewaye4" ifconfig="payment/globalgatewaye4/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="globalgatewaye4/creditcard" name="customer_creditcard" template="globalgatewaye4/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="globalgatewaye4/creditcard" name="customer_creditcard" template="globalgatewaye4/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="globalgatewaye4/creditcard" name="customer_creditcard" template="globalgatewaye4/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="globalgatewaye4/creditcard" name="customer_creditcard" template="globalgatewaye4/creditcard/delete.phtml" />
54
+ </reference>
55
+ </customer_creditcard_delete>
56
+ </layout>
app/design/frontend/base/default/template/globalgatewaye4/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_GlobalGatewaye4
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('globalgatewaye4/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/globalgatewaye4/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_GlobalGatewaye4
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_globalgatewaye4">
43
+ <li>
44
+ <label for="globalgatewaye4_cc_type" class="required"><em>*</em><?php echo $this->__('Credit Card Type') ?></label>
45
+ <div class="input-box">
46
+ <select id="globalgatewaye4_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="globalgatewaye4_cc_number" class="required"><em>*</em><?php echo $this->__('Credit Card Number') ?></label>
56
+ <div class="input-box">
57
+ <input type="text" id="globalgatewaye4_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="globalgatewaye4_cc_type_exp_div" class="sp-methods">
61
+ <label for="globalgatewaye4_expiration" class="required"><em>*</em><?php echo $this->__('Expiration Date') ?></label>
62
+ <div class="input-box">
63
+ <div class="v-fix">
64
+ <select id="globalgatewaye4_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="globalgatewaye4_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="globalgatewaye4_cc_type_cvv_div" class="sp-methods">
81
+ <label for="globalgatewaye4_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="globalgatewaye4_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="globalgatewaye4_cc_make_default_div">
92
+ <label for="globalgatewaye4_cc_make_default"><?php echo $this->__('Make Default') ?></label>
93
+ <div class="input-box">
94
+ <input type="checkbox" name="payment[is_default]" id="globalgatewaye4_cc_make_default" value="1" />
95
+ </div>
96
+ </li>
97
+ <?php else: ?>
98
+ <input type="hidden" name="payment[is_default]" id="globalgatewaye4_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/globalgatewaye4/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_GlobalGatewaye4
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
+ $globalgatewaye4 = Mage::getModel('globalgatewaye4/creditcard');
21
+ $_savedCards = $globalgatewaye4->currentCustomerCards();
22
+ ?>
23
+ <div class="page-title title-buttons">
24
+ <h1><?php echo $this->__('My Credit Cards') ?></h1>
25
+ <?php if ($globalgatewaye4->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/globalgatewaye4/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_GlobalGatewaye4
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('globalgatewaye4/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, 'globalgatewaye4_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, 'globalgatewaye4_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_GlobalGatewaye4.xml ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Cardpay_GlobalGatewaye4>
5
+ <active>false</active>
6
+ <codePool>community</codePool>
7
+ <depends>
8
+ <Mage_Payment />
9
+ </depends>
10
+ </Cardpay_GlobalGatewaye4>
11
+ </modules>
12
+ </config>
app/locale/en_US/Cardpay_GlobalGatewaye4.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_GlobalGatewaye4</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 Global Gateway e4 payment extension with TransArmor.</summary>
10
+ <description>The First Data Global Gateway e4 payment extension allows you to securely accept credit cards through your Magento store. 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-23</date>
14
+ <time>19:38:43</time>
15
+ <contents><target name="magecommunity"><dir name="Cardpay"><dir name="GlobalGatewaye4"><dir name="Block"><file name="Creditcard.php" hash="b26130c3e60a3baa86356f6901880bd7"/><file name="Form.php" hash="431030b3d0848cbf3e69ee49512daf7a"/><file name="Info.php" hash="56fe37578d6aa6e6c722894571b06d3e"/></dir><dir name="Helper"><file name="Data.php" hash="7c86f3dc7466d5db9c47deb4fec9414d"/></dir><dir name="Model"><file name="Creditcard.php" hash="93713255bdf16405336463767076a894"/><file name="PaymentMethod.php" hash="e4c643ef7a63dd5a91c01ae266e4cd5d"/><dir name="Resource"><dir name="Creditcard"><file name="Collection.php" hash="4cb6c51d028306fc0578db563fbdc749"/></dir><file name="Creditcard.php" hash="c58f28c911141b84715782822ef334c7"/></dir><dir name="Source"><file name="Cctype.php" hash="e5ba63826c4a7445836fc2747a5c0a7c"/><file name="PaymentAction.php" hash="dab7cf7a6aaf36fab506b8b73cd3663e"/></dir></dir><dir name="controllers"><file name="CreditcardController.php" hash="d14b27a57b784b7a5e8668f6489e51a4"/></dir><dir name="etc"><file name="config.xml" hash="c7780e3b08163bde8abb4b4d2dfb6cf1"/><file name="system.xml" hash="9d7250c1b4b60c38a3590081f270e51e"/></dir><dir name="sql"><dir name="globalgatewaye4_setup"><file name="install-1.0.0.php" hash="d833d213526f1f92de011ed44eeb821f"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="template"><dir name="globalgatewaye4"><file name="form.phtml" hash="5b11ecfc64755a57378d71cdfd935d2f"/></dir></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="globalgatewaye4.xml" hash="14d4d99a2c3ba5b7739a7840b5e79bae"/></dir><dir name="template"><dir name="globalgatewaye4"><dir name="creditcard"><file name="delete.phtml" hash="69ebb39a4f8c1e2b4c0ffe08a0a9fcba"/><file name="edit.phtml" hash="3b908561a07e83b564e0ee6c23af5ac0"/><file name="index.phtml" hash="ecd154705df55134e5d9b16de05b3e0a"/></dir><file name="form.phtml" hash="e3ebbdc3832b3730a5cf9fb9cbcbbbbe"/></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Cardpay_GlobalGatewaye4.xml" hash="1dbdf72918b1c4cf0447a2df6f6efafd"/></dir></target><target name="magelocale"><dir name="en_US"><file name="Cardpay_GlobalGatewaye4.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>