Craig_Tco - Version 1.1.9

Version Notes

Add additional data sanitation
Updated to work with 1.6.0.0

Download this release

Release Info

Developer Magento Core Team
Extension Craig_Tco
Version 1.1.9
Comparing to
See all releases


Code changes from version 1.1.8 to 1.1.9

app/code/local/Craig/Tco/Block/Redirect.php DELETED
@@ -1,53 +0,0 @@
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
- * @category Craig Christenson
17
- * @package Tco (2Checkout.com)
18
- * @copyright Copyright (c) 2010 Craig Christenson
19
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
- */
21
-
22
-
23
-
24
- class Craig_Tco_Block_Redirect extends Mage_Core_Block_Abstract
25
- {
26
- protected function _toHtml()
27
- {
28
- $tco = Mage::getModel('tco/checkout');
29
-
30
- $form = new Varien_Data_Form();
31
- $form->setAction($tco->getUrl())
32
- ->setId('pay')
33
- ->setName('pay')
34
- ->setMethod('POST')
35
- ->setUseContainer(true);
36
- $tco->getFormFields();
37
- foreach ($tco->getFormFields() as $field=>$value) {
38
- $form->addField($field, 'hidden', array('name'=>$field, 'value'=>$value, 'size'=>200));
39
- }
40
-
41
- $html = '<html><body>';
42
- $html.= $this->__('You will be redirected to 2Checkout in a few seconds.');
43
- $html.= $form->toHtml();
44
- $html.= '<br>';
45
- $html.= '<script type="text/javascript">document.getElementById("pay").submit();</script>';
46
- $html.= '</body></html>';
47
-
48
-
49
- return $html;
50
- }
51
- }
52
-
53
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/Craig/Tco/Model/Checkout.php CHANGED
@@ -41,10 +41,12 @@ class Craig_Tco_Model_Checkout extends Mage_Payment_Model_Method_Abstract {
41
 
42
  //get Demo Setting
43
  public function getDemo() {
44
- if ($this->getConfigData('demo') == '1') {
45
- $demo = 'Y';
46
- }
47
- return $demo;
 
 
48
  }
49
 
50
  //get purchase routine URL
41
 
42
  //get Demo Setting
43
  public function getDemo() {
44
+ if ($this->getConfigData('demo') == '1') {
45
+ $demo = 'Y';
46
+ } else {
47
+ $demo = 'N';
48
+ }
49
+ return $demo;
50
  }
51
 
52
  //get purchase routine URL
app/code/local/Craig/Tco/controllers/NotificationController.php CHANGED
@@ -1,4 +1,4 @@
1
- <?php
2
 
3
  /*
4
  * Magento
@@ -18,8 +18,8 @@
18
  * @copyright Copyright (c) 2010 Craig Christenson
19
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
  */
21
-
22
- class Craig_Tco_NotificationController extends Mage_Core_Controller_Front_Action {
23
 
24
  public function indexAction() {
25
  if (!$this->getRequest()->isPost()) {
@@ -28,22 +28,24 @@ class Craig_Tco_NotificationController extends Mage_Core_Controller_Front_Action
28
  }
29
  }
30
 
31
-
32
  public function insAction()
33
  {
34
  $insMessage = $this->getRequest()->getPost();
35
- foreach ($_POST as $key => $value) {
36
- $request .= '<' . $k . '>' . $v . '</' . $k . '>';
 
 
37
  }
38
-
39
  if (empty($insMessage)) {
40
  echo "No Parameters";
41
  } else
42
  echo "Parameters Found";
43
-
44
 
45
  $order = Mage::getModel('sales/order');
46
- $order->loadByIncrementId($insMessage['vendor_order_id']);
47
  $hashSecretWord = Mage::getStoreConfig('payment/tco/secret_word');
48
  $hashSid = $insMessage['vendor_id'];
49
  $hashOrder = $insMessage['sale_id'];
@@ -53,20 +55,20 @@ class Craig_Tco_NotificationController extends Mage_Core_Controller_Front_Action
53
  if ($StringToHash != $insMessage['md5_hash']) {
54
  die('Hash Incorrect');
55
  }
56
-
57
  if ($insMessage['fraud_status'] == 'fail') {
58
  $order->setState(Mage_Sales_Model_Order::STATE_CANCELED, true)->save(); }
59
  else {
60
  echo "Order did not fail fraud review"; }
61
-
62
  if ($insMessage['fraud_status'] == 'pass') {
63
- $order->setState(Mage_Sales_Model_Order::STATE_COMPLETE, true)->save(); }
64
  else {
65
  echo "Order did not pass fraud review"; }
66
-
67
  }
68
-
69
-
70
-
71
  }
72
  ?>
1
+ <?php
2
 
3
  /*
4
  * Magento
18
  * @copyright Copyright (c) 2010 Craig Christenson
19
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
  */
21
+
22
+ class Craig_Tco_NotificationController extends Mage_Core_Controller_Front_Action {
23
 
24
  public function indexAction() {
25
  if (!$this->getRequest()->isPost()) {
28
  }
29
  }
30
 
31
+
32
  public function insAction()
33
  {
34
  $insMessage = $this->getRequest()->getPost();
35
+ foreach ($_REQUEST as $k => $v) {
36
+ $v = htmlspecialchars($v);
37
+ $v = stripslashes($v);
38
+ $insMessage[$k] = $v;
39
  }
40
+
41
  if (empty($insMessage)) {
42
  echo "No Parameters";
43
  } else
44
  echo "Parameters Found";
45
+
46
 
47
  $order = Mage::getModel('sales/order');
48
+ $order->loadByIncrementId($insMessage['vendor_order_id']);
49
  $hashSecretWord = Mage::getStoreConfig('payment/tco/secret_word');
50
  $hashSid = $insMessage['vendor_id'];
51
  $hashOrder = $insMessage['sale_id'];
55
  if ($StringToHash != $insMessage['md5_hash']) {
56
  die('Hash Incorrect');
57
  }
58
+
59
  if ($insMessage['fraud_status'] == 'fail') {
60
  $order->setState(Mage_Sales_Model_Order::STATE_CANCELED, true)->save(); }
61
  else {
62
  echo "Order did not fail fraud review"; }
63
+
64
  if ($insMessage['fraud_status'] == 'pass') {
65
+ $order->setState(Mage_Sales_Model_Order::STATE_PROCESSING, true)->save(); }
66
  else {
67
  echo "Order did not pass fraud review"; }
68
+
69
  }
70
+
71
+
72
+
73
  }
74
  ?>
app/code/local/Craig/Tco/controllers/RedirectController.php CHANGED
@@ -24,7 +24,7 @@ class Craig_Tco_RedirectController extends Mage_Core_Controller_Front_Action {
24
  public function getCheckout() {
25
  return Mage::getSingleton('checkout/session');
26
  }
27
-
28
  protected $order;
29
 
30
  protected function _expireAjax() {
@@ -40,40 +40,51 @@ class Craig_Tco_RedirectController extends Mage_Core_Controller_Front_Action {
40
  ->setBody($this->getLayout()
41
  ->createBlock('tco/redirect')
42
  ->toHtml());
43
-
44
  }
45
 
46
  public function successAction() {
47
  $post = $this->getRequest()->getPost();
 
 
 
 
 
 
 
 
 
 
48
  $session = Mage::getSingleton('checkout/session');
49
- $session->setQuoteId($_REQUEST['cart_order_id']);
50
  Mage::getSingleton('checkout/session')->getQuote()->setIsActive(false)->save();
51
  $this->_redirect('checkout/onepage/success');
52
- $order = Mage::getModel('sales/order');
 
53
  $order->loadByIncrementId($session->getLastRealOrderId());
54
-
55
  $hashSecretWord = Mage::getStoreConfig('payment/tco/secret_word');
56
- $hashSid = $_REQUEST['sid'];
57
  if (Mage::getStoreConfig('payment/tco/demo') == '1') {
58
  $hashOrder = '1';
59
  }
60
  else {
61
- $hashOrder = $_REQUEST['order_number'];
62
  }
63
- $hashTotal = $_REQUEST['total'];
64
 
65
  $StringToHash = strtoupper(md5($hashSecretWord . $hashSid . $hashOrder . $hashTotal));
66
-
67
- if ($StringToHash == $_REQUEST['key']) {
68
  $this->_redirect('checkout/onepage/success');
69
  $order->sendNewOrderEmail();
70
  $order->setState(Mage_Sales_Model_Order::STATE_PROCESSING, true)->save();
71
- }
72
  else {
73
- $this->_redirect('checkout/onepage/');
74
-
75
  }
76
-
77
  }
78
 
79
  }
24
  public function getCheckout() {
25
  return Mage::getSingleton('checkout/session');
26
  }
27
+
28
  protected $order;
29
 
30
  protected function _expireAjax() {
40
  ->setBody($this->getLayout()
41
  ->createBlock('tco/redirect')
42
  ->toHtml());
43
+
44
  }
45
 
46
  public function successAction() {
47
  $post = $this->getRequest()->getPost();
48
+
49
+
50
+ $insMessage = $this->getRequest()->getPost();
51
+ foreach ($_REQUEST as $k => $v) {
52
+ $v = htmlspecialchars($v);
53
+ $v = stripslashes($v);
54
+
55
+ $post[$k] = $v;
56
+ }
57
+
58
  $session = Mage::getSingleton('checkout/session');
59
+ $session->setQuoteId($post['cart_order_id']);
60
  Mage::getSingleton('checkout/session')->getQuote()->setIsActive(false)->save();
61
  $this->_redirect('checkout/onepage/success');
62
+
63
+ $order = Mage::getModel('sales/order');
64
  $order->loadByIncrementId($session->getLastRealOrderId());
65
+
66
  $hashSecretWord = Mage::getStoreConfig('payment/tco/secret_word');
67
+ $hashSid = Mage::getStoreConfig('payment/tco/sid');
68
  if (Mage::getStoreConfig('payment/tco/demo') == '1') {
69
  $hashOrder = '1';
70
  }
71
  else {
72
+ $hashOrder = $post['order_number'];
73
  }
74
+ $hashTotal = $post['total'];
75
 
76
  $StringToHash = strtoupper(md5($hashSecretWord . $hashSid . $hashOrder . $hashTotal));
77
+
78
+ if ($StringToHash == $post['key']) {
79
  $this->_redirect('checkout/onepage/success');
80
  $order->sendNewOrderEmail();
81
  $order->setState(Mage_Sales_Model_Order::STATE_PROCESSING, true)->save();
82
+ }
83
  else {
84
+ $this->_redirect('checkout/onepage/success');
85
+
86
  }
87
+
88
  }
89
 
90
  }
app/code/local/Craig/Tco/etc/config.xml CHANGED
@@ -24,7 +24,7 @@
24
  <config>
25
  <modules>
26
  <Craig_Tco>
27
- <version>1.1.8</version>
28
  </Craig_Tco>
29
  </modules>
30
  <global>
@@ -82,7 +82,7 @@
82
  <payment>
83
  <tco>
84
  <active>1</active>
85
- <submit_url>https://www.2checkout.com/checkout/purchase</submit_url>
86
  <model>tco/checkout</model>
87
  <title>2Checkout (Visa, MasterCard, Amex, Discover, JCB, Diners Club, Debit Card, PayPal)</title>
88
  <sid>Enter USD 2Checkout Account Number</sid>
24
  <config>
25
  <modules>
26
  <Craig_Tco>
27
+ <version>1.1.9</version>
28
  </Craig_Tco>
29
  </modules>
30
  <global>
82
  <payment>
83
  <tco>
84
  <active>1</active>
85
+ <submit_url>https://www.2checkout.com/checkout/spurchase</submit_url>
86
  <model>tco/checkout</model>
87
  <title>2Checkout (Visa, MasterCard, Amex, Discover, JCB, Diners Club, Debit Card, PayPal)</title>
88
  <sid>Enter USD 2Checkout Account Number</sid>
app/design/frontend/base/default/template/tco/info.phtml CHANGED
@@ -19,7 +19,8 @@
19
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
  */
21
 
22
- echo $this->__('2Checkout (Credit Card, Debit Card, PayPal)');
23
  ?>
 
24
 
25
 
19
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
  */
21
 
22
+ //echo $this->__('2Checkout (Credit Card, Debit Card, PayPal)');
23
  ?>
24
+ 2Checkout (Credit Card, Debit Card, PayPal)
25
 
26
 
package.xml CHANGED
@@ -1,18 +1,19 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Craig_Tco</name>
4
- <version>1.1.8</version>
5
  <stability>stable</stability>
6
- <license uri="http://www.opensource.org/licenses/osl-3.0.php">OSL v3.0</license>
7
  <channel>community</channel>
8
  <extends/>
9
  <summary>2Checkout Payment Extension</summary>
10
  <description>2Checkout Payment Extension</description>
11
- <notes>Update to correct template issue</notes>
12
- <authors><author><name>Craig Christenson</name><user>undeadzed</user><email>christensoncraig@gmail.com</email></author></authors>
13
- <date>2011-03-22</date>
14
- <time>14:24:46</time>
15
- <contents><target name="magelocal"><dir name="Craig"><dir name="Tco"><dir name="Block"><file name="Form.php" hash="b552018543f57090c42784d939004dd4"/><file name="Info.php" hash="2e42f56143a93944240faa7dfca3e183"/><file name="Redirect.php" hash="d3766dbf0c0a206c8630cd1e8de4927f"/></dir><dir name="controllers"><file name="NotificationController.php" hash="1ca96f3dc5a4bfadc1c82dffe84ef887"/><file name="RedirectController.php" hash="c7bf19340a3f90c2f42b69a85d084a59"/></dir><dir name="etc"><file name="config.xml" hash="de77bd22e6c8a0aa461316eef0494de2"/><file name="system.xml" hash="d76189971008c4ba88e7a45864b7d60c"/></dir><dir name="Helper"><file name="Data.php" hash="de7680011db7d6821c1f68d70a8fa684"/></dir><dir name="Model"><file name="Checkout.php" hash="e80f72724a3d2e4cfc2a17d56af79963"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Craig_Tco.xml" hash="4a6e92678d9b2a310af880d35a4c355f"/></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="template"><dir name="tco"><file name="form.phtml" hash="08ae585e158550d0a5dccbed3d37758d"/><file name="info.phtml" hash="b714a7398773adc71ea086024dfc96b1"/></dir></dir></dir></dir></dir></target></contents>
 
16
  <compatible/>
17
- <dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
18
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Craig_Tco</name>
4
+ <version>1.1.9</version>
5
  <stability>stable</stability>
6
+ <license uri="http://www.opensource.org/licenses/osl-3.0.php">OSL-3.0</license>
7
  <channel>community</channel>
8
  <extends/>
9
  <summary>2Checkout Payment Extension</summary>
10
  <description>2Checkout Payment Extension</description>
11
+ <notes>Add additional data sanitation&#xD;
12
+ Updated to work with 1.6.0.0</notes>
13
+ <authors><author><name>Craig Christenson</name><user>auto-converted</user><email>christensoncraig@gmail.com</email></author></authors>
14
+ <date>2011-07-20</date>
15
+ <time>19:25:14</time>
16
+ <contents><target name="magelocal"><dir name="Craig"><dir name="Tco"><dir name="Block"><file name="Form.php" hash="b552018543f57090c42784d939004dd4"/><file name="Info.php" hash="2e42f56143a93944240faa7dfca3e183"/><file name="Redirect.php.php" hash=""/></dir><dir name="controllers"><file name="NotificationController.php" hash="ed3053c683eeb64f71d675564e30e5bb"/><file name="RedirectController.php" hash="6db70f5247fc921a07de2767cc8a5750"/></dir><dir name="Model"><file name="Checkout.php" hash="f38834dd1a3025d0ee1e85dbaf6ea1dc"/></dir><dir name="Helper"><file name="Data.php" hash="de7680011db7d6821c1f68d70a8fa684"/></dir><dir name="etc"><file name="config.xml" hash="743aa88539fdd7123fd7b7bf792a73d1"/><file name="system.xml" hash="d76189971008c4ba88e7a45864b7d60c"/></dir></dir></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="template"><dir name="tco"><file name="form.phtml" hash="08ae585e158550d0a5dccbed3d37758d"/><file name="info.phtml" hash="9064c9a14c49105f6ef69222d50dc675"/></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Craig_Tco.xml" hash="4a6e92678d9b2a310af880d35a4c355f"/></dir></target></contents>
17
  <compatible/>
18
+ <dependencies/>
19
  </package>