Mage_Usaepay - Version 1.1.7

Version Notes

- Implements backup URL failover. When a failure occurs at the primary USAePay datacenter requests will start directing traffic to the backup urls.

Download this release

Release Info

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


Code changes from version 1.1.4 to 1.1.7

app/code/community/Mage/Usaepay/Block/Form.php CHANGED
@@ -1,41 +1,41 @@
1
  <?php
2
  /**
3
  * USA ePay Magento Plugin.
4
- * v1.1.4 - November 8th, 2013
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_Block_Form
41
  * @copyright Copyright (c) 2010 USAePay (www.usaepay.com)
@@ -46,14 +46,14 @@
46
  class Mage_Usaepay_Block_Form extends Mage_Payment_Block_Form
47
  {
48
  protected $_paymentConfig;
49
-
50
  protected function _construct()
51
  {
52
  $this->_paymentConfig = Mage::getStoreConfig('payment/usaepay');
53
  $this->setTemplate('usaepay/form.phtml');
54
  parent::_construct();
55
  }
56
-
57
  /**
58
  * Retrieve payment configuration object
59
  *
@@ -63,26 +63,26 @@ class Mage_Usaepay_Block_Form extends Mage_Payment_Block_Form
63
  {
64
  return Mage::getSingleton('payment/config');
65
  }
66
-
67
  public function createExtendedFraudProfilingSession()
68
  {
69
  if(!$this->_paymentConfig['extendedfraudprofiling']) return false;
70
-
71
  $checkout = Mage::getSingleton('checkout/session');
72
  $stepIsAllowed = $checkout->getStepData('payment', 'allow');
73
  $stepIsComplete = $checkout->getStepData('payment', 'complete');
74
-
75
  if(!$stepIsAllowed || $stepIsComplete)
76
  {
77
  return false;
78
  }
79
-
80
  try
81
  {
82
  $method = $this->getMethod();
83
-
84
  if(!$method) return false;
85
-
86
  // payment info might not be avliable at this point (first render?)
87
  $paymentInfo = $method->getInfoInstance();
88
  }
@@ -91,20 +91,20 @@ class Mage_Usaepay_Block_Form extends Mage_Payment_Block_Form
91
  Mage::logException($e);
92
  return false;
93
  }
94
-
95
  $results = self::_getExtendedFraudProfilingSession($this->_paymentConfig);
96
-
97
  // Mage::log('createExtendedFraudProfilingSession() sessionid: '.$results['sessionid']);
98
-
99
  if($results)
100
  {
101
  // efp = extended fraud profiling
102
  $paymentInfo->setAdditionalInformation('usaepay_efpSessionId', $results['sessionid']);
103
  }
104
-
105
  return $results;
106
  }
107
-
108
  public function getCcAvailableTypes()
109
  {
110
  $types = $this->_getConfig()->getCcTypes();
@@ -121,7 +121,7 @@ class Mage_Usaepay_Block_Form extends Mage_Payment_Block_Form
121
  }
122
  return $types;
123
  }
124
-
125
  public function getCcMonths(){
126
  $months['01'] = 'January';
127
  $months['02'] = 'February';
@@ -143,7 +143,7 @@ class Mage_Usaepay_Block_Form extends Mage_Payment_Block_Form
143
  $years[date('Y',strtotime("+$i years"))] = date('Y',strtotime("+$i years"));
144
  return $years;
145
  }
146
-
147
  static protected function _getExtendedFraudProfilingSession($config)
148
  {
149
  $seed = md5(mt_rand());
@@ -167,9 +167,9 @@ class Mage_Usaepay_Block_Form extends Mage_Payment_Block_Form
167
 
168
  // Make Rest Call
169
  $output = file_get_contents($url);
170
-
171
  // Mage::log("usaepay -> extended fraud profiling session\nrequest url:\n$url\nresponse:\n$output", null, 'usaepay.log');
172
-
173
  if(!$output) {
174
  Mage::log('usaepay -> payment form error -> extended fraud profiling -> Blank response', Zend_Log::ERR);
175
  return false;
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
+ *
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_Block_Form
41
  * @copyright Copyright (c) 2010 USAePay (www.usaepay.com)
46
  class Mage_Usaepay_Block_Form extends Mage_Payment_Block_Form
47
  {
48
  protected $_paymentConfig;
49
+
50
  protected function _construct()
51
  {
52
  $this->_paymentConfig = Mage::getStoreConfig('payment/usaepay');
53
  $this->setTemplate('usaepay/form.phtml');
54
  parent::_construct();
55
  }
56
+
57
  /**
58
  * Retrieve payment configuration object
59
  *
63
  {
64
  return Mage::getSingleton('payment/config');
65
  }
66
+
67
  public function createExtendedFraudProfilingSession()
68
  {
69
  if(!$this->_paymentConfig['extendedfraudprofiling']) return false;
70
+
71
  $checkout = Mage::getSingleton('checkout/session');
72
  $stepIsAllowed = $checkout->getStepData('payment', 'allow');
73
  $stepIsComplete = $checkout->getStepData('payment', 'complete');
74
+
75
  if(!$stepIsAllowed || $stepIsComplete)
76
  {
77
  return false;
78
  }
79
+
80
  try
81
  {
82
  $method = $this->getMethod();
83
+
84
  if(!$method) return false;
85
+
86
  // payment info might not be avliable at this point (first render?)
87
  $paymentInfo = $method->getInfoInstance();
88
  }
91
  Mage::logException($e);
92
  return false;
93
  }
94
+
95
  $results = self::_getExtendedFraudProfilingSession($this->_paymentConfig);
96
+
97
  // Mage::log('createExtendedFraudProfilingSession() sessionid: '.$results['sessionid']);
98
+
99
  if($results)
100
  {
101
  // efp = extended fraud profiling
102
  $paymentInfo->setAdditionalInformation('usaepay_efpSessionId', $results['sessionid']);
103
  }
104
+
105
  return $results;
106
  }
107
+
108
  public function getCcAvailableTypes()
109
  {
110
  $types = $this->_getConfig()->getCcTypes();
121
  }
122
  return $types;
123
  }
124
+
125
  public function getCcMonths(){
126
  $months['01'] = 'January';
127
  $months['02'] = 'February';
143
  $years[date('Y',strtotime("+$i years"))] = date('Y',strtotime("+$i years"));
144
  return $years;
145
  }
146
+
147
  static protected function _getExtendedFraudProfilingSession($config)
148
  {
149
  $seed = md5(mt_rand());
167
 
168
  // Make Rest Call
169
  $output = file_get_contents($url);
170
+
171
  // Mage::log("usaepay -> extended fraud profiling session\nrequest url:\n$url\nresponse:\n$output", null, 'usaepay.log');
172
+
173
  if(!$output) {
174
  Mage::log('usaepay -> payment form error -> extended fraud profiling -> Blank response', Zend_Log::ERR);
175
  return false;
app/code/community/Mage/Usaepay/Helper/Data.php CHANGED
@@ -1,41 +1,41 @@
1
  <?php
2
  /**
3
  * USA ePay Magento Plugin.
4
- * v1.1.4 - November 8th, 2013
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
41
  * @copyright Copyright (c) 2010 USAePay (www.usaepay.com)
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
+ *
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
41
  * @copyright Copyright (c) 2010 USAePay (www.usaepay.com)
app/code/community/Mage/Usaepay/Model/CCPaymentAction.php CHANGED
@@ -1,41 +1,41 @@
1
  <?php
2
  /**
3
  * USA ePay Magento Plugin.
4
- * v1.1.4 - November 8th, 2013
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_CCPaymentAction
41
  * @copyright Copyright (c) 2010 USAePay (www.usaepay.com)
@@ -58,24 +58,24 @@ class Mage_Usaepay_Model_CCPaymentAction extends Mage_Payment_Model_Method_Cc
58
  protected $_canUseCheckout = true;
59
  protected $_canUseForMultishipping = true;
60
  protected $_canSaveCc = false;
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
-
70
  $useExtendedFraudProfiling = $this->getConfigData('extendedfraudprofiling');
71
-
72
  if($useExtendedFraudProfiling)
73
  {
74
  // Mage::log('payment additional information (sessionid): '.print_r($payment->getAdditionalInformation('usaepay_efpSessionId'), true));
75
  $sessionId = $payment->getAdditionalInformation('usaepay_efpSessionId');
76
  if($sessionId) $tran->session = $sessionId;
77
  }
78
-
79
  // general payment data
80
  $tran->cardholder = $payment->getCcOwner();
81
  $tran->card = $payment->getCcNumber();
@@ -83,27 +83,27 @@ class Mage_Usaepay_Model_CCPaymentAction extends Mage_Payment_Model_Method_Cc
83
  $tran->cvv2 = $payment->getCcCid();
84
  $tran->amount = $amount;
85
  $tran->ponum = $payment->getPoNumber();
86
-
87
  if($this->getConfigData('sandbox')) {
88
  $tran->custreceipt=true;
89
- $tran->custreceipt_template = $this->getConfigData('custreceipt_template');
90
  }
91
-
92
  // if order exists, add order data
93
  $order = $payment->getOrder();
94
  if (!empty($order)) {
95
-
96
  $orderid = $order->getIncrementId();
97
  $tran->invoice = $orderid;
98
  $tran->orderid = $orderid;
99
  $tran->ip = $order->getRemoteIp();
100
  $tran->email = $order->getCustomerEmail();
101
-
102
  $tran->tax = $order->getTaxAmount();
103
  $tran->shipping = $order->getShippingAmount();
104
 
105
  $tran->description=($this->getConfigData('description')?str_replace('[orderid]',$orderid,$this->getConfigData('description')):"Magento Order #" . $orderid);
106
-
107
  // billing info
108
  $billing = $order->getBillingAddress();
109
  if (!empty($billing)) {
@@ -111,7 +111,7 @@ class Mage_Usaepay_Model_CCPaymentAction extends Mage_Payment_Model_Method_Cc
111
  list($avsstreet) = $billing->getStreet();
112
  $tran->street = $avsstreet;
113
  $tran->zip = $billing->getPostcode();
114
-
115
  $tran->billfname = $billing->getFirstname();
116
  $tran->billlname = $billing->getLastname();
117
  $tran->billcompany = $billing->getCompany();
@@ -124,7 +124,7 @@ class Mage_Usaepay_Model_CCPaymentAction extends Mage_Payment_Model_Method_Cc
124
  $tran->billphone= $billing->getTelephone();
125
  $tran->custid = $billing->getCustomerId();
126
  }
127
-
128
  // shipping info
129
  $shipping = $order->getShippingAddress();
130
  if (!empty($shipping)) {
@@ -138,7 +138,7 @@ class Mage_Usaepay_Model_CCPaymentAction extends Mage_Payment_Model_Method_Cc
138
  $tran->shipzip = $shipping->getPostcode();
139
  $tran->shipcountry = $shipping->getCountry();
140
  }
141
-
142
  // line item data
143
  foreach ($order->getAllVisibleItems() as $item) {
144
  $tran->addLine($item->getSku(), $item->getName(), '', $item->getPrice(), $item->getQtyToInvoice(), $item->getTaxAmount());
@@ -146,34 +146,34 @@ class Mage_Usaepay_Model_CCPaymentAction extends Mage_Payment_Model_Method_Cc
146
  }
147
 
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
-
159
  // store response variables
160
  $payment->setCcApproval($tran->authcode)
161
  ->setCcTransId($tran->refnum)
162
  ->setCcAvsStatus($tran->avs_result_code)
163
  ->setCcCidStatus($tran->cvv2_result_code);
164
-
165
  if($tran->resultcode=='A')
166
  {
167
  if($this->getConfigData('payment_action') == self::ACTION_AUTHORIZE) $payment->setLastTransId('0');
168
  else $payment->setLastTransId($tran->refnum);
169
-
170
  $isResponseSet = false;
171
  if($useExtendedFraudProfiling)
172
  {
173
  $useSuspectedFraudConfig = (int)$this->getConfigData('usesuspectedfraud');
174
  $isFraud = ($useSuspectedFraudConfig === 2 && $tran->profilerResponse == 'reject') ||
175
  ($useSuspectedFraudConfig === 3 && ($tran->profilerResponse == 'reject' || $tran->profilerResponse == 'review'));
176
-
177
  if($useSuspectedFraudConfig && $isFraud)
178
  {
179
  $payment->setIsTransactionPending(true);
@@ -181,26 +181,26 @@ class Mage_Usaepay_Model_CCPaymentAction extends Mage_Payment_Model_Method_Cc
181
  $isResponseSet = true;
182
  }
183
  }
184
-
185
  if(!$isResponseSet)
186
  {
187
  $payment->setStatus(self::STATUS_APPROVED);
188
  }
189
-
190
  //ueLogDebug("CCPaymentAction::Authorize Approved");
191
-
192
  } elseif($tran->resultcode == 'D') {
193
-
194
  //ueLogDebug("CCPaymentAction::Authorize Declined" );
195
-
196
  Mage::throwException(Mage::helper('paygate')->__('Payment authorization transaction has been declined: ' . $tran->error));
197
  } else {
198
-
199
  //ueLogDebug("CCPaymentAction::Authorize Error" );
200
-
201
  Mage::throwException(Mage::helper('paygate')->__('Payment authorization error: ' . $tran->error . '('.$tran->errorcode . ')'));
202
  }
203
-
204
  if ($useExtendedFraudProfiling && $tran->profilerResponse && !empty($order)) {
205
  $comment = "Extended Fraud Profiler Results:\n";
206
  if($tran->profilerResponse) $comment .= "<br>response: {$tran->profilerResponse}\n";
@@ -210,43 +210,43 @@ class Mage_Usaepay_Model_CCPaymentAction extends Mage_Payment_Model_Method_Cc
210
  $order->addStatusHistoryComment($comment);
211
  $order->save();
212
  }
213
-
214
  return $this;
215
  }
216
-
217
  public function quicksale(Varien_Object $payment, $amount)
218
  {
219
-
220
  // initialize transaction object
221
  $tran = $this->_initTransaction($payment);
222
-
223
  if(!$payment->getLastTransId()) Mage::throwException(Mage::helper('paygate')->__('Unable to find previous transaction to reference'));
224
-
225
- // payment data
226
  $tran->refnum = $payment->getLastTransId();
227
  $tran->amount = $amount;
228
  $tran->ponum = $payment->getPoNumber();
229
-
230
  if($this->getConfigData('sandbox')) {
231
  $tran->custreceipt=true;
232
- $tran->custreceipt_template = $this->getConfigData('custreceipt_template');
233
  }
234
-
235
  // if order exists, add order data
236
  $order = $payment->getOrder();
237
  if (!empty($order)) {
238
-
239
  $orderid = $order->getIncrementId();
240
  $tran->invoice = $orderid;
241
  $tran->orderid = $orderid;
242
  $tran->ip = $order->getRemoteIp();
243
  $tran->email = $order->getCustomerEmail();
244
-
245
  $tran->tax = $order->getTaxAmount();
246
  $tran->shipping = $order->getShippingAmount();
247
-
248
  $tran->description=($this->getConfigData('description')?str_replace('[orderid]',$orderid,$this->getConfigData('description')):"Magento Order #" . $orderid);
249
-
250
  // billing info
251
  $billing = $order->getBillingAddress();
252
  if (!empty($billing)) {
@@ -254,7 +254,7 @@ class Mage_Usaepay_Model_CCPaymentAction extends Mage_Payment_Model_Method_Cc
254
  list($avsstreet) = $billing->getStreet();
255
  $tran->street = $avsstreet;
256
  $tran->zip = $billing->getPostcode();
257
-
258
  $tran->billfname = $billing->getFirstname();
259
  $tran->billlname = $billing->getLastname();
260
  $tran->billcompany = $billing->getCompany();
@@ -267,7 +267,7 @@ class Mage_Usaepay_Model_CCPaymentAction extends Mage_Payment_Model_Method_Cc
267
  $tran->billphone= $billing->getTelephone();
268
  $tran->custid = $billing->getCustomerId();
269
  }
270
-
271
  // shipping info
272
  $shipping = $order->getShippingAddress();
273
  if (!empty($shipping)) {
@@ -284,23 +284,23 @@ class Mage_Usaepay_Model_CCPaymentAction extends Mage_Payment_Model_Method_Cc
284
  }
285
 
286
  //file_put_contents(tempnam('/tmp','quicksale'), print_r($payment,true));
287
-
288
 
289
  //ueLogDebug("Sending quicksale for $amount on prior transid {$tran->refnum}");
290
  $tran->command='quicksale';
291
-
292
  // process transactions
293
  $tran->Process();
294
-
295
  // store response variables
296
  $payment->setCcApproval($tran->authcode)
297
  ->setCcTransId($tran->refnum)
298
  ->setCcAvsStatus($tran->avs_result_code)
299
  ->setCcCidStatus($tran->cvv2_result_code);
300
-
301
  // ueLogDebug("Tran:" . print_r($tran, true));
302
-
303
-
304
  if($tran->resultcode=='A')
305
  {
306
  if($tran->refnum) $payment->setLastTransId($tran->refnum);
@@ -313,26 +313,26 @@ class Mage_Usaepay_Model_CCPaymentAction extends Mage_Payment_Model_Method_Cc
313
  //ueLogDebug("Transaction Error");
314
  Mage::throwException(Mage::helper('paygate')->__('Payment authorization error: ' . $tran->error . '('.$tran->errorcode . ')'));
315
  }
316
-
317
  return $this;
318
  }
319
-
320
  public function refund(Varien_Object $payment, $amount)
321
  {
322
-
323
  // ueLogDebug("CCPaymentAction::refund amount: $amount transid: " . $payment->getLastTransId());
324
  $error = false;
325
-
326
  $orderid=$payment->getOrder()->getIncrementId();
327
-
328
  list($avsstreet) = $payment->getOrder()->getBillingAddress()->getStreet();
329
  $avszip = $payment->getOrder()->getBillingAddress()->getPostcode();
330
-
331
  $tran = $this->_initTransaction($payment);
332
-
333
  if(!$payment->getLastTransId()) Mage::throwException(Mage::helper('paygate')->__('Unable to find previous transaction to reference'));
334
-
335
- // payment data
336
  $tran->refnum = $payment->getLastTransId();
337
  $tran->amount=$amount;
338
  $tran->invoice=$orderid;
@@ -343,7 +343,7 @@ class Mage_Usaepay_Model_CCPaymentAction extends Mage_Payment_Model_Method_Cc
343
  $tran->description="Online Order";
344
  $tran->cvv2=$payment->getCcCid();
345
  $tran->command='quickcredit';
346
-
347
  if(!$tran->Process())
348
  {
349
  $payment->setStatus(self::STATUS_ERROR);
@@ -352,7 +352,7 @@ class Mage_Usaepay_Model_CCPaymentAction extends Mage_Payment_Model_Method_Cc
352
  } else {
353
  $payment->setStatus(self::STATUS_APPROVED);
354
  }
355
-
356
  if ($error !== false) {
357
  Mage::throwException($error);
358
  }
@@ -361,32 +361,32 @@ class Mage_Usaepay_Model_CCPaymentAction extends Mage_Payment_Model_Method_Cc
361
 
362
  public function capture(Varien_Object $payment, $amount)
363
  {
364
-
365
  //file_put_contents(tempnam('/tmp','capture'), print_r($payment,true));
366
-
367
  //ueLogDebug("CCPaymentAction::Capture Amount: $amount CcTransId: " . $payment->getCcTransId() . " LastTransId: " . $payment->getLastTransId() . " TotalPaid: " . $payment->getOrder()->getTotalPaid() . " Cardnumber(doh):" . $payment->getCcNumber() . "\n");
368
-
369
- // we have already captured the original auth, we need to do full sale
370
  if($payment->getLastTransId() && $payment->getOrder()->getTotalPaid()>0)
371
  {
372
  return $this->quicksale($payment, $amount);
373
  }
374
-
375
  // if we don't have a transid than we are need to authorize
376
  if(!$payment->getCcTransId() || $payment->getLastTransId()) {
377
  $this->_authMode='capture';
378
  return $this->authorize($payment, $amount);
379
  }
380
-
381
  $tran = $this->_initTransaction($payment);
382
  $tran->command='cc:capture';
383
  $tran->refnum=$payment->getCcTransId();
384
-
385
  $tran->amount=$amount;
386
-
387
  // process transaction
388
  $tran->Process();
389
-
390
  // look at result code
391
  if($tran->resultcode=='A')
392
  {
@@ -397,7 +397,7 @@ class Mage_Usaepay_Model_CCPaymentAction extends Mage_Payment_Model_Method_Cc
397
  Mage::throwException(Mage::helper('paygate')->__('Payment authorization transaction has been declined: ' . $tran->error));
398
  } else {
399
  Mage::throwException(Mage::helper('paygate')->__('Payment authorization error: ' . $tran->error . '('.$tran->errorcode . ')'));
400
- }
401
  }
402
 
403
  public function canVoid(Varien_Object $payment)
@@ -408,18 +408,18 @@ class Mage_Usaepay_Model_CCPaymentAction extends Mage_Payment_Model_Method_Cc
408
  public function void(Varien_Object $payment)
409
  {
410
  //ueLogDebug("CCPaymentAction::refund amount: $amount transid: " . $payment->getLastTransId());
411
-
412
  if ($payment->getCcTransId()) {
413
  $tran = $this->_initTransaction($payment);
414
  $tran->command='creditvoid';
415
  $tran->refnum=$payment->getCcTransId();
416
-
417
  // process transactions
418
  $tran->Process();
419
  if($tran->resultcode=='A')
420
  {
421
  $payment->setStatus(self::STATUS_SUCCESS);
422
-
423
  } elseif($tran->resultcode == 'D') {
424
  $payment->setStatus(self::STATUS_ERROR);
425
  Mage::throwException(Mage::helper('paygate')->__('Payment authorization transaction has been declined: ' . $tran->error));
@@ -433,12 +433,12 @@ class Mage_Usaepay_Model_CCPaymentAction extends Mage_Payment_Model_Method_Cc
433
  }
434
  return $this;
435
  }
436
-
437
-
438
-
439
  /**
440
  * Setup the USAePay transaction api class.
441
- *
442
  * Much of this code is common to all commands
443
  *
444
  * @param Mage_Sales_Model_Document $pament
@@ -447,9 +447,9 @@ class Mage_Usaepay_Model_CCPaymentAction extends Mage_Payment_Model_Method_Cc
447
  protected function _initTransaction(Varien_Object $payment)
448
  {
449
  $tran = Mage::getModel('usaepay/TranApi');
450
-
451
  if($this->getConfigData('sandbox')) $tran->usesandbox=true;
452
-
453
  $tran->key=$this->getConfigData('sourcekey');
454
  $tran->pin=$this->getConfigData('sourcepin');
455
  $tran->software = 'Mage_Usaepay 1.0.2';
@@ -461,12 +461,12 @@ class Mage_Usaepay_Model_CCPaymentAction extends Mage_Payment_Model_Method_Cc
461
  function ueLogDebug($mesg)
462
  {
463
  global $debugfd;
464
-
465
  if(!$debugfd) {
466
  $debugfd = fopen('/tmp/uelog','a');
467
  }
468
-
469
  fwrite($debugfd, $mesg. "\n");
470
-
471
  }
472
  */
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
+ *
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_CCPaymentAction
41
  * @copyright Copyright (c) 2010 USAePay (www.usaepay.com)
