Version Notes
Fixed compatibility with Credit Card module
Download this release
Release Info
Developer | Justin Slingerland |
Extension | BluePay_Echeck |
Version | 1.5.1.9 |
Comparing to | |
See all releases |
Code changes from version 1.5.1.8 to 1.5.1.9
app/code/local/BluePay/Echeck/Model/EcheckPayment_bikemania.php
ADDED
@@ -0,0 +1,480 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Magento
|
5 |
+
*
|
6 |
+
* NOTICE OF LICENSE
|
7 |
+
*
|
8 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
9 |
+
* that is bundled with this package in the file LICENSE.txt.
|
10 |
+
* It is also available through the world-wide-web at this URL:
|
11 |
+
* http://opensource.org/licenses/osl-3.0.php
|
12 |
+
* If you did not receive a copy of the license and are unable to
|
13 |
+
* obtain it through the world-wide-web, please send an email
|
14 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
15 |
+
*
|
16 |
+
* DISCLAIMER
|
17 |
+
*
|
18 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
19 |
+
* versions in the future. If you wish to customize Magento for your
|
20 |
+
* needs please refer to http://www.magentocommerce.com for more information.
|
21 |
+
*
|
22 |
+
* @category BluePay
|
23 |
+
* @package BluePay_Echeck
|
24 |
+
* @copyright Copyright (c) 2010 BluePay Processing, LLC (http://www.bluepay.com)
|
25 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
26 |
+
*/
|
27 |
+
|
28 |
+
class BluePay_Echeck_Model_EcheckPayment extends Mage_Paygate_Model_Authorizenet
|
29 |
+
{
|
30 |
+
|
31 |
+
const CGI_URL = 'https://secure.bluepay.com/interfaces/bp10emu';
|
32 |
+
const CURRENT_VERSION = '1.5.1.0';
|
33 |
+
|
34 |
+
|
35 |
+
const REQUEST_METHOD_CC = 'CREDIT';
|
36 |
+
const REQUEST_METHOD_ECHECK = 'ACH';
|
37 |
+
|
38 |
+
const REQUEST_TYPE_AUTH_CAPTURE = 'SALE';
|
39 |
+
const REQUEST_TYPE_AUTH_ONLY = 'AUTH';
|
40 |
+
const REQUEST_TYPE_CAPTURE_ONLY = 'CAPTURE';
|
41 |
+
const REQUEST_TYPE_CREDIT = 'CREDIT';
|
42 |
+
const REQUEST_TYPE_VOID = 'VOID';
|
43 |
+
const REQUEST_TYPE_PRIOR_AUTH_CAPTURE = 'PRIOR_AUTH_CAPTURE';
|
44 |
+
|
45 |
+
const ECHECK_ACCT_TYPE_CHECKING = 'CHECKING';
|
46 |
+
const ECHECK_ACCT_TYPE_BUSINESS = 'BUSINESSCHECKING';
|
47 |
+
const ECHECK_ACCT_TYPE_SAVINGS = 'SAVINGS';
|
48 |
+
|
49 |
+
const ECHECK_TRANS_TYPE_CCD = 'CCD';
|
50 |
+
const ECHECK_TRANS_TYPE_PPD = 'PPD';
|
51 |
+
const ECHECK_TRANS_TYPE_TEL = 'TEL';
|
52 |
+
const ECHECK_TRANS_TYPE_WEB = 'WEB';
|
53 |
+
|
54 |
+
const RESPONSE_DELIM_CHAR = ',';
|
55 |
+
|
56 |
+
const RESPONSE_CODE_APPROVED = 'APPROVED';
|
57 |
+
const RESPONSE_CODE_DECLINED = 'DECLINED';
|
58 |
+
const RESPONSE_CODE_ERROR = 'ERROR';
|
59 |
+
const RESPONSE_CODE_HELD = 4;
|
60 |
+
|
61 |
+
const INVOICE_ID = 0;
|
62 |
+
const BANK_NAME = 1;
|
63 |
+
const PAYMENT_ACCOUNT = 2;
|
64 |
+
const AUTH_CODE = 3;
|
65 |
+
const CARD_TYPE = 4;
|
66 |
+
const AMOUNT = 5;
|
67 |
+
const REBID = 6;
|
68 |
+
const AVS = 7;
|
69 |
+
const ORDER_ID = 8;
|
70 |
+
const CARD_EXPIRE = 9;
|
71 |
+
const Result = 10;
|
72 |
+
const RRNO = 11;
|
73 |
+
const CVV2 = 12;
|
74 |
+
const PAYMENT_TYPE = 13;
|
75 |
+
const MESSAGE = 14;
|
76 |
+
|
77 |
+
protected $responseHeaders;
|
78 |
+
|
79 |
+
protected $_code = 'echeckpayment';
|
80 |
+
protected $_formBlockType = 'echeck/form';
|
81 |
+
protected $_infoBlockType = 'echeck/info_echeck';
|
82 |
+
/**
|
83 |
+
* Availability options
|
84 |
+
*/
|
85 |
+
protected $_isGateway = true;
|
86 |
+
protected $_canAuthorize = true;
|
87 |
+
protected $_canCapture = true;
|
88 |
+
protected $_canCapturePartial = true;
|
89 |
+
protected $_canRefund = true;
|
90 |
+
protected $_canVoid = true;
|
91 |
+
protected $_canUseInternal = true;
|
92 |
+
protected $_canUseCheckout = true;
|
93 |
+
protected $_canUseForMultishipping = true;
|
94 |
+
protected $_canSaveCc = false;
|
95 |
+
|
96 |
+
public function authorize(Varien_Object $payment, $amount)
|
97 |
+
{
|
98 |
+
Mage::throwException(Mage::helper('echeck')->__('Error:'));
|
99 |
+
if ($amount <= 0) {
|
100 |
+
Mage::throwException(Mage::helper('paygate')->__('Invalid amount for authorization.'));
|
101 |
+
}
|
102 |
+
$payment->setTransactionType(self::REQUEST_TYPE_AUTH_CAPTURE);
|
103 |
+
$payment->setAmount($amount);
|
104 |
+
|
105 |
+
$request= $this->_buildRequest($payment);
|
106 |
+
$result = $this->_postRequest($request);
|
107 |
+
|
108 |
+
$payment->setCcApproval($result->getAuthCode())
|
109 |
+
->setLastTransId($result->getRrno())
|
110 |
+
->setTransactionId($result->getRrno())
|
111 |
+
->setIsTransactionClosed(0)
|
112 |
+
->setCcTransId($result->getRrno())
|
113 |
+
->setCcAvsStatus($result->getAvs())
|
114 |
+
->setCcCidStatus($result->getCvv2());
|
115 |
+
switch ($result->getResult()) {
|
116 |
+
case self::RESPONSE_CODE_APPROVED:
|
117 |
+
$payment->setStatus(self::STATUS_APPROVED);
|
118 |
+
Mage::throwException(Mage::helper('echeck')->__('Error: ' . $result->getMessage()));
|
119 |
+
return $this;
|
120 |
+
case self::RESPONSE_CODE_DECLINED:
|
121 |
+
Mage::throwException(Mage::helper('echeck')->__('The transaction has been declined'));
|
122 |
+
case self::RESPONSE_CODE_ERROR:
|
123 |
+
Mage::throwException(Mage::helper('echeck')->__('Error: ' . $result->getMessage()));
|
124 |
+
default:
|
125 |
+
Mage::throwException(Mage::helper('echeck')->__('Error!'));
|
126 |
+
}
|
127 |
+
}
|
128 |
+
|
129 |
+
|
130 |
+
public function capture(Varien_Object $payment, $amount)
|
131 |
+
{
|
132 |
+
$error = false;
|
133 |
+
$payment->setTransactionType(self::REQUEST_TYPE_AUTH_CAPTURE);
|
134 |
+
$payment->setAmount($amount);
|
135 |
+
|
136 |
+
$request= $this->_buildRequest($payment);
|
137 |
+
$result = $this->_postRequest($request);
|
138 |
+
if ($result->getResult() == self::RESPONSE_CODE_APPROVED) {
|
139 |
+
$payment->setStatus(self::STATUS_APPROVED);
|
140 |
+
$payment->setLastTransId($result->getRrno())
|
141 |
+
->setTransactionId($result->getRrno());
|
142 |
+
return $this;
|
143 |
+
}
|
144 |
+
if ($result->getMessage()) {
|
145 |
+
Mage::throwException($this->_wrapGatewayError($result->getMessage()));
|
146 |
+
}
|
147 |
+
//Mage::throwException(Mage::helper('echeck')->__('Error in capturing the payment.'));
|
148 |
+
if ($error !== false) {
|
149 |
+
Mage::throwException($error);
|
150 |
+
}
|
151 |
+
}
|
152 |
+
|
153 |
+
public function void(Varien_Object $payment)
|
154 |
+
{
|
155 |
+
$error = false;
|
156 |
+
if($payment->getParentTransactionId()){
|
157 |
+
$payment->setTransactionType(self::REQUEST_TYPE_CREDIT);
|
158 |
+
$request = $this->_buildRequest($payment);
|
159 |
+
$result = $this->_postRequest($request);
|
160 |
+
if($result->getResult()==self::RESPONSE_CODE_APPROVED){
|
161 |
+
$payment->setStatus(self::STATUS_SUCCESS );
|
162 |
+
$order->setState(Mage_Sales_Model_Order::STATE_CANCELED, true)->save();
|
163 |
+
return $this;
|
164 |
+
}
|
165 |
+
$payment->setStatus(self::STATUS_ERROR);
|
166 |
+
Mage::throwException($this->_wrapGatewayError($result->getMessage()));
|
167 |
+
}
|
168 |
+
$payment->setStatus(self::STATUS_ERROR);
|
169 |
+
Mage::throwException(Mage::helper('echeck')->__('Invalid transaction ID.'));
|
170 |
+
}
|
171 |
+
|
172 |
+
public function refund(Varien_Object $payment, $amount)
|
173 |
+
{
|
174 |
+
if ($payment->getRefundTransactionId() && $amount > 0) {
|
175 |
+
$payment->setTransactionType(self::REQUEST_TYPE_CREDIT);
|
176 |
+
$payment->setRrno($payment->getRefundTransactionId());
|
177 |
+
$payment->setAmount($amount);
|
178 |
+
$request = $this->_buildRequest($payment);
|
179 |
+
$request->setRrno($payment->getRefundTransactionId());
|
180 |
+
$result = $this->_postRequest($request);
|
181 |
+
if ($result->getResult()==self::RESPONSE_CODE_APPROVED) {
|
182 |
+
$payment->setStatus(self::STATUS_SUCCESS);
|
183 |
+
return $this;
|
184 |
+
}
|
185 |
+
if ($result->getResult()==self::RESPONSE_CODE_DECLINED) {
|
186 |
+
Mage::throwException($this->_wrapGatewayError('DECLINED'));
|
187 |
+
}
|
188 |
+
if ($result->getResult()==self::RESPONSE_CODE_ERROR) {
|
189 |
+
Mage::throwException($this->_wrapGatewayError('ERROR'));
|
190 |
+
}
|
191 |
+
Mage::throwException($this->_wrapGatewayError($result->getRrno()));
|
192 |
+
}
|
193 |
+
Mage::throwException(Mage::helper('echeck')->__('Error in refunding the payment.'));
|
194 |
+
}
|
195 |
+
|
196 |
+
protected function _buildRequest(Varien_Object $payment)
|
197 |
+
{
|
198 |
+
$order = $payment->getOrder();
|
199 |
+
|
200 |
+
$this->setStore($order->getStoreId());
|
201 |
+
|
202 |
+
if (!$payment->getPaymentType()) {
|
203 |
+
$payment->setPaymentType(self::REQUEST_METHOD_ECHECK);
|
204 |
+
}
|
205 |
+
$payment->setPaymentType(self::REQUEST_METHOD_ECHECK);
|
206 |
+
$request = Mage::getModel('echeck/EcheckPayment_request');
|
207 |
+
|
208 |
+
if ($order && $order->getIncrementId()) {
|
209 |
+
$request->setInvoiceID($order->getIncrementId());
|
210 |
+
}
|
211 |
+
|
212 |
+
$request->setMode(($this->getConfigData('test_mode') == 'TEST') ? 'TEST' : 'LIVE');
|
213 |
+
$request->setMerchant($this->getConfigData('login'))
|
214 |
+
->setTransactionType($payment->getTransactionType())
|
215 |
+
->setPaymentType($payment->getPaymentType())
|
216 |
+
->setTamperProofSeal($this->calcTPS($payment));
|
217 |
+
if($payment->getAmount()){
|
218 |
+
$request->setAmount($payment->getAmount(),2);
|
219 |
+
}
|
220 |
+
switch ($payment->getTransactionType()) {
|
221 |
+
case self::REQUEST_TYPE_CREDIT:
|
222 |
+
case self::REQUEST_TYPE_VOID:
|
223 |
+
case self::REQUEST_TYPE_CAPTURE_ONLY:
|
224 |
+
$request->setRrno($payment->getCcTransId());
|
225 |
+
break;
|
226 |
+
}
|
227 |
+
$cart = Mage::helper('checkout/cart')->getCart()->getItemsCount();
|
228 |
+
$cartSummary = Mage::helper('checkout/cart')->getCart()->getSummaryQty();
|
229 |
+
Mage::getSingleton('core/session', array('name'=>'frontend'));
|
230 |
+
$session = Mage::getSingleton('checkout/session');
|
231 |
+
|
232 |
+
$comment = "";
|
233 |
+
|
234 |
+
foreach ($session->getQuote()->getAllItems() as $item) {
|
235 |
+
|
236 |
+
$comment .= $item->getQty() . ' ';
|
237 |
+
$comment .= '[' . $item->getSku() . ']' . ' ';
|
238 |
+
$comment .= $item->getName() . ' ';
|
239 |
+
$comment .= $item->getDescription() . ' ';
|
240 |
+
$comment .= $item->getBaseCalculationPrice . ' ';
|
241 |
+
}
|
242 |
+
|
243 |
+
|
244 |
+
if (!empty($order)) {
|
245 |
+
$billing = $order->getBillingAddress();
|
246 |
+
if (!empty($billing)) {
|
247 |
+
$request->setName1($billing->getFirstname())
|
248 |
+
->setName2($billing->getLastname())
|
249 |
+
->setCompany($billing->getCompany())
|
250 |
+
->setAddr1($billing->getStreet(1))
|
251 |
+
->setCity($billing->getCity())
|
252 |
+
->setState($billing->getRegion())
|
253 |
+
->setZipcode($billing->getPostcode())
|
254 |
+
->setCountry($billing->getCountry())
|
255 |
+
->setPhone($billing->getTelephone())
|
256 |
+
->setFax($billing->getFax())
|
257 |
+
->setCustomId($billing->getCustomerId())
|
258 |
+
->setComment($comment)
|
259 |
+
->setEmail($order->getCustomerEmail());
|
260 |
+
}
|
261 |
+
}
|
262 |
+
|
263 |
+
switch ($payment->getPaymentType()) {
|
264 |
+
case self::REQUEST_METHOD_ECHECK:
|
265 |
+
$request->setAchRouting($payment->getEcheckRoutingNumber())
|
266 |
+
->setAchAccount($payment->getEcheckBankAcctNum())
|
267 |
+
->setAchAccountType($payment->getEcheckAccountType())
|
268 |
+
->setName($payment->getEcheckAccountName())
|
269 |
+
->setDocType(self::ECHECK_TRANS_TYPE_CCD);
|
270 |
+
break;
|
271 |
+
}
|
272 |
+
return $request;
|
273 |
+
}
|
274 |
+
|
275 |
+
protected function _postRequest(Varien_Object $request)
|
276 |
+
{
|
277 |
+
$debugData = array('request' => $request->getData());
|
278 |
+
|
279 |
+
$result = Mage::getModel('echeck/EcheckPayment_result');
|
280 |
+
if (isset($_POST["?Result"])) {
|
281 |
+
$_POST["Result"] = $_POST["?Result"];
|
282 |
+
unset($_POST["?Result"]);
|
283 |
+
}
|
284 |
+
if (!isset($_POST["Result"])) {
|
285 |
+
$client = new Varien_Http_Client();
|
286 |
+
|
287 |
+
$uri = $this->getConfigData('cgi_url');
|
288 |
+
$client->setUri(self::CGI_URL);
|
289 |
+
$client->setConfig(array(
|
290 |
+
'maxredirects'=>0,
|
291 |
+
'timeout'=>30,
|
292 |
+
'useragent' => 'BluePay Magento ACH Plugin/' . self::CURRENT_VERSION,
|
293 |
+
));
|
294 |
+
$client->setParameterPost($request->getData());
|
295 |
+
$client->setMethod(Zend_Http_Client::POST);
|
296 |
+
|
297 |
+
try {
|
298 |
+
$response = $client->request();
|
299 |
+
}
|
300 |
+
catch (Exception $e) {
|
301 |
+
$debugData['result'] = $result->getData();
|
302 |
+
$this->_debug($debugData);
|
303 |
+
Mage::throwException($this->_wrapGatewayError($e->getMessage()));
|
304 |
+
}
|
305 |
+
$r = $response->getHeader('location');
|
306 |
+
if ($r) {
|
307 |
+
$result->setResult($this->parseHeader($r, 'value', self::Result))
|
308 |
+
->setInvoiceId($this->parseHeader($r, 'value', self::INVOICE_ID))
|
309 |
+
->setMessage($this->parseHeader($r, 'value', self::MESSAGE))
|
310 |
+
->setAuthCode($this->parseHeader($r, 'value', self::AUTH_CODE))
|
311 |
+
->setAvs($this->parseHeader($r, 'value', self::AVS))
|
312 |
+
->setRrno($this->parseHeader($r, 'value', self::RRNO))
|
313 |
+
->setAmount($this->parseHeader($r, 'value', self::AMOUNT))
|
314 |
+
->setPaymentType($this->parseHeader($r, 'value', self::PAYMENT_TYPE))
|
315 |
+
->setOrderId($this->parseHeader($r, 'value', self::ORDER_ID))
|
316 |
+
->setCvv2($this->parseHeader($r, 'value', self::CVV2));
|
317 |
+
if($this->parseHeader($r, 'value', 0) == "ERROR") {
|
318 |
+
Mage::throwException($this->_wrapGatewayError($this->parseHeader($r, 'value', 1)));
|
319 |
+
}
|
320 |
+
} else {
|
321 |
+
Mage::throwException(
|
322 |
+
Mage::helper('echeck')->__('Error in payment gateway.')
|
323 |
+
);
|
324 |
+
}
|
325 |
+
$debugData['result'] = $result->getData();
|
326 |
+
$this->_debug($debugData);
|
327 |
+
} else {
|
328 |
+
$result->setResult($_POST["Result"]);
|
329 |
+
$result->setMessage($_POST["MESSAGE"]);
|
330 |
+
}
|
331 |
+
return $result;
|
332 |
+
}
|
333 |
+
|
334 |
+
public function validateRoutingNumber($routingNumber) {
|
335 |
+
$routingNumber = preg_replace('[\D]', '', $routingNumber); //only digits
|
336 |
+
if(strlen($routingNumber) != 9) {
|
337 |
+
return false;
|
338 |
+
}
|
339 |
+
|
340 |
+
$checkSum = 0;
|
341 |
+
for ($i = 0, $j = strlen($routingNumber); $i < $j; $i+= 3 ) {
|
342 |
+
//loop through routingNumber character by character
|
343 |
+
$checkSum += ($routingNumber[$i] * 3);
|
344 |
+
$checkSum += ($routingNumber[$i+1] * 7);
|
345 |
+
$checkSum += ($routingNumber[$i+2]);
|
346 |
+
}
|
347 |
+
|
348 |
+
if($checkSum != 0 and ($checkSum % 10) == 0) {
|
349 |
+
return true;
|
350 |
+
} else {
|
351 |
+
return false;
|
352 |
+
}
|
353 |
+
}
|
354 |
+
|
355 |
+
|
356 |
+
public function validate()
|
357 |
+
{
|
358 |
+
$paymentInfo = $this->getInfoInstance();
|
359 |
+
if(strlen($paymentInfo->getCcType()))
|
360 |
+
{
|
361 |
+
$paymentInfo = $this->unmapData($paymentInfo);
|
362 |
+
}
|
363 |
+
|
364 |
+
if ($paymentInfo instanceof Mage_Sales_Model_Order_Payment) {
|
365 |
+
$billingCountry = $paymentInfo->getOrder()->getBillingAddress()->getCountryId();
|
366 |
+
} else {
|
367 |
+
$billingCountry = $paymentInfo->getQuote()->getBillingAddress()->getCountryId();
|
368 |
+
}
|
369 |
+
if (!$this->canUseForCountry($billingCountry)) {
|
370 |
+
Mage::throwException($this->_getHelper()->__('Selected payment type is not allowed for billing country.'));
|
371 |
+
}
|
372 |
+
|
373 |
+
$info = $this->getInfoInstance();
|
374 |
+
$errorMsg = false;
|
375 |
+
$availableTypes = explode(',',$this->getConfigData('accounttypes'));
|
376 |
+
|
377 |
+
$accountType = '';
|
378 |
+
|
379 |
+
if (!in_array($info->getEcheckAccountType(), $availableTypes))
|
380 |
+
{
|
381 |
+
$errorCode = 'echeck_account_type';
|
382 |
+
$errorMsg = $this->_getHelper()->__('Account type is not allowed for this payment method '. $info->getAccountType());
|
383 |
+
}
|
384 |
+
$errorMsg = (!$this->validateRoutingNumber($info->getEcheckRoutingNumber())) ? 'Invalid Routing Number entered.' : $errorMsg;
|
385 |
+
$errorMsg = (!is_numeric($info->getEcheckBankAcctNum())) ? 'Invalid Account Number entered.' : $errorMsg;
|
386 |
+
if($errorMsg && $this->getConfigData('use_iframe') == '0')
|
387 |
+
{
|
388 |
+
Mage::throwException($errorMsg);
|
389 |
+
}
|
390 |
+
return $this;
|
391 |
+
}
|
392 |
+
|
393 |
+
public function getInfoInstance()
|
394 |
+
{
|
395 |
+
$instance = $this->getData('info_instance');
|
396 |
+
return $instance;
|
397 |
+
}
|
398 |
+
|
399 |
+
public function assignData($data)
|
400 |
+
{
|
401 |
+
if (!($data instanceof Varien_Object)) {
|
402 |
+
$data = new Varien_Object($data);
|
403 |
+
}
|
404 |
+
$data->setEcheckBankAcctNum4(substr($data->getEcheckBankAcctNum(), -4));
|
405 |
+
$info = $this->getInfoInstance();
|
406 |
+
$info->setEcheckRoutingNumber($data->getEcheckRoutingNumber())
|
407 |
+
->setEcheckBankName($data->getEcheckBankName())
|
408 |
+
->setData('echeck_account_type', $data->getEcheckAccountType())
|
409 |
+
->setEcheckAccountName($data->getEcheckAccountName())
|
410 |
+
->setEcheckBankAcctNum($data->getEcheckBankAcctNum())
|
411 |
+
->setEcheckBankAcctNum4($data->getEcheckBankAcctNum4());
|
412 |
+
|
413 |
+
$this->mapData($data);
|
414 |
+
return $this;
|
415 |
+
}
|
416 |
+
|
417 |
+
public function mapData($data)
|
418 |
+
{
|
419 |
+
if (!($data instanceof Varien_Object)) {
|
420 |
+
$data = new Varien_Object($data);
|
421 |
+
}
|
422 |
+
$info = $this->getInfoInstance();
|
423 |
+
$info->setCcLast4($data->getEcheckRoutingNumber())
|
424 |
+
->setCcNumberEnc($data->getEcheckBankName())
|
425 |
+
->setCcType($data->getEcheckAccountType())
|
426 |
+
->setCcOwner($data->getEcheckAccountName())
|
427 |
+
->setCcSsIssue($data->getEcheckBankAcctNum())
|
428 |
+
->setCcSsOwner($data->getEcheckBankAcctNum4());
|
429 |
+
}
|
430 |
+
|
431 |
+
public function unmapData($info)
|
432 |
+
{
|
433 |
+
$info->setEcheckRoutingNumber($info->getCcLast4())
|
434 |
+
->setEcheckBankName($info->getCcNumberEnc())
|
435 |
+
->setEcheckAccountType($info->getCcType())
|
436 |
+
->setEcheckAccountName($info->getCcOwner())
|
437 |
+
->setEcheckBankAcctNum($info->getCcSsIssue())
|
438 |
+
->setEcheckBankAcctNum4($info->getCcSsOwner());
|
439 |
+
return $info;
|
440 |
+
}
|
441 |
+
|
442 |
+
public function prepareSave()
|
443 |
+
{
|
444 |
+
$info = $this->getInfoInstance();
|
445 |
+
$info->setCcSsIssue(null);
|
446 |
+
return $this;
|
447 |
+
}
|
448 |
+
|
449 |
+
public function isAvailable($quote = null){
|
450 |
+
$checkResult = new StdClass;
|
451 |
+
$checkResult->isAvailable = (bool)(int)$this->getConfigData('active', ($quote ? $quote->getStoreId() : null));
|
452 |
+
Mage::dispatchEvent('payment_method_is_active', array(
|
453 |
+
'result' => $checkResult,
|
454 |
+
'method_instance' => $this,
|
455 |
+
'quote' => $quote,
|
456 |
+
));
|
457 |
+
return $checkResult->isAvailable;
|
458 |
+
}
|
459 |
+
|
460 |
+
protected final function calcTPS(Varien_Object $payment) {
|
461 |
+
|
462 |
+
$order = $payment->getOrder();
|
463 |
+
$billing = $order->getBillingAddress();
|
464 |
+
|
465 |
+
$hashstr = $this->getConfigData('trans_key') . $this->getConfigData('login') .
|
466 |
+
$payment->getTransactionType() . $payment->getAmount() . $payment->getRrno() .
|
467 |
+
$this->getConfigData('test_mode');
|
468 |
+
|
469 |
+
return bin2hex( md5($hashstr, true) );
|
470 |
+
}
|
471 |
+
|
472 |
+
protected function parseHeader($header, $nameVal, $pos) {
|
473 |
+
$nameVal = ($nameVal == 'name') ? '0' : '1';
|
474 |
+
$s = explode("?", $header);
|
475 |
+
$t = explode("&", $s[1]);
|
476 |
+
$value = explode("=", $t[$pos]);
|
477 |
+
return $value[$nameVal];
|
478 |
+
}
|
479 |
+
|
480 |
+
}
|
app/design/frontend/base/default/template/bluepay/echeck_form.phtml
CHANGED
@@ -2,7 +2,9 @@
|
|
2 |
if ((Mage::getSingleton('checkout/session')->getQuote()->getPayment()->getMethod() == 'echeckpayment' &&
|
3 |
Mage::getStoreConfig('payment/echeckpayment/use_iframe') == '0') ||
|
4 |
(Mage::getSingleton('checkout/session')->getQuote()->getPayment()->getMethod() == 'ccpayment' &&
|
5 |
-
Mage::getStoreConfig('payment/ccpayment/use_iframe') == '0')
|
|
|
|
|
6 |
return false;
|
7 |
$_initial = true;
|
8 |
$_form = $this;
|
2 |
if ((Mage::getSingleton('checkout/session')->getQuote()->getPayment()->getMethod() == 'echeckpayment' &&
|
3 |
Mage::getStoreConfig('payment/echeckpayment/use_iframe') == '0') ||
|
4 |
(Mage::getSingleton('checkout/session')->getQuote()->getPayment()->getMethod() == 'ccpayment' &&
|
5 |
+
Mage::getStoreConfig('payment/ccpayment/use_iframe') == '0') ||
|
6 |
+
((Mage::getSingleton('checkout/session')->getQuote()->getPayment()->getMethod() != 'echeckpayment') &&
|
7 |
+
(Mage::getSingleton('checkout/session')->getQuote()->getPayment()->getMethod() != 'ccpayment')))
|
8 |
return false;
|
9 |
$_initial = true;
|
10 |
$_form = $this;
|
package.xml
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>BluePay_Echeck</name>
|
4 |
-
<version>1.5.1.
|
5 |
<stability>stable</stability>
|
6 |
<license>GNU General Public License</license>
|
7 |
<channel>community</channel>
|
@@ -10,9 +10,9 @@
|
|
10 |
<description>Echeck payment module for the BluePay gateway.</description>
|
11 |
<notes>Fixed compatibility with Credit Card module</notes>
|
12 |
<authors><author><name>Justin Slingerland</name><user>jslingerland</user><email>jslingerland@bluepay.com</email></author></authors>
|
13 |
-
<date>2014-09-
|
14 |
-
<time>
|
15 |
-
<contents><target name="mageetc"><dir name="modules"><file name="BluePay_Echeck.xml" hash="252f244ae4f8cba53f883559a23273c7"/></dir></target><target name="mageweb"><dir name="js"><dir name="bluepay_echeck"><file name="bluepay.js" hash="61932dea7f7b14192d33408ad829c3b0"/><dir name="easyXDM"><file name="easyXDM.Widgets.debug.js" hash="26b23561d39a64b926fe8dafea2f0a7b"/><file name="easyXDM.Widgets.js" hash="26b23561d39a64b926fe8dafea2f0a7b"/><file name="easyXDM.Widgets.min.js" hash="790f5fa04af75a8013d0ff5fd6dc770d"/><file name="easyXDM.debug.js" hash="2f74fa97b0aacdfb5e8570e381465905"/><file name="easyXDM.js" hash="499464a0c3d89679c11df6ee5d188df5"/><file name="easyXDM.min.js" hash="e3fd912457d7213fe5ccae7bf0fd0c82"/><file name="name.html" hash="990620350432f6c7e28f1e111ce598c8"/><file name=".gitignore" hash="f256c78995e7e95eb33afc3cee8ff195"/></dir></dir></dir></target><target name="magelocal"><dir name="BluePay"><dir name="Echeck"><dir name="Block"><dir name="Form"><file name="Echeck.php" hash="9ff5f7eb3301d8f049a853a556e6f0c9"/></dir><file name="Form.php" hash="e8219ff37abcb6640857c4f19deb7bdb"/><dir name="Info"><file name="Echeck.php" hash="967c7f583f10f449154a77315029647b"/></dir><file name="Info.php" hash="de65c278c010d85d67e5b1ae031a1c28"/></dir><dir name="Helper"><file name="Data.php" hash="8f64e111734ce162a0d0b28ebad1db90"/></dir><dir name="Model"><file name="Config.php" hash="94567f95c4463897ba822ca1c61dca7a"/><dir name="EcheckPayment"><file name="Debug.php" hash="76d8cb6c86a595b2b78d43664c6dd6e8"/><file name="Request.php" hash="0a65c3aae69eb0c196231cbf6f007cec"/><file name="Result.php" hash="6935ba845811c005b9c501a03891e33a"/><dir name="Source"><file name="Accounttypes.php" hash="3c8b8034d6c96b0280db4e7e595ab73c"/><file name="PaymentAction.php" hash="9da2c6580cfd6d611c207e5be3b2aea5"/></dir></dir><file name="EcheckPayment.php" hash="196bd8ef164582af39a56c73416ff9b2"/><dir name="Mysql4"><dir name="ECheckPayment"><dir name="Debug"><file name="Collection.php" hash="aa8222f78f17b4c35050c9d06dc085bc"/></dir><file name="Debug.php" hash="829e050092ffb527e08a6a9d9959374a"/></dir></dir></dir><dir name="etc"><file name="config.xml" hash="bf862e0ba158cebf78b785c98cfdca3e"/><file name="system.xml" hash="b68b53fb8a301bc3f21b0cd0bd788ba1"/></dir><dir name="sql"><dir name="echeck_setup"><file name="mysql4-install-0.7.0.php" hash="8a9c16edd149e1e41c4015aeebb35892"/></dir></dir></dir></dir></target><target name="magecore"><dir name="Mage"><dir name="Adminhtml"><dir name="Model"><dir name="System"><dir name="Config"><dir name="Source"><file name="TestmodeACH.php" hash="371db79c030d69b3b19fc4caac4e7ba0"/></dir></dir></dir></dir></dir></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="bluepay_echeck.xml" hash="4d1a4de9be145ce19db6b28c2cac81e7"/></dir><dir name="template"><dir name="bluepay"><file name="echeck.phtml" hash="2aad3205d674d1dd77b12b55e1d0c49b"/><file name="echeck_form.phtml" hash="
|
16 |
<compatible/>
|
17 |
<dependencies><required><php><min>5.3.0</min><max>5.6.9</max></php></required></dependencies>
|
18 |
</package>
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>BluePay_Echeck</name>
|
4 |
+
<version>1.5.1.9</version>
|
5 |
<stability>stable</stability>
|
6 |
<license>GNU General Public License</license>
|
7 |
<channel>community</channel>
|
10 |
<description>Echeck payment module for the BluePay gateway.</description>
|
11 |
<notes>Fixed compatibility with Credit Card module</notes>
|
12 |
<authors><author><name>Justin Slingerland</name><user>jslingerland</user><email>jslingerland@bluepay.com</email></author></authors>
|
13 |
+
<date>2014-09-26</date>
|
14 |
+
<time>19:49:33</time>
|
15 |
+
<contents><target name="mageetc"><dir name="modules"><file name="BluePay_Echeck.xml" hash="252f244ae4f8cba53f883559a23273c7"/></dir></target><target name="mageweb"><dir name="js"><dir name="bluepay_echeck"><file name="bluepay.js" hash="61932dea7f7b14192d33408ad829c3b0"/><dir name="easyXDM"><file name="easyXDM.Widgets.debug.js" hash="26b23561d39a64b926fe8dafea2f0a7b"/><file name="easyXDM.Widgets.js" hash="26b23561d39a64b926fe8dafea2f0a7b"/><file name="easyXDM.Widgets.min.js" hash="790f5fa04af75a8013d0ff5fd6dc770d"/><file name="easyXDM.debug.js" hash="2f74fa97b0aacdfb5e8570e381465905"/><file name="easyXDM.js" hash="499464a0c3d89679c11df6ee5d188df5"/><file name="easyXDM.min.js" hash="e3fd912457d7213fe5ccae7bf0fd0c82"/><file name="name.html" hash="990620350432f6c7e28f1e111ce598c8"/><file name=".gitignore" hash="f256c78995e7e95eb33afc3cee8ff195"/></dir></dir></dir></target><target name="magelocal"><dir name="BluePay"><dir name="Echeck"><dir name="Block"><dir name="Form"><file name="Echeck.php" hash="9ff5f7eb3301d8f049a853a556e6f0c9"/></dir><file name="Form.php" hash="e8219ff37abcb6640857c4f19deb7bdb"/><dir name="Info"><file name="Echeck.php" hash="967c7f583f10f449154a77315029647b"/></dir><file name="Info.php" hash="de65c278c010d85d67e5b1ae031a1c28"/></dir><dir name="Helper"><file name="Data.php" hash="8f64e111734ce162a0d0b28ebad1db90"/></dir><dir name="Model"><file name="Config.php" hash="94567f95c4463897ba822ca1c61dca7a"/><dir name="EcheckPayment"><file name="Debug.php" hash="76d8cb6c86a595b2b78d43664c6dd6e8"/><file name="Request.php" hash="0a65c3aae69eb0c196231cbf6f007cec"/><file name="Result.php" hash="6935ba845811c005b9c501a03891e33a"/><dir name="Source"><file name="Accounttypes.php" hash="3c8b8034d6c96b0280db4e7e595ab73c"/><file name="PaymentAction.php" hash="9da2c6580cfd6d611c207e5be3b2aea5"/></dir></dir><file name="EcheckPayment.php" hash="196bd8ef164582af39a56c73416ff9b2"/><file name="EcheckPayment_bikemania.php" hash="a692b0062ebdc014ca347ab15a3a84e5"/><dir name="Mysql4"><dir name="ECheckPayment"><dir name="Debug"><file name="Collection.php" hash="aa8222f78f17b4c35050c9d06dc085bc"/></dir><file name="Debug.php" hash="829e050092ffb527e08a6a9d9959374a"/></dir></dir></dir><dir name="etc"><file name="config.xml" hash="bf862e0ba158cebf78b785c98cfdca3e"/><file name="system.xml" hash="b68b53fb8a301bc3f21b0cd0bd788ba1"/></dir><dir name="sql"><dir name="echeck_setup"><file name="mysql4-install-0.7.0.php" hash="8a9c16edd149e1e41c4015aeebb35892"/></dir></dir></dir></dir></target><target name="magecore"><dir name="Mage"><dir name="Adminhtml"><dir name="Model"><dir name="System"><dir name="Config"><dir name="Source"><file name="TestmodeACH.php" hash="371db79c030d69b3b19fc4caac4e7ba0"/></dir></dir></dir></dir></dir></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="bluepay_echeck.xml" hash="4d1a4de9be145ce19db6b28c2cac81e7"/></dir><dir name="template"><dir name="bluepay"><file name="echeck.phtml" hash="2aad3205d674d1dd77b12b55e1d0c49b"/><file name="echeck_form.phtml" hash="56bc0ad6f3ae4a5be03febd87d4b74e9"/><file name="echeck_iframe.phtml" hash="59436bef6158dbd19d81daf8dcdfd157"/><file name="buttonach.phtml" hash="544c43035f36042b75b96887b19d3f37"/><file name="echeck_inforeview.phtml" hash="0d29af5174235ded956fea6e92302a54"/></dir></dir></dir></dir></dir><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="template"><dir name="bluepay"><file name="echeck.phtml" hash="b2e6165c19e46e361bebc671010f7d07"/></dir></dir></dir></dir></dir></target></contents>
|
16 |
<compatible/>
|
17 |
<dependencies><required><php><min>5.3.0</min><max>5.6.9</max></php></required></dependencies>
|
18 |
</package>
|