MagCheck - Version 0.0.7.0

Version Notes

E-Check payment module to be used with a MagCheck gateway account.

Download this release

Release Info

Developer Magento Core Team
Extension MagCheck
Version 0.0.7.0
Comparing to
See all releases


Version 0.0.7.0

Files changed (30) hide show
  1. app/code/core/Mage/Adminhtml/Model/System/Config/Backend/BankOfFirstDepositAccountNumber.php +1 -0
  2. app/code/core/Mage/Adminhtml/Model/System/Config/Backend/BankOfFirstDepositName.php +12 -0
  3. app/code/core/Mage/Adminhtml/Model/System/Config/Backend/BankOfFirstDepositRoutingNumber.php +1 -0
  4. app/code/core/Mage/Adminhtml/Model/System/Config/Backend/ReturningRoutingNumber.php +1 -0
  5. app/code/core/Mage/Adminhtml/Model/System/Config/Source/Order/Status/Processingcomplete.php +40 -0
  6. app/code/core/Mage/Adminhtml/Model/System/Config/Source/TestmodeACH.php +47 -0
  7. app/code/local/MagCheck/Echeck/Block/Form.php +53 -0
  8. app/code/local/MagCheck/Echeck/Block/Form/Echeck.php +57 -0
  9. app/code/local/MagCheck/Echeck/Block/Info.php +55 -0
  10. app/code/local/MagCheck/Echeck/Block/Info/Echeck.php +80 -0
  11. app/code/local/MagCheck/Echeck/Helper/Data.php +31 -0
  12. app/code/local/MagCheck/Echeck/Model/Config.php +71 -0
  13. app/code/local/MagCheck/Echeck/Model/EcheckPayment.php +687 -0
  14. app/code/local/MagCheck/Echeck/Model/EcheckPayment/Debug.php +34 -0
  15. app/code/local/MagCheck/Echeck/Model/EcheckPayment/Request.php +31 -0
  16. app/code/local/MagCheck/Echeck/Model/EcheckPayment/Result.php +31 -0
  17. app/code/local/MagCheck/Echeck/Model/EcheckPayment/Source/Accounttypes.php +51 -0
  18. app/code/local/MagCheck/Echeck/Model/EcheckPayment/Source/PaymentAction.php +39 -0
  19. app/code/local/MagCheck/Echeck/Model/Mysql4/ECheckPayment/Debug.php +34 -0
  20. app/code/local/MagCheck/Echeck/Model/Mysql4/ECheckPayment/Debug/Collection.php +34 -0
  21. app/code/local/MagCheck/Echeck/etc/config.xml +119 -0
  22. app/code/local/MagCheck/Echeck/etc/system.xml +293 -0
  23. app/code/local/MagCheck/Echeck/sql/echeck_setup/mysql4-install-0.7.0.php +49 -0
  24. app/design/adminhtml/default/default/template/payment/form/echeck.phtml +62 -0
  25. app/design/adminhtml/default/default/template/payment/info/echeck.phtml +7 -0
  26. app/design/frontend/base/default/template/payment/form/echeck.phtml +56 -0
  27. app/design/frontend/default/default/template/payment/form/echeck.phtml +94 -0
  28. app/design/frontend/default/default/template/payment/info/echeck.phtml +7 -0
  29. app/etc/modules/MagCheck_Echeck.xml +8 -0
  30. package.xml +18 -0
app/code/core/Mage/Adminhtml/Model/System/Config/Backend/BankOfFirstDepositAccountNumber.php ADDED
@@ -0,0 +1 @@
 
0
  public function _beforeSave()
1
  {
2
  }
1
+ <?php
2
  public function _beforeSave()
3
  {
4
  }
app/code/core/Mage/Adminhtml/Model/System/Config/Backend/BankOfFirstDepositName.php ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Mage_Adminhtml_Model_System_Config_Backend_BankOfFirstDepositName extends Mage_Core_Model_Config_Data
3
+ {
4
+ public function _beforeSave()
5
+ {
6
+ $bofdn = $this->getValue();
7
+ if(empty($bofdn))
8
+ Mage::throwException("Banck Of First Deposit Name can't be empty!");
9
+ if(strlen($bofdn) <3)
10
+ Mage::throwException("Banck Of First Deposit Name must have at least 3 characteres in lenght!");
11
+ }
12
+ }
app/code/core/Mage/Adminhtml/Model/System/Config/Backend/BankOfFirstDepositRoutingNumber.php ADDED
@@ -0,0 +1 @@
 
0
  public function _beforeSave()
1
  {
2
  }
1
+ <?php
2
  public function _beforeSave()
3
  {
4
  }
app/code/core/Mage/Adminhtml/Model/System/Config/Backend/ReturningRoutingNumber.php ADDED
@@ -0,0 +1 @@
 
0
  public function _beforeSave()
1
  {
2
  }
1
+ <?php
2
  public function _beforeSave()
3
  {
4
  }