58
  protected $_canUseCheckout = true;
59
  protected $_canUseForMultishipping = true;
60
  protected $_canSaveCc = false;
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
+
70
  $useExtendedFraudProfiling = $this->getConfigData('extendedfraudprofiling');
71
+
72
  if($useExtendedFraudProfiling)
73
  {
74
  // Mage::log('payment additional information (sessionid): '.print_r($payment->getAdditionalInformation('usaepay_efpSessionId'), true));
75
  $sessionId = $payment->getAdditionalInformation('usaepay_efpSessionId');
76
  if($sessionId) $tran->session = $sessionId;
77
  }
78
+
79
  // general payment data
80
  $tran->cardholder = $payment->getCcOwner();
81
  $tran->card = $payment->getCcNumber();
83
  $tran->cvv2 = $payment->getCcCid();
84
  $tran->amount = $amount;
85
  $tran->ponum = $payment->getPoNumber();
86
+
87
  if($this->getConfigData('sandbox')) {
88
  $tran->custreceipt=true;
89
+ $tran->custreceipt_template = $this->getConfigData('custreceipt_template');
90
  }
91
+
92
  // if order exists, add order data
93
  $order = $payment->getOrder();
94
  if (!empty($order)) {
95
+
96
  $orderid = $order->getIncrementId();
97
  $tran->invoice = $orderid;
98
  $tran->orderid = $orderid;
99
  $tran->ip = $order->getRemoteIp();
100
  $tran->email = $order->getCustomerEmail();
101
+
102
  $tran->tax = $order->getTaxAmount();
103
  $tran->shipping = $order->getShippingAmount();
104
 
105
  $tran->description=($this->getConfigData('description')?str_replace('[orderid]',$orderid,$this->getConfigData('description')):"Magento Order #" . $orderid);
106
+
107
  // billing info
108
  $billing = $order->getBillingAddress();
109
  if (!empty($billing)) {
111
  list($avsstreet) = $billing->getStreet();
112
  $tran->street = $avsstreet;
113
  $tran->zip = $billing->getPostcode();
114
+
115
  $tran->billfname = $billing->getFirstname();
116
  $tran->billlname = $billing->getLastname();
117
  $tran->billcompany = $billing->getCompany();
124
  $tran->billphone= $billing->getTelephone();
125
  $tran->custid = $billing->getCustomerId();
126
  }
127
+
128
  // shipping info
129
  $shipping = $order->getShippingAddress();
130
  if (!empty($shipping)) {
138
  $tran->shipzip = $shipping->getPostcode();
139
  $tran->shipcountry = $shipping->getCountry();
140
  }
141
+
142
  // line item data
143
  foreach ($order->getAllVisibleItems() as $item) {
144
  $tran->addLine($item->getSku(), $item->getName(), '', $item->getPrice(), $item->getQtyToInvoice(), $item->getTaxAmount());
146
  }
147
 
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
+
159
  // store response variables
160
  $payment->setCcApproval($tran->authcode)
161
  ->setCcTransId($tran->refnum)
162
  ->setCcAvsStatus($tran->avs_result_code)
163
  ->setCcCidStatus($tran->cvv2_result_code);
164
+
165
  if($tran->resultcode=='A')
166
  {
167
  if($this->getConfigData('payment_action') == self::ACTION_AUTHORIZE) $payment->setLastTransId('0');
168
  else $payment->setLastTransId($tran->refnum);
169
+
170
  $isResponseSet = false;
171
  if($useExtendedFraudProfiling)
172
  {
173
  $useSuspectedFraudConfig = (int)$this->getConfigData('usesuspectedfraud');
174
  $isFraud = ($useSuspectedFraudConfig === 2 && $tran->profilerResponse == 'reject') ||
175
  ($useSuspectedFraudConfig === 3 && ($tran->profilerResponse == 'reject' || $tran->profilerResponse == 'review'));
176
+
177
  if($useSuspectedFraudConfig && $isFraud)
178
  {
179
  $payment->setIsTransactionPending(true);
181
  $isResponseSet = true;
182
  }
183
  }
184
+
185
  if(!$isResponseSet)
186
  {
187
  $payment->setStatus(self::STATUS_APPROVED);
188
  }
189
+
190
  //ueLogDebug("CCPaymentAction::Authorize Approved");
191
+
192
  } elseif($tran->resultcode == 'D') {
193
+
194
  //ueLogDebug("CCPaymentAction::Authorize Declined" );
195
+
196
  Mage::throwException(Mage::helper('paygate')->__('Payment authorization transaction has been declined: ' . $tran->error));
197
  } else {
198
+
199
  //ueLogDebug("CCPaymentAction::Authorize Error" );
200
+
201
  Mage::throwException(Mage::helper('paygate')->__('Payment authorization error: ' . $tran->error . '('.$tran->errorcode . ')'));
202
  }
203
+
204
  if ($useExtendedFraudProfiling && $tran->profilerResponse && !empty($order)) {
205
  $comment = "Extended Fraud Profiler Results:\n";
206
  if($tran->profilerResponse) $comment .= "<br>response: {$tran->profilerResponse}\n";
210
  $order->addStatusHistoryComment($comment);
211
  $order->save();
212
  }
213
+
214
  return $this;
215
  }
