Mage_Usaepay - Version 1.1.9

Version Notes

- Tokenization
- Timeout
- Gift Card support
- Auto detect card type

Download this release

Release Info

Developer Tim McEwen
Extension Mage_Usaepay
Version 1.1.9
Comparing to
See all releases


Code changes from version 1.1.7 to 1.1.9

app/code/community/Mage/Usaepay/Block/Form.php CHANGED
@@ -1,7 +1,7 @@
1
  <?php
2
  /**
3
  * USA ePay Magento Plugin.
4
- * v1.1.7 - December 19th, 2014
5
  *
6
  * For assistance please contact devsupport@usaepay.com
7
  *
@@ -202,4 +202,85 @@ class Mage_Usaepay_Block_Form extends Mage_Payment_Block_Form
202
  // cast xml 'objects' as strings to avoid weird issues elsewhere (like setAdditionalInfo for payments)
203
  return array('sessionid'=> (string)$xml->SessionID, 'orgid'=> (string)$xml->OrgID, 'html'=> $out);
204
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
205
  }
1
  <?php
2
  /**
3
  * USA ePay Magento Plugin.
4
+ * v1.1.9 - July 3rd, 2015
5
  *
6
  * For assistance please contact devsupport@usaepay.com
7
  *
202
  // cast xml 'objects' as strings to avoid weird issues elsewhere (like setAdditionalInfo for payments)
203
  return array('sessionid'=> (string)$xml->SessionID, 'orgid'=> (string)$xml->OrgID, 'html'=> $out);
204
  }
205
+
206
+
207
+ /**
208
+ * Return gateway url
209
+ *
210
+ * @return string
211
+ */
212
+ protected function _getGatewayUrl()
213
+ {
214
+ $tran = Mage::getModel('usaepay/TranApi');
215
+
216
+ if($this->_paymentConfig['sandbox']) $tran->usesandbox = true;
217
+
218
+ return $tran->getGatewayBaseUrl() . '/tokenize';
219
+ }
220
+
221
+ /**
222
+ * Check if enabled tokenization
223
+ *
224
+ * @return bool
225
+ */
226
+ protected function _ifTokenizationEnabled()
227
+ {
228
+ return $this->_paymentConfig['tokenization'] ? true : false;
229
+ }
230
+
231
+ /**
232
+ * Check that cart auto detect is run
233
+ * @return bool
234
+ */
235
+ protected function _ifAutoCardDetect()
236
+ {
237
+ return $this->_paymentConfig['card_detect'] == 1;
238
+ }
239
+
240
+ /**
241
+ * Return JavaScript rules for detect card
242
+ * @return string
243
+ */
244
+ protected function _getCCRules()
245
+ {
246
+ $data = array
247
+ (
248
+ "VI" => "{name: 'VI', pattern: /^4/}",
249
+ "MC" => "{name: 'MC', pattern: /^5[1-5]/}",
250
+ "AE" => "{name: 'AE', pattern: /^3[47]/}",
251
+ "DI" => "{name: 'DI', pattern: /^(6011|622(12[6-9]|1[3-9][0-9]|[2-8][0-9]{2}|9[0-1][0-9]|92[0-5]|64[4-9])|65)/}",
252
+ "GC" => "{name: 'GC', pattern: /[0-9]{19}/}",
253
+ "OT" => "{name: 'OT', pattern: /[0-9]{1-20}/}"
254
+ );
255
+ $rules = array();
256
+
257
+ $availableTypes = $this->_paymentConfig['cctypes'];
258
+ if ($availableTypes)
259
+ {
260
+ $types = explode(',', $availableTypes);
261
+ foreach ($data AS $code=>$rule)
262
+ {
263
+ if (in_array($code, $types))
264
+ {
265
+ $rules[] = $rule;
266
+ }
267
+ }
268
+ }
269
+ return implode(",", $rules);
270
+ }
271
+
272
+ protected function _getCCImages()
273
+ {
274
+ $images = array();
275
+ $availableTypes = $this->_paymentConfig['cctypes'];
276
+ if ($availableTypes)
277
+ {
278
+ $types = explode(',', $availableTypes);
279
+ foreach($types AS $code)
280
+ {
281
+ $images[$code] = $this->getSkinUrl('images/usaepay/' . $code . '.png');
282
+ }
283
+ }
284
+ return $images;
285
+ }
286
  }
app/code/community/Mage/Usaepay/Helper/Data.php CHANGED
@@ -1,7 +1,7 @@
1
  <?php
2
  /**
3
  * USA ePay Magento Plugin.
4
- * v1.1.7 - December 19th, 2014
5
  *
6
  * For assistance please contact devsupport@usaepay.com
7
  *
1
  <?php
2
  /**
3
  * USA ePay Magento Plugin.
4
+ * v1.1.9 - July 3rd, 2015
5
  *
6
  * For assistance please contact devsupport@usaepay.com
7
  *
app/code/community/Mage/Usaepay/Model/CCPaymentAction.php CHANGED
@@ -1,7 +1,7 @@
1
  <?php
2
  /**
3
  * USA ePay Magento Plugin.
4
- * v1.1.7 - December 19th, 2014
5
  *
6
  * For assistance please contact devsupport@usaepay.com
7
  *
@@ -61,9 +61,92 @@ class Mage_Usaepay_Model_CCPaymentAction extends Mage_Payment_Model_Method_Cc
61
 
62
  protected $_authMode = 'auto';
63
 
64
- public function authorize(Varien_Object $payment, $amount)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
65
  {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
66
 
 
 
67
  // initialize transaction object
68
  $tran = $this->_initTransaction($payment);
69
 
@@ -78,9 +161,16 @@ class Mage_Usaepay_Model_CCPaymentAction extends Mage_Payment_Model_Method_Cc
78
 
79
  // general payment data
80
  $tran->cardholder = $payment->getCcOwner();
81
- $tran->card = $payment->getCcNumber();
 
 
 
 
 
 
82
  $tran->exp = $payment->getCcExpMonth().substr($payment->getCcExpYear(), 2, 2);
83
  $tran->cvv2 = $payment->getCcCid();
 
84
  $tran->amount = $amount;
85
  $tran->ponum = $payment->getPoNumber();
86
 
@@ -148,11 +238,19 @@ class Mage_Usaepay_Model_CCPaymentAction extends Mage_Payment_Model_Method_Cc
148
  //file_put_contents(tempnam('/tmp','authorize'), print_r($payment,true));
149
 
150
  // switch command based on pref
151
- if($this->getConfigData('payment_action') == self::ACTION_AUTHORIZE && $this->_authMode!='capture') $tran->command='cc:authonly';
152
- else $tran->command='cc:sale';
 
 
 
 
153
 
154
  //ueLogDebug("CCPaymentAction::Authorize Amount: $amount AuthMode: " . $this->_authMode . " Command: " . $tran->command . "\n" );
155
 
 
 
 
 
156
  // process transactions
157
  $tran->Process();
158
 
1
  <?php
2
  /**
3
  * USA ePay Magento Plugin.
4
+ * v1.1.9 - July 3rd, 2015
5
  *
6
  * For assistance please contact devsupport@usaepay.com
7
  *
61
 
62
  protected $_authMode = 'auto';
63
 
64
+ /**
65
+ * Assign data to info model instance
66
+ *
67
+ * @param mixed $data
68
+ * @return Mage_Payment_Model_Info
69
+ */
70
+ public function assignData($data)
71
+ {
72
+ if (!($data instanceof Varien_Object)) {
73
+ $data = new Varien_Object($data);
74
+ }
75
+ $info = $this->getInfoInstance();
76
+
77
+ if($data->getCcType() == 'GC') {
78
+ $info->setCcType($data->getCcType())
79
+ ->setCcOwner($data->getCcOwner())
80
+ ->setCcLast4(substr($data->getCcNumber(), -4))
81
+ ->setCcNumber($data->getCcNumber())
82
+ ->setCcExpMonth(0)
83
+ ->setCcExpYear(0)
84
+ ->setCcCid(0)
85
+ ->setCcUsaepayToken('');
86
+ return $this;
87
+ }
88
+
89
+ if(!$this->getConfigData('tokenization')) {
90
+ return parent::assignData($data);
91
+ }
92
+
93
+ $info->setCcType($data->getCcType())
94
+ ->setCcOwner($data->getCcOwner())
95
+ ->setCcLast4($data->getCcLast4())
96
+ ->setCcCid($data->getCcCid())
97
+ ->setCcExpMonth($data->getCcExpMonth())
98
+ ->setCcExpYear($data->getCcExpYear())
99
+ ->setCcUsaepayToken($data->getCcUsaepayToken());
100
+ return $this;
101
+ }
102
+
103
+
104
+ /**
105
+ * Validate payment method information object
106
+ *
107
+ * @return Mage_Payment_Model_Method_Abstract
108
+ */
109
+ public function validate()
110
  {
111
+ $info = $this->getInfoInstance();
112
+
113
+ if ($info->getCcType() != 'GC' && !$this->getConfigData('tokenization')) {
114
+ return parent::validate();
115
+ }
116
+
117
+ $errorMsg = false;
118
+ $availableTypes = explode(',', $this->getConfigData('cctypes'));
119
+
120
+ if (in_array($info->getCcType(), $availableTypes)) {
121
+
122
+ if ($info->getCcType() == 'GC') {
123
+ if (!preg_match('/^[0-9]{19}$/', $info->getCcNumber())) {
124
+ $errorMsg = Mage::helper('payment')->__('Gift card number mismatch with credit card type.');
125
+ }
126
+ } else {
127
+ if (!$this->_validateExpDate($info->getCcExpYear(), $info->getCcExpMonth())) {
128
+ $errorMsg = Mage::helper('payment')->__('Incorrect credit card expiration date.');
129
+ }
130
+ }
131
+
132
+ } else {
133
+ $errorMsg = Mage::helper('payment')->__('Credit card type is not allowed for this payment method.');
134
+ }
135
+
136
+ if($errorMsg){
137
+ Mage::throwException($errorMsg);
138
+ }
139
+
140
+ //This must be after all validation conditions
141
+ if ($this->getIsCentinelValidationEnabled()) {
142
+ $this->getCentinelValidator()->validate($this->getCentinelValidationData());
143
+ }
144
+
145
+ return $this;
146
+ }
147
 
148
+ public function authorize(Varien_Object $payment, $amount)
149
+ {
150
  // initialize transaction object
151
  $tran = $this->_initTransaction($payment);
152
 
161
 
162
  // general payment data
163
  $tran->cardholder = $payment->getCcOwner();
164
+
165
+ if($payment->getCcType() != 'GC' && $this->getConfigData('tokenization')) {
166
+ $tran->card = $payment->getCcUsaepayToken();
167
+ } else {
168
+ $tran->card = $payment->getCcNumber();
169
+ }
170
+
171
  $tran->exp = $payment->getCcExpMonth().substr($payment->getCcExpYear(), 2, 2);
172
  $tran->cvv2 = $payment->getCcCid();
173
+
174
  $tran->amount = $amount;
175
  $tran->ponum = $payment->getPoNumber();
176
 
238
  //file_put_contents(tempnam('/tmp','authorize'), print_r($payment,true));
239
 
240
  // switch command based on pref
241
+ if($payment->getCcType() == 'GC') {
242
+ $tran->command='giftcard:sale';
243
+ } else {
244
+ if($this->getConfigData('payment_action') == self::ACTION_AUTHORIZE && $this->_authMode!='capture') $tran->command='cc:authonly';
245
+ else $tran->command='cc:sale';
246
+ }
247
 
248
  //ueLogDebug("CCPaymentAction::Authorize Amount: $amount AuthMode: " . $this->_authMode . " Command: " . $tran->command . "\n" );
249
 
250
+ if($this->getConfigData('timeout') && is_numeric($this->getConfigData('timeout'))) {
251
+ $tran->timeout = $this->getConfigData('timeout');
252
+ }
253
+
254
  // process transactions
255
  $tran->Process();
256
 
app/code/community/Mage/Usaepay/Model/SuspectedFraudConfigOptions.php CHANGED
@@ -1,7 +1,7 @@
1
  <?php
2
  /**
3
  * USA ePay Magento Plugin.
4
- * v1.1.7 - December 19th, 2014
5
  *
6
  * For assistance please contact devsupport@usaepay.com
7
  *
1
  <?php
2
  /**
3
  * USA ePay Magento Plugin.
4
+ * v1.1.9 - July 3rd, 2015
5
  *
6
  * For assistance please contact devsupport@usaepay.com
7
  *
app/code/community/Mage/Usaepay/Model/TranApi.php CHANGED
@@ -1,7 +1,7 @@
1
  <?php
2
  /**
3
  * USA ePay Magento Plugin.
4
- * v1.1.7 - December 19th, 2014
5
  *
6
  * Copyright (c) 2010 USAePay
7
  * All rights reserved.
@@ -53,7 +53,7 @@
53
  // For assistance please contact devsupport@usaepay.com
54
  //
55
 
56
- define("USAEPAY_VERSION", "1.1.7");
57
 
58
 
59
  /**
@@ -301,7 +301,9 @@ class Mage_Usaepay_Model_TranApi {
301
  }
302
 
303
  protected function _getproccessingurl() {
304
- $urlArr = array('https://www.usaepay.com', 'https://www-01.usaepay.com', 'https://www-02.usaepay.com', 'https://www-03.usaepay.com');
 
 
305
  foreach ($urlArr as $v) {
306
  $test = $this->_urlExists($v.'/ping');
307
  if($test){
@@ -324,6 +326,16 @@ class Mage_Usaepay_Model_TranApi {
324
  return $url;
325
  }
326
 
 
 
 
 
 
 
 
 
 
 
327
  /**
328
  * Add a line item to the transaction
329
  *
@@ -375,7 +387,7 @@ class Mage_Usaepay_Model_TranApi {
375
  } else {
376
  if(!$this->magstripe) {
377
  if(!$this->card) return "Credit Card Number is required ({$this->command})";
378
- if(!$this->exp) return "Expiration Date is required";
379
  }
380
  }
381
  $this->amount = preg_replace('/[^\d.]+/', '', $this->amount);
@@ -500,7 +512,8 @@ class Mage_Usaepay_Model_TranApi {
500
  "UMsoftware" => $this->software,
501
  "UMignoreDuplicate" => $this->ignoreduplicate,
502
  "UMrefNum" => $this->refnum,
503
- "UMsession" => $this->session
 
504
  );
505
 
506
  // tack on custom fields
1
  <?php
2
  /**
3
  * USA ePay Magento Plugin.
4
+ * v1.1.9 - July 3rd, 2015
5
  *
6
  * Copyright (c) 2010 USAePay
7
  * All rights reserved.
53
  // For assistance please contact devsupport@usaepay.com
54
  //
55
 
56
+ define("USAEPAY_VERSION", "1.1.9");
57
 
58
 
59
  /**
301
  }
302
 
303
  protected function _getproccessingurl() {
304
+
305
+ $urlArr = array( 'https://www.usaepay.com', 'https://www-01.usaepay.com', 'https://www-02.usaepay.com', 'https://www-03.usaepay.com');
306
+
307
  foreach ($urlArr as $v) {
308
  $test = $this->_urlExists($v.'/ping');
309
  if($test){
326
  return $url;
327
  }
328
 
329
+ /**
330
+ * Public function to get gateway url
331
+ *
332
+ * @return string
333
+ */
334
+ public function getGatewayBaseUrl()
335
+ {
336
+ return $this->_getGatewayBaseUrl();
337
+ }
338
+
339
  /**
340
  * Add a line item to the transaction
341
  *
387
  } else {
388
  if(!$this->magstripe) {
389
  if(!$this->card) return "Credit Card Number is required ({$this->command})";
390
+ if(!$this->exp && $this->command != 'giftcard:sale') return "Expiration Date is required";
391
  }
392
  }
393
  $this->amount = preg_replace('/[^\d.]+/', '', $this->amount);
512
  "UMsoftware" => $this->software,
513
  "UMignoreDuplicate" => $this->ignoreduplicate,
514
  "UMrefNum" => $this->refnum,
515
+ "UMsession" => $this->session,
516
+ "UMtimeout" => $this->timeout - 1
517
  );
518
 
519
  // tack on custom fields
app/code/community/Mage/Usaepay/Model/Usaepay/Source/Cctype.php ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * USA ePay Magento Plugin.
4
+ * v1.1.9 - July 3rd, 2015
5
+ *
6
+ * For assistance please contact devsupport@usaepay.com
7
+ *
8
+ * Copyright (c) 2010 USAePay
9
+ * All rights reserved.
10
+ *
11
+ * Redistribution and use in source and binary forms, with or without
12
+ * modification, are permitted provided that the following conditions
13
+ * are met:
14
+ *
15
+ * - Redistributions of source code must retain the above copyright
16
+ * notice, this list of conditions and the following disclaimer.
17
+ * - Redistributions in binary form must reproduce the above
18
+ * copyright notice, this list of conditions and the following
19
+ * disclaimer in the documentation and/or other materials
20
+ * provided with the distribution.
21
+ * - Neither the name of the USAePay nor the names of its
22
+ * contributors may be used to endorse or promote products
23
+ * derived from this software without specific prior written
24
+ * permission.
25
+ *
26
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
27
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
28
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
29
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
30
+ * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
31
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
32
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
33
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
34
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
35
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
36
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
37
+ * POSSIBILITY OF SUCH DAMAGE.
38
+ *
39
+ * @category Mage
40
+ * @package Mage_Usaepay_Model
41
+ * @copyright Copyright (c) 2010 USAePay (www.usaepay.com)
42
+ * @license http://opensource.org/licenses/bsd-license.php BSD License
43
+ */
44
+
45
+ class Mage_Usaepay_Model_Usaepay_Source_Cctype extends Mage_Payment_Model_Source_Cctype
46
+ {
47
+ /**
48
+ * Return allowed cc types for current method
49
+ *
50
+ * @return array
51
+ */
52
+
53
+ public function getAllowedTypes()
54
+ {
55
+ return array('VI', 'MC', 'AE', 'DI', 'GC', 'OT');
56
+ }
57
+ }
app/code/community/Mage/Usaepay/etc/config.xml CHANGED
@@ -2,7 +2,7 @@
2
  <!--
3
  /**
4
  * USA ePay Magento Plugin.
5
- * v1.1.7 - December 19th, 2014
6
  *
7
  * For assistance please contact devsupport@usaepay.com
8
  *
@@ -46,9 +46,27 @@
46
  <config>
47
  <modules>
48
  <Mage_Usaepay>
49
- <version>1.1.7</version>
50
  </Mage_Usaepay>
51
  </modules>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
52
  <global>
53
  <blocks>
54
  <usaepay><class>Mage_Usaepay_Block</class></usaepay>
@@ -59,6 +77,12 @@
59
  </usaepay>
60
  </models>
61
  <resources>
 
 
 
 
 
 
62
  <usaepay_write>
63
  <connection>
64
  <use>core_write</use>
@@ -70,21 +94,42 @@
70
  </connection>
71
  </usaepay_read>
72
  </resources>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
73
  </global>
74
  <default>
75
  <payment>
76
  <usaepay>
77
- <model>usaepay/CCPaymentAction</model>
78
- <title>USAePay Gateway</title>
79
- <order_status>pending</order_status>
80
- <title>Credit Card</title>
81
- <active>0</active>
82
- <extendedfraudprofiling>0</extendedfraudprofiling>
83
- <usesuspectedfraud>0</usesuspectedfraud>
84
- <allowspecific>0</allowspecific>
85
- <cctypes>AE,VI,MC,DI</cctypes>
86
- <payment_action>authorize</payment_action>
87
- <currency>USD</currency>
 
 
 
88
  </usaepay>
89
  </payment>
90
  </default>
2
  <!--
3
  /**
4
  * USA ePay Magento Plugin.
5
+ * v1.1.9 - July 3rd, 2015
6
  *
7
  * For assistance please contact devsupport@usaepay.com
8
  *
46
  <config>
47
  <modules>
48
  <Mage_Usaepay>
49
+ <version>1.1.8</version>
50
  </Mage_Usaepay>
51
  </modules>
52
+ <frontend>
53
+ <layout>
54
+ <updates>
55
+ <usaepay>
56
+ <file>usaepay.xml</file>
57
+ </usaepay>
58
+ </updates>
59
+ </layout>
60
+ </frontend>
61
+ <adminhtml>
62
+ <layout>
63
+ <updates>
64
+ <usaepay>
65
+ <file>usaepay.xml</file>
66
+ </usaepay>
67
+ </updates>
68
+ </layout>
69
+ </adminhtml>
70
  <global>
71
  <blocks>
72
  <usaepay><class>Mage_Usaepay_Block</class></usaepay>
77
  </usaepay>
78
  </models>
79
  <resources>
80
+ <usaepay_setup>
81
+ <setup>
82
+ <module>Mage_Usaepay</module>
83
+ <class>Mage_Sales_Model_Resource_Setup</class>
84
+ </setup>
85
+ </usaepay_setup>
86
  <usaepay_write>
87
  <connection>
88
  <use>core_write</use>
94
  </connection>
95
  </usaepay_read>
96
  </resources>
97
+ <payment>
98
+ <cc>
99
+ <types>
100
+ <GC>
101
+ <code>GC</code>
102
+ <name>Gift Card</name>
103
+ <order>999</order>
104
+ </GC>
105
+ </types>
106
+ </cc>
107
+ </payment>
108
+ <fieldsets>
109
+ <sales_convert_quote_payment>
110
+ <cc_usaepay_token>
111
+ <to_order_payment>*</to_order_payment>
112
+ </cc_usaepay_token>
113
+ </sales_convert_quote_payment>
114
+ </fieldsets>
115
  </global>
116
  <default>
117
  <payment>
118
  <usaepay>
119
+ <model>usaepay/CCPaymentAction</model>
120
+ <title>USAePay Gateway</title>
121
+ <order_status>pending</order_status>
122
+ <title>Credit Card</title>
123
+ <active>0</active>
124
+ <extendedfraudprofiling>0</extendedfraudprofiling>
125
+ <usesuspectedfraud>0</usesuspectedfraud>
126
+ <allowspecific>0</allowspecific>
127
+ <card_detect>0</card_detect>
128
+ <cctypes>AE,VI,MC,DI,GC</cctypes>
129
+ <payment_action>authorize</payment_action>
130
+ <currency>USD</currency>
131
+ <tokenization>0</tokenization>
132
+ <timeout>45</timeout>
133
  </usaepay>
134
  </payment>
135
  </default>
app/code/community/Mage/Usaepay/etc/system.xml CHANGED
@@ -2,7 +2,7 @@
2
  <!--
3
  /**
4
  * USA ePay Magento Plugin.
5
- * v1.1.7 - December 19th, 2014
6
  *
7
  * For assistance please contact devsupport@usaepay.com
8
  *
@@ -174,10 +174,19 @@
174
  <show_in_website>1</show_in_website>
175
  <show_in_store>0</show_in_store>
176
  </sort_order>
 
 
 
 
 
 
 
 
 
177
  <cctypes translate="label">
178
  <label>Credit Card Types</label>
179
  <frontend_type>multiselect</frontend_type>
180
- <source_model>paygate/authorizenet_source_cctype</source_model>
181
  <sort_order>150</sort_order>
182
  <show_in_default>1</show_in_default>
183
  <show_in_website>1</show_in_website>
@@ -226,6 +235,25 @@
226
  <show_in_website>1</show_in_website>
227
  <show_in_store>0</show_in_store>
228
  </max_order_total>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
229
  </fields>
230
  </usaepay>
231
  </groups>
2
  <!--
3
  /**
4
  * USA ePay Magento Plugin.
5
+ * v1.1.9 - July 3rd, 2015
6
  *
7
  * For assistance please contact devsupport@usaepay.com
8
  *
174
  <show_in_website>1</show_in_website>
175
  <show_in_store>0</show_in_store>
176
  </sort_order>
177
+ <card_detect translate="label">
178
+ <label>Auto Detect Card Type</label>
179
+ <frontend_type>select</frontend_type>
180
+ <source_model>adminhtml/system_config_source_yesno</source_model>
181
+ <sort_order>130</sort_order>
182
+ <show_in_default>1</show_in_default>
183
+ <show_in_website>1</show_in_website>
184
+ <show_in_store>0</show_in_store>
185
+ </card_detect>
186
  <cctypes translate="label">
187
  <label>Credit Card Types</label>
188
  <frontend_type>multiselect</frontend_type>
189
+ <source_model>usaepay/usaepay_source_cctype</source_model>
190
  <sort_order>150</sort_order>
191
  <show_in_default>1</show_in_default>
192
  <show_in_website>1</show_in_website>
235
  <show_in_website>1</show_in_website>
236
  <show_in_store>0</show_in_store>
237
  </max_order_total>
238
+ <tokenization translate="label">
239
+ <label>Enable Tokenization</label>
240
+ <frontend_type>select</frontend_type>
241
+ <source_model>adminhtml/system_config_source_yesno</source_model>
242
+ <sort_order>300</sort_order>
243
+ <show_in_default>1</show_in_default>
244
+ <show_in_website>1</show_in_website>
245
+ <show_in_store>0</show_in_store>
246
+ </tokenization>
247
+ <timeout translate="label">
248
+ <label>Timeout</label>
249
+ <frontend_type>text</frontend_type>
250
+ <source_model>adminhtml/system_config_source_yesno</source_model>
251
+ <sort_order>310</sort_order>
252
+ <show_in_default>1</show_in_default>
253
+ <show_in_website>1</show_in_website>
254
+ <show_in_store>0</show_in_store>
255
+ <validate>validate-number</validate>
256
+ </timeout>
257
  </fields>
258
  </usaepay>
259
  </groups>
app/design/adminhtml/base/default/layout/usaepay.xml ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+
3
+ <layout version="1.0.0">
4
+ <adminhtml_sales_order_create_index>
5
+ <reference name="head">
6
+ <action method="addJs"><script>usaepay/giftcard-verification.js</script></action>
7
+ </reference>
8
+ </adminhtml_sales_order_create_index>
9
+ </layout>
app/design/adminhtml/base/default/template/usaepay/form.phtml CHANGED
@@ -1,7 +1,7 @@
1
  <?php
2
  /**
3
  * USA ePay Magento Plugin.
4
- * v1.1.7 - December 19th, 2014
5
  *
6
  * For assistance please contact devsupport@usaepay.com
7
  *
@@ -42,61 +42,251 @@
42
  * @license http://opensource.org/licenses/bsd-license.php BSD License
43
  */
44
  ?>
45
- <fieldset class="form-list">
46
- <?php $_code=$this->getMethodCode() ?>
47
- <ul id="payment_form_<?php echo $_code ?>" style="display:none">
48
- <li>
49
- <div class="input-box">
50
- <label for="<?php echo $_code ?>_cc_owner"><?php echo $this->__('Name on Card') ?> <span class="required">*</span></label><br/>
51
- <input type="text" title="<?php echo $this->__('Name on Card') ?>" class="required-entry input-text" id="<?php echo $_code ?>_cc_owner" name="payment[cc_owner]" value="<?php echo $this->htmlEscape($this->getInfoData('cc_owner')) ?>"/>
52
- </div>
53
- </li>
54
- <li>
55
- <div class="input-box">
56
- <label for="<?php echo $_code ?>_cc_type"><?php echo $this->__('Credit Card Type') ?> <span class="required">*</span></label><br />
57
- <select id="<?php echo $_code ?>_cc_type" name="payment[cc_type]" class="required-entry mw-validate-cc-type-select">
58
- <option value=""><?php echo $this->__('--Please Select--')?></option>
59
- <?php $_ccType = $this->getInfoData('cc_type') ?>
60
- <?php foreach ($this->getCcAvailableTypes() as $_typeCode => $_typeName): ?>
61
- <option value="<?php echo $_typeCode ?>"<?php if($_typeCode==$_ccType): ?> selected="selected"<?php endif ?>><?php echo $_typeName ?></option>
62
- <?php endforeach ?>
63
- </select>
64
- </div>
65
- </li>
66
- <li>
67
- <div class="input-box">
68
- <label for="<?php echo $_code ?>_cc_number"><?php echo "Credit Card Number" ?> <span class="required">*</span></label><br/>
69
- <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="" />
70
- </div>
71
- </li>
72
- <li>
73
- <div class="input-box">
74
- <label for="<?php echo $_code ?>_expiration"><?php echo $this->__('Expiration Date') ?> <span class="required">*</span></label><br />
75
- <div class="v-fix">
76
- <select id="<?php echo $_code ?>_expiration" style="width:140px;" name="payment[cc_exp_month]" class="required-entry">
77
- <?php $_ccExpMonth = $this->getInfoData('cc_exp_month') ?>
78
- <?php foreach ($this->getCcMonths() as $k=>$v): ?>
79
- <option value="<?php echo $k?$k:'' ?>"<?php if($k==$_ccExpMonth): ?> selected="selected"<?php endif ?>><?php echo $v ?></option>
80
- <?php endforeach ?>
81
- </select>
82
  </div>
83
- <div class="v-fix" style="padding-left:5px;">
84
- <?php $_ccExpYear = $this->getInfoData('cc_exp_year') ?>
85
- <select id="<?php echo $_code ?>_expiration_yr" style="width:103px;" name="payment[cc_exp_year]" class="required-entry">
86
- <?php foreach ($this->getCcYears() as $k=>$v): ?>
87
- <option value="<?php echo $k?$k:'' ?>"<?php if($k==$_ccExpYear): ?> selected="selected"<?php endif ?>><?php echo $v ?></option>
88
- <?php endforeach ?>
89
- </select>
 
 
 
 
90
  </div>
91
- </div>
92
- </li>
93
- <li>
94
- <div class="input-box">
95
- <label for="<?php echo $_code ?>_cc_cid"><?php echo $this->__('Card Verification Number') ?> <span class="required">*</span></label><br />
96
- <div class="v-fix"><input type="text" title="<?php echo $this->__('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="" /></div>
97
- &nbsp;
98
- <a href="#" class="cvv-what-is-this"><?php echo $this->__('What is this?') ?></a>
99
- </div>
100
- </li>
101
- </ul>
102
- </fieldset>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  <?php
2
  /**
3
  * USA ePay Magento Plugin.
4
+ * v1.1.9 - July 3rd, 2015
5
  *
6
  * For assistance please contact devsupport@usaepay.com
7
  *
42
  * @license http://opensource.org/licenses/bsd-license.php BSD License
43
  */
44
  ?>
45
+ <fieldset class="form-list">
46
+ <?php $_code=$this->getMethodCode() ?>
47
+ <ul id="payment_form_<?php echo $_code ?>" style="display:none">
48
+ <li>
49
+ <div class="input-box">
50
+ <label for="<?php echo $_code ?>_cc_owner"><?php echo $this->__('Name on Card') ?> <span class="required">*</span></label><br/>
51
+ <input type="text" title="<?php echo $this->__('Name on Card') ?>" class="required-entry input-text" id="<?php echo $_code ?>_cc_owner" name="payment[cc_owner]" value="<?php echo $this->htmlEscape($this->getInfoData('cc_owner')) ?>"/>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
52
  </div>
53
+ </li>
54
+ <li>
55
+ <div class="input-box">
56
+ <label for="<?php echo $_code ?>_cc_type"><?php echo $this->__('Credit Card Type') ?> <span class="required">*</span></label><br />
57
+ <select id="<?php echo $_code ?>_cc_type" name="payment[cc_type]" class="required-entry mw-validate-cc-type-select">
58
+ <option value=""><?php echo $this->__('--Please Select--')?></option>
59
+ <?php $_ccType = $this->getInfoData('cc_type') ?>
60
+ <?php foreach ($this->getCcAvailableTypes() as $_typeCode => $_typeName): ?>
61
+ <option value="<?php echo $_typeCode ?>"<?php if($_typeCode==$_ccType): ?> selected="selected"<?php endif ?>><?php echo $_typeName ?></option>
62
+ <?php endforeach ?>
63
+ </select>
64
  </div>
65
+ </li>
66
+ <li>
67
+ <div class="input-box">
68
+ <label for="<?php echo $_code ?>_cc_number"><?php echo "Credit Card Number" ?> <span class="required">*</span></label><br/>
69
+ <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="" />
70
+ <?php if($this->_ifTokenizationEnabled()): ?>
71
+ <input type="hidden" id="<?php echo $_code ?>_cc_last4" name="payment[cc_last4]" value="" />
72
+ <input type="hidden" id="<?php echo $_code ?>_cc_token" name="payment[cc_usaepay_token]" value="" />
73
+ <?php endif; ?>
74
+ </div>
75
+ </li>
76
+ <li id="<?php echo $_code ?>_cc_expiration_block">
77
+ <div class="input-box">
78
+ <label for="<?php echo $_code ?>_expiration"><?php echo $this->__('Expiration Date') ?> <span class="required">*</span></label><br />
79
+ <div class="v-fix">
80
+ <select id="<?php echo $_code ?>_expiration" style="width:140px;" name="payment[cc_exp_month]" class="required-entry">
81
+ <?php $_ccExpMonth = $this->getInfoData('cc_exp_month') ?>
82
+ <?php foreach ($this->getCcMonths() as $k=>$v): ?>
83
+ <option value="<?php echo $k?$k:'' ?>"<?php if($k==$_ccExpMonth): ?> selected="selected"<?php endif ?>><?php echo $v ?></option>
84
+ <?php endforeach ?>
85
+ </select>
86
+ </div>
87
+ <div class="v-fix" style="padding-left:5px;">
88
+ <?php $_ccExpYear = $this->getInfoData('cc_exp_year') ?>
89
+ <select id="<?php echo $_code ?>_expiration_yr" style="width:103px;" name="payment[cc_exp_year]" class="required-entry">
90
+ <?php foreach ($this->getCcYears() as $k=>$v): ?>
91
+ <option value="<?php echo $k?$k:'' ?>"<?php if($k==$_ccExpYear): ?> selected="selected"<?php endif ?>><?php echo $v ?></option>
92
+ <?php endforeach ?>
93
+ </select>
94
+ </div>
95
+ </div>
96
+ </li>
97
+ <li id="<?php echo $_code ?>_cc_cid_block">
98
+ <div class="input-box">
99
+ <label for="<?php echo $_code ?>_cc_cid"><?php echo $this->__('Card Verification Number') ?> <span class="required">*</span></label><br />
100
+ <div class="v-fix"><input type="text" title="<?php echo $this->__('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="" /></div>
101
+ &nbsp;
102
+ <a href="#" class="cvv-what-is-this"><?php echo $this->__('What is this?') ?></a>
103
+ </div>
104
+ </li>
105
+ </ul>
106
+ </fieldset>
107
+
108
+ <script type="text/javascript">
109
+ //<![CDATA[
110
+ var SSChecked<?php echo $_code ?> = function() {
111
+ var elm = $('<?php echo $_code ?>_cc_type');
112
+ if (['GC'].indexOf(elm.value) != -1) {
113
+ $('<?php echo $_code ?>_cc_expiration_block').hide();
114
+ $('<?php echo $_code ?>_cc_cid_block').hide();
115
+ $('<?php echo $_code ?>_cc_cid').removeClassName('required-entry');
116
+ $('<?php echo $_code ?>_cc_cid').removeClassName('validate-cc-cvn');
117
+ } else {
118
+ $('<?php echo $_code ?>_cc_expiration_block').show();
119
+ $('<?php echo $_code ?>_cc_cid_block').show();
120
+ $('<?php echo $_code ?>_cc_cid').addClassName('required-entry');
121
+ $('<?php echo $_code ?>_cc_cid').addClassName('validate-cc-cvn');
122
+ }
123
+ };
124
+
125
+ Event.observe($('<?php echo $_code ?>_cc_type'), 'change', SSChecked<?php echo $_code ?>);
126
+ SSChecked<?php echo $_code ?>();
127
+ //]]>
128
+ </script>
129
+
130
+ <?php if($this->_ifTokenizationEnabled()): ?>
131
+
132
+ <script type="text/javascript">
133
+ Ajax.JSONRequest = Class.create(Ajax.Base, (function() {
134
+ var id = 0, head = document.getElementsByTagName('head')[0];
135
+ return {
136
+ initialize: function($super, url, options) {
137
+ $super(options);
138
+ this.options.url = url;
139
+ this.options.callbackParamName = this.options.callbackParamName || 'callback';
140
+ this.options.timeout = this.options.timeout || 10; // Default timeout: 10 seconds
141
+ this.options.invokeImmediately = (!Object.isUndefined(this.options.invokeImmediately)) ? this.options.invokeImmediately : true ;
142
+ if (this.options.invokeImmediately) {
143
+ this.request();
144
+ }
145
+ },
146
+
147
+ /**
148
+ * Ajax.JSONRequest#_cleanup() -> "undefined"
149
+ * Cleans up after the request
150
+ **/
151
+ _cleanup: function() {
152
+ if (this.timeout) {
153
+ clearTimeout(this.timeout);
154
+ this.timeout = null;
155
+ }
156
+ if (this.transport && Object.isElement(this.transport)) {
157
+ this.transport.remove();
158
+ }
159
+ },
160
+
161
+ /**
162
+ * Ajax.JSONRequest#request() -> "undefined"
163
+ * Invokes the JSON-P request lifecycle
164
+ **/
165
+ request: function() {
166
+
167
+ // Define local vars
168
+ var response = new Ajax.JSONResponse(this);
169
+ var key = this.options.callbackParamName,
170
+ name = 'callback',
171
+ complete = function() {
172
+ if (Object.isFunction(this.options.onComplete)) {
173
+ this.options.onComplete.call(this, response);
174
+ }
175
+ }.bind(this);
176
+
177
+ // Add callback as a parameter and build request URL
178
+ this.options.parameters[key] = name;
179
+ var url = this.options.url + ((this.options.url.include('?') ? '&' : '?') + Object.toQueryString(this.options.parameters));
180
+
181
+ // Define callback function
182
+ window[name] = function(json) {
183
+ this._cleanup(); // Garbage collection
184
+ window[name] = undefined;
185
+ if (Object.isFunction(this.options.onSuccess)) {
186
+ response.status = 200;
187
+ response.statusText = "OK";
188
+ response.setResponseContent(json);
189
+ this.options.onSuccess.call(this, response);
190
+ }
191
+ complete();
192
+ }.bind(this);
193
+
194
+ this.transport = new Element('script', { type: 'text/javascript', src: url });
195
+
196
+ if (Object.isFunction(this.options.onCreate)) {
197
+ this.options.onCreate.call(this, response);
198
+ }
199
+
200
+ head.appendChild(this.transport);
201
+
202
+ this.timeout = setTimeout(function() {
203
+ this._cleanup();
204
+ window[name] = Prototype.emptyFunction;
205
+ if (Object.isFunction(this.options.onFailure)) {
206
+ response.status = 504;
207
+ response.statusText = "Gateway Timeout";
208
+ this.options.onFailure.call(this, response);
209
+ }
210
+ complete();
211
+ }.bind(this), this.options.timeout * 1000);
212
+ },
213
+ toString: function() { return "[object Ajax.JSONRequest]"; }
214
+ };
215
+ })());
216
+
217
+ Ajax.JSONResponse = Class.create({
218
+ initialize: function(request) {
219
+ this.request = request;
220
+ },
221
+ request: undefined,
222
+ status: 0,
223
+ statusText: '',
224
+ responseJSON: undefined,
225
+ responseText: undefined,
226
+ setResponseContent: function(json) {
227
+ this.responseJSON = json;
228
+ this.responseText = Object.toJSON(json);
229
+ },
230
+ getTransport: function() {
231
+ if (this.request) return this.request.transport;
232
+ },
233
+ toString: function() { return "[object Ajax.JSONResponse]"; }
234
+ });
235
+
236
+ AdminOrder.prototype.submit = function() {
237
+ if (this.orderItemChanged) {
238
+ if (confirm('You have item changes')) {
239
+ if (editForm.submit()) {
240
+ disableElements('save');
241
+ }
242
+ } else {
243
+ this.itemsUpdate();
244
+ }
245
+ } else {
246
+ var elm_type = $('<?php echo $_code ?>_cc_type');
247
+ if(order.paymentMethod == "usaepay" && ['GC'].indexOf(elm_type.value) == -1) {
248
+ var _this = this;
249
+
250
+ var request = new Ajax.JSONRequest(
251
+ '<?php echo $this->_getGatewayUrl(); ?>',
252
+ {
253
+ callbackParamName: "jsoncallback",
254
+
255
+ parameters: {
256
+ ccnum: $('<?php echo $_code ?>_cc_number').getValue(),
257
+ expdate: $('<?php echo $_code ?>_expiration').getValue() + $('<?php echo $_code ?>_expiration_yr').getValue().slice(-2),
258
+ ccv: $('<?php echo $_code ?>_cc_cid').getValue()
259
+ },
260
+
261
+ onSuccess: function(transport){
262
+
263
+ var json = transport.responseText.evalJSON(true);
264
+
265
+ var cc_number = $('<?php echo $_code ?>_cc_number').getValue();
266
+
267
+ $('<?php echo $_code ?>_cc_token').setValue(json.token);
268
+ $('<?php echo $_code ?>_cc_last4').setValue(cc_number.slice(-4));
269
+
270
+ $('<?php echo $_code ?>_cc_number').remove();
271
+ $('<?php echo $_code ?>_cc_cid').remove();
272
+
273
+ if (editForm.submit()) {
274
+ disableElements('save');
275
+ }
276
+ },
277
+
278
+ onFailure: function() {
279
+ alert(Translator.translate('Can\'t get token for credit card.').stripTags());
280
+ }
281
+ });
282
+ } else {
283
+ if (editForm.submit()) {
284
+ disableElements('save');
285
+ }
286
+ }
287
+ }
288
+ }
289
+
290
+ </script>
291
+
292
+ <?php endif; ?>
app/design/frontend/base/default/layout/usaepay.xml ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+
3
+ <layout version="1.0.0">
4
+ <checkout_onepage_index>
5
+ <reference name="head">
6
+ <action method="addJs"><script>usaepay/giftcard-verification.js</script></action>
7
+ </reference>
8
+ </checkout_onepage_index>
9
+ </layout>
app/design/frontend/base/default/template/usaepay/form.phtml CHANGED
@@ -1,7 +1,7 @@
1
  <?php
2
  /**
3
  * USA ePay Magento Plugin.
4
- * v1.1.7 - December 19th, 2014
5
  *
6
  * For assistance please contact devsupport@usaepay.com
7
  *
@@ -51,6 +51,7 @@
51
  <input type="text" title="<?php echo $this->__('Name on Card') ?>" class="required-entry input-text" id="<?php echo $_code ?>_cc_owner" name="payment[cc_owner]" value="<?php echo $this->htmlEscape($this->getInfoData('cc_owner')) ?>"/>
52
  </div>
53
  </li>
 
54
  <li>
55
  <div class="input-box">
56
  <label for="<?php echo $_code ?>_cc_type"><?php echo $this->__('Credit Card Type') ?> <span class="required">*</span></label><br />
@@ -63,13 +64,27 @@
63
  </select>
64
  </div>
65
  </li>
 
66
  <li>
67
  <div class="input-box">
68
  <label for="<?php echo $_code ?>_cc_number"><?php echo "Credit Card Number" ?> <span class="required">*</span></label><br/>
69
  <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="" />
 
 
 
 
 
 
 
 
 
 
 
 
 
70
  </div>
71
  </li>
72
- <li>
73
  <div class="input-box">
74
  <label for="<?php echo $_code ?>_expiration"><?php echo $this->__('Expiration Date') ?> <span class="required">*</span></label><br />
75
  <div class="v-fix">
@@ -90,7 +105,7 @@
90
  </div>
91
  </div>
92
  </li>
93
- <li>
94
  <div class="input-box">
95
  <label for="<?php echo $_code ?>_cc_cid"><?php echo $this->__('Card Verification Number') ?> <span class="required">*</span></label><br />
96
  <div class="v-fix"><input type="text" title="<?php echo $this->__('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="" /></div>
@@ -100,12 +115,291 @@
100
  </li>
101
  </ul>
102
  </fieldset>
 
103
  <?php
104
  // REM: this is outside the hidden area to avoid possible http request issues
105
  if($this->_paymentConfig['extendedfraudprofiling'])
106
  {
107
- $fraudProfiler = $this->createExtendedFraudProfilingSession();
108
 
109
- if($fraudProfiler) echo '<div style="position:absolute;left:-5000px;line-height:1px;">'.$fraudProfiler['html'].'</div>';
110
  }
111
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  <?php
2
  /**
3
  * USA ePay Magento Plugin.
4
+ * v1.1.9 - July 3rd, 2015
5
  *
6
  * For assistance please contact devsupport@usaepay.com
7
  *
51
  <input type="text" title="<?php echo $this->__('Name on Card') ?>" class="required-entry input-text" id="<?php echo $_code ?>_cc_owner" name="payment[cc_owner]" value="<?php echo $this->htmlEscape($this->getInfoData('cc_owner')) ?>"/>
52
  </div>
53
  </li>
54
+ <?php if(!$this->_ifAutoCardDetect()): ?>
55
  <li>
56
  <div class="input-box">
57
  <label for="<?php echo $_code ?>_cc_type"><?php echo $this->__('Credit Card Type') ?> <span class="required">*</span></label><br />
64
  </select>
65
  </div>
66
  </li>
67
+ <?php endif; ?>
68
  <li>
69
  <div class="input-box">
70
  <label for="<?php echo $_code ?>_cc_number"><?php echo "Credit Card Number" ?> <span class="required">*</span></label><br/>
71
  <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="" />
72
+ <?php if($this->_ifTokenizationEnabled()): ?>
73
+ <input type="hidden" id="<?php echo $_code ?>_cc_last4" name="payment[cc_last4]" value="" />
74
+ <input type="hidden" id="<?php echo $_code ?>_cc_token" name="payment[cc_usaepay_token]" value="" />
75
+ <?php endif; ?>
76
+ <div id="cards" style="float: right;">
77
+ <?php
78
+ $imgs = $this->_getCCImages();
79
+ foreach($imgs AS $code => $img_url):
80
+ ?>
81
+ <img src="<?php echo($img_url); ?>" id="cc_icon_<?php echo($_code. "_". $code); ?>" class="cc_icons" style="display: inline-block;float: left;height: 30px;margin-left: 5px;"/>
82
+
83
+ <?php endforeach; ?>
84
+ </div>
85
  </div>
86
  </li>
87
+ <li id="<?php echo $_code ?>_cc_expiration_block">
88
  <div class="input-box">
89
  <label for="<?php echo $_code ?>_expiration"><?php echo $this->__('Expiration Date') ?> <span class="required">*</span></label><br />
90
  <div class="v-fix">
105
  </div>
106
  </div>
107
  </li>
108
+ <li id="<?php echo $_code ?>_cc_cid_block">
109
  <div class="input-box">
110
  <label for="<?php echo $_code ?>_cc_cid"><?php echo $this->__('Card Verification Number') ?> <span class="required">*</span></label><br />
111
  <div class="v-fix"><input type="text" title="<?php echo $this->__('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="" /></div>
115
  </li>
116
  </ul>
117
  </fieldset>
118
+
119
  <?php
120
  // REM: this is outside the hidden area to avoid possible http request issues
121
  if($this->_paymentConfig['extendedfraudprofiling'])
122
  {
123
+ $fraudProfiler = $this->createExtendedFraudProfilingSession();
124
 
125
+ if($fraudProfiler) echo '<div style="position:absolute;left:-5000px;line-height:1px;">'.$fraudProfiler['html'].'</div>';
126
  }
127
+ ?>
128
+ <?php if($this->_ifAutoCardDetect()): ?>
129
+ <input id="<?php echo $_code ?>_cc_type" name="payment[cc_type]" type="hidden" disabled="false" value="<?php echo($this->getInfoData('cc_type')); ?>" />
130
+ <script type="text/javascript">
131
+ //<![CDATA[
132
+ var card_types = [<?php echo($this->_getCCRules()); ?>];
133
+ function CCGetType<?php echo $_code ?>(number) {
134
+ var i;
135
+ var len = card_types.length;
136
+
137
+ for(i=0; i<len; i++) {
138
+ var rule = card_types[i];
139
+ if (number.match(rule.pattern)) {
140
+ return rule.name;
141
+ }
142
+ }
143
+
144
+ return '';
145
+ }
146
+ function CCAutoDetect<?php echo $_code ?>() {
147
+ var elm = $('<?php echo $_code ?>_cc_number');
148
+ var cc_type = $('<?php echo $_code ?>_cc_type');
149
+ var type = CCGetType<?php echo $_code ?>(elm.value);
150
+ cc_type.value = type;
151
+ cc_type.disabled = false;
152
+ fireEvent(cc_type,'change');
153
+ }
154
+ Event.observe($('<?php echo $_code ?>_cc_number'), 'keyup', CCAutoDetect<?php echo $_code ?>);
155
+ Event.observe($('<?php echo $_code ?>_cc_number'), 'change', CCAutoDetect<?php echo $_code ?>);
156
+ CCAutoDetect<?php echo $_code ?>();
157
+ //]]>
158
+ </script>
159
+ <?php endif; ?>
160
+
161
+ <script type="text/javascript">
162
+ //<![CDATA[
163
+ function CCSelectType<?php echo($_code); ?>(type) {
164
+ $$('.cc_icons').each(function (elem) {
165
+ elem.setOpacity(0.3);
166
+ elem.setStyle({border:'none'});
167
+ });
168
+ var icon_id = 'cc_icon_<?php echo($_code); ?>_' + type;
169
+ if ($(icon_id))
170
+ {
171
+ $(icon_id).setOpacity(1);
172
+ $(icon_id).setStyle({border:'solid 1px #bbb'});
173
+ }
174
+ }
175
+ function SSChecked<?php echo $_code ?>() {
176
+ var elm = $('<?php echo $_code ?>_cc_type');
177
+ if (['GC'].indexOf(elm.value) != -1) {
178
+ $('<?php echo $_code ?>_cc_expiration_block').hide();
179
+ $('<?php echo $_code ?>_cc_cid_block').hide();
180
+ } else {
181
+ $('<?php echo $_code ?>_cc_expiration_block').show();
182
+ $('<?php echo $_code ?>_cc_cid_block').show();
183
+ }
184
+ CCSelectType<?php echo($_code); ?>(elm.value);
185
+ }
186
+ Event.observe($('<?php echo $_code ?>_cc_type'), 'change', SSChecked<?php echo $_code ?>);
187
+ SSChecked<?php echo $_code ?>();
188
+ //]]>
189
+ </script>
190
+
191
+ <?php if($this->_ifTokenizationEnabled()): ?>
192
+
193
+ <script type="text/javascript">
194
+ Ajax.JSONRequest = Class.create(Ajax.Base, (function() {
195
+ var id = 0, head = document.getElementsByTagName('head')[0];
196
+ return {
197
+ initialize: function($super, url, options) {
198
+ $super(options);
199
+ this.options.url = url;
200
+ this.options.callbackParamName = this.options.callbackParamName || 'callback';
201
+ this.options.timeout = this.options.timeout || 10; // Default timeout: 10 seconds
202
+ this.options.invokeImmediately = (!Object.isUndefined(this.options.invokeImmediately)) ? this.options.invokeImmediately : true ;
203
+ if (this.options.invokeImmediately) {
204
+ this.request();
205
+ }
206
+ },
207
+
208
+ /**
209
+ * Ajax.JSONRequest#_cleanup() -> "undefined"
210
+ * Cleans up after the request
211
+ **/
212
+ _cleanup: function() {
213
+ if (this.timeout) {
214
+ clearTimeout(this.timeout);
215
+ this.timeout = null;
216
+ }
217
+ if (this.transport && Object.isElement(this.transport)) {
218
+ this.transport.remove();
219
+ }
220
+ },
221
+
222
+ /**
223
+ * Ajax.JSONRequest#request() -> "undefined"
224
+ * Invokes the JSON-P request lifecycle
225
+ **/
226
+ request: function() {
227
+
228
+ // Define local vars
229
+ var response = new Ajax.JSONResponse(this);
230
+ var key = this.options.callbackParamName,
231
+ name = 'callback',
232
+ complete = function() {
233
+ if (Object.isFunction(this.options.onComplete)) {
234
+ this.options.onComplete.call(this, response);
235
+ }
236
+ }.bind(this);
237
+
238
+ // Add callback as a parameter and build request URL
239
+ this.options.parameters[key] = name;
240
+ var url = this.options.url + ((this.options.url.include('?') ? '&' : '?') + Object.toQueryString(this.options.parameters));
241
+
242
+ // Define callback function
243
+ window[name] = function(json) {
244
+ this._cleanup(); // Garbage collection
245
+ window[name] = undefined;
246
+ if (Object.isFunction(this.options.onSuccess)) {
247
+ response.status = 200;
248
+ response.statusText = "OK";
249
+ response.setResponseContent(json);
250
+ this.options.onSuccess.call(this, response);
251
+ }
252
+ complete();
253
+ }.bind(this);
254
+
255
+ this.transport = new Element('script', { type: 'text/javascript', src: url });
256
+
257
+ if (Object.isFunction(this.options.onCreate)) {
258
+ this.options.onCreate.call(this, response);
259
+ }
260
+
261
+ head.appendChild(this.transport);
262
+
263
+ this.timeout = setTimeout(function() {
264
+ this._cleanup();
265
+ window[name] = Prototype.emptyFunction;
266
+ if (Object.isFunction(this.options.onFailure)) {
267
+ response.status = 504;
268
+ response.statusText = "Gateway Timeout";
269
+ this.options.onFailure.call(this, response);
270
+ }
271
+ complete();
272
+ }.bind(this), this.options.timeout * 1000);
273
+ },
274
+ toString: function() { return "[object Ajax.JSONRequest]"; }
275
+ };
276
+ })());
277
+
278
+ Ajax.JSONResponse = Class.create({
279
+ initialize: function(request) {
280
+ this.request = request;
281
+ },
282
+ request: undefined,
283
+ status: 0,
284
+ statusText: '',
285
+ responseJSON: undefined,
286
+ responseText: undefined,
287
+ setResponseContent: function(json) {
288
+ this.responseJSON = json;
289
+ this.responseText = Object.toJSON(json);
290
+ },
291
+ getTransport: function() {
292
+ if (this.request) return this.request.transport;
293
+ },
294
+ toString: function() { return "[object Ajax.JSONResponse]"; }
295
+ });
296
+
297
+ Payment.prototype.save = function(){
298
+ if (checkout.loadWaiting!=false) return;
299
+ var validator = new Validation(this.form);
300
+ if (this.validate() && validator.validate()) {
301
+ checkout.setLoadWaiting('payment');
302
+
303
+ var elm_type = $('<?php echo $_code ?>_cc_type');
304
+
305
+ if(payment.currentMethod == "usaepay" && ['GC'].indexOf(elm_type.value) == -1) {
306
+ var _this = this;
307
+
308
+ var request = new Ajax.JSONRequest(
309
+ '<?php echo $this->_getGatewayUrl(); ?>',
310
+ {
311
+ callbackParamName: "jsoncallback",
312
+
313
+ parameters: {
314
+ ccnum: $('<?php echo $_code ?>_cc_number').getValue(),
315
+ expdate: $('<?php echo $_code ?>_expiration').getValue() + $('<?php echo $_code ?>_expiration_yr').getValue().slice(-2),
316
+ ccv: $('<?php echo $_code ?>_cc_cid').getValue()
317
+ },
318
+
319
+ onSuccess: function(transport){
320
+
321
+ var json = transport.responseText.evalJSON(true);
322
+
323
+ var cc_number = $('<?php echo $_code ?>_cc_number').getValue();
324
+
325
+ $('<?php echo $_code ?>_cc_token').setValue(json.token);
326
+ $('<?php echo $_code ?>_cc_last4').setValue(cc_number.slice(-4));
327
+
328
+ var request = new Ajax.Request(
329
+ _this.saveUrl,
330
+ {
331
+ method:'post',
332
+ onComplete: _this.onComplete,
333
+ onSuccess: _this.onSave,
334
+ onFailure: checkout.ajaxFailure.bind(checkout),
335
+ parameters: Object.extend($(_this.form).serialize(true), {'payment[cc_number]': '','payment[cc_cid]' : ''})
336
+ }
337
+ );
338
+ },
339
+
340
+ onFailure: function() {
341
+ alert(Translator.translate('Can\'t get token for credit card.').stripTags());
342
+ _this.resetLoadWaiting();
343
+ }
344
+ });
345
+
346
+ } else {
347
+ var request = new Ajax.Request(
348
+ this.saveUrl,
349
+ {
350
+ method:'post',
351
+ onComplete: this.onComplete,
352
+ onSuccess: this.onSave,
353
+ onFailure: checkout.ajaxFailure.bind(checkout),
354
+ parameters: Form.serialize(this.form)
355
+ }
356
+ );
357
+ }
358
+ }
359
+ };
360
+
361
+ Review.prototype.save = function() {
362
+ if (checkout.loadWaiting!=false) return;
363
+ checkout.setLoadWaiting('review');
364
+
365
+ var elm_type = $('<?php echo $_code ?>_cc_type');
366
+
367
+ if(payment.currentMethod == "usaepay" && ['GC'].indexOf(elm_type.value) == -1) {
368
+ var params = $(payment.form).serialize(true);
369
+ Object.extend(params, {'payment[cc_number]': '', 'payment[cc_cid]' : ''});
370
+ if (this.agreementsForm) {
371
+ Object.extend(params, $(this.agreementsForm).serialize(true));
372
+ }
373
+ params.save = true;
374
+ var request = new Ajax.Request(
375
+ this.saveUrl,
376
+ {
377
+ method:'post',
378
+ parameters:params,
379
+ onComplete: this.onComplete,
380
+ onSuccess: this.onSave,
381
+ onFailure: checkout.ajaxFailure.bind(checkout)
382
+ }
383
+ );
384
+ } else {
385
+ var params = Form.serialize(payment.form);
386
+ if (this.agreementsForm) {
387
+ params += '&'+Form.serialize(this.agreementsForm);
388
+ }
389
+ params.save = true;
390
+ var request = new Ajax.Request(
391
+ this.saveUrl,
392
+ {
393
+ method:'post',
394
+ parameters:params,
395
+ onComplete: this.onComplete,
396
+ onSuccess: this.onSave,
397
+ onFailure: checkout.ajaxFailure.bind(checkout)
398
+ }
399
+ );
400
+ }
401
+ }
402
+
403
+ </script>
404
+
405
+ <?php endif; ?>
app/etc/modules/Mage_Usaepay.xml CHANGED
@@ -2,7 +2,7 @@
2
  <!--
3
  /**
4
  * USA ePay Magento Plugin.
5
- * v1.1.7 - December 19th, 2014
6
  *
7
  * For assistance please contact devsupport@usaepay.com
8
  *
2
  <!--
3
  /**
4
  * USA ePay Magento Plugin.
5
+ * v1.1.9 - July 3rd, 2015
6
  *
7
  * For assistance please contact devsupport@usaepay.com
8
  *
js/usaepay/giftcard-verification.js ADDED
@@ -0,0 +1 @@
 
1
+ Validation.creditCartTypes.set('GC', [new RegExp('^[0-9]{19}$'), false, false]);
package.xml CHANGED
@@ -1,18 +1,25 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Mage_Usaepay</name>
4
- <version>1.1.7</version>
5
  <stability>stable</stability>
6
- <license>BSD License</license>
7
  <channel>community</channel>
8
  <extends/>
9
- <summary>Payment gateway module for USAePay.</summary>
10
- <description>Provides native support for the USAePay gateway. To use module you must first generate a source key and pin within the USAePay console.</description>
11
- <notes>- Implements backup URL failover. When a failure occurs at the primary USAePay datacenter requests will start directing traffic to the backup urls.</notes>
12
- <authors><author><name>Tim McEwen</name><user>tmcewen</user><email>tim@usaepay.com</email></author></authors>
13
- <date>2014-12-26</date>
14
- <time>18:36:52</time>
15
- <contents><target name="mageetc"><dir name="modules"><file name="Mage_Usaepay.xml" hash="76f8a80720a28a4486255f867c3fb62e"/></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="template"><dir name="usaepay"><file name="form.phtml" hash="53e690b0513b262de06c8bfca0280f81"/></dir></dir></dir></dir></dir><dir name="adminhtml"><dir name="base"><dir name="default"><dir name="template"><dir name="usaepay"><file name="form.phtml" hash="f7a0e0ceeda003b592b2706179b9742e"/></dir></dir></dir></dir></dir></target><target name="magecommunity"><dir name="Mage"><dir name="Usaepay"><dir name="Model"><file name="CCPaymentAction.php" hash="01f41226a32444e97a6cef4111b99e01"/><file name="SuspectedFraudConfigOptions.php" hash="d67a477da7f8fee01e1b79dfe3b6e3de"/><file name="TranApi.php" hash="149c9de4a9f6686f51b57983a911d418"/></dir><dir name="Helper"><file name="Data.php" hash="aa05ac0e2bd8ddc3b470209e7372ced8"/></dir><dir name="etc"><file name="config.xml" hash="f04d99646faa4487b8c842e214229cf2"/><file name="system.xml" hash="a3c58096d075a928cbcfb3a56ca0f4aa"/></dir><dir name="Block"><file name="Form.php" hash="81320b00e0daeb377596afd12790881d"/></dir></dir></dir></target></contents>
 
 
 
 
 
 
 
16
  <compatible/>
17
- <dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
18
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Mage_Usaepay</name>
4
+ <version>1.1.9</version>
5
  <stability>stable</stability>
6
+ <license uri="http://www.opensource.org/licenses/bsd-license.php">BSD License</license>
7
  <channel>community</channel>
8
  <extends/>
9
+ <summary>Payment gateway extension for USAePay</summary>
10
+ <description>Added:&#xD;
11
+ - Tokenization&#xD;
12
+ - Timeout&#xD;
13
+ - Gift Card support&#xD;
14
+ - Auto detect card type</description>
15
+ <notes>- Tokenization&#xD;
16
+ - Timeout&#xD;
17
+ - Gift Card support&#xD;
18
+ - Auto detect card type</notes>
19
+ <authors><author><name>Tim McEwen</name><user>USAePay</user><email>magento@usaepay.com</email></author></authors>
20
+ <date>2015-07-06</date>
21
+ <time>20:12:23</time>
22
+ <contents><target name="magecommunity"><dir name="Mage"><dir name="Usaepay"><dir name="Block"><file name="Form.php" hash="b188fd27f57c580629c3e67b356e09e7"/></dir><dir name="etc"><file name="config.xml" hash="c8fcba63b91b650128ccbf07f97bfe01"/><file name="system.xml" hash="ea3d6bc7b9823b86127007edb034929e"/></dir><dir name="Helper"><file name="Data.php" hash="e03600fc74f5de10cbadb32ec67fb18d"/></dir><dir name="Model"><file name="CCPaymentAction.php" hash="fae664c6a4717aa7b2f9ffc19ad23850"/><dir name="sql"><dir name="usaepay_setup"><file name="install-1.1.8.php" hash=""/></dir></dir><file name="SuspectedFraudConfigOptions.php" hash="459f042c92ac2af6ba26dd26099ac576"/><file name="TranApi.php" hash="c1050440657b61c0760c0a875f350947"/><dir name="Usaepay"><dir name="Source"><file name="Cctype.php" hash="aac57b423714813bf9d1643a02ae8a34"/></dir></dir></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="base"><dir name="default"><dir name="layout"><file name="usaepay.xml" hash="a4e96aa951ce3c632de7d5b2177b3b09"/></dir><dir name="template"><dir name="usaepay"><file name="form.phtml" hash="f158fbc5533ae623cdc354c3f0b27000"/></dir></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="usaepay.xml" hash="9b199d82bd9945aee13c6063bc8f52f1"/></dir><dir name="template"><dir name="usaepay"><file name="form.phtml" hash="09b479eda8cdae590b7ccfd77b3d036c"/></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Mage_Usaepay.xml" hash="4b1efb355d6def36e974a9205309ac0a"/></dir></target><target name="mageweb"><dir name="js"><dir name="usaepay"><file name="giftcard-verification.js" hash="59e487ec0bf8b33345abef3f1996ebcf"/></dir></dir></target><target name="mageskin"><dir name="frontend"><dir name="base"><dir name="default"><dir name="images"><dir name="usaepay"><file name="AE.png" hash="c49a4247984b3732a4af50a3390aa978"/><file name="DI.png" hash="6c0a386a00307f87db7bea366cca35f5"/><file name="GC.png" hash="d936e11fa3884b8c9f1bd5c914be8629"/><file name="MC.png" hash="6f6cdc29ee2e22e06b1ac029cb52ef71"/><file name="OT.png" hash="8e06c094c1871376dfea1da8088c29d1"/><file name="VI.png" hash="3ddc4a4d25c946e8ad7e6998f30fd4e3"/></dir></dir></dir></dir></dir></target></contents>
23
  <compatible/>
24
+ <dependencies><required><php><min>5.4.0</min><max>5.6.0</max></php></required></dependencies>
25
  </package>
skin/frontend/base/default/images/usaepay/AE.png ADDED
Binary file
skin/frontend/base/default/images/usaepay/DI.png ADDED
Binary file
skin/frontend/base/default/images/usaepay/GC.png ADDED
Binary file
skin/frontend/base/default/images/usaepay/MC.png ADDED
Binary file
skin/frontend/base/default/images/usaepay/OT.png ADDED
Binary file
skin/frontend/base/default/images/usaepay/VI.png ADDED
Binary file