app/code/core/Mage/Adminhtml/Model/System/Config/Source/Order/Status/Processingcomplete.php ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2010 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Order Statuses source model
29
+ */
30
+ class Mage_Adminhtml_Model_System_Config_Source_Order_Status_Processingcomplete extends Mage_Adminhtml_Model_System_Config_Source_Order_Status
31
+ {
32
+ public function toOptionArray()
33
+ {
34
+ return array(
35
+ array('value' =>Mage_Sales_Model_Order::STATE_PROCESSING, 'label'=> 'Processing'),
36
+ array('value' =>'paid', 'label'=> 'Paid'),
37
+ array('value' =>Mage_Sales_Model_Order::STATE_COMPLETE, 'label'=> 'Complete'),
38
+ );
39
+ }
40
+ }
app/code/core/Mage/Adminhtml/Model/System/Config/Source/TestmodeACH.php ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2010 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Used in creating options for TEST|LIVE config value selection
29
+ *
30
+ */
31
+ class Mage_Adminhtml_Model_System_Config_Source_TestmodeACH
32
+ {
33
+
34
+ /**
35
+ * Options getter
36
+ *
37
+ * @return array
38
+ */
39
+ public function toOptionArray()
40
+ {
41
+ return array(
42
+ array('value' => 'TEST', 'label'=>Mage::helper('adminhtml')->__('TEST')),
43
+ array('value' => 'LIVE', 'label'=>Mage::helper('adminhtml')->__('LIVE')),
44
+ );
45
+ }
46
+
47
+ }
app/code/local/MagCheck/Echeck/Block/Form.php ADDED
@@ -0,0 +1,53 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 MagCheck
23
+ * @package MagCheck_Echeck
24
+ * @copyright Copyright (c) 2013 MagCheck (http://www.MagCheck.com)
25
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
26
+ */
27
+
28
+ /**
29
+ * Payment method form base block
30
+ */
31
+ class MagCheck_Echeck_Block_Form extends Mage_Core_Block_Template
32
+ {
33
+
34
+ public function getMethod()
35
+ {
36
+ $method = $this->getData('method');
37
+
38
+ if (!($method instanceof Mage_Payment_Model_Method_Abstract)) {
39
+ Mage::throwException($this->__('Can not retrieve payment method model object.'));
40
+ }
41
+ return $method;
42
+ }
43
+
44
+ public function getMethodCode()
45
+ {
46
+ return $this->getMethod()->getCode();
47
+ }
48
+
49
+ public function getInfoData($field)
50
+ {
51
+ return $this->htmlEscape($this->getMethod()->getInfoInstance()->getData($field));
52
+ }
53
+ }
app/code/local/MagCheck/Echeck/Block/Form/Echeck.php ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 MagCheck
23
+ * @package MagCheck_Echeck
24
+ * @copyright Copyright (c) 2013 MagCheck (http://www.MagCheck.com)
25
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
26
+ */
27
+
28
+ class MagCheck_Echeck_Block_Form_Echeck extends Mage_Payment_Block_Form
29
+ {
30
+ protected function _construct()
31
+ {
32
+ parent::_construct();
33
+ $this->setTemplate('payment/form/echeck.phtml');
34
+ }
35
+
36
+ protected function _getConfig()
37
+ {
38
+ return Mage::getSingleton('echeck/config');
39
+ }
40
+
41
+ public function getAccountAvailableTypes()
42
+ {
43
+ $types = $this->_getConfig()->getAccountTypes();
44
+ if ($method = $this->getMethod()) {
45
+ $availableTypes = $method->getConfigData('accounttypes');
46
+ if ($availableTypes) {
47
+ $availableTypes = explode(',', $availableTypes);
48
+ foreach ($types as $code=>$name) {
49
+ if (!in_array($code, $availableTypes)) {
50
+ unset($types[$code]);
51
+ }
52
+ }
53
+ }
54
+ }
55
+ return $types;
56
+ }
57
+ }
app/code/local/MagCheck/Echeck/Block/Info.php ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 MagCheck
23
+ * @package MagCheck_Echeck
24
+ * @copyright Copyright (c) 2013 MagCheck (http://www.MagCheck.com)
25
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
26
+ */
27
+
28
+ class MagCheck_Echeck_Block_Info extends Mage_Core_Block_Template
29
+ {
30
+ protected function _construct()
31
+ {
32
+ parent::_construct();
33
+ $this->setTemplate('payment/info/default.phtml');
34
+ }
35
+
36
+ public function getInfo()
37
+ {
38
+ $info = $this->getData('info');
39
+ if (!($info instanceof MagCheck_Echeck_Model_Info)) {
40
+ Mage::throwException($this->__('Can not retrieve payment info model object.'));
41
+ }
42
+ return $info;
43
+ }
44
+
45
+ public function getMethod()
46
+ {
47
+ return $this->getInfo()->getMethodInstance();
48
+ }
49
+
50
+ public function toPdf()
51
+ {
52
+ $this->setTemplate('payment/info/pdf/default.phtml');
53
+ return $this->toHtml();
54
+ }
55
+ }
app/code/local/MagCheck/Echeck/Block/Info/Echeck.php ADDED
@@ -0,0 +1,80 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 MagCheck
23
+ * @package MagCheck_Echeck
24
+ * @copyright Copyright (c) 2013 MagCheck (http://www.MagCheck.com)
25
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
26
+ */
27
+
28
+
29
+ class MagCheck_Echeck_Block_Info_Echeck extends Mage_Payment_Block_Info
30
+ {
31
+
32
+ protected function _construct()
33
+ {
34
+ parent::_construct();
35
+
36
+ $this->setTemplate('payment/info/echeck.phtml');
37
+ }
38
+
39
+ public function getAccountTypeName()
40
+ {
41
+ $types = Mage::getSingleton('echeck/config')->getAccountTypes();
42
+ if (isset($types[$this->getInfo()->getAccountType()])) {
43
+ return $types[$this->getInfo()->getAccountType()];
44
+ }
45
+ return $this->getInfo()->getAccountType();
46
+ }
47
+
48
+ public function toPdf()
49
+ {
50
+
51
+ $this->setTemplate('payment/info/pdf/echeck.phtml');
52
+ return $this->toHtml();
53
+ }
54
+
55
+ public function getInfo()
56
+ {
57
+ $info = Mage::getSingleton('checkout/session')->getQuote()->getPayment();
58
+ $this->unmapData($info);
59
+
60
+ if (!strlen($info->getMethod())) {
61
+ $this->unmapData($this->getData('info'));
62
+ return $this->getData('info');
63
+ }
64
+ return $info;
65
+ }
66
+
67
+ public function unmapData($info)
68
+ {
69
+ $info->setEcheckRoutingNumber($info->getCcLast4())
70
+ ->setEcheckBankName($info->getCcNumberEnc())
71
+ ->setEcheckAccountType($info->getCcType())
72
+ ->setEcheckAccountName($info->getCcOwner())
73
+ ->setEcheckBankAcctNum($info->getCcSsIssue())
74
+ ->setEcheckBankAcctNum4($info->getCcSsOwner());
75
+ if(strlen($info->getEcheckBankAcctNum()))
76
+ {
77
+ $info->setEcheckBankAcctNum4(substr($info->getEcheckBankAcctNum(), -4));
78
+ }
79
+ }
80
+ }
app/code/local/MagCheck/Echeck/Helper/Data.php ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 MagCheck
23
+ * @package MagCheck_Echeck
24
+ * @copyright Copyright (c) 2010 MagCheck (http://www.MagCheck.com)
25
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
26
+ */
27
+
28
+ class MagCheck_Echeck_Helper_Data extends Mage_Core_Helper_Abstract
29
+ {
30
+
31
+ }
app/code/local/MagCheck/Echeck/Model/Config.php ADDED
@@ -0,0 +1,71 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 MagCheck
23
+ * @package MagCheck_Echeck
24
+ * @copyright Copyright (c) 2013 MagCheck (http://www.MagCheck.com)
25
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
26
+ */
27
+
28
+ class MagCheck_Echeck_Model_Config
29
+ {
30
+ protected static $_methods;
31
+
32
+ public function getActiveMethods($store=null)
33
+ {
34
+ $methods = array();
35
+ $config = Mage::getStoreConfig('echeck', $store);
36
+ foreach ($config as $code => $methodConfig) {
37
+ if (Mage::getStoreConfigFlag('echeck/'.$code.'/active', $store)) {
38
+ $methods[$code] = $this->_getMethod($code, $methodConfig);
39
+ }
40
+ }
41
+ return $methods;
42
+ }
43
+
44
+ public function getAllMethods($store=null)
45
+ {
46
+ $methods = array();
47
+ $config = Mage::getStoreConfig('payment', $store);
48
+ foreach ($config as $code => $methodConfig) {
49
+ $methods[$code] = $this->_getMethod($code, $methodConfig);
50
+ }
51
+ return $methods;
52
+ }
53
+
54
+ protected function _getMethod($code, $config, $store=null)
55
+ {
56
+ if (isset(self::$_methods[$code])) {
57
+ return self::$_methods[$code];
58
+ }
59
+ $modelName = $config['model'];
60
+ $method = Mage::getModel($modelName);
61
+ $method->setId($code)->setStore($store);
62
+ self::$_methods[$code] = $method;
63
+ return self::$_methods[$code];
64
+ }
65
+
66
+ public function getAccountTypes()
67
+ {
68
+ $types = array('CHECKING' => 'Personal Checking', 'BUSINESSCHECKING' => 'Business checking');
69
+ return $types;
70
+ }
71
+ }
app/code/local/MagCheck/Echeck/Model/EcheckPayment.php ADDED
@@ -0,0 +1,687 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 MagCheck
23
+ * @package MagCheck_Echeck
24
+ * @copyright Copyright (c) 2013 MagCheck (http://www.MagCheck.com)
25
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
26
+ */
27
+
28
+ class MagCheck_Echeck_Model_EcheckPayment extends Mage_Paygate_Model_Authorizenet
29
+ {
30
+
31
+ protected $_formBlockType = 'echeck/form_echeck';
32
+ protected $_infoBlockType = 'echeck/info_echeck';
33
+
34
+ const REQUEST_METHOD_CC = 'CREDIT';
35
+ const REQUEST_METHOD_ECHECK = 'ACH';
36
+
37
+ const REQUEST_TYPE_AUTH_CAPTURE = 'SALE';
38
+ const REQUEST_TYPE_AUTH_ONLY = 'AUTH';
39
+ const REQUEST_TYPE_CAPTURE_ONLY = 'CAPTURE';
40
+ const REQUEST_TYPE_CREDIT = 'CREDIT';
41
+ const REQUEST_TYPE_VOID = 'VOID';
42
+ const REQUEST_TYPE_PRIOR_AUTH_CAPTURE = 'PRIOR_AUTH_CAPTURE';
43
+
44
+ const ECHECK_ACCT_TYPE_CHECKING = 'CHECKING';
45
+ const ECHECK_ACCT_TYPE_BUSINESS = 'BUSINESSCHECKING';
46
+ const ECHECK_ACCT_TYPE_SAVINGS = 'SAVINGS';
47
+
48
+ const ECHECK_TRANS_TYPE_CCD = 'CCD';
49
+ const ECHECK_TRANS_TYPE_PPD = 'PPD';
50
+ const ECHECK_TRANS_TYPE_TEL = 'TEL';
51
+ const ECHECK_TRANS_TYPE_WEB = 'WEB';
52
+
53
+ const RESPONSE_DELIM_CHAR = ',';
54
+
55
+ const RESPONSE_CODE_APPROVED = 'APPROVED';
56
+ const RESPONSE_CODE_DECLINED = 'DECLINED';
57
+ const RESPONSE_CODE_ERROR = 'ERROR';
58
+ const RESPONSE_CODE_HELD = 4;
59
+
60
+ const INVOICE_ID = 0;
61
+ const BANK_NAME = 1;
62
+ const PAYMENT_ACCOUNT = 2;
63
+ const AUTH_CODE = 3;
64
+ const CARD_TYPE = 4;
65
+ const AMOUNT = 5;
66
+ const REBID = 6;
67
+ const AVS = 7;
68
+ const ORDER_ID = 8;
69
+ const CARD_EXPIRE = 9;
70
+ const Result = 10;
71
+ const RRNO = 11;
72
+ const CVV2 = 12;
73
+ const PAYMENT_TYPE = 13;
74
+ const MESSAGE = 14;
75
+
76
+ protected $responseHeaders;
77
+
78
+ protected $_code = 'echeckpayment';
79
+
80
+ /**
81
+ * Availability options
82
+ */
83
+ protected $_isGateway = true;
84
+ protected $_canAuthorize = true;
85
+ protected $_canCapture = true;
86
+ protected $_canCapturePartial = true;
87
+ protected $_canRefund = true;
88
+ protected $_canVoid = true;
89
+ protected $_canUseInternal = true;
90
+ protected $_canUseCheckout = true;
91
+ protected $_canUseForMultishipping = true;
92
+ protected $_canSaveCc = false;
93
+
94
+ public function authorize(Varien_Object $payment, $amount)
95
+ {
96
+ Mage::throwException(Mage::helper('echeck')->__('Error:'));
97
+ if ($amount <= 0) {
98
+ Mage::throwException(Mage::helper('paygate')->__('Invalid amount for authorization.'));
99
+ }
100
+ $payment->setTransactionType(self::REQUEST_TYPE_AUTH_CAPTURE);
101
+ $payment->setAmount($amount);
102
+
103
+ $request= $this->_buildRequest($payment);
104
+ $result = $this->_postRequest($request);
105
+
106
+ $payment->setCcApproval($result->getAuthCode())
107
+ ->setLastTransId($result->getRrno())
108
+ ->setTransactionId($result->getRrno())
109
+ ->setIsTransactionClosed(0)
110
+ ->setCcTransId($result->getRrno())
111
+ ->setCcAvsStatus($result->getAvs())
112
+ ->setCcCidStatus($result->getCvv2());
113
+ Mage::throwException(Mage::helper('paygate')->__('Error: ' . $result->getMessage()));
114
+ switch ($result->getResult()) {
115
+ case self::RESPONSE_CODE_APPROVED:
116
+ $payment->setStatus(self::STATUS_APPROVED);
117
+ Mage::throwException(Mage::helper('echeck')->__('Error: ' . $result->getMessage()));
118
+ return $this;
119
+ case self::RESPONSE_CODE_DECLINED:
120
+ Mage::throwException(Mage::helper('echeck')->__('The transaction has been declined'));
121
+ case self::RESPONSE_CODE_ERROR:
122
+ Mage::throwException(Mage::helper('echeck')->__('Error: ' . $result->getMessage()));
123
+ default:
124
+ Mage::throwException(Mage::helper('echeck')->__('Error!'));
125
+ }
126
+ }
127
+
128
+
129
+ public function capture(Varien_Object $payment, $amount)
130
+ {
131
+ $error = false;
132
+ if ($payment->getCcTransId()) {
133
+ $payment->setTransactionType(self::REQUEST_TYPE_AUTH_CAPTURE);
134
+ } else {
135
+ $payment->setTransactionType(self::REQUEST_TYPE_AUTH_CAPTURE);
136
+ }
137
+ $payment->setAmount($amount);
138
+
139
+ $request= $this->_buildRequest($payment);
140
+ $result = $this->_postRequest($request);
141
+ if ($result->getResult() == self::RESPONSE_CODE_APPROVED) {
142
+ $payment->setStatus(self::STATUS_APPROVED);
143
+ $payment->setLastTransId($result->getRrno())
144
+ ->setTransactionId($result->getRrno());
145
+ return $this;
146
+ }
147
+ if ($result->getMessage()) {
148
+ Mage::throwException($this->_wrapGatewayError($result->getMessage()));
149
+ }
150
+ Mage::throwException(Mage::helper('echeck')->__('Error in capturing the payment.'));
151
+ if ($error !== false) {
152
+ Mage::throwException($error);
153
+ }
154
+ }
155
+
156
+ public function void(Varien_Object $payment)
157
+ {
158
+ $error = false;
159
+ if($payment->getParentTransactionId()){
160
+ $payment->setTransactionType(self::REQUEST_TYPE_CREDIT);
161
+ $request = $this->_buildRequest($payment);
162
+ $result = $this->_postRequest($request);
163
+ if($result->getResult()==self::RESPONSE_CODE_APPROVED){
164
+ $payment->setStatus(self::STATUS_SUCCESS );
165
+ $order->setState(Mage_Sales_Model_Order::STATE_CANCELED, true)->save();
166
+ return $this;
167
+ }
168
+ $payment->setStatus(self::STATUS_ERROR);
169
+ Mage::throwException($this->_wrapGatewayError($result->getMessage()));
170
+ }
171
+ $payment->setStatus(self::STATUS_ERROR);
172
+ Mage::throwException(Mage::helper('echeck')->__('Invalid transaction ID.'));
173
+ }
174
+
175
+ public function refund(Varien_Object $payment, $amount)
176
+ {
177
+ if ($payment->getRefundTransactionId() && $amount > 0) {
178
+ $payment->setTransactionType(self::REQUEST_TYPE_CREDIT);
179
+ $payment->setRrno($payment->getRefundTransactionId());
180
+ $payment->setAmount($amount);
181
+ $request = $this->_buildRequest($payment);
182
+ $request->setRrno($payment->getRefundTransactionId());
183
+ $result = $this->_postRequest($request);
184
+ if ($result->getResult()==self::RESPONSE_CODE_APPROVED) {
185
+ $payment->setStatus(self::STATUS_SUCCESS);
186
+ return $this;
187
+ }
188
+ if ($result->getResult()==self::RESPONSE_CODE_DECLINED) {
189
+ Mage::throwException($this->_wrapGatewayError('DECLINED'));
190
+ }
191
+ if ($result->getResult()==self::RESPONSE_CODE_ERROR) {
192
+ Mage::throwException($this->_wrapGatewayError('ERROR'));
193
+ }
194
+ Mage::throwException($this->_wrapGatewayError($result->getRrno()));
195
+ }
196
+ Mage::throwException(Mage::helper('echeck')->__('Error in refunding the payment.'));
197
+ }
198
+
199
+ protected function _buildRequest(Varien_Object $payment)
200
+ {
201
+ $order = $payment->getOrder();
202
+
203
+ $this->setStore($order->getStoreId());
204
+
205
+ if (!$payment->getPaymentType()) {
206
+ $payment->setPaymentType(self::REQUEST_METHOD_ECHECK);
207
+ }
208
+ $payment->setPaymentType(self::REQUEST_METHOD_ECHECK);
209
+ $request = Mage::getModel('echeck/EcheckPayment_request');
210
+
211
+ if ($order && $order->getIncrementId()) {
212
+ $request->setInvoiceID($order->getIncrementId());
213
+ }
214
+
215
+ $request->setMode(($this->getConfigData('test_mode') == 'TEST') ? 'TEST' : 'LIVE');
216
+ $request->setMerchant($this->getConfigData('login'))
217
+ ->setTransactionType($payment->getTransactionType())
218
+ ->setPaymentType($payment->getPaymentType())
219
+ ->setTamperProofSeal($this->calcTPS($payment));
220
+ if($payment->getAmount()){
221
+ $request->setAmount($payment->getAmount(),2);
222
+ }
223
+ switch ($payment->getTransactionType()) {
224
+ case self::REQUEST_TYPE_CREDIT:
225
+ case self::REQUEST_TYPE_VOID:
226
+ case self::REQUEST_TYPE_CAPTURE_ONLY:
227
+ $request->setRrno($payment->getCcTransId());
228
+ break;
229
+ }
230
+ $cart = Mage::helper('checkout/cart')->getCart()->getItemsCount();
231
+ $cartSummary = Mage::helper('checkout/cart')->getCart()->getSummaryQty();
232
+ Mage::getSingleton('core/session', array('name'=>'frontend'));
233
+ $session = Mage::getSingleton('checkout/session');
234
+
235
+ $comment = "";
236
+
237
+ foreach ($session->getQuote()->getAllItems() as $item) {
238
+
239
+ $comment .= $item->getQty() . ' ';
240
+ $comment .= '[' . $item->getSku() . ']' . ' ';
241
+ $comment .= $item->getName() . ' ';
242
+ $comment .= $item->getDescription() . ' ';
243
+ $comment .= $item->getBaseCalculationPrice . ' ';
244
+ }
245
+
246
+ if (!empty($order)) {
247
+ $billing = $order->getBillingAddress();
248
+ if (!empty($billing)) {
249
+ $request->setName1($billing->getFirstname())
250
+ ->setName2($billing->getLastname())
251
+ ->setCompany($billing->getCompany())
252
+ ->setAddr1($billing->getStreet(1))
253
+ ->setCity($billing->getCity())
254
+ ->setState($billing->getRegion())
255
+ ->setZipcode($billing->getPostcode())
256
+ ->setCountry($billing->getCountry())
257
+ ->setPhone($billing->getTelephone())
258
+ ->setFax($billing->getFax())
259
+ ->setCustomId($billing->getCustomerId())
260
+ ->setComment($comment)
261
+ ->setEmail($order->getCustomerEmail());
262
+ }
263
+ }
264
+
265
+ switch ($payment->getPaymentType()) {
266
+ case self::REQUEST_METHOD_ECHECK:
267
+ $request->setAchRouting($payment->getEcheckRoutingNumber())
268
+ ->setAchAccount($payment->getEcheckBankAcctNum())
269
+ ->setAchAccountType($payment->getEcheckAccountType())
270
+ ->setName($payment->getEcheckAccountName())
271
+ ->setDocType(self::ECHECK_TRANS_TYPE_CCD)
272
+ ->setAchCheckNumber($payment->getEcheckCheckNumber())
273
+ ->setAchCheckDate($payment->getEcheckCheckDate())
274
+ ->setAchBankName($payment->getEcheckBankName())
275
+ ;
276
+ break;
277
+ }
278
+
279
+ return $request;
280
+ }
281
+
282
+ protected function _postRequest(Varien_Object $request)
283
+ {
284
+ $debugData = array('request' => $request->getData());
285
+
286
+ $requestdata = $request->getData();
287
+
288
+ $result = Mage::getModel('echeck/EcheckPayment_result');
289
+
290
+ $d = str_split($requestdata[ach_routing],1);
291
+ $Check_Digit = (7*($d[0]+$d[3]+$d[6])+3*($d[1]+$d[4]+$d[7])+9*($d[2]+$d[5]))%10;
292
+
293
+ $isvalid = false;
294
+
295
+ $stateArray = array(
296
+ "Alabama"=>"AL",
297
+ "Alaska"=>"AK",
298
+ "Arizona"=>"AZ",
299
+ "Arkansas"=>"AR",
300
+ "California"=>"CA",
301
+ "Colorado"=>"CO",
302
+ "Connecticut"=>"CT",
303
+ "Delaware"=>"DE",
304
+ "District of Columbia"=>"DC",
305
+ "Florida"=>"FL",
306
+ "Georgia"=>"GA",
307
+ "Hawaii"=>"HI",
308
+ "Idaho"=>"ID",
309
+ "Illinois"=>"IL",
310
+ "Indiana"=>"IN",
311
+ "Iowa"=>"IA",
312
+ "Kansas"=>"KS",
313
+ "Kentucky"=>"KY",
314
+ "Louisiana"=>"LA",
315
+ "Maine"=>"ME",
316
+ "Maryland"=>"MD",
317
+ "Massachusetts"=>"MA",
318
+ "Michigan"=>"MI",
319
+ "Minnesota"=>"MN",
320
+ "Mississippi"=>"MS",
321
+ "Missouri"=>"MO",
322
+ "Montana"=>"MT",
323
+ "Nebraska"=>"NE",
324
+ "Nevada"=>"NV",
325
+ "New Hampshire"=>"NH",
326
+ "New Jersey"=>"NJ",
327
+ "New Mexico"=>"NM",
328
+ "New York"=>"NY",
329
+ "North Carolina"=>"NC",
330
+ "North Dakota"=>"ND",
331
+ "Ohio"=>"OH",
332
+ "Oklahoma"=>"OK",
333
+ "Oregon"=>"OR",
334
+ "Pennsylvania"=>"PA",
335
+ "Rhode Island"=>"RI",
336
+ "South Carolina"=>"SC",
337
+ "South Dakota"=>"SD",
338
+ "Tennessee"=>"TN",
339
+ "Texas"=>"TX",
340
+ "Utah"=>"UT",
341
+ "Vermont"=>"VT",
342
+ "Virginia"=>"VA",
343
+ "Washington"=>"WA",
344
+ "West Virginia"=>"WV",
345
+ "Wisconsin"=>"WI",
346
+ "Wyoming"=>"WY",
347
+ "American Samoa"=>"AS",
348
+ "Guam"=>"GU",
349
+ "Northern Mariana Islands"=>"MP",
350
+ "Puerto Rico"=>"PR",
351
+ "Virgin Islands"=>"VI",
352
+ "U.S. Minor Outlying Islands"=>"UM",
353
+ "Federated States of Micronesia"=>"FM",
354
+ "Marshall Islands"=>"MH",
355
+ "Palau"=>"PW"
356
+ );
357
+
358
+ if (strlen($requestdata[ach_routing].$Check_Digit)!=10)
359
+ $isvalid = false;
360
+ else
361
+ {
362
+ $d=str_split($requestdata[ach_routing].$Check_Digit,1);
363
+ if ((3*($d[0]+$d[3]+$d[6])+7*($d[1]+$d[4]+$d[7])+($d[2]+$d[5]+$d[8]))%10==0)
364
+ $isvalid = true;
365
+ else
366
+ $isvalid = false;
367
+ }
368
+ if ($isvalid)
369
+ {
370
+ $client_code = $this->getConfigData('client_code');
371
+ $invoice_id = $requestdata[invoice_id];
372
+ $mode = $requestdata[mode];
373
+ $merchant = $requestdata[merchant];
374
+ $transaction_type = $requestdata[transaction_type];
375
+ $payment_type = $requestdata[payment_type];
376
+ $tamper_proof_seal = $requestdata[tamper_proof_seal];
377
+ $amount = $requestdata[amount];
378
+ $name1 = $requestdata[name1];
379
+ $name2 = $requestdata[name2];
380
+ $company = $requestdata[company];
381
+ $phone = $requestdata[phone];
382
+ $fax = $requestdata[fax];
383
+ $custom_id = $requestdata[custom_id];
384
+ $comment = $requestdata[comment];
385
+ $addr1 = $requestdata[addr1];
386
+ $city = $requestdata[city];
387
+ $state = $requestdata[state];
388
+ $zipcode = $requestdata[zipcode];
389
+
390
+ if(!is_numeric($zipcode))
391
+ Mage::throwException($this->_wrapGatewayError('Zip code must contain only digits (0-9)'));
392
+ if(strlen($zipcode)!=5)
393
+ Mage::throwException($this->_wrapGatewayError('Zip code must be 5 digits in length'));
394
+
395
+ $country = $requestdata[country];
396
+ $email = $requestdata[email];
397
+
398
+ $ach_bank_name = $requestdata[ach_bank_name];
399
+ $ach_check_number = $requestdata[ach_check_number];
400
+ $ach_check_date = date("Y-m-d");
401
+ $ach_check_payto = $this->getConfigData('payto');
402
+
403
+ $ach_extra1 = 'Order Number: ' . $requestdata[invoice_id];
404
+ $ach_extra2 = date("Y-m-d H:m:s");
405
+ $ach_extra3 = $this->getConfigData('support_url');
406
+ $ach_extra4 = $this->getConfigData('support_number');
407
+ $ach_extra5 = $this->getConfigData('message');
408
+ $ach_extra6 = $this->getConfigData('extra6');
409
+
410
+ $ach_user_name = $this->getConfigData('user_name');
411
+ $ach_password = $this->getConfigData('password');
412
+ $ach_teminal_number = $this->getConfigData('terminal_number');
413
+
414
+ $ach_routing = $requestdata[ach_routing];
415
+ $ach_account = $requestdata[ach_account];
416
+ $ach_account_type = $requestdata[ach_account_type];
417
+ $name = $requestdata[name];
418
+ $doc_type = $requestdata[doc_type];
419
+
420
+ $bank_of_first_deposit_name = $this->getConfigData('bank_of_first_deposit_name');
421
+ $bank_of_first_deposit_routing_number = $this->getConfigData('bank_of_first_deposit_routing_number');
422
+ $bank_of_first_deposit_account_number = $this->getConfigData('bank_of_first_deposit_account_number');
423
+ $returning_routing_number = $this->getConfigData('return_routing_number');
424
+ $do_not_add_virtual_endorsement = $this->getConfigData('do_not_add_virtual_endorsement');
425
+ $non_virtual_endorsement = $this->getConfigData('non_virtual_endorsement');
426
+
427
+ $min_order_total = $this->getConfigData('min_order_total');
428
+ $max_order_total = $this->getConfigData('max_order_total');
429
+ $black_list = $this->getConfigData('black_list');
430
+
431
+ $black_list = explode("\n", $black_list);
432
+ $black_list = array_filter($black_list, 'trim');
433
+
434
+ $ach_account = str_replace("-","",$ach_account);
435
+ $ach_account = str_pad($ach_account, 17, "0", STR_PAD_LEFT);
436
+
437
+ foreach ($black_list as $line) {
438
+ $forbiden = explode("|",$line);
439
+ $forbiden_size = sizeof($forbiden);
440
+ if($forbiden_size >= 2)
441
+ {
442
+ if($forbiden[0] == $ach_routing)
443
+ {
444
+ if($forbiden[1] == "*")
445
+ {
446
+ Mage::throwException($this->_wrapGatewayError('Routing/Account number not allowed'));
447
+ }else
448
+ {
449
+ $facct = str_replace("-","",$forbiden[1]);
450
+ $facct = str_pad($facct, 17, "0", STR_PAD_LEFT);
451
+
452
+ if($facct == $ach_account)
453
+ {
454
+ Mage::throwException($this->_wrapGatewayError('Routing/Account number not allowed'));
455
+ }
456
+ }
457
+ }
458
+ }
459
+ else
460
+ {
461
+ if($forbiden[0] == $ach_routing)
462
+ Mage::throwException($this->_wrapGatewayError('Routing/Account number not allowed'));
463
+ }
464
+ }
465
+
466
+ setlocale(LC_MONETARY, 'en_US');
467
+ if(is_numeric($min_order_total) && $amount < $min_order_total)
468
+ Mage::throwException($this->_wrapGatewayError('Minimum order of ' . money_format('%i', $min_order_total) . ' not satisfied!'));
469
+
470
+ if(is_numeric($max_order_total) && $amount > $max_order_total)
471
+ Mage::throwException($this->_wrapGatewayError('Maximum order of ' . money_format('%i', $max_order_total) . ' exceeded!'));
472
+
473
+ $ret = ':(';
474
+ try {
475
+
476
+ if(array_key_exists($state,$stateArray))
477
+ $state = $stateArray[$state];
478
+ else
479
+ $state = '';
480
+
481
+ $client = new Zend_Soap_Client($this->getConfigData('ws_url'));
482
+ $client->setSoapVersion(SOAP_1_2);
483
+ $ret = $client->SingleDraftData(
484
+ array(
485
+ 'UserName'=>$ach_user_name,
486
+ 'Password'=>$ach_password,
487
+ 'ClientCode'=>$client_code,
488
+ 'ClientTerminalNo'=>$ach_teminal_number,
489
+ 'CheckBankName'=>$ach_bank_name,
490
+ 'CheckBankNameFractionalForm'=>'',
491
+ 'CheckRoutingNumber'=>$ach_routing,
492
+ 'CheckAccountNumber'=>$ach_account,
493
+ 'CheckNumber'=>$ach_check_number,
494
+ 'CheckDate'=>$ach_check_date,
495
+ 'CheckPayTo'=>$ach_check_payto,
496
+ 'IsPersonalCheck'=>$ach_account_type == 'CHECKING' ? 'True' : 'False',
497
+ 'CheckAmount'=>$amount,
498
+ 'CheckMakerLine1'=>$name1 . ' ' . $name2,
499
+ 'CheckMakerLine2'=>$addr1,
500
+ 'CheckMakerLine3'=>$city . ', ' . $state . ' ' . $zipcode,
501
+ 'CheckMakerLine4'=>'',
502
+ 'CheckExtraLine1'=>$ach_extra1,
503
+ 'CheckExtraLine2'=>$ach_extra2,
504
+ 'CheckExtraLine3'=>$ach_extra3,
505
+ 'CheckExtraLine4'=>$ach_extra4,
506
+ 'CheckExtraLine5'=>$ach_extra5,
507
+ 'CheckExtraLine6'=>$ach_extra6,
508
+ 'BankOfFirstDepositName'=>$bank_of_first_deposit_name,
509
+ 'BankOfFirstDepositRoutingNumber'=>$bank_of_first_deposit_routing_number,
510
+ 'BankOfFirstDepositAccountNumber'=>$bank_of_first_deposit_account_number,
511
+ 'ReturnRoutingNumber'=>$returning_routing_number,
512
+ 'EndorsementDate'=>$ach_check_date,
513
+ 'TestMode'=>$mode == 'TEST' ? 'True' : 'False',
514
+ 'SourceID'=>$invoice_id,
515
+ 'DoNotAddVirtualEndorsement'=>$do_not_add_virtual_endorsement,
516
+ 'NonVirtualEndorsementString'=>$non_virtual_endorsement
517
+ )
518
+ );
519
+ }
520
+ catch (Exception $e) {
521
+ Mage::throwException($this->_wrapGatewayError($e->getMessage()));
522
+ }
523
+ $s = (string)$ret->SingleDraftDataResult;
524
+ $s = str_replace('<?xml version="1.0" encoding="utf-16"?>','',$s);
525
+ $retXml = simplexml_load_string($s);
526
+
527
+ $status = (string)$retXml->StatusCode->{0}=="OK"?"APPROVED" : "ERROR";
528
+ $message = (string)$retXml->StatusMessage->{0};
529
+ $rid = (string)$retXml->SingleDraftRequestID->{0};
530
+
531
+ $result->setResult($status)
532
+ ->setInvoiceId($invoice_id)
533
+ ->setMessage($message)
534
+ ->setAuthCode($rid)
535
+ ->setAvs(0)
536
+ ->setRrno(0)
537
+ ->setAmount($amount)
538
+ ->setPaymentType($ach_account_type)
539
+ ->setOrderId(0)
540
+ ->setCvv2('');
541
+ if($status == "ERROR") {
542
+ Mage::throwException($this->_wrapGatewayError($message));
543
+ }
544
+
545
+ } else {
546
+ Mage::throwException(
547
+ Mage::helper('echeck')->__('Invalid routing number.')
548
+ );
549
+ }
550
+
551
+ $debugData['result'] = $result->getData();
552
+ $this->_debug($debugData);
553
+ return $result;
554
+ }
555
+
556
+ public function validate()
557
+ {
558
+ $paymentInfo = $this->getInfoInstance();
559
+ if(strlen($paymentInfo->getCcType()))
560
+ {
561
+ $paymentInfo = $this->unmapData($paymentInfo);
562
+ }
563
+
564
+ if ($paymentInfo instanceof Mage_Sales_Model_Order_Payment) {
565
+ $billingCountry = $paymentInfo->getOrder()->getBillingAddress()->getCountryId();
566
+ } else {
567
+ $billingCountry = $paymentInfo->getQuote()->getBillingAddress()->getCountryId();
568
+ }
569
+ if (!$this->canUseForCountry($billingCountry)) {
570
+ Mage::throwException($this->_getHelper()->__('Selected payment type is not allowed for billing country.'));
571
+ }
572
+
573
+ $info = $this->getInfoInstance();
574
+ $errorMsg = false;
575
+ $availableTypes = explode(',',$this->getConfigData('accounttypes'));
576
+
577
+ $accountType = '';
578
+
579
+ if (!in_array($info->getEcheckAccountType(), $availableTypes))
580
+ {
581
+ $errorCode = 'echeck_account_type';
582
+ $errorMsg = $this->_getHelper()->__('Account type is not allowed for this payment method '. $info->getAccountType());
583
+ }
584
+ if($errorMsg)
585
+ {
586
+ Mage::throwException($errorMsg);
587
+ }
588
+ return $this;
589
+ }
590
+
591
+ public function getInfoInstance()
592
+ {
593
+ $instance = $this->getData('info_instance');
594
+ return $instance;
595
+ }
596
+
597
+ public function assignData($data)
598
+ {
599
+ if (!($data instanceof Varien_Object)) {
600
+ $data = new Varien_Object($data);
601
+ }
602
+ $data->setEcheckBankAcctNum4(substr($data->getEcheckBankAcctNum(), -4));
603
+ $info = $this->getInfoInstance();
604
+ $info->setEcheckRoutingNumber($data->getEcheckRoutingNumber())
605
+ ->setEcheckBankName($data->getEcheckBankName())
606
+ ->setData('echeck_account_type', $data->getEcheckAccountType())
607
+ ->setEcheckAccountName($data->getEcheckAccountName())
608
+ ->setEcheckBankAcctNum($data->getEcheckBankAcctNum())
609
+ ->setEcheckBankAcctNum4($data->getEcheckBankAcctNum4())
610
+ ->setEcheckCheckNumber($data->getEcheckCheckNumber())
611
+ ->setEcheckCheckDate($data->getEcheckCheckDate())
612
+ ;
613
+
614
+ $this->mapData($data);
615
+ return $this;
616
+ }
617
+
618
+ public function mapData($data)
619
+ {
620
+ if (!($data instanceof Varien_Object)) {
621
+ $data = new Varien_Object($data);
622
+ }
623
+ $info = $this->getInfoInstance();
624
+ $info->setCcLast4($data->getEcheckRoutingNumber())
625
+ ->setCcNumberEnc($data->getEcheckBankName())
626
+ ->setCcType($data->getEcheckAccountType())
627
+ ->setCcOwner($data->getEcheckAccountName())
628
+ ->setCcSsIssue($data->getEcheckBankAcctNum())
629
+ ->setCcSsOwner($data->getEcheckBankAcctNum4());
630
+
631
+ $info->setAdditionalInformation('EcheckCheckNumber',$data->getEcheckCheckNumber());
632
+ $info->setAdditionalInformation('EcheckCheckDate',$data->getEcheckCheckDate());
633
+
634
+ }
635
+
636
+ public function unmapData($info)
637
+ {
638
+ $info->setEcheckRoutingNumber($info->getCcLast4())
639
+ ->setEcheckBankName($info->getCcNumberEnc())
640
+ ->setEcheckAccountType($info->getCcType())
641
+ ->setEcheckAccountName($info->getCcOwner())
642
+ ->setEcheckBankAcctNum($info->getCcSsIssue())
643
+ ->setEcheckBankAcctNum4($info->getCcSsOwner())
644
+ ->setEcheckCheckNumber($info->getAdditionalInformation('EcheckCheckNumber'))
645
+ ->setEcheckCheckDate($info->getAdditionalInformation('EcheckCheckDate'));
646
+
647
+ return $info;
648
+ }
649
+
650
+ public function prepareSave()
651
+ {
652
+ $info = $this->getInfoInstance();
653
+ $info->setCcSsIssue(null);
654
+ return $this;
655
+ }
656
+
657
+ public function isAvailable($quote = null){
658
+ $checkResult = new StdClass;
659
+ $checkResult->isAvailable = (bool)(int)$this->getConfigData('active', ($quote ? $quote->getStoreId() : null));
660
+ Mage::dispatchEvent('payment_method_is_active', array(
661
+ 'result' => $checkResult,
662
+ 'method_instance' => $this,
663
+ 'quote' => $quote,
664
+ ));
665
+ return $checkResult->isAvailable;
666
+ }
667
+
668
+ protected final function calcTPS(Varien_Object $payment) {
669
+
670
+ $order = $payment->getOrder();
671
+ $billing = $order->getBillingAddress();
672
+
673
+ $hashstr = $this->getConfigData('trans_key') . $this->getConfigData('login') .
674
+ $payment->getTransactionType() . $payment->getAmount() . $payment->getRrno() .
675
+ $this->getConfigData('test_mode');
676
+
677
+ return bin2hex( md5($hashstr, true) );
678
+ }
679
+
680
+ protected function parseHeader($header, $nameVal, $pos) {
681
+ $nameVal = ($nameVal == 'name') ? '0' : '1';
682
+ $s = explode("?", $header);
683
+ $t = explode("&", $s[1]);
684
+ $value = explode("=", $t[$pos]);
685
+ return $value[$nameVal];
686
+ }
687
+ }
app/code/local/MagCheck/Echeck/Model/EcheckPayment/Debug.php ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 MagCheck
23
+ * @package MagCheck_Echeck
24
+ * @copyright Copyright (c) 2013 MagCheck (http://www.MagCheck.com)
25
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
26
+ */
27
+
28
+ class MagCheck_Echeck_Model_EcheckPayment_Debug extends Mage_Core_Model_Abstract
29
+ {
30
+ protected function _construct()
31
+ {
32
+ $this->_init('echeck/EcheckPayment_debug');
33
+ }
34
+ }
app/code/local/MagCheck/Echeck/Model/EcheckPayment/Request.php ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 MagCheck
23
+ * @package MagCheck_Echeck
24
+ * @copyright Copyright (c) 2013 MagCheck (http://www.MagCheck.com)
25
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
26
+ */
27
+
28
+ class MagCheck_Echeck_Model_EcheckPayment_Request extends Varien_Object
29
+ {
30
+
31
+ }
app/code/local/MagCheck/Echeck/Model/EcheckPayment/Result.php ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 MagCheck
23
+ * @package MagCheck_Echeck
24
+ * @copyright Copyright (c) 2013 MagCheck (http://www.MagCheck.com)
25
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
26
+ */
27
+
28
+ class MagCheck_Echeck_Model_EcheckPayment_Result extends Varien_Object
29
+ {
30
+
31
+ }
app/code/local/MagCheck/Echeck/Model/EcheckPayment/Source/Accounttypes.php ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 MagCheck
23
+ * @package MagCheck_Echeck
24
+ * @copyright Copyright (c) 2013 MagCheck (http://www.MagCheck.com)
25
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
26
+ */
27
+
28
+ class MagCheck_Echeck_Model_EcheckPayment_Source_Accounttypes
29
+ {
30
+ public function getAllowedTypes()
31
+ {
32
+ return array('CHECKING', 'BUSINESSCHECKING', 'SAVINGS');
33
+ }
34
+
35
+ public function toOptionArray()
36
+ {
37
+ $allowed = $this->getAllowedTypes();
38
+ $options = array();
39
+
40
+ foreach (Mage::getSingleton('echeck/config')->getAccountTypes() as $code => $name) {
41
+ if (in_array($code, $allowed) || !count($allowed)) {
42
+ $options[] = array(
43
+ 'value' => $code,
44
+ 'label' => $name
45
+ );
46
+ }
47
+ }
48
+
49
+ return $options;
50
+ }
51
+ }
app/code/local/MagCheck/Echeck/Model/EcheckPayment/Source/PaymentAction.php ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 MagCheck
23
+ * @package MagCheck_Echeck
24
+ * @copyright Copyright (c) 2013 MagCheck (http://www.MagCheck.com)
25
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
26
+ */
27
+
28
+ class MagCheck_Echeck_Model_EcheckPayment_Source_PaymentAction
29
+ {
30
+ public function toOptionArray()
31
+ {
32
+ return array(
33
+ array(
34
+ 'value' => MagCheck_Echeck_Model_EcheckPayment::ACTION_AUTHORIZE_CAPTURE,
35
+ 'label' => 'SALE'
36
+ ),
37
+ );
38
+ }
39
+ }
app/code/local/MagCheck/Echeck/Model/Mysql4/ECheckPayment/Debug.php ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 MagCheck
23
+ * @package MagCheck_Echeck
24
+ * @copyright Copyright (c) 2013 MagCheck (http://www.MagCheck.com)
25
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
26
+ */
27
+
28
+ class MagCheck_Echeck_Model_Mysql4_ECheckPayment_Debug extends Mage_Core_Model_Mysql4_Abstract
29
+ {
30
+ protected function _construct()
31
+ {
32
+ $this->_init('echeck/ECheckPayment_debug', 'debug_id');
33
+ }
34
+ }
app/code/local/MagCheck/Echeck/Model/Mysql4/ECheckPayment/Debug/Collection.php ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 MagCheck
23
+ * @package MagCheck_Echeck
24
+ * @copyright Copyright (c) 2013 MagCheck (http://www.MagCheck.com)
25
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
26
+ */
27
+
28
+ class MagCheck_Echeck_Model_Mysql4_ECheckPayment_Debug_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
29
+ {
30
+ protected function _construct()
31
+ {
32
+ $this->_init('echeck/ECheckPayment_debug');
33
+ }
34
+ }
app/code/local/MagCheck/Echeck/etc/config.xml ADDED
@@ -0,0 +1,119 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * Magento
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Academic Free License (AFL 3.0)
9
+ * that is bundled with this package in the file LICENSE_AFL.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/afl-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 MagCheck
23
+ * @package MagCheck_Echeck
24
+ * @copyright Copyright (c) 2013 MagCheck (http://www.MagCheck.com)
25
+ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
26
+ */
27
+ -->
28
+ <config>
29
+ <modules>
30
+ <MagCheck_Echeck>
31
+ <version>0.6.0</version>
32
+ </MagCheck_Echeck>
33
+ </modules>
34
+ <global>
35
+ <blocks>
36
+ <echeck>
37
+ <class>MagCheck_Echeck_Block</class>
38
+ </echeck>
39
+ </blocks>
40
+ <helpers>
41
+ <echeck>
42
+ <class>MagCheck_Echeck_Helper</class>
43
+ </echeck>
44
+ </helpers>
45
+ <models>
46
+ <echeck>
47
+ <class>MagCheck_Echeck_Model</class>
48
+ <resourceModel>echeck_mysql4</resourceModel>
49
+ </echeck>
50
+ <echeck_mysql4>
51
+ <class>MagCheck_Echeck_Model_Mysql4</class>
52
+ <entities>
53
+ <echeckpayment_debug><table>echeck_EcheckPayment_debug</table></echeckpayment_debug>
54
+ </entities>
55
+ </echeck_mysql4>
56
+ </models>
57
+ <resources>
58
+ <echeck_setup>
59
+ <setup>
60
+ <module>MagCheck_Echeck</module>
61
+ </setup>
62
+ <connection>
63
+ <use>core_setup</use>
64
+ </connection>
65
+ </echeck_setup>
66
+ <echeck_write>
67
+ <connection>
68
+ <use>core_write</use>
69
+ </connection>
70
+ </echeck_write>
71
+ <echeck_read>
72
+ <connection>
73
+ <use>core_read</use>
74
+ </connection>
75
+ </echeck_read>
76
+ </resources>
77
+ </global>
78
+
79
+ <adminhtml>
80
+ <translate>
81
+ <modules>
82
+ <MagCheck_Echeck>
83
+ <files>
84
+ <default>MagCheck_Echeck.csv</default>
85
+ </files>
86
+ </MagCheck_Echeck>
87
+ </modules>
88
+ </translate>
89
+ </adminhtml>
90
+
91
+ <frontend>
92
+ <translate>
93
+ <modules>
94
+ <MagCheck_Echeck>
95
+ <files>
96
+ <default>MagCheck_Echeck.csv</default>
97
+ </files>
98
+ </MagCheck_Echeck>
99
+ </modules>
100
+ </translate>
101
+ </frontend>
102
+
103
+ <default>
104
+ <payment>
105
+ <echeckpayment>
106
+ <active>1</active>
107
+ <accounttypes>CHECKING,BUSINESSCHECKING,SAVINGS</accounttypes>
108
+ <debug>0</debug>
109
+ <login backend_model="adminhtml/system_config_backend_encrypted"/>
110
+ <model>echeck/EcheckPayment</model>
111
+ <order_status>2</order_status>
112
+ <test>1</test>
113
+ <title>E-Check (MagCheck)</title>
114
+ <trans_key backend_model="adminhtml/system_config_backend_encrypted"/>
115
+ <allowspecific>0</allowspecific>
116
+ </echeckpayment>
117
+ </payment>
118
+ </default>
119
+ </config>
app/code/local/MagCheck/Echeck/etc/system.xml ADDED
@@ -0,0 +1,293 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * Magento
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Academic Free License (AFL 3.0)
9
+ * that is bundled with this package in the file LICENSE_AFL.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/afl-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 MagCheck
23
+ * @package MagCheck_Echeck
24
+ * @copyright Copyright (c) 2013 MagCheck (http://www.MagCheck.com)
25
+ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
26
+ */
27
+ -->
28
+ <config>
29
+ <sections>
30
+ <payment>
31
+ <groups>
32
+ <echeckpayment translate="label" module="echeck">
33
+ <label>MagCheck (E-Check)</label>
34
+ <frontend_type>text</frontend_type>
35
+ <sort_order>10</sort_order>
36
+ <show_in_default>1</show_in_default>
37
+ <show_in_website>1</show_in_website>
38
+ <show_in_store>1</show_in_store>
39
+ <fields>
40
+
41
+ <client_code translate="label">
42
+ <label>Client Code</label>
43
+ <validate>required-entry</validate>
44
+ <frontend_type>text</frontend_type>
45
+ <sort_order>2</sort_order>
46
+ <show_in_default>1</show_in_default>
47
+ <show_in_website>1</show_in_website>
48
+ <show_in_store>0</show_in_store>
49
+ </client_code>
50
+ <user_name translate="label">
51
+ <label>User Name</label>
52
+ <validate>required-entry</validate>
53
+ <frontend_type>text</frontend_type>
54
+ <sort_order>3</sort_order>
55
+ <show_in_default>1</show_in_default>
56
+ <show_in_website>1</show_in_website>
57
+ <show_in_store>0</show_in_store>
58
+ </user_name>
59
+
60
+ <password translate="label">
61
+ <label>Password</label>
62
+ <validate>required-entry</validate>
63
+ <frontend_type>text</frontend_type>
64
+ <sort_order>4</sort_order>
65
+ <show_in_default>1</show_in_default>
66
+ <show_in_website>1</show_in_website>
67
+ <show_in_store>0</show_in_store>
68
+ </password>
69
+
70
+ <terminal_number translate="label">
71
+ <label>Terminal Number</label>
72
+ <validate>required-entry</validate>
73
+ <frontend_type>text</frontend_type>
74
+ <sort_order>5</sort_order>
75
+ <show_in_default>1</show_in_default>
76
+ <show_in_website>1</show_in_website>
77
+ <show_in_store>0</show_in_store>
78
+ </terminal_number>
79
+
80
+ <ws_url translate="label">
81
+ <label>Service Url</label>
82
+ <validate>required-entry</validate>
83
+ <frontend_type>text</frontend_type>
84
+ <sort_order>6</sort_order>
85
+ <show_in_default>1</show_in_default>
86
+ <show_in_website>1</show_in_website>
87
+ <show_in_store>0</show_in_store>
88
+ </ws_url>
89
+
90
+ <payto translate="label">
91
+ <label>Pay to</label>
92
+ <validate>required-entry</validate>
93
+ <frontend_type>text</frontend_type>
94
+ <sort_order>7</sort_order>
95
+ <show_in_default>1</show_in_default>
96
+ <show_in_website>1</show_in_website>
97
+ <show_in_store>0</show_in_store>
98
+ </payto>
99
+
100
+ <bank_of_first_deposit_name translate="label">
101
+ <label>Bank Of First Deposit Name</label>
102
+ <validate>required-entry</validate>
103
+ <frontend_type>text</frontend_type>
104
+ <backend_model>adminhtml/system_config_backend_bankoffirstdepositname</backend_model>
105
+ <sort_order>8</sort_order>
106
+ <show_in_default>1</show_in_default>
107
+ <show_in_website>1</show_in_website>
108
+ <show_in_store>0</show_in_store>
109
+ </bank_of_first_deposit_name>
110
+
111
+ <bank_of_first_deposit_routing_number translate="label">
112
+ <label>Bank Of First Deposit Routing Number</label>
113
+ <validate>required-entry</validate>
114
+ <backend_model>adminhtml/system_config_backend_bankoffirstdepositroutingnumber</backend_model>
115
+ <frontend_type>text</frontend_type>
116
+ <sort_order>9</sort_order>
117
+ <show_in_default>1</show_in_default>
118
+ <show_in_website>1</show_in_website>
119
+ <show_in_store>0</show_in_store>
120
+ </bank_of_first_deposit_routing_number>
121
+
122
+ <bank_of_first_deposit_account_number translate="label">
123
+ <label>Bank Of First Deposit Account Number</label>
124
+ <validate>required-entry</validate>
125
+ <backend_model>adminhtml/system_config_backend_bankoffirstdepositaccountnumber</backend_model>
126
+ <frontend_type>text</frontend_type>
127
+ <sort_order>10</sort_order>
128
+ <show_in_default>1</show_in_default>
129
+ <show_in_website>1</show_in_website>
130
+ <show_in_store>0</show_in_store>
131
+ </bank_of_first_deposit_account_number>
132
+
133
+ <return_routing_number translate="label">
134
+ <label>Return Routing Number</label>
135
+ <validate>required-entry</validate>
136
+ <backend_model>adminhtml/system_config_backend_returningroutingnumber</backend_model>
137
+ <frontend_type>text</frontend_type>
138
+ <sort_order>11</sort_order>
139
+ <show_in_default>1</show_in_default>
140
+ <show_in_website>1</show_in_website>
141
+ <show_in_store>0</show_in_store>
142
+ </return_routing_number>
143
+
144
+ <do_not_add_virtual_endorsement translate="label">
145
+ <label>Do Not Add Virtual Endorsement</label>
146
+ <frontend_type>select</frontend_type>
147
+ <source_model>adminhtml/system_config_source_yesno</source_model>
148
+ <sort_order>12</sort_order>
149
+ <show_in_default>1</show_in_default>
150
+ <show_in_website>1</show_in_website>
151
+ <show_in_store>0</show_in_store>
152
+ </do_not_add_virtual_endorsement>
153
+
154
+ <non_virtual_endorsement translate="label">
155
+ <label>Non Virtual Endorsement</label>
156
+ <frontend_type>text</frontend_type>
157
+ <sort_order>13</sort_order>
158
+ <show_in_default>1</show_in_default>
159
+ <show_in_website>1</show_in_website>
160
+ <show_in_store>0</show_in_store>
161
+ </non_virtual_endorsement>
162
+
163
+ <support_url translate="label">
164
+ <label>Support URL</label>
165
+ <frontend_type>text</frontend_type>
166
+ <sort_order>14</sort_order>
167
+ <show_in_default>1</show_in_default>
168
+ <show_in_website>1</show_in_website>
169
+ <show_in_store>0</show_in_store>
170
+ </support_url>
171
+ <support_number translate="label">
172
+ <label>Support Number</label>
173
+ <frontend_type>text</frontend_type>
174
+ <sort_order>15</sort_order>
175
+ <show_in_default>1</show_in_default>
176
+ <show_in_website>1</show_in_website>
177
+ <show_in_store>0</show_in_store>
178
+ </support_number>
179
+ <message translate="label">
180
+ <label>Thank you Message</label>
181
+ <frontend_type>text</frontend_type>
182
+ <sort_order>16</sort_order>
183
+ <show_in_default>1</show_in_default>
184
+ <show_in_website>1</show_in_website>
185
+ <show_in_store>0</show_in_store>
186
+ </message>
187
+ <extra6 translate="label">
188
+ <label>Extra line 6</label>
189
+ <frontend_type>text</frontend_type>
190
+ <sort_order>17</sort_order>
191
+ <show_in_default>1</show_in_default>
192
+ <show_in_website>1</show_in_website>
193
+ <show_in_store>0</show_in_store>
194
+ </extra6>
195
+
196
+ <active translate="label">
197
+ <label>Enabled</label>
198
+ <frontend_type>select</frontend_type>
199
+ <source_model>adminhtml/system_config_source_yesno</source_model>
200
+ <sort_order>18</sort_order>
201
+ <show_in_default>1</show_in_default>
202
+ <show_in_website>1</show_in_website>
203
+ <show_in_store>0</show_in_store>
204
+ </active>
205
+ <accounttypes translate="label">
206
+ <label>Account Types</label>
207
+ <frontend_type>multiselect</frontend_type>
208
+ <source_model>echeck/EcheckPayment_source_accounttypes</source_model>
209
+ <sort_order>19</sort_order>
210
+ <show_in_default>1</show_in_default>
211
+ <show_in_website>1</show_in_website>
212
+ <show_in_store>0</show_in_store>
213
+ </accounttypes>
214
+
215
+ <order_status translate="label">
216
+ <label>New Order Status</label>
217
+ <frontend_type>select</frontend_type>
218
+ <source_model>adminhtml/system_config_source_order_status_processingcomplete</source_model>
219
+ <sort_order>20</sort_order>
220
+ <show_in_default>1</show_in_default>
221
+ <show_in_website>1</show_in_website>
222
+ <show_in_store>0</show_in_store>
223
+ </order_status>
224
+
225
+ <test_mode translate="label">
226
+ <label>Test Mode</label>
227
+ <frontend_type>select</frontend_type>
228
+ <source_model>adminhtml/system_config_source_testmodeACH</source_model>
229
+ <sort_order>21</sort_order>
230
+ <show_in_default>1</show_in_default>
231
+ <show_in_website>1</show_in_website>
232
+ <show_in_store>0</show_in_store>
233
+ </test_mode>
234
+ <debug translate="label">
235
+ <label>Debug</label>
236
+ <frontend_type>select</frontend_type>
237
+ <source_model>adminhtml/system_config_source_yesno</source_model>
238
+ <sort_order>22</sort_order>
239
+ <show_in_default>1</show_in_default>
240
+ <show_in_website>1</show_in_website>
241
+ <show_in_store>0</show_in_store>
242
+ </debug>
243
+ <title translate="label">
244
+ <label>Title</label>
245
+ <validate>required-entry</validate>
246
+ <frontend_type>text</frontend_type>
247
+ <sort_order>23</sort_order>
248
+ <show_in_default>1</show_in_default>
249
+ <show_in_website>1</show_in_website>
250
+ <show_in_store>1</show_in_store>
251
+ </title>
252
+
253
+ <min_order_total translate="label">
254
+ <label>Minimum Order Total Amount</label>
255
+ <frontend_type>text</frontend_type>
256
+ <sort_order>24</sort_order>
257
+ <show_in_default>1</show_in_default>
258
+ <show_in_website>1</show_in_website>
259
+ <show_in_store>0</show_in_store>
260
+ </min_order_total>
261
+ <max_order_total translate="label">
262
+ <label>Maximum Order Total Amount</label>
263
+ <frontend_type>text</frontend_type>
264
+ <sort_order>25</sort_order>
265
+ <show_in_default>1</show_in_default>
266
+ <show_in_website>1</show_in_website>
267
+ <show_in_store>0</show_in_store>
268
+ </max_order_total>
269
+ <payment_action translate="label">
270
+ <label>Transaction Type</label>
271
+ <frontend_type>select</frontend_type>
272
+ <source_model>echeck/EcheckPayment_source_paymentAction</source_model>
273
+ <sort_order>26</sort_order>
274
+ <show_in_default>1</show_in_default>
275
+ <show_in_website>1</show_in_website>
276
+ <show_in_store>0</show_in_store>
277
+ </payment_action>
278
+ <black_list translate="label">
279
+ <label>Black list of routing/account #</label>
280
+ <frontend_type>textarea</frontend_type>
281
+ <sort_order>27</sort_order>
282
+ <show_in_default>1</show_in_default>
283
+ <show_in_website>1</show_in_website>
284
+ <show_in_store>0</show_in_store>
285
+ </black_list>
286
+ <model>
287
+ </model>
288
+ </fields>
289
+ </echeckpayment>
290
+ </groups>
291
+ </payment>
292
+ </sections>
293
+ </config>
app/code/local/MagCheck/Echeck/sql/echeck_setup/mysql4-install-0.7.0.php ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 MagCheck
23
+ * @package MagCheck_Echeck
24
+ * @copyright Copyright (c) 2013 MagCheck (http://www.MagCheck.com)
25
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
26
+ */
27
+
28
+ $installer = $this;
29
+ /* @var $installer Mage_Core_Model_Resource_Setup */
30
+
31
+ $installer->startSetup();
32
+
33
+ $installer->run("
34
+
35
+ -- DROP TABLE if exists {$this->getTable('echeck_echeckpayment_debug')};
36
+ CREATE TABLE {$this->getTable('echeck_echeckpayment_debug')} (
37
+ `debug_id` int(10) unsigned NOT NULL auto_increment,
38
+ `request_body` text,
39
+ `response_body` text,
40
+ `request_serialized` text,
41
+ `result_serialized` text,
42
+ `request_dump` text,
43
+ `result_dump` text,
44
+ PRIMARY KEY (`debug_id`)
45
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
46
+
47
+ ");
48
+
49
+ $installer->endSetup();
app/design/adminhtml/default/default/template/payment/form/echeck.phtml ADDED
@@ -0,0 +1,62 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <fieldset class="form-list">
2
+ <?php $_code=$this->getMethodCode() ?>
3
+ <ul id="payment_form_<?php echo $_code ?>" style="display:none">
4
+ <li>
5
+ <div class="input-box">
6
+ <label for="<?php echo $_code ?>_echeck_routing_number"><?php echo $this->__('Bank routing number') ?> <span class="required">*</span></label><br />
7
+ <input id="<?php echo $_code ?>_echeck_routing_number" name="payment[echeck_routing_number]" class="required-entry">
8
+ </div>
9
+ </li>
10
+ <li>
11
+ <div class="input-box">
12
+ <label for="<?php echo $_code ?>_echeck_bank_name"><?php echo $this->__('Bank name') ?> <span class="required">*</span></label><br />
13
+ <input id="<?php echo $_code ?>_echeck_bank_name" name="payment[echeck_bank_name]" class="required-entry">
14
+ </div>
15
+ </li>
16
+ <li>
17
+ <div class="input-box">
18
+ <label for="<?php echo $_code ?>_echeck_bank_acct_num"><?php echo $this->__('Bank account number') ?> <span class="required">*</span></label><br />
19
+ <input id="<?php echo $_code ?>_echeck_bank_acct_num" name="payment[echeck_bank_acct_num]" class="required-entry">
20
+ </div>
21
+ </li>
22
+ <li>
23
+ <div class="input-box">
24
+ <label for="<?php echo $_code ?>_echeck_account_type"><?php echo $this->__('Account type') ?> <span class="required">*</span></label><br />
25
+ <select id="<?php echo $_code ?>_echeck_account_type" name="payment[echeck_account_type]" class="required-entry">
26
+ <option value=""><?php echo $this->__('--Please Select--')?></option>
27
+ <?php $_accountType = $this->getInfoData('account_type') ?>
28
+ <?php foreach ($this->getAccountAvailableTypes() as $_typeCode => $_typeName): ?>
29
+ <option value="<?php echo $_typeCode ?>"<?php if($_typeCode==$_accountType): ?> selected="selected"<?php endif ?>><?php echo $_typeName ?></option>
30
+ <?php endforeach ?>
31
+ </select>
32
+ </div>
33
+ </li>
34
+
35
+ <li>
36
+ <div class="input-box">
37
+ <label for="<?php echo $_code ?>_echeck_check_number"><?php echo $this->__('Check #') ?> <span class="required">*</span></label><br />
38
+ <input id="<?php echo $_code ?>_echeck_check_number" name="payment[echeck_check_number]" class="required-entry">
39
+ </div>
40
+ </li>
41
+
42
+ <li>
43
+ <div class="input-box">
44
+ <label for="<?php echo $_code ?>_echeck_check_date"><?php echo $this->__('Check Date (yyyy-mm-dd)') ?> <span class="required">*</span></label><br />
45
+ <input id="<?php echo $_code ?>_echeck_check_date" name="payment[echeck_check_date]" class="required-entry">
46
+ </div>
47
+ </li>
48
+
49
+ <!-- <li>
50
+ <div class="input-box">
51
+ <label for="<?php echo $_code ?>_echeck_account_name"><?php echo $this->__('Name On Account') ?> <span class="required">*</span></label><br />
52
+ <input id="<?php echo $_code ?>_echeck_account_name" name="payment[echeck_account_name]" class="required-entry">
53
+ </div>
54
+ </li> -->
55
+ <!-- li>
56
+ <div class="input-box">
57
+ <label for="<?php echo $_code ?>_echeck_type"><?php echo $this->__('Echeck type') ?> <span class="required">*</span></label><br />
58
+ <input id="<?php echo $_code ?>_echeck_type" name="payment[echeck_type]" class="required-entry">
59
+ </div>
60
+ </li-->
61
+ </ul>
62
+ </fieldset>
app/design/adminhtml/default/default/template/payment/info/echeck.phtml ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
1
+ <?php if($_info = $this->getInfo()): ?>
2
+ <?php echo $this->__('Bank routing number: %s', $this->htmlEscape($_info->getEcheckRoutingNumber())) ?><br />
3
+ <?php echo $this->__('Bank name: %s', $this->htmlEscape($_info->getEcheckBankName())) ?><br />
4
+ <?php echo $this->__('Account type: %s', $this->htmlEscape($_info->getEcheckAccountType())) ?><br />
5
+ <!-- <?php echo $this->__('Account name: %s', $this->htmlEscape($_info->getEcheckAccountName())) ?><br /> -->
6
+ <?php echo $this->__('Account number: ***%s', $this->htmlEscape($_info->getEcheckBankAcctNum4())) ?><br />
7
+ <?php endif; ?>
app/design/frontend/base/default/template/payment/form/echeck.phtml ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <fieldset class="form-list">
2
+ <?php $_code=$this->getMethodCode() ?>
3
+ <ul id="payment_form_<?php echo $_code ?>" style="display:none">
4
+ <li>
5
+ <div class="input-box">
6
+ <label for="<?php echo $_code ?>_echeck_routing_number"><?php echo $this->__('Bank routing number') ?> <span class="required">*</span></label><br />
7
+ <input id="<?php echo $_code ?>_echeck_routing_number" name="payment[echeck_routing_number]" class="required-entry validate-digits validate-length minimum-length-9 maximum-length-9">
8
+ </div>
9
+ </li>
10
+ <li>
11
+ <div class="input-box">
12
+ <label for="<?php echo $_code ?>_echeck_bank_name"><?php echo $this->__('Bank name') ?> <span class="required">*</span></label><br />
13
+ <input id="<?php echo $_code ?>_echeck_bank_name" name="payment[echeck_bank_name]" class="required-entry validate-length minimum-length-3 maximum-length-100">
14
+ </div>
15
+ </li>
16
+ <li>
17
+ <div class="input-box">
18
+ <label for="<?php echo $_code ?>_echeck_bank_acct_num"><?php echo $this->__('Bank account number') ?> <span class="required">*</span></label><br />
19
+ <input id="<?php echo $_code ?>_echeck_bank_acct_num" name="payment[echeck_bank_acct_num]" class="required-entry validate-digits validate-length minimum-length-5 maximum-length-17">
20
+ </div>
21
+ </li>
22
+ <li>
23
+ <div class="input-box">
24
+ <label for="<?php echo $_code ?>_echeck_account_type"><?php echo $this->__('Account type') ?> <span class="required">*</span></label><br />
25
+ <select id="<?php echo $_code ?>_echeck_account_type" name="payment[echeck_account_type]" class="required-entry">
26
+ <option value=""><?php echo $this->__('--Please Select--')?></option>
27
+ <?php $_accountType = $this->getInfoData('account_type') ?>
28
+ <?php foreach ($this->getAccountAvailableTypes() as $_typeCode => $_typeName): ?>
29
+ <option value="<?php echo $_typeCode ?>"<?php if($_typeCode==$_accountType): ?> selected="selected"<?php endif ?>><?php echo $_typeName ?></option>
30
+ <?php endforeach ?>
31
+ </select>
32
+ </div>
33
+ </li>
34
+
35
+ <li>
36
+ <div class="input-box">
37
+ <label for="<?php echo $_code ?>_echeck_check_number"><?php echo $this->__('Check #') ?> <span class="required">*</span></label><br />
38
+ <input id="<?php echo $_code ?>_echeck_check_number" name="payment[echeck_check_number]" class="required-entry validate-digits validate-length minimum-length-3 maximum-length-6">
39
+ </div>
40
+ </li>
41
+
42
+
43
+ <!-- <li>
44
+ <div class="input-box">
45
+ <label for="<?php echo $_code ?>_echeck_account_name"><?php echo $this->__('Name On Account') ?> <span class="required">*</span></label><br />
46
+ <input id="<?php echo $_code ?>_echeck_account_name" name="payment[echeck_account_name]" class="required-entry">
47
+ </div>
48
+ </li> -->
49
+ <!-- li>
50
+ <div class="input-box">
51
+ <label for="<?php echo $_code ?>_echeck_type"><?php echo $this->__('Echeck type') ?> <span class="required">*</span></label><br />
52
+ <input id="<?php echo $_code ?>_echeck_type" name="payment[echeck_type]" class="required-entry">
53
+ </div>
54
+ </li-->
55
+ </ul>
56
+ </fieldset>
app/design/frontend/default/default/template/payment/form/echeck.phtml ADDED
@@ -0,0 +1,94 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <fieldset class="form-list">
2
+ <?php $_code=$this->getMethodCode() ?>
3
+ <ul id="payment_form_<?php echo $_code ?>" style="display:none">
4
+ <li>
5
+ <div class="input-box">
6
+ <label for="<?php echo $_code ?>_echeck_routing_number"><?php echo $this->__('Bank routing number') ?> <span class="required">*</span></label><br />
7
+ <input id="<?php echo $_code ?>_echeck_routing_number" name="payment[echeck_routing_number]" class="required-entry validate-digits validate-length minimum-length-9 maximum-length-9 routingnumer">
8
+ </div>
9
+ </li>
10
+ <li>
11
+ <div class="input-box">
12
+ <label for="<?php echo $_code ?>_echeck_bank_name"><?php echo $this->__('Bank name') ?> <span class="required">*</span></label><br />
13
+ <input id="<?php echo $_code ?>_echeck_bank_name" name="payment[echeck_bank_name]" class="required-entry validate-length minimum-length-3 maximum-length-100">
14
+ </div>
15
+ </li>
16
+ <li>
17
+ <div class="input-box">
18
+ <label for="<?php echo $_code ?>_echeck_bank_acct_num"><?php echo $this->__('Bank account number') ?> <span class="required">*</span></label><br />
19
+ <input id="<?php echo $_code ?>_echeck_bank_acct_num" name="payment[echeck_bank_acct_num]" class="required-entry validate-accountnumber validate-length minimum-length-5 maximum-length-17">
20
+ </div>
21
+ </li>
22
+ <li>
23
+ <div class="input-box">
24
+ <label for="<?php echo $_code ?>_echeck_account_type"><?php echo $this->__('Account type') ?> <span class="required">*</span></label><br />
25
+ <select id="<?php echo $_code ?>_echeck_account_type" name="payment[echeck_account_type]" class="required-entry">
26
+ <option value=""><?php echo $this->__('--Please Select--')?></option>
27
+ <?php $_accountType = $this->getInfoData('account_type') ?>
28
+ <?php foreach ($this->getAccountAvailableTypes() as $_typeCode => $_typeName): ?>
29
+ <option value="<?php echo $_typeCode ?>"<?php if($_typeCode==$_accountType): ?> selected="selected"<?php endif ?>><?php echo $_typeName ?></option>
30
+ <?php endforeach ?>
31
+ </select>
32
+ </div>
33
+ </li>
34
+
35
+ <li>
36
+ <div class="input-box">
37
+ <label for="<?php echo $_code ?>_echeck_check_number"><?php echo $this->__('Check #') ?> <span class="required">*</span></label><br />
38
+ <input id="<?php echo $_code ?>_echeck_check_number" name="payment[echeck_check_number]" class="required-entry validate-digits validate-length minimum-length-3 maximum-length-6">
39
+ </div>
40
+ </li>
41
+
42
+
43
+ <!-- <li>
44
+ <div class="input-box">
45
+ <label for="<?php echo $_code ?>_echeck_account_name"><?php echo $this->__('Name On Account') ?> <span class="required">*</span></label><br />
46
+ <input id="<?php echo $_code ?>_echeck_account_name" name="payment[echeck_account_name]" class="required-entry">
47
+ </div>
48
+ </li> -->
49
+ <!-- li>
50
+ <div class="input-box">
51
+ <label for="<?php echo $_code ?>_echeck_type"><?php echo $this->__('Echeck type') ?> <span class="required">*</span></label><br />
52
+ <input id="<?php echo $_code ?>_echeck_type" name="payment[echeck_type]" class="required-entry">
53
+ </div>
54
+ </li-->
55
+ </ul>
56
+ </fieldset>
57
+
58
+ <script type='text/javascript'>
59
+
60
+ //< ![CDATA[
61
+ Validation.add('validate-accountnumber', 'Account Number can only contain digits and dashes at the middle.', function(v) {
62
+ var n = v.replace("-","0");
63
+ n = n.replace("+","*");
64
+ n = n.replace(" ","*");
65
+
66
+ var isdigit = !isNaN(n);
67
+ ret = true;
68
+ if(v.indexOf("-") == 0 || v.indexOf("-") == (v.length-1) || (v.length - v.replace("-","").length) > 1)
69
+ ret = false;
70
+ return ret && isdigit;
71
+ });
72
+
73
+ Validation.add('routingnumer', 'Invalid Routing Number.', function(v) {
74
+
75
+ if (v.length ==9)
76
+ {
77
+ d = v.split("");
78
+ if ((3*(Number(d[0])+Number(d[3])+Number(d[6]))+7*(Number(d[1])+Number(d[4])+Number(d[7]))+(Number(d[2])+Number(d[5])+Number(d[8])))%10==0)
79
+ isvalid = true;
80
+ else
81
+ isvalid = false;
82
+
83
+ if(isvalid)
84
+ {
85
+ var pattern =new RegExp("^((0\\d)|(1[0-2])|(2[1-9])|(3[0-2])|(80))\\d{2}[\\d|-]\\d{4}$");
86
+ isvalid = v.match(pattern);
87
+ }
88
+ }
89
+ return isvalid;
90
+ });
91
+
92
+
93
+ //]]>
94
+ </script>
app/design/frontend/default/default/template/payment/info/echeck.phtml ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
1
+ <?php if($_info = $this->getInfo()): ?>
2
+ <?php echo $this->__('Bank routing number: %s', $this->htmlEscape($_info->getEcheckRoutingNumber())) ?><br />
3
+ <?php echo $this->__('Bank name: %s', $this->htmlEscape($_info->getEcheckBankName())) ?><br />
4
+ <?php echo $this->__('Account type: %s', $this->htmlEscape($_info->getEcheckAccountType())) ?><br />
5
+ <!-- <?php echo $this->__('Account name: %s', $this->htmlEscape($_info->getEcheckAccountName())) ?><br /> -->
6
+ <?php echo $this->__('Account number: ***%s', $this->htmlEscape($_info->getEcheckBankAcctNum4())) ?><br />
7
+ <?php endif; ?>
app/etc/modules/MagCheck_Echeck.xml ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ <config>
2
+ <modules>
3
+ <MagCheck_Echeck>
4
+ <active>true</active>
5
+ <codePool>local</codePool>
6
+ </MagCheck_Echeck>
7
+ </modules>
8
+ </config>
package.xml ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>MagCheck</name>
4
+ <version>0.0.7.0</version>
5
+ <stability>stable</stability>
6
+ <license>OSL v3.0</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>Magcheck gateway electronic check payment module.</summary>
10
+ <description>This is an e-check module to be used with the MagCheck payment gateway. This extension requires a MagCheck gateway account.</description>
11
+ <notes>E-Check payment module to be used with a MagCheck gateway account.</notes>
12
+ <authors><author><name>MagCheck</name><user>auto-converted</user><email>MagCheck@MagCheck.com</email></author></authors>
13
+ <date>2013-01-03</date>
14
+ <time>17:08:50</time>
15
+ <contents><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="template"><dir name="payment"><dir name="form"><file name="echeck.phtml" hash="9fafb7aedbd119d560e46924ee051616"/></dir><dir name="info"><file name="echeck.phtml" hash="a42bea9e87b1c57d5189e0ac0b9d5df9"/></dir></dir></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="template"><dir name="payment"><dir name="form"><file name="echeck.phtml" hash="9fafb7aedbd119d560e46924ee051616"/></dir></dir></dir></dir></dir><dir name="default"><dir name="default"><dir name="template"><dir name="payment"><dir name="form"><file name="echeck.phtml" hash="9fafb7aedbd119d560e46924ee051616"/></dir><dir name="info"><file name="echeck.phtml" hash="a42bea9e87b1c57d5189e0ac0b9d5df9"/></dir></dir></dir></dir></dir></dir></target><target name="magelocal"><dir name="MagCheck"><dir name="Echeck"><dir name="Block"><dir name="Form"><file name="Echeck.php" hash="8923468466074253526500bd4fabe2e2"/></dir><dir name="Info"><file name="Echeck.php" hash="76a035e618edbcd0463db55f26ce3cb1"/></dir><file name="Form.php" hash="f6559b3ed104627ef0b2d19e9795dc17"/><file name="Info.php" hash="de65c278c010d85d67e5b1ae031a1c28"/></dir><dir name="etc"><file name="config.xml" hash="744ed9c6ff46796ab6e9e6951a204855"/><file name="system.xml" hash="6fa190cc20acd35f35547c1f2509b2c1"/></dir><dir name="Helper"><file name="Data.php" hash="8f64e111734ce162a0d0b28ebad1db90"/></dir><dir name="Model"><dir name="EcheckPayment"><dir name="Source"><file name="Accounttypes.php" hash="3c8b8034d6c96b0280db4e7e595ab73c"/><file name="PaymentAction.php" hash="9da2c6580cfd6d611c207e5be3b2aea5"/></dir><file name="Debug.php" hash="76d8cb6c86a595b2b78d43664c6dd6e8"/><file name="Request.php" hash="0a65c3aae69eb0c196231cbf6f007cec"/><file name="Result.php" hash="6935ba845811c005b9c501a03891e33a"/></dir><dir name="Mysql4"><dir name="ECheckPayment"><dir name="Debug"><file name="Collection.php" hash="aa8222f78f17b4c35050c9d06dc085bc"/></dir><file name="Debug.php" hash="829e050092ffb527e08a6a9d9959374a"/></dir></dir><file name="Config.php" hash="94567f95c4463897ba822ca1c61dca7a"/><file name="EcheckPayment.php" hash="d9350ce4158a8cdf6e2f848cfd667ba6"/></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="Backend"> <file name="BankOfFirstDepositAccountNumber.php" hash="aa8222f78f17b4c35050c9d06dc085bd"/> <file name="BankOfFirstDepositName.php" hash="aa8222f78f17b4c35050c9d06dc085be"/> <file name="BankOfFirstDepositRoutingNumber.php" hash="aa8222f78f17b4c35050c9d06dc085bf"/> <file name="ReturningRoutingNumber.php" hash="aa8222f78f17b4c35050c9d06dc085ca"/></dir><dir name="Source"><dir name="Order"><dir name="Status"><file name="Processingcomplete.php" hash="f9eb96ffc645117a04cc094b62fb24d4"/></dir></dir><file name="TestmodeACH.php" hash="371db79c030d69b3b19fc4caac4e7ba0"/></dir></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="MagCheck_Echeck.xml" hash="252f244ae4f8cba53f883559a23273c7"/></dir></target></contents>
16
+ <compatible/>
17
+ <dependencies/>
18
+ </package>