216
+
217
  public function quicksale(Varien_Object $payment, $amount)
218
  {
219
+
220
  // initialize transaction object
221
  $tran = $this->_initTransaction($payment);
222
+
223
  if(!$payment->getLastTransId()) Mage::throwException(Mage::helper('paygate')->__('Unable to find previous transaction to reference'));
224
+
225
+ // payment data
226
  $tran->refnum = $payment->getLastTransId();
227
  $tran->amount = $amount;
228
  $tran->ponum = $payment->getPoNumber();
229
+
230
  if($this->getConfigData('sandbox')) {
231
  $tran->custreceipt=true;
232
+ $tran->custreceipt_template = $this->getConfigData('custreceipt_template');
233
  }
234
+
235
  // if order exists, add order data
236
  $order = $payment->getOrder();
237
  if (!empty($order)) {
238
+
239
  $orderid = $order->getIncrementId();
240
  $tran->invoice = $orderid;
241
  $tran->orderid = $orderid;
242
  $tran->ip = $order->getRemoteIp();
243
  $tran->email = $order->getCustomerEmail();
244
+
245
  $tran->tax = $order->getTaxAmount();
246
  $tran->shipping = $order->getShippingAmount();
247
+
248
  $tran->description=($this->getConfigData('description')?str_replace('[orderid]',$orderid,$this->getConfigData('description')):"Magento Order #" . $orderid);
249
+
250
  // billing info
251
  $billing = $order->getBillingAddress();
252
  if (!empty($billing)) {
254
  list($avsstreet) = $billing->getStreet();
255
  $tran->street = $avsstreet;
256
  $tran->zip = $billing->getPostcode();
257
+
258
  $tran->billfname = $billing->getFirstname();
259
  $tran->billlname = $billing->getLastname();
260
  $tran->billcompany = $billing->getCompany();
267
  $tran->billphone= $billing->getTelephone();
268
  $tran->custid = $billing->getCustomerId();
269
  }
270
+
271
  // shipping info
272
  $shipping = $order->getShippingAddress();
273
  if (!empty($shipping)) {
284
  }
285
 
286
  //file_put_contents(tempnam('/tmp','quicksale'), print_r($payment,true));
287
+
288
 
289
  //ueLogDebug("Sending quicksale for $amount on prior transid {$tran->refnum}");
290
  $tran->command='quicksale';
291
+
292
  // process transactions
293
  $tran->Process();
294
+
295
  // store response variables
296
  $payment->setCcApproval($tran->authcode)
297
  ->setCcTransId($tran->refnum)
298
  ->setCcAvsStatus($tran->avs_result_code)
299
  ->setCcCidStatus($tran->cvv2_result_code);
300
+
301
  // ueLogDebug("Tran:" . print_r($tran, true));
302
+
303
+
304
  if($tran->resultcode=='A')
305
  {
306
  if($tran->refnum) $payment->setLastTransId($tran->refnum);
313
  //ueLogDebug("Transaction Error");
314
  Mage::throwException(Mage::helper('paygate')->__('Payment authorization error: ' . $tran->error . '('.$tran->errorcode . ')'));
315
  }
316
+
317
  return $this;
318
  }
319
+
320
  public function refund(Varien_Object $payment, $amount)
321
  {
322
+
323
  // ueLogDebug("CCPaymentAction::refund amount: $amount transid: " . $payment->getLastTransId());
324
  $error = false;
325
+
326
  $orderid=$payment->getOrder()->getIncrementId();
327
+
328
  list($avsstreet) = $payment->getOrder()->getBillingAddress()->getStreet();
329
  $avszip = $payment->getOrder()->getBillingAddress()->getPostcode();
330
+
331
  $tran = $this->_initTransaction($payment);
332
+
333
  if(!$payment->getLastTransId()) Mage::throwException(Mage::helper('paygate')->__('Unable to find previous transaction to reference'));
334
+
335
+ // payment data
336
  $tran->refnum = $payment->getLastTransId();
337
  $tran->amount=$amount;
338
  $tran->invoice=$orderid;
343
  $tran->description="Online Order";
344
  $tran->cvv2=$payment->getCcCid();
345
  $tran->command='quickcredit';
346
+
347
  if(!$tran->Process())
348
  {
349
  $payment->setStatus(self::STATUS_ERROR);
352
  } else {
353
  $payment->setStatus(self::STATUS_APPROVED);
354
  }
355
+
356
  if ($error !== false) {
357
  Mage::throwException($error);
358
  }
361
 
362
  public function capture(Varien_Object $payment, $amount)
363
  {
364
+
365
  //file_put_contents(tempnam('/tmp','capture'), print_r($payment,true));
366
+
367
  //ueLogDebug("CCPaymentAction::Capture Amount: $amount CcTransId: " . $payment->getCcTransId() . " LastTransId: " . $payment->getLastTransId() . " TotalPaid: " . $payment->getOrder()->getTotalPaid() . " Cardnumber(doh):" . $payment->getCcNumber() . "\n");
368
+
369
+ // we have already captured the original auth, we need to do full sale
370
  if($payment->getLastTransId() && $payment->getOrder()->getTotalPaid()>0)
371
  {
372
  return $this->quicksale($payment, $amount);
373
  }
374
+
375
  // if we don't have a transid than we are need to authorize
376
  if(!$payment->getCcTransId() || $payment->getLastTransId()) {
377
  $this->_authMode='capture';
378
  return $this->authorize($payment, $amount);
379
  }
380
+
381
  $tran = $this->_initTransaction($payment);
382
  $tran->command='cc:capture';
383
  $tran->refnum=$payment->getCcTransId();
384
+
385
  $tran->amount=$amount;
386
+
387
  // process transaction
388
  $tran->Process();
389
+
390
  // look at result code
391
  if($tran->resultcode=='A')
392
  {
397
  Mage::throwException(Mage::helper('paygate')->__('Payment authorization transaction has been declined: ' . $tran->error));
398
  } else {
399
  Mage::throwException(Mage::helper('paygate')->__('Payment authorization error: ' . $tran->error . '('.$tran->errorcode . ')'));
400
+ }
401
  }
402
 
403
  public function canVoid(Varien_Object $payment)
408
  public function void(Varien_Object $payment)
409
  {
410
  //ueLogDebug("CCPaymentAction::refund amount: $amount transid: " . $payment->getLastTransId());
411
+
412
  if ($payment->getCcTransId()) {
413
  $tran = $this->_initTransaction($payment);
414
  $tran->command='creditvoid';
415
  $tran->refnum=$payment->getCcTransId();
416
+
417
  // process transactions
418
  $tran->Process();
419
  if($tran->resultcode=='A')
420
  {
421
  $payment->setStatus(self::STATUS_SUCCESS);
422
+
423
  } elseif($tran->resultcode == 'D') {
424
  $payment->setStatus(self::STATUS_ERROR);
425
  Mage::throwException(Mage::helper('paygate')->__('Payment authorization transaction has been declined: ' . $tran->error));
433
  }
434
  return $this;
435
  }
436
+
437
+
438
+
439
  /**
440
  * Setup the USAePay transaction api class.
441
+ *
442
  * Much of this code is common to all commands
443
  *
444
  * @param Mage_Sales_Model_Document $pament
447
  protected function _initTransaction(Varien_Object $payment)
448
  {
449
  $tran = Mage::getModel('usaepay/TranApi');
450
+
451
  if($this->getConfigData('sandbox')) $tran->usesandbox=true;
452
+
453
  $tran->key=$this->getConfigData('sourcekey');
454
  $tran->pin=$this->getConfigData('sourcepin');
455
  $tran->software = 'Mage_Usaepay 1.0.2';
461
  function ueLogDebug($mesg)
462
  {
463
  global $debugfd;
464
+
465
  if(!$debugfd) {
466
  $debugfd = fopen('/tmp/uelog','a');
467
  }
468
+
469
  fwrite($debugfd, $mesg. "\n");
470
+
471
  }
472
  */
app/code/community/Mage/Usaepay/Model/SuspectedFraudConfigOptions.php CHANGED
@@ -1,41 +1,41 @@
1
  <?php
2
  /**
3
  * USA ePay Magento Plugin.
4
- * v1.1.4 - November 8th, 2013
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)
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
+ *
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)
app/code/community/Mage/Usaepay/Model/TranApi.php CHANGED
@@ -1,44 +1,44 @@
1
  <?php
2
  /**
3
  * USA ePay Magento Plugin.
4
- * v1.1.4 - November 8th, 2013
5
- *
6
  * Copyright (c) 2010 USAePay
7
  * All rights reserved.
8
- *
9
  * The code in this file based on the USA ePay PHP Library.
10
  * v1.6.5 - Nov 11, 2009
11
  * Copyright (c) 2001-2009 USAePay
12
  * http://help.usaepay.com/developer/phplibrary
13
- *
14
- * Redistribution and use in source and binary forms, with or without
15
- * modification, are permitted provided that the following conditions
16
  * are met:
17
- *
18
- * - Redistributions of source code must retain the above copyright
19
  * notice, this list of conditions and the following disclaimer.
20
- * - Redistributions in binary form must reproduce the above
21
- * copyright notice, this list of conditions and the following
22
- * disclaimer in the documentation and/or other materials
23
  * provided with the distribution.
24
- * - Neither the name of the USAePay nor the names of its
25
- * contributors may be used to endorse or promote products
26
- * derived from this software without specific prior written
27
  * permission.
28
- *
29
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
30
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
31
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
32
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
33
- * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
34
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
35
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
36
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
37
- * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
38
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
39
- * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
40
  * POSSIBILITY OF SUCH DAMAGE.
41
- *
42
  * @category Mage
43
  * @package Mage_Usaepay_Model
44
  * @copyright Copyright (c) 2010 USAePay (www.usaepay.com)
@@ -53,7 +53,7 @@
53
  // For assistance please contact devsupport@usaepay.com
54
  //
55
 
56
- define("USAEPAY_VERSION", "1.6.5");
57
 
58
 
59
  /**
@@ -61,37 +61,38 @@ define("USAEPAY_VERSION", "1.6.5");
61
  *
62
  */
63
  class Mage_Usaepay_Model_TranApi {
64
-
65
  // Required for all transactions
66
  public $key; // Source key
67
  public $pin; // Source pin (optional)
68
- public $amount; // the entire amount that will be charged to the customers card
69
  // (including tax, shipping, etc)
70
- public $invoice; // invoice number. must be unique. limited to 10 digits. use orderid if you need longer.
71
-
72
  // Required for Commercial Card support
73
  public $ponum; // Purchase Order Number
74
  public $tax; // Tax
75
  public $nontaxable; // Order is non taxable
76
-
 
77
  // Amount details (optional)
78
  public $tip; // Tip
79
  public $shipping; // Shipping charge
80
  public $discount; // Discount amount (ie gift certificate or coupon code)
81
- public $subtotal; // if subtotal is set, then
82
- // subtotal + tip + shipping - discount + tax must equal amount
83
  // or the transaction will be declined. If subtotal is left blank
84
  // then it will be ignored
85
  public $currency; // Currency of $amount
86
-
87
  // Required Fields for Card Not Present transacitons (Ecommerce)
88
  public $card; // card number, no dashes, no spaces
89
  public $exp; // expiration date 4 digits no /
90
  public $cardholder; // name of card holder
91
  public $street; // street address
92
  public $zip; // zip code
93
-
94
- // Fields for Card Present (POS)
95
  public $magstripe; // mag stripe data. can be either Track 1, Track2 or Both (Required if card,exp,cardholder,street and zip aren't filled in)
96
  public $cardpresent; // Must be set to true if processing a card present transaction (Default is false)
97
  public $termtype; // The type of terminal being used: Optons are POS - cash register, StandAlone - self service terminal, Unattended - ie gas pump, Unkown (Default: Unknown)
@@ -99,7 +100,7 @@ class Mage_Usaepay_Model_TranApi {
99
  public $contactless; // Magstripe was read with contactless reader: yes, no (default is no)
100
  public $dukpt; // DUK/PT for PIN Debit
101
  public $signature; // Signature Capture data
102
-
103
  // fields required for check transactions
104
  public $account; // bank account number
105
  public $routing; // bank routing number
@@ -111,23 +112,23 @@ class Mage_Usaepay_Model_TranApi {
111
  public $checkformat; // Override default check record format
112
  public $checkimage_front; // Check front
113
  public $checkimage_back; // Check back
114
-
115
-
116
  // Fields required for Secure Vault Payments (Direct Pay)
117
  public $svpbank; // ID of cardholders bank
118
  public $svpreturnurl; // URL that the bank should return the user to when tran is completed
119
  public $svpcancelurl; // URL that the bank should return the user if they cancel
120
-
121
-
122
 
123
  // Option parameters
124
  public $origauthcode; // required if running postauth transaction.
125
- public $command; // type of command to run; Possible values are:
126
- // sale, credit, void, preauth, postauth, check and checkcredit.
127
  // Default is sale.
128
- public $orderid; // Unique order identifier. This field can be used to reference
129
- // the order for which this transaction corresponds to. This field
130
- // can contain up to 64 characters and should be used instead of
131
  // UMinvoice when orderids longer that 10 digits are needed.
132
  public $custid; // Alpha-numeric id that uniquely identifies the customer.
133
  public $description; // description of charge
@@ -145,17 +146,17 @@ class Mage_Usaepay_Model_TranApi {
145
  public $ignoresslcerterrors; // Bypasses ssl certificate errors. It is highly recommended that you do not use this option. Fix your openssl installation instead!
146
  public $cabundle; // manually specify location of root ca bundle (useful of root ca is not in default location)
147
  public $transport; // manually select transport to use (curl or stream), by default the library will auto select based on what is available
148
-
149
  // Card Authorization - Verified By Visa and Mastercard SecureCode
150
  public $cardauth; // enable card authentication
151
- public $pares; //
152
-
153
  // Third Party Card Authorization
154
  public $xid;
155
  public $cavv;
156
  public $eci;
157
 
158
- // Recurring Billing
159
  public $recurring; // Save transaction as a recurring transaction: yes/no
160
  public $schedule; // How often to run transaction: daily, weekly, biweekly, monthly, bimonthly, quarterly, annually. Default is monthly.
161
  public $numleft; // The number of times to run. Either a number or * for unlimited. Default is unlimited.
@@ -164,7 +165,7 @@ class Mage_Usaepay_Model_TranApi {
164
  public $billamount; // Optional recurring billing amount. If not specified, the amount field will be used for future recurring billing payments
165
  public $billtax;
166
  public $billsourcekey;
167
-
168
  // Billing Fields
169
  public $billfname;
170
  public $billlname;
@@ -192,7 +193,7 @@ class Mage_Usaepay_Model_TranApi {
192
  public $shipzip;
193
  public $shipcountry;
194
  public $shipphone;
195
-
196
  // Custom Fields
197
  public $custom1;
198
  public $custom2;
@@ -214,17 +215,17 @@ class Mage_Usaepay_Model_TranApi {
214
  public $custom18;
215
  public $custom19;
216
  public $custom20;
217
-
218
 
219
  // Line items (see addLine)
220
  public $lineitems;
221
-
222
-
223
  public $comments; // Additional transaction details or comments (free form text field supports up to 65,000 chars)
224
-
225
  public $software; // Allows developers to identify their application to the gateway (for troubleshooting purposes)
226
 
227
-
228
  // response fields
229
  public $rawresult; // raw result from gateway
230
  public $result; // full result: Approved, Declined, Error
@@ -243,26 +244,26 @@ class Mage_Usaepay_Model_TranApi {
243
  public $convertedamountcurrency; // merchants currency
244
  public $conversionrate; // the conversion rate that was used
245
  public $custnum; // gateway assigned customer ref number for recurring billing
246
-
247
  // Cardinal Response Fields
248
  public $acsurl; // card auth url
249
  public $pareq; // card auth request
250
  public $cctransid; // cardinal transid
251
 
252
-
253
  // Errors Response Feilds
254
  public $error; // error message if result is an error
255
  public $errorcode; // numerical error code
256
  public $blank; // blank response
257
  public $transporterror; // transport error
258
-
259
  // Extended Fraud Profiler Fields
260
  public $session; // session id
261
  // responses fields
262
  public $profilerScore;
263
  public $profilerResponse;
264
  public $profilerReason;
265
-
266
  function __construct()
267
  {
268
  // Set default values.
@@ -276,17 +277,53 @@ class Mage_Usaepay_Model_TranApi {
276
  if(isset($_SERVER['REMOTE_ADDR'])) $this->ip=$_SERVER['REMOTE_ADDR'];
277
  $this->software="USAePay PHP API v" . USAEPAY_VERSION;
278
  }
279
-
280
  protected function _log($message, $level = null)
281
  {
282
  Mage::log($message, $level, 'usaepay.log');
283
  }
284
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
285
  protected function _getGatewayBaseUrl()
286
  {
287
- return $this->usesandbox ? 'https://sandbox.usaepay.com' : 'https://www.usaepay.com';
 
 
 
 
 
 
 
288
  }
289
-
290
  /**
291
  * Add a line item to the transaction
292
  *
@@ -298,7 +335,7 @@ class Mage_Usaepay_Model_TranApi {
298
  * @param int $qty
299
  */
300
  function addLine($sku, $name, $description, $cost, $qty, $taxAmount)
301
- {
302
  $this->lineitems[] = array(
303
  'sku' => $sku,
304
  'name' => $name,
@@ -311,10 +348,10 @@ class Mage_Usaepay_Model_TranApi {
311
 
312
  function clearLines()
313
  {
314
- $this->lineitems=array();
315
  }
316
-
317
-
318
  /**
319
  * Verify that all required data has been set
320
  *
@@ -325,12 +362,12 @@ class Mage_Usaepay_Model_TranApi {
325
  if(!$this->key) return "Source Key is required";
326
  if(in_array(strtolower($this->command), array("quickcredit","quicksale","cc:capture", "cc:refund", "refund", "check:refund","capture", "creditvoid")))
327
  {
328
- if(!$this->refnum) return "Reference Number is required";
329
  }else if(in_array(strtolower($this->command), array("svp")))
330
  {
331
- if(!$this->svpbank) return "Bank ID is required";
332
- if(!$this->svpreturnurl) return "Return URL is required";
333
- if(!$this->svpcancelurl) return "Cancel URL is required";
334
  } else {
335
  if(in_array(strtolower($this->command), array("check:sale","check:credit", "check", "checkcredit","reverseach") )) {
336
  if(!$this->account) return "Account Number is required";
@@ -350,9 +387,10 @@ class Mage_Usaepay_Model_TranApi {
350
  //if(!$this->zip) return "Zipcode is required";
351
  }
352
  }
353
- return 0;
354
  }
355
-
 
356
  /**
357
  * Send transaction to the USAePay Gateway and parse response
358
  *
@@ -362,7 +400,7 @@ class Mage_Usaepay_Model_TranApi {
362
  {
363
  if($this->command=='quicksale') return $this->ProcessQuickSale();
364
  if($this->command=='quickcredit') return $this->ProcessQuickCredit();
365
-
366
  // check that we have the needed data
367
  $tmp=$this->CheckData();
368
  if($tmp)
@@ -373,28 +411,28 @@ class Mage_Usaepay_Model_TranApi {
373
  $this->errorcode=10129;
374
  return false;
375
  }
376
-
377
  // format the data
378
- $data =
379
- array("UMkey" => $this->key,
380
  "UMcommand" => $this->command,
381
  "UMauthCode" => $this->origauthcode,
382
  "UMcard" => $this->card,
383
  "UMexpir" => $this->exp,
384
- "UMbillamount" => $this->billamount,
385
- "UMamount" => $this->amount,
386
- "UMinvoice" => $this->invoice,
387
- "UMorderid" => $this->orderid,
388
- "UMponum" => $this->ponum,
389
- "UMtax" => $this->tax,
390
  "UMnontaxable" => ($this->nontaxable?'Y':''),
391
- "UMtip" => $this->tip,
392
- "UMshipping" => $this->shipping,
393
- "UMdiscount" => $this->discount,
394
- "UMsubtotal" => $this->subtotal,
395
- "UMcurrency" => $this->currency,
396
  "UMname" => $this->cardholder,
397
- "UMstreet" => $this->street,
398
  "UMzip" => $this->zip,
399
  "UMdescription" => $this->description,
400
  "UMcomments" => $this->comments,
@@ -445,22 +483,22 @@ class Mage_Usaepay_Model_TranApi {
445
  "UMshipstate" => $this->shipstate,
446
  "UMshipzip" => $this->shipzip,
447
  "UMshipcountry" => $this->shipcountry,
448
- "UMshipphone" => $this->shipphone,
449
- "UMcardauth" => $this->cardauth,
450
- "UMpares" => $this->pares,
451
- "UMxid" => $this->xid,
452
- "UMcavv" => $this->cavv,
453
- "UMeci" => $this->eci,
454
- "UMcustid" => $this->custid,
455
- "UMcardpresent" => ($this->cardpresent?"1":"0"),
456
- "UMmagstripe" => $this->magstripe,
457
- "UMdukpt" => $this->dukpt,
458
- "UMtermtype" => $this->termtype,
459
- "UMmagsupport" => $this->magsupport,
460
- "UMcontactless" => $this->contactless,
461
- "UMsignature" => $this->signature,
462
- "UMsoftware" => $this->software,
463
- "UMignoreDuplicate" => $this->ignoreduplicate,
464
  "UMrefNum" => $this->refnum,
465
  "UMsession" => $this->session
466
  );
@@ -470,7 +508,7 @@ class Mage_Usaepay_Model_TranApi {
470
  {
471
  if($this->{"custom$i"}) $data["UMcustom$i"] = $this->{"custom$i"};
472
  }
473
-
474
  // tack on line level detail
475
  $c=1;
476
  if(!is_array($this->lineitems)) $this->lineitems=array();
@@ -482,37 +520,37 @@ class Mage_Usaepay_Model_TranApi {
482
  $data["UMline{$c}cost"] = $lineitem['cost'];
483
  $data["UMline{$c}taxable"] = $lineitem['taxable'];
484
  $data["UMline{$c}qty"] = $lineitem['qty'];
485
- $c++;
486
  }
487
-
488
  // Create hash if pin has been set.
489
  if(trim($this->pin))
490
  {
491
  // generate random seed value
492
  $seed = microtime(true) . rand();
493
-
494
  // assemble prehash data
495
  $prehash = $this->command . ":" . trim($this->pin) . ":" . $this->amount . ":" . $this->invoice . ":" . $seed;
496
-
497
  // if sha1 is available, create sha1 hash, else use md5
498
  if(function_exists('sha1')) $hash = 's/' . $seed . '/' . sha1($prehash) . '/n';
499
  else $hash = 'm/' . $seed . '/' . md5($prehash) . '/n';
500
-
501
  // populate hash value
502
- $data['UMhash'] = $hash;
503
- }
504
-
505
  $url = $this->_getGatewayBaseUrl().'/gate';
506
-
507
- // $this->_log("TranApi::Process\nURL: $url\n------------------------\nRequest:\n".print_r($data, true)."\n------------------------\n");
508
-
509
  // Post data to Gateway
510
  $result=$this->httpPost($url, $data);
511
-
512
- // $this->_log("TranApi::Process\nResponse:\n$result\n------------------------\n");
513
-
514
  if($result===false) return false;
515
-
516
  // result is in urlencoded format, parse into an array
517
  parse_str($result,$tmp);
518
 
@@ -523,12 +561,12 @@ class Mage_Usaepay_Model_TranApi {
523
  $this->resultcode="E";
524
  $this->error="Error parsing data from card processing gateway.";
525
  $this->errorcode=10132;
526
- return false;
527
  }
528
 
529
- // Store results
530
- $this->result=(isset($tmp["UMstatus"])?$tmp["UMstatus"]:"Error");
531
- $this->resultcode=(isset($tmp["UMresult"])?$tmp["UMresult"]:"E");
532
  $this->authcode=(isset($tmp["UMauthCode"])?$tmp["UMauthCode"]:"");
533
  $this->refnum=(isset($tmp["UMrefNum"])?$tmp["UMrefNum"]:"");
534
  $this->batch=(isset($tmp["UMbatch"])?$tmp["UMbatch"]:"");
@@ -543,7 +581,7 @@ class Mage_Usaepay_Model_TranApi {
543
  $this->error=(isset($tmp["UMerror"])?$tmp["UMerror"]:"");
544
  $this->errorcode=(isset($tmp["UMerrorcode"])?$tmp["UMerrorcode"]:"10132");
545
  $this->custnum=(isset($tmp["UMcustnum"])?$tmp["UMcustnum"]:"");
546
-
547
  // extended fraud profiler results
548
  $this->profilerScore = isset($tmp['UMprofilerScore']) ? $tmp['UMprofilerScore'] : '';
549
  $this->profilerResponse = isset($tmp['UMprofilerResponse']) ? $tmp['UMprofilerResponse'] : '';
@@ -553,19 +591,19 @@ class Mage_Usaepay_Model_TranApi {
553
  $this->avs=(isset($tmp["UMavsResult"])?$tmp["UMavsResult"]:"");
554
  $this->cvv2=(isset($tmp["UMcvv2Result"])?$tmp["UMcvv2Result"]:"");
555
 
556
-
557
  if(isset($tmp["UMcctransid"])) $this->cctransid=$tmp["UMcctransid"];
558
  if(isset($tmp["UMacsurl"])) $this->acsurl=$tmp["UMacsurl"];
559
  if(isset($tmp["UMpayload"])) $this->pareq=$tmp["UMpayload"];
560
-
561
  if($this->resultcode == "A") return true;
562
  return false;
563
-
564
  }
565
-
566
  function ProcessQuickSale()
567
  {
568
-
569
  // check that we have the needed data
570
  $tmp=$this->CheckData();
571
  if($tmp)
@@ -576,7 +614,7 @@ class Mage_Usaepay_Model_TranApi {
576
  $this->errorcode=10129;
577
  return false;
578
  }
579
-
580
  // Create hash if pin has been set.
581
  if(!trim($this->pin))
582
  {
@@ -586,33 +624,33 @@ class Mage_Usaepay_Model_TranApi {
586
  $this->errorcode=999;
587
  return false;
588
  }
589
-
590
  // generate random seed value
591
  $seed = microtime(true) . rand();
592
-
593
  // assemble prehash data
594
  $prehash = $this->key . $seed . trim($this->pin);
595
-
596
  // hash the data
597
  $hash = sha1($prehash);
598
-
599
-
600
  $data = '<?xml version="1.0" encoding="UTF-8"?>' .
601
- '<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="urn:usaepay" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">' .
602
  '<SOAP-ENV:Body>' .
603
  '<ns1:runQuickSale>' .
604
  '<Token xsi:type="ns1:ueSecurityToken">' .
605
  '<ClientIP xsi:type="xsd:string">' . $_SERVER['REMOTE_ADDR'] . '</ClientIP>' .
606
  '<PinHash xsi:type="ns1:ueHash">' .
607
  '<HashValue xsi:type="xsd:string">' . $hash . '</HashValue>' .
608
- '<Seed xsi:type="xsd:string">' . $seed . '</Seed>' .
609
  '<Type xsi:type="xsd:string">sha1</Type>' .
610
  '</PinHash>' .
611
  '<SourceKey xsi:type="xsd:string">' . $this->key . '</SourceKey>' .
612
  '</Token>' .
613
  '<RefNum xsi:type="xsd:integer">' . preg_replace('/[^0-9]/','',$this->refnum) . '</RefNum>' .
614
- '<Details xsi:type="ns1:TransactionDetail">' .
615
- '<Amount xsi:type="xsd:double">' . $this->xmlentities($this->amount) . '</Amount>' .
616
  '<Description xsi:type="xsd:string">' . $this->xmlentities($this->description) . '</Description>'.
617
  '<Discount xsi:type="xsd:double">' . $this->xmlentities($this->discount) . '</Discount>' .
618
  '<Invoice xsi:type="xsd:string">' . $this->xmlentities($this->invoice) . '</Invoice>' .
@@ -628,21 +666,21 @@ class Mage_Usaepay_Model_TranApi {
628
  '</ns1:runQuickSale>' .
629
  '</SOAP-ENV:Body>' .
630
  '</SOAP-ENV:Envelope>';
631
-
632
-
633
-
634
  $url = $this->_getGatewayBaseUrl().'/soap/gate/15E7FB61';
635
 
636
- // $this->_log("TranApi::ProcessQuickSale\nURL: $url\n------------------------\nRequest:\n$data\n------------------------\n");
637
-
638
  // Post data to Gateway
639
  $result=$this->httpPost($url, array('xml'=>$data));
640
-
641
- // $this->_log("TranApi::ProcessQuickSale\nResponse:\n$result\n------------------------\n");
642
-
643
  if($result===false) return false;
644
-
645
-
646
  if(preg_match('~<AuthCode[^>]*>(.*)</AuthCode>~', $result, $m)) $this->authcode=$m[1];
647
  if(preg_match('~<AvsResult[^>]*>(.*)</AvsResult>~', $result, $m)) $this->avs_result=$m[1];
648
  if(preg_match('~<AvsResultCode[^>]*>(.*)</AvsResultCode>~', $result, $m)) $this->avs_result_code=$m[1];
@@ -661,19 +699,19 @@ class Mage_Usaepay_Model_TranApi {
661
  if(preg_match('~<Result[^>]*>(.*)</Result>~', $result, $m)) $this->result=$m[1];
662
  if(preg_match('~<ResultCode[^>]*>(.*)</ResultCode>~', $result, $m)) $this->resultcode=$m[1];
663
  if(preg_match('~<VpasResultCode[^>]*>(.*)</VpasResultCode>~', $result, $m)) $this->vpas_result_code=$m[1];
664
-
665
 
666
- // Store results
 
667
  if($this->resultcode == "A") return true;
668
  return false;
669
- }
 
 
 
670
 
671
-
672
-
673
-
674
  function ProcessQuickCredit()
675
  {
676
-
677
  // check that we have the needed data
678
  $tmp=$this->CheckData();
679
  if($tmp)
@@ -684,7 +722,7 @@ class Mage_Usaepay_Model_TranApi {
684
  $this->errorcode=10129;
685
  return false;
686
  }
687
-
688
  // Create hash if pin has been set.
689
  if(!trim($this->pin))
690
  {
@@ -694,33 +732,33 @@ class Mage_Usaepay_Model_TranApi {
694
  $this->errorcode=999;
695
  return false;
696
  }
697
-
698
  // generate random seed value
699
  $seed = microtime(true) . rand();
700
-
701
  // assemble prehash data
702
  $prehash = $this->key . $seed . trim($this->pin);
703
-
704
  // hash the data
705
  $hash = sha1($prehash);
706
-
707
-
708
  $data = '<?xml version="1.0" encoding="UTF-8"?>' .
709
- '<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="urn:usaepay" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">' .
710
  '<SOAP-ENV:Body>' .
711
  '<ns1:runQuickCredit>' .
712
  '<Token xsi:type="ns1:ueSecurityToken">' .
713
  '<ClientIP xsi:type="xsd:string">' . $_SERVER['REMOTE_ADDR'] . '</ClientIP>' .
714
  '<PinHash xsi:type="ns1:ueHash">' .
715
  '<HashValue xsi:type="xsd:string">' . $hash . '</HashValue>' .
716
- '<Seed xsi:type="xsd:string">' . $seed . '</Seed>' .
717
  '<Type xsi:type="xsd:string">sha1</Type>' .
718
  '</PinHash>' .
719
  '<SourceKey xsi:type="xsd:string">' . $this->key . '</SourceKey>' .
720
  '</Token>' .
721
  '<RefNum xsi:type="xsd:integer">' . preg_replace('/[^0-9]/','',$this->refnum) . '</RefNum>' .
722
- '<Details xsi:type="ns1:TransactionDetail">' .
723
- '<Amount xsi:type="xsd:double">' . $this->xmlentities($this->amount) . '</Amount>' .
724
  '<Description xsi:type="xsd:string">' . $this->xmlentities($this->description) . '</Description>'.
725
  '<Discount xsi:type="xsd:double">' . $this->xmlentities($this->discount) . '</Discount>' .
726
  '<Invoice xsi:type="xsd:string">' . $this->xmlentities($this->invoice) . '</Invoice>' .
@@ -736,20 +774,20 @@ class Mage_Usaepay_Model_TranApi {
736
  '</ns1:runQuickCredit>' .
737
  '</SOAP-ENV:Body>' .
738
  '</SOAP-ENV:Envelope>';
739
-
740
-
741
  $url = $this->_getGatewayBaseUrl().'/soap/gate/15E7FB61';
742
 
743
- // $this->_log("TranApi::ProcessQuickCredit\nURL: $url\n------------------------\nRequest:\n$data\n------------------------\n");
744
-
745
  // Post data to Gateway
746
  $result=$this->httpPost($url, array('xml'=>$data));
747
-
748
  // $this->_log("TranApi::ProcessQuickCredit\nResponse:\n$result\n------------------------\n");
749
-
750
  if($result===false) return false;
751
-
752
-
753
  if(preg_match('~<AuthCode[^>]*>(.*)</AuthCode>~', $result, $m)) $this->authcode=$m[1];
754
  if(preg_match('~<AvsResult[^>]*>(.*)</AvsResult>~', $result, $m)) $this->avs_result=$m[1];
755
  if(preg_match('~<AvsResultCode[^>]*>(.*)</AvsResultCode>~', $result, $m)) $this->avs_result_code=$m[1];
@@ -768,30 +806,30 @@ class Mage_Usaepay_Model_TranApi {
768
  if(preg_match('~<Result[^>]*>(.*)</Result>~', $result, $m)) $this->result=$m[1];
769
  if(preg_match('~<ResultCode[^>]*>(.*)</ResultCode>~', $result, $m)) $this->resultcode=$m[1];
770
  if(preg_match('~<VpasResultCode[^>]*>(.*)</VpasResultCode>~', $result, $m)) $this->vpas_result_code=$m[1];
771
-
772
 
773
- // Store results
 
774
  if($this->resultcode == "A") return true;
775
  return false;
776
- }
777
-
778
-
779
-
780
-
781
  function buildQuery($data)
782
  {
783
  //ueLogDebug("TranApi::buildQuery");
784
  if(function_exists('http_build_query') && ini_get('arg_separator.output')=='&') return http_build_query($data);
785
-
786
  $tmp=array();
787
  foreach($data as $key=>$val) $tmp[] = rawurlencode($key) . '=' . rawurlencode($val);
788
-
789
  return implode('&', $tmp);
790
-
791
  }
792
-
793
  function httpPost($url, $data)
794
- {
795
  // if transport was not specified, auto select transport
796
  if(!$this->transport)
797
  {
@@ -803,7 +841,7 @@ class Mage_Usaepay_Model_TranApi {
803
  }
804
  }
805
  }
806
-
807
  // Use selected transport to post request to the gateway
808
  switch($this->transport)
809
  {
@@ -811,19 +849,19 @@ class Mage_Usaepay_Model_TranApi {
811
  case 'stream': return $this->httpPostPHP($url, $data);
812
  }
813
 
814
-
815
-
816
- // No HTTPs libraries found, return error
817
  $this->result="Error";
818
  $this->resultcode="E";
819
  $this->error="Libary Error: SSL HTTPS support not found";
820
  $this->errorcode=10130;
821
- return false;
822
  }
823
-
824
  function httpPostCurl($url, $data)
825
  {
826
-
827
  //init the connection
828
  $ch = curl_init($url);
829
  if(!is_resource($ch))
@@ -832,9 +870,9 @@ class Mage_Usaepay_Model_TranApi {
832
  $this->resultcode="E";
833
  $this->error="Libary Error: Unable to initialize CURL ($ch)";
834
  $this->errorcode=10131;
835
- return false;
836
  }
837
-
838
  // set some options for the connection
839
  curl_setopt($ch,CURLOPT_HEADER, 1);
840
  curl_setopt($ch,CURLOPT_POST,1);
@@ -847,28 +885,28 @@ class Mage_Usaepay_Model_TranApi {
847
  curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
848
  curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
849
  }
850
-
851
  // apply custom ca bundle location
852
  if($this->cabundle)
853
- {
854
- curl_setopt($ch, CURLOPT_CAINFO, $this->cabundle);
855
  }
856
-
857
  // set proxy
858
  if($this->proxyurl)
859
  {
860
  curl_setopt ($ch, CURLOPT_PROXYTYPE, CURLPROXY_HTTP);
861
  curl_setopt ($ch, CURLOPT_PROXY, $this->proxyurl);
862
- }
863
-
864
  $soapcall=false;
865
  if(is_array($data))
866
  {
867
  if(array_key_exists('xml',$data)) $soapcall=true;
868
  }
869
-
870
-
871
-
872
  if($soapcall)
873
  {
874
  curl_setopt($ch, CURLOPT_HTTPHEADER, array(
@@ -876,18 +914,18 @@ class Mage_Usaepay_Model_TranApi {
876
  "SoapAction: urn:ueSoapServerAction"
877
  ));
878
  curl_setopt($ch,CURLOPT_POSTFIELDS,$data['xml']);
879
-
880
  } else {
881
- // rawurlencode data
882
- $data = $this->buildQuery($data);
883
-
884
  // attach the data
885
  curl_setopt($ch,CURLOPT_POSTFIELDS,$data);
886
- }
887
-
888
  // run the transfer
889
  $result=curl_exec ($ch);
890
-
891
  //get the result and parse it for the response line.
892
  if(!strlen($result))
893
  {
@@ -899,14 +937,14 @@ class Mage_Usaepay_Model_TranApi {
899
  $this->transporterror=$this->curlerror=curl_error($ch);
900
  // $this->_log('curl error: '.$this->curlerror, Zend_Log::ERR);
901
  curl_close ($ch);
902
- return false;
903
  }
904
-
905
  curl_close ($ch);
906
  $this->rawresult=$result;
907
-
908
  if($soapcall) {
909
- return $result;
910
  }
911
 
912
  if(!$result) {
@@ -914,24 +952,24 @@ class Mage_Usaepay_Model_TranApi {
914
  $this->resultcode="E";
915
  $this->error="Blank response from card processing gateway.";
916
  $this->errorcode=10132;
917
- return false;
918
  }
919
-
920
  // result will be on the last line of the return
921
  $tmp=explode("\n",$result);
922
- $result=$tmp[count($tmp)-1];
923
-
924
  return $result;
925
  }
926
-
927
  function httpPostPHP($url, $data)
928
  {
929
 
930
-
931
- // rawurlencode data
932
- $data = $this->buildQuery($data);
933
-
934
- // set stream http options
935
  $options = array(
936
  'http'=> array(
937
  'method'=>'POST',
@@ -943,18 +981,18 @@ class Mage_Usaepay_Model_TranApi {
943
  ),
944
  'ssl' => array(
945
  'verify_peer' => ($this->ignoresslcerterrors?false:true),
946
- 'allow_self_signed' => ($this->ignoresslcerterrors?true:false)
947
  )
948
  );
949
-
950
  if($this->cabundle) $options['ssl']['cafile'] = $this->cabundle;
951
-
952
  if(trim($this->proxyurl)) $options['http']['proxy'] = $this->proxyurl;
953
-
954
-
955
  // create stream context
956
  $context = stream_context_create($options);
957
-
958
  // post data to gateway
959
  $fd = fopen($url, 'r', null, $context);
960
  if(!$fd)
@@ -971,9 +1009,9 @@ class Mage_Usaepay_Model_TranApi {
971
  $this->transporterror=$GLOBALS['php_errormsg'];
972
  }
973
  //curl_close ($ch);
974
- return false;
975
- }
976
-
977
  // pull result
978
  $result = stream_get_contents($fd);
979
 
@@ -986,12 +1024,12 @@ class Mage_Usaepay_Model_TranApi {
986
  $this->errorcode=10132;
987
  $this->blank=1;
988
  fclose($fd);
989
- return false;
990
- }
991
-
992
  fclose($fd);
993
  return $result;
994
-
995
  }
996
 
997
  function xmlentities($string)
@@ -1000,7 +1038,7 @@ class Mage_Usaepay_Model_TranApi {
1000
  $string = preg_replace_callback('/[^a-zA-Z0-9 _\-\.\'\r\n]/', array('self', '_xmlEntitesReplaceCallback'), $string);
1001
  return $string;
1002
  }
1003
-
1004
  static protected function _xmlEntitesReplaceCallback($matches)
1005
  {
1006
  return self::_uePrivateXMLEntities($matches[0]);
@@ -1033,8 +1071,8 @@ class Mage_Usaepay_Model_TranApi {
1033
  153 => '&#8482;',
1034
  154 => '&#353;',
1035
  155 => '&#8250;',
1036
- 156 => '&#339;',
1037
- 158 => '&#382;',
1038
  159 => '&#376;'
1039
  );
1040
  $num = ord($char);
@@ -1046,17 +1084,17 @@ function _uePrivateXMLEntities($num)
1046
  { $chars = array(
1047
  128 => '&#8364;',
1048
  130 => '&#8218;',
1049
- 131 => '&#402;',
1050
  132 => '&#8222;',
1051
  133 => '&#8230;',
1052
  134 => '&#8224;',
1053
  135 => '&#8225;',
1054
- 136 => '&#710;',
1055
  137 => '&#8240;',
1056
- 138 => '&#352;',
1057
  139 => '&#8249;',
1058
- 140 => '&#338;',
1059
- 142 => '&#381;',
1060
  145 => '&#8216;',
1061
  146 => '&#8217;',
1062
  147 => '&#8220;',
@@ -1064,12 +1102,12 @@ function _uePrivateXMLEntities($num)
1064
  149 => '&#8226;',
1065
  150 => '&#8211;',
1066
  151 => '&#8212;',
1067
- 152 => '&#732;',
1068
  153 => '&#8482;',
1069
- 154 => '&#353;',
1070
  155 => '&#8250;',
1071
- 156 => '&#339;',
1072
- 158 => '&#382;',
1073
  159 => '&#376;');
1074
  $num = ord($num);
1075
  return (($num > 127 && $num < 160) ? $chars[$num] : "&#".$num.";" );
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.
8
+ *
9
  * The code in this file based on the USA ePay PHP Library.
10
  * v1.6.5 - Nov 11, 2009
11
  * Copyright (c) 2001-2009 USAePay
12
  * http://help.usaepay.com/developer/phplibrary
13
+ *
14
+ * Redistribution and use in source and binary forms, with or without
15
+ * modification, are permitted provided that the following conditions
16
  * are met:
17
+ *
18
+ * - Redistributions of source code must retain the above copyright
19
  * notice, this list of conditions and the following disclaimer.
20
+ * - Redistributions in binary form must reproduce the above
21
+ * copyright notice, this list of conditions and the following
22
+ * disclaimer in the documentation and/or other materials
23
  * provided with the distribution.
24
+ * - Neither the name of the USAePay nor the names of its
25
+ * contributors may be used to endorse or promote products
26
+ * derived from this software without specific prior written
27
  * permission.
28
+ *
29
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
30
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
31
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
32
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
33
+ * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
34
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
35
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
36
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
37
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
38
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
39
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
40
  * POSSIBILITY OF SUCH DAMAGE.
41
+ *
42
  * @category Mage
43
  * @package Mage_Usaepay_Model
44
  * @copyright Copyright (c) 2010 USAePay (www.usaepay.com)
53
  // For assistance please contact devsupport@usaepay.com
54
  //
55
 
56
+ define("USAEPAY_VERSION", "1.1.7");
57
 
58
 
59
  /**
61
  *
62
  */
63
  class Mage_Usaepay_Model_TranApi {
64
+
65
  // Required for all transactions
66
  public $key; // Source key
67
  public $pin; // Source pin (optional)
68
+ public $amount; // the entire amount that will be charged to the customers card
69
  // (including tax, shipping, etc)
70
+ public $invoice; // invoice number. must be unique. limited to 10 digits. use orderid if you need longer.
71
+
72
  // Required for Commercial Card support
73
  public $ponum; // Purchase Order Number
74
  public $tax; // Tax
75
  public $nontaxable; // Order is non taxable
76
+ public $proccessingurl;
77
+ public $proccessingnum;
78
  // Amount details (optional)
79
  public $tip; // Tip
80
  public $shipping; // Shipping charge
81
  public $discount; // Discount amount (ie gift certificate or coupon code)
82
+ public $subtotal; // if subtotal is set, then
83
+ // subtotal + tip + shipping - discount + tax must equal amount
84
  // or the transaction will be declined. If subtotal is left blank
85
  // then it will be ignored
86
  public $currency; // Currency of $amount
87
+
88
  // Required Fields for Card Not Present transacitons (Ecommerce)
89
  public $card; // card number, no dashes, no spaces
90
  public $exp; // expiration date 4 digits no /
91
  public $cardholder; // name of card holder
92
  public $street; // street address
93
  public $zip; // zip code
94
+
95
+ // Fields for Card Present (POS)
96
  public $magstripe; // mag stripe data. can be either Track 1, Track2 or Both (Required if card,exp,cardholder,street and zip aren't filled in)
97
  public $cardpresent; // Must be set to true if processing a card present transaction (Default is false)
98
  public $termtype; // The type of terminal being used: Optons are POS - cash register, StandAlone - self service terminal, Unattended - ie gas pump, Unkown (Default: Unknown)
100
  public $contactless; // Magstripe was read with contactless reader: yes, no (default is no)
101
  public $dukpt; // DUK/PT for PIN Debit
102
  public $signature; // Signature Capture data
103
+
104
  // fields required for check transactions
105
  public $account; // bank account number
106
  public $routing; // bank routing number
112
  public $checkformat; // Override default check record format
113
  public $checkimage_front; // Check front
114
  public $checkimage_back; // Check back
115
+
116
+
117
  // Fields required for Secure Vault Payments (Direct Pay)
118
  public $svpbank; // ID of cardholders bank
119
  public $svpreturnurl; // URL that the bank should return the user to when tran is completed
120
  public $svpcancelurl; // URL that the bank should return the user if they cancel
121
+
122
+
123
 
124
  // Option parameters
125
  public $origauthcode; // required if running postauth transaction.
126
+ public $command; // type of command to run; Possible values are:
127
+ // sale, credit, void, preauth, postauth, check and checkcredit.
128
  // Default is sale.
129
+ public $orderid; // Unique order identifier. This field can be used to reference
130
+ // the order for which this transaction corresponds to. This field
131
+ // can contain up to 64 characters and should be used instead of
132
  // UMinvoice when orderids longer that 10 digits are needed.
133
  public $custid; // Alpha-numeric id that uniquely identifies the customer.
134
  public $description; // description of charge
146
  public $ignoresslcerterrors; // Bypasses ssl certificate errors. It is highly recommended that you do not use this option. Fix your openssl installation instead!
147
  public $cabundle; // manually specify location of root ca bundle (useful of root ca is not in default location)
148
  public $transport; // manually select transport to use (curl or stream), by default the library will auto select based on what is available
149
+
150
  // Card Authorization - Verified By Visa and Mastercard SecureCode
151
  public $cardauth; // enable card authentication
152
+ public $pares; //
153
+
154
  // Third Party Card Authorization
155
  public $xid;
156
  public $cavv;
157
  public $eci;
158
 
159
+ // Recurring Billings
160
  public $recurring; // Save transaction as a recurring transaction: yes/no
161
  public $schedule; // How often to run transaction: daily, weekly, biweekly, monthly, bimonthly, quarterly, annually. Default is monthly.
162
  public $numleft; // The number of times to run. Either a number or * for unlimited. Default is unlimited.
165
  public $billamount; // Optional recurring billing amount. If not specified, the amount field will be used for future recurring billing payments
166
  public $billtax;
167
  public $billsourcekey;
168
+
169
  // Billing Fields
170
  public $billfname;
171
  public $billlname;
193
  public $shipzip;
194
  public $shipcountry;
195
  public $shipphone;
196
+
197
  // Custom Fields
198
  public $custom1;
199
  public $custom2;
215
  public $custom18;
216
  public $custom19;
217
  public $custom20;
218
+
219
 
220
  // Line items (see addLine)
221
  public $lineitems;
222
+
223
+
224
  public $comments; // Additional transaction details or comments (free form text field supports up to 65,000 chars)
225
+
226
  public $software; // Allows developers to identify their application to the gateway (for troubleshooting purposes)
227
 
228
+
229
  // response fields
230
  public $rawresult; // raw result from gateway
231
  public $result; // full result: Approved, Declined, Error
244
  public $convertedamountcurrency; // merchants currency
245
  public $conversionrate; // the conversion rate that was used
246
  public $custnum; // gateway assigned customer ref number for recurring billing
247
+
248
  // Cardinal Response Fields
249
  public $acsurl; // card auth url
250
  public $pareq; // card auth request
251
  public $cctransid; // cardinal transid
252
 
253
+
254
  // Errors Response Feilds
255
  public $error; // error message if result is an error
256
  public $errorcode; // numerical error code
257
  public $blank; // blank response
258
  public $transporterror; // transport error
259
+
260
  // Extended Fraud Profiler Fields
261
  public $session; // session id
262
  // responses fields
263
  public $profilerScore;
264
  public $profilerResponse;
265
  public $profilerReason;
266
+
267
  function __construct()
268
  {
269
  // Set default values.
277
  if(isset($_SERVER['REMOTE_ADDR'])) $this->ip=$_SERVER['REMOTE_ADDR'];
278
  $this->software="USAePay PHP API v" . USAEPAY_VERSION;
279
  }
280
+
281
  protected function _log($message, $level = null)
282
  {
283
  Mage::log($message, $level, 'usaepay.log');
284
  }
285
+
286
+ protected function _urlExists($url=NULL)
287
+ {
288
+ if($url == NULL) return false;
289
+ $ch = curl_init($url);
290
+ curl_setopt($ch, CURLOPT_TIMEOUT, 45);
291
+ curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 45);
292
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
293
+ $data = curl_exec($ch);
294
+ $httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
295
+ curl_close($ch);
296
+ if($httpcode>=200 && $httpcode<300){
297
+ return true;
298
+ } else {
299
+ return false;
300
+ }
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){
308
+ $temp = $v;
309
+ break;
310
+ }
311
+ }
312
+ return $temp;
313
+ }
314
+
315
  protected function _getGatewayBaseUrl()
316
  {
317
+ if($this->usesandbox){
318
+ $url = 'https://sandbox.usaepay.com';
319
+ }
320
+ else {
321
+ $url = $this->_getproccessingurl();
322
+ }
323
+ //$this->_log("urlExists\nURL: $url\n------------------------\nRequestURL:\n".$url."\n------------------------\n");
324
+ return $url;
325
  }
326
+
327
  /**
328
  * Add a line item to the transaction
329
  *
335
  * @param int $qty
336
  */
337
  function addLine($sku, $name, $description, $cost, $qty, $taxAmount)
338
+ {
339
  $this->lineitems[] = array(
340
  'sku' => $sku,
341
  'name' => $name,
348
 
349
  function clearLines()
350
  {
351
+ $this->lineitems=array();
352
  }
353
+
354
+
355
  /**
356
  * Verify that all required data has been set
357
  *
362
  if(!$this->key) return "Source Key is required";
363
  if(in_array(strtolower($this->command), array("quickcredit","quicksale","cc:capture", "cc:refund", "refund", "check:refund","capture", "creditvoid")))
364
  {
365
+ if(!$this->refnum) return "Reference Number is required";
366
  }else if(in_array(strtolower($this->command), array("svp")))
367
  {
368
+ if(!$this->svpbank) return "Bank ID is required";
369
+ if(!$this->svpreturnurl) return "Return URL is required";
370
+ if(!$this->svpcancelurl) return "Cancel URL is required";
371
  } else {
372
  if(in_array(strtolower($this->command), array("check:sale","check:credit", "check", "checkcredit","reverseach") )) {
373
  if(!$this->account) return "Account Number is required";
387
  //if(!$this->zip) return "Zipcode is required";
388
  }
389
  }
390
+ return 0;
391
  }
392
+
393
+
394
  /**
395
  * Send transaction to the USAePay Gateway and parse response
396
  *
400
  {
401
  if($this->command=='quicksale') return $this->ProcessQuickSale();
402
  if($this->command=='quickcredit') return $this->ProcessQuickCredit();
403
+
404
  // check that we have the needed data
405
  $tmp=$this->CheckData();
406
  if($tmp)
411
  $this->errorcode=10129;
412
  return false;
413
  }
414
+
415
  // format the data
416
+ $data =
417
+ array("UMkey" => $this->key,
418
  "UMcommand" => $this->command,
419
  "UMauthCode" => $this->origauthcode,
420
  "UMcard" => $this->card,
421
  "UMexpir" => $this->exp,
422
+ "UMbillamount" => $this->billamount,
423
+ "UMamount" => $this->amount,
424
+ "UMinvoice" => $this->invoice,
425
+ "UMorderid" => $this->orderid,
426
+ "UMponum" => $this->ponum,
427
+ "UMtax" => $this->tax,
428
  "UMnontaxable" => ($this->nontaxable?'Y':''),
429
+ "UMtip" => $this->tip,
430
+ "UMshipping" => $this->shipping,
431
+ "UMdiscount" => $this->discount,
432
+ "UMsubtotal" => $this->subtotal,
433
+ "UMcurrency" => $this->currency,
434
  "UMname" => $this->cardholder,
435
+ "UMstreet" => $this->street,
436
  "UMzip" => $this->zip,
437
  "UMdescription" => $this->description,
438
  "UMcomments" => $this->comments,
483
  "UMshipstate" => $this->shipstate,
484
  "UMshipzip" => $this->shipzip,
485
  "UMshipcountry" => $this->shipcountry,
486
+ "UMshipphone" => $this->shipphone,
487
+ "UMcardauth" => $this->cardauth,
488
+ "UMpares" => $this->pares,
489
+ "UMxid" => $this->xid,
490
+ "UMcavv" => $this->cavv,
491
+ "UMeci" => $this->eci,
492
+ "UMcustid" => $this->custid,
493
+ "UMcardpresent" => ($this->cardpresent?"1":"0"),
494
+ "UMmagstripe" => $this->magstripe,
495
+ "UMdukpt" => $this->dukpt,
496
+ "UMtermtype" => $this->termtype,
497
+ "UMmagsupport" => $this->magsupport,
498
+ "UMcontactless" => $this->contactless,
499
+ "UMsignature" => $this->signature,
500
+ "UMsoftware" => $this->software,
501
+ "UMignoreDuplicate" => $this->ignoreduplicate,
502
  "UMrefNum" => $this->refnum,
503
  "UMsession" => $this->session
504
  );
508
  {
509
  if($this->{"custom$i"}) $data["UMcustom$i"] = $this->{"custom$i"};
510
  }
511
+
512
  // tack on line level detail
513
  $c=1;
514
  if(!is_array($this->lineitems)) $this->lineitems=array();
520
  $data["UMline{$c}cost"] = $lineitem['cost'];
521
  $data["UMline{$c}taxable"] = $lineitem['taxable'];
522
  $data["UMline{$c}qty"] = $lineitem['qty'];
523
+ $c++;
524
  }
525
+
526
  // Create hash if pin has been set.
527
  if(trim($this->pin))
528
  {
529
  // generate random seed value
530
  $seed = microtime(true) . rand();
531
+
532
  // assemble prehash data
533
  $prehash = $this->command . ":" . trim($this->pin) . ":" . $this->amount . ":" . $this->invoice . ":" . $seed;
534
+
535
  // if sha1 is available, create sha1 hash, else use md5
536
  if(function_exists('sha1')) $hash = 's/' . $seed . '/' . sha1($prehash) . '/n';
537
  else $hash = 'm/' . $seed . '/' . md5($prehash) . '/n';
538
+
539
  // populate hash value
540
+ $data['UMhash'] = $hash;
541
+ }
542
+
543
  $url = $this->_getGatewayBaseUrl().'/gate';
544
+
545
+ //$this->_log("TranApi::Process\nURL: $url\n------------------------\nRequest:\n".print_r($data, true)."\n------------------------\n");
546
+
547
  // Post data to Gateway
548
  $result=$this->httpPost($url, $data);
549
+ //$this->_log("_getGatewayBaseUrl\nResponse:\n".$this->proccessingurl."\n------------------------\n");
550
+ //$this->_log("TranApi::Process\nResponse:\n$result\n------------------------\n");
551
+
552
  if($result===false) return false;
553
+
554
  // result is in urlencoded format, parse into an array
555
  parse_str($result,$tmp);
556
 
561
  $this->resultcode="E";
562
  $this->error="Error parsing data from card processing gateway.";
563
  $this->errorcode=10132;
564
+ return false;
565
  }
566
 
567
+ // Store results
568
+ $this->result=(isset($tmp["UMstatus"])?$tmp["UMstatus"]:"Error");
569
+ $this->resultcode=(isset($tmp["UMresult"])?$tmp["UMresult"]:"E");
570
  $this->authcode=(isset($tmp["UMauthCode"])?$tmp["UMauthCode"]:"");
571
  $this->refnum=(isset($tmp["UMrefNum"])?$tmp["UMrefNum"]:"");
572
  $this->batch=(isset($tmp["UMbatch"])?$tmp["UMbatch"]:"");
581
  $this->error=(isset($tmp["UMerror"])?$tmp["UMerror"]:"");
582
  $this->errorcode=(isset($tmp["UMerrorcode"])?$tmp["UMerrorcode"]:"10132");
583
  $this->custnum=(isset($tmp["UMcustnum"])?$tmp["UMcustnum"]:"");
584
+
585
  // extended fraud profiler results
586
  $this->profilerScore = isset($tmp['UMprofilerScore']) ? $tmp['UMprofilerScore'] : '';
587
  $this->profilerResponse = isset($tmp['UMprofilerResponse']) ? $tmp['UMprofilerResponse'] : '';
591
  $this->avs=(isset($tmp["UMavsResult"])?$tmp["UMavsResult"]:"");
592
  $this->cvv2=(isset($tmp["UMcvv2Result"])?$tmp["UMcvv2Result"]:"");
593
 
594
+
595
  if(isset($tmp["UMcctransid"])) $this->cctransid=$tmp["UMcctransid"];
596
  if(isset($tmp["UMacsurl"])) $this->acsurl=$tmp["UMacsurl"];
597
  if(isset($tmp["UMpayload"])) $this->pareq=$tmp["UMpayload"];
598
+
599
  if($this->resultcode == "A") return true;
600
  return false;
601
+
602
  }
603
+
604
  function ProcessQuickSale()
605
  {
606
+
607
  // check that we have the needed data
608
  $tmp=$this->CheckData();
609
  if($tmp)
614
  $this->errorcode=10129;
615
  return false;
616
  }
617
+
618
  // Create hash if pin has been set.
619
  if(!trim($this->pin))
620
  {
624
  $this->errorcode=999;
625
  return false;
626
  }
627
+
628
  // generate random seed value
629
  $seed = microtime(true) . rand();
630
+
631
  // assemble prehash data
632
  $prehash = $this->key . $seed . trim($this->pin);
633
+
634
  // hash the data
635
  $hash = sha1($prehash);
636
+
637
+
638
  $data = '<?xml version="1.0" encoding="UTF-8"?>' .
639
+ '<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="urn:usaepay" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">' .
640
  '<SOAP-ENV:Body>' .
641
  '<ns1:runQuickSale>' .
642
  '<Token xsi:type="ns1:ueSecurityToken">' .
643
  '<ClientIP xsi:type="xsd:string">' . $_SERVER['REMOTE_ADDR'] . '</ClientIP>' .
644
  '<PinHash xsi:type="ns1:ueHash">' .
645
  '<HashValue xsi:type="xsd:string">' . $hash . '</HashValue>' .
646
+ '<Seed xsi:type="xsd:string">' . $seed . '</Seed>' .
647
  '<Type xsi:type="xsd:string">sha1</Type>' .
648
  '</PinHash>' .
649
  '<SourceKey xsi:type="xsd:string">' . $this->key . '</SourceKey>' .
650
  '</Token>' .
651
  '<RefNum xsi:type="xsd:integer">' . preg_replace('/[^0-9]/','',$this->refnum) . '</RefNum>' .
652
+ '<Details xsi:type="ns1:TransactionDetail">' .
653
+ '<Amount xsi:type="xsd:double">' . $this->xmlentities($this->amount) . '</Amount>' .
654
  '<Description xsi:type="xsd:string">' . $this->xmlentities($this->description) . '</Description>'.
655
  '<Discount xsi:type="xsd:double">' . $this->xmlentities($this->discount) . '</Discount>' .
656
  '<Invoice xsi:type="xsd:string">' . $this->xmlentities($this->invoice) . '</Invoice>' .
666
  '</ns1:runQuickSale>' .
667
  '</SOAP-ENV:Body>' .
668
  '</SOAP-ENV:Envelope>';
669
+
670
+
671
+
672
  $url = $this->_getGatewayBaseUrl().'/soap/gate/15E7FB61';
673
 
674
+ //$this->_log("TranApi::ProcessQuickSale\nURL: $url\n------------------------\nRequest:\n$data\n------------------------\n");
675
+
676
  // Post data to Gateway
677
  $result=$this->httpPost($url, array('xml'=>$data));
678
+
679
+ //$this->_log("TranApi::ProcessQuickSale\nResponse:\n$result\n------------------------\n");
680
+
681
  if($result===false) return false;
682
+
683
+
684
  if(preg_match('~<AuthCode[^>]*>(.*)</AuthCode>~', $result, $m)) $this->authcode=$m[1];
685
  if(preg_match('~<AvsResult[^>]*>(.*)</AvsResult>~', $result, $m)) $this->avs_result=$m[1];
686
  if(preg_match('~<AvsResultCode[^>]*>(.*)</AvsResultCode>~', $result, $m)) $this->avs_result_code=$m[1];
699
  if(preg_match('~<Result[^>]*>(.*)</Result>~', $result, $m)) $this->result=$m[1];
700
  if(preg_match('~<ResultCode[^>]*>(.*)</ResultCode>~', $result, $m)) $this->resultcode=$m[1];
701
  if(preg_match('~<VpasResultCode[^>]*>(.*)</VpasResultCode>~', $result, $m)) $this->vpas_result_code=$m[1];
 
702
 
703
+
704
+ // Store results
705
  if($this->resultcode == "A") return true;
706
  return false;
707
+ }
708
+
709
+
710
+
711
 
 
 
 
712
  function ProcessQuickCredit()
713
  {
714
+
715
  // check that we have the needed data
716
  $tmp=$this->CheckData();
717
  if($tmp)
722
  $this->errorcode=10129;
723
  return false;
724
  }
725
+
726
  // Create hash if pin has been set.
727
  if(!trim($this->pin))
728
  {
732
  $this->errorcode=999;
733
  return false;
734
  }
735
+
736
  // generate random seed value
737
  $seed = microtime(true) . rand();
738
+
739
  // assemble prehash data
740
  $prehash = $this->key . $seed . trim($this->pin);
741
+
742
  // hash the data
743
  $hash = sha1($prehash);
744
+
745
+
746
  $data = '<?xml version="1.0" encoding="UTF-8"?>' .
747
+ '<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="urn:usaepay" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">' .
748
  '<SOAP-ENV:Body>' .
749
  '<ns1:runQuickCredit>' .
750
  '<Token xsi:type="ns1:ueSecurityToken">' .
751
  '<ClientIP xsi:type="xsd:string">' . $_SERVER['REMOTE_ADDR'] . '</ClientIP>' .
752
  '<PinHash xsi:type="ns1:ueHash">' .
753
  '<HashValue xsi:type="xsd:string">' . $hash . '</HashValue>' .
754
+ '<Seed xsi:type="xsd:string">' . $seed . '</Seed>' .
755
  '<Type xsi:type="xsd:string">sha1</Type>' .
756
  '</PinHash>' .
757
  '<SourceKey xsi:type="xsd:string">' . $this->key . '</SourceKey>' .
758
  '</Token>' .
759
  '<RefNum xsi:type="xsd:integer">' . preg_replace('/[^0-9]/','',$this->refnum) . '</RefNum>' .
760
+ '<Details xsi:type="ns1:TransactionDetail">' .
761
+ '<Amount xsi:type="xsd:double">' . $this->xmlentities($this->amount) . '</Amount>' .
762
  '<Description xsi:type="xsd:string">' . $this->xmlentities($this->description) . '</Description>'.
763
  '<Discount xsi:type="xsd:double">' . $this->xmlentities($this->discount) . '</Discount>' .
764
  '<Invoice xsi:type="xsd:string">' . $this->xmlentities($this->invoice) . '</Invoice>' .
774
  '</ns1:runQuickCredit>' .
775
  '</SOAP-ENV:Body>' .
776
  '</SOAP-ENV:Envelope>';
777
+
778
+
779
  $url = $this->_getGatewayBaseUrl().'/soap/gate/15E7FB61';
780
 
781
+ //$this->_log("TranApi::ProcessQuickCredit\nURL: $url\n------------------------\nRequest:\n$data\n------------------------\n");
782
+
783
  // Post data to Gateway
784
  $result=$this->httpPost($url, array('xml'=>$data));
785
+
786
  // $this->_log("TranApi::ProcessQuickCredit\nResponse:\n$result\n------------------------\n");
787
+
788
  if($result===false) return false;
789
+
790
+
791
  if(preg_match('~<AuthCode[^>]*>(.*)</AuthCode>~', $result, $m)) $this->authcode=$m[1];
792
  if(preg_match('~<AvsResult[^>]*>(.*)</AvsResult>~', $result, $m)) $this->avs_result=$m[1];
793
  if(preg_match('~<AvsResultCode[^>]*>(.*)</AvsResultCode>~', $result, $m)) $this->avs_result_code=$m[1];
806
  if(preg_match('~<Result[^>]*>(.*)</Result>~', $result, $m)) $this->result=$m[1];
807
  if(preg_match('~<ResultCode[^>]*>(.*)</ResultCode>~', $result, $m)) $this->resultcode=$m[1];
808
  if(preg_match('~<VpasResultCode[^>]*>(.*)</VpasResultCode>~', $result, $m)) $this->vpas_result_code=$m[1];
 
809
 
810
+
811
+ // Store results
812
  if($this->resultcode == "A") return true;
813
  return false;
814
+ }
815
+
816
+
817
+
818
+
819
  function buildQuery($data)
820
  {
821
  //ueLogDebug("TranApi::buildQuery");
822
  if(function_exists('http_build_query') && ini_get('arg_separator.output')=='&') return http_build_query($data);
823
+
824
  $tmp=array();
825
  foreach($data as $key=>$val) $tmp[] = rawurlencode($key) . '=' . rawurlencode($val);
826
+
827
  return implode('&', $tmp);
828
+
829
  }
830
+
831
  function httpPost($url, $data)
832
+ {
833
  // if transport was not specified, auto select transport
834
  if(!$this->transport)
835
  {
841
  }
842
  }
843
  }
844
+
845
  // Use selected transport to post request to the gateway
846
  switch($this->transport)
847
  {
849
  case 'stream': return $this->httpPostPHP($url, $data);
850
  }
851
 
852
+
853
+
854
+ // No HTTPs libraries found, return error
855
  $this->result="Error";
856
  $this->resultcode="E";
857
  $this->error="Libary Error: SSL HTTPS support not found";
858
  $this->errorcode=10130;
859
+ return false;
860
  }
861
+
862
  function httpPostCurl($url, $data)
863
  {
864
+
865
  //init the connection
866
  $ch = curl_init($url);
867
  if(!is_resource($ch))
870
  $this->resultcode="E";
871
  $this->error="Libary Error: Unable to initialize CURL ($ch)";
872
  $this->errorcode=10131;
873
+ return false;
874
  }
875
+
876
  // set some options for the connection
877
  curl_setopt($ch,CURLOPT_HEADER, 1);
878
  curl_setopt($ch,CURLOPT_POST,1);
885
  curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
886
  curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
887
  }
888
+
889
  // apply custom ca bundle location
890
  if($this->cabundle)
891
+ {
892
+ curl_setopt($ch, CURLOPT_CAINFO, $this->cabundle);
893
  }
894
+
895
  // set proxy
896
  if($this->proxyurl)
897
  {
898
  curl_setopt ($ch, CURLOPT_PROXYTYPE, CURLPROXY_HTTP);
899
  curl_setopt ($ch, CURLOPT_PROXY, $this->proxyurl);
900
+ }
901
+
902
  $soapcall=false;
903
  if(is_array($data))
904
  {
905
  if(array_key_exists('xml',$data)) $soapcall=true;
906
  }
907
+
908
+
909
+
910
  if($soapcall)
911
  {
912
  curl_setopt($ch, CURLOPT_HTTPHEADER, array(
914
  "SoapAction: urn:ueSoapServerAction"
915
  ));
916
  curl_setopt($ch,CURLOPT_POSTFIELDS,$data['xml']);
917
+
918
  } else {
919
+ // rawurlencode data
920
+ $data = $this->buildQuery($data);
921
+
922
  // attach the data
923
  curl_setopt($ch,CURLOPT_POSTFIELDS,$data);
924
+ }
925
+
926
  // run the transfer
927
  $result=curl_exec ($ch);
928
+
929
  //get the result and parse it for the response line.
930
  if(!strlen($result))
931
  {
937
  $this->transporterror=$this->curlerror=curl_error($ch);
938
  // $this->_log('curl error: '.$this->curlerror, Zend_Log::ERR);
939
  curl_close ($ch);
940
+ return false;
941
  }
942
+
943
  curl_close ($ch);
944
  $this->rawresult=$result;
945
+
946
  if($soapcall) {
947
+ return $result;
948
  }
949
 
950
  if(!$result) {
952
  $this->resultcode="E";
953
  $this->error="Blank response from card processing gateway.";
954
  $this->errorcode=10132;
955
+ return false;
956
  }
957
+
958
  // result will be on the last line of the return
959
  $tmp=explode("\n",$result);
960
+ $result=$tmp[count($tmp)-1];
961
+
962
  return $result;
963
  }
964
+
965
  function httpPostPHP($url, $data)
966
  {
967
 
968
+
969
+ // rawurlencode data
970
+ $data = $this->buildQuery($data);
971
+
972
+ // set stream http options
973
  $options = array(
974
  'http'=> array(
975
  'method'=>'POST',
981
  ),
982
  'ssl' => array(
983
  'verify_peer' => ($this->ignoresslcerterrors?false:true),
984
+ 'allow_self_signed' => ($this->ignoresslcerterrors?true:false)
985
  )
986
  );
987
+
988
  if($this->cabundle) $options['ssl']['cafile'] = $this->cabundle;
989
+
990
  if(trim($this->proxyurl)) $options['http']['proxy'] = $this->proxyurl;
991
+
992
+
993
  // create stream context
994
  $context = stream_context_create($options);
995
+
996
  // post data to gateway
997
  $fd = fopen($url, 'r', null, $context);
998
  if(!$fd)
1009
  $this->transporterror=$GLOBALS['php_errormsg'];
1010
  }
1011
  //curl_close ($ch);
1012
+ return false;
1013
+ }
1014
+
1015
  // pull result
1016
  $result = stream_get_contents($fd);
1017
 
1024
  $this->errorcode=10132;
1025
  $this->blank=1;
1026
  fclose($fd);
1027
+ return false;
1028
+ }
1029
+
1030
  fclose($fd);
1031
  return $result;
1032
+
1033
  }
1034
 
1035
  function xmlentities($string)
1038
  $string = preg_replace_callback('/[^a-zA-Z0-9 _\-\.\'\r\n]/', array('self', '_xmlEntitesReplaceCallback'), $string);
1039
  return $string;
1040
  }
1041
+
1042
  static protected function _xmlEntitesReplaceCallback($matches)
1043
  {
1044
  return self::_uePrivateXMLEntities($matches[0]);
1071
  153 => '&#8482;',
1072
  154 => '&#353;',
1073
  155 => '&#8250;',
1074
+ 156 => '&#339;',
1075
+ 158 => '&#382;',
1076
  159 => '&#376;'
1077
  );
1078
  $num = ord($char);
1084
  { $chars = array(
1085
  128 => '&#8364;',
1086
  130 => '&#8218;',
1087
+ 131 => '&#402;',
1088
  132 => '&#8222;',
1089
  133 => '&#8230;',
1090
  134 => '&#8224;',
1091
  135 => '&#8225;',
1092
+ 136 => '&#710;',
1093
  137 => '&#8240;',
1094
+ 138 => '&#352;',
1095
  139 => '&#8249;',
1096
+ 140 => '&#338;',
1097
+ 142 => '&#381;',
1098
  145 => '&#8216;',
1099
  146 => '&#8217;',
1100
  147 => '&#8220;',
1102
  149 => '&#8226;',
1103
  150 => '&#8211;',
1104
  151 => '&#8212;',
1105
+ 152 => '&#732;',
1106
  153 => '&#8482;',
1107
+ 154 => '&#353;',
1108
  155 => '&#8250;',
1109
+ 156 => '&#339;',
1110
+ 158 => '&#382;',
1111
  159 => '&#376;');
1112
  $num = ord($num);
1113
  return (($num > 127 && $num < 160) ? $chars[$num] : "&#".$num.";" );
app/code/community/Mage/Usaepay/etc/config.xml CHANGED
@@ -2,41 +2,41 @@
2
  <!--
3
  /**
4
  * USA ePay Magento Plugin.
5
- * v1.1.4 - November 8th, 2013
6
- *
7
  * For assistance please contact devsupport@usaepay.com
8
- *
9
  * Copyright (c) 2010 USAePay
10
  * All rights reserved.
11
- *
12
- * Redistribution and use in source and binary forms, with or without
13
- * modification, are permitted provided that the following conditions
14
  * are met:
15
- *
16
- * - Redistributions of source code must retain the above copyright
17
  * notice, this list of conditions and the following disclaimer.
18
- * - Redistributions in binary form must reproduce the above
19
- * copyright notice, this list of conditions and the following
20
- * disclaimer in the documentation and/or other materials
21
  * provided with the distribution.
22
- * - Neither the name of the USAePay nor the names of its
23
- * contributors may be used to endorse or promote products
24
- * derived from this software without specific prior written
25
  * permission.
26
- *
27
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
28
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
29
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
30
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
31
- * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
32
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
33
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
34
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
35
- * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
36
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
37
- * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
38
  * POSSIBILITY OF SUCH DAMAGE.
39
- *
40
  * @category Mage
41
  * @package Mage_Usaepay_Block_Form
42
  * @copyright Copyright (c) 2010 USAePay (www.usaepay.com)
@@ -46,7 +46,7 @@
46
  <config>
47
  <modules>
48
  <Mage_Usaepay>
49
- <version>1.1.4</version>
50
  </Mage_Usaepay>
51
  </modules>
52
  <global>
2
  <!--
3
  /**
4
  * USA ePay Magento Plugin.
5
+ * v1.1.7 - December 19th, 2014
6
+ *
7
  * For assistance please contact devsupport@usaepay.com
8
+ *
9
  * Copyright (c) 2010 USAePay
10
  * All rights reserved.
11
+ *
12
+ * Redistribution and use in source and binary forms, with or without
13
+ * modification, are permitted provided that the following conditions
14
  * are met:
15
+ *
16
+ * - Redistributions of source code must retain the above copyright
17
  * notice, this list of conditions and the following disclaimer.
18
+ * - Redistributions in binary form must reproduce the above
19
+ * copyright notice, this list of conditions and the following
20
+ * disclaimer in the documentation and/or other materials
21
  * provided with the distribution.
22
+ * - Neither the name of the USAePay nor the names of its
23
+ * contributors may be used to endorse or promote products
24
+ * derived from this software without specific prior written
25
  * permission.
26
+ *
27
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
28
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
29
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
30
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
31
+ * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
32
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
33
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
34
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
35
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
36
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
37
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
38
  * POSSIBILITY OF SUCH DAMAGE.
39
+ *
40
  * @category Mage
41
  * @package Mage_Usaepay_Block_Form
42
  * @copyright Copyright (c) 2010 USAePay (www.usaepay.com)
46
  <config>
47
  <modules>
48
  <Mage_Usaepay>
49
+ <version>1.1.7</version>
50
  </Mage_Usaepay>
51
  </modules>
52
  <global>
app/code/community/Mage/Usaepay/etc/system.xml CHANGED
@@ -2,41 +2,41 @@
2
  <!--
3
  /**
4
  * USA ePay Magento Plugin.
5
-