Craig_Tco - Version 2.1.6

Version Notes

Updating INS logic to check order total

Download this release

Release Info

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


Code changes from version 2.1.5 to 2.1.6

app/code/local/Craig/Tco/controllers/NotificationController.php CHANGED
@@ -47,72 +47,61 @@ class Craig_Tco_NotificationController extends Mage_Core_Controller_Front_Action
47
  $hashInvoice = $insMessage['invoice_id'];
48
  $StringToHash = strtoupper(md5($hashOrder . $hashSid . $hashInvoice . $hashSecretWord));
49
 
50
- if ($StringToHash != $insMessage['md5_hash']) {
 
 
51
  die('Hash Incorrect');
52
- }
53
-
54
- if ($insMessage['message_type'] == 'FRAUD_STATUS_CHANGED') {
55
- if ($insMessage['fraud_status'] == 'fail') {
56
  $order->setState(Mage_Sales_Model_Order::STATE_CANCELED, true)->addStatusHistoryComment('Order failed fraud review.')->save();
57
-
58
- } else if ($insMessage['fraud_status'] == 'pass') {
59
- $order->setState(Mage_Sales_Model_Order::STATE_PROCESSING, true)->addStatusHistoryComment('Order passed fraud review.')->save();
60
- //Invoice
61
- if ($invoice_on_fraud == '1') {
62
- try {
63
- if(!$order->canInvoice())
64
- {
65
  Mage::throwException(Mage::helper('core')->__('Cannot create an invoice.'));
66
  }
67
-
68
- $invoice = Mage::getModel('sales/service_order', $order)->prepareInvoice();
69
- if (!$invoice->getTotalQty()) {
70
- Mage::throwException(Mage::helper('core')->__('Cannot create an invoice without products.'));
71
- }
72
-
73
- $invoice->setRequestedCaptureCase(Mage_Sales_Model_Order_Invoice::CAPTURE_OFFLINE);
74
- $invoice->register();
75
- $transactionSave = Mage::getModel('core/resource_transaction')
76
- ->addObject($invoice)
77
- ->addObject($invoice->getOrder());
78
-
79
- $transactionSave->save();
80
- }
81
- catch (Mage_Core_Exception $e) {
82
  }
 
 
 
83
  }
84
-
85
- } else if ($insMessage['fraud_status'] == 'wait') {
86
- $order->addStatusHistoryComment('Order undergoing additional fraud investigation.');
87
- $order->save();
88
- }
89
- }
90
-
91
- if ($insMessage['message_type'] == 'ORDER_CREATED') {
92
- //Invoice
93
- if ($invoice_on_order == '1') {
94
- try {
95
- if(!$order->canInvoice())
96
- {
97
  Mage::throwException(Mage::helper('core')->__('Cannot create an invoice.'));
98
  }
 
 
 
 
99
 
100
- $invoice = Mage::getModel('sales/service_order', $order)->prepareInvoice();
101
- if (!$invoice->getTotalQty()) {
102
- Mage::throwException(Mage::helper('core')->__('Cannot create an invoice without products.'));
103
- }
104
-
105
- $invoice->setRequestedCaptureCase(Mage_Sales_Model_Order_Invoice::CAPTURE_OFFLINE);
106
- $invoice->register();
107
- $transactionSave = Mage::getModel('core/resource_transaction')
108
- ->addObject($invoice)
109
- ->addObject($invoice->getOrder());
110
-
111
- $transactionSave->save();
112
- }
113
- catch (Mage_Core_Exception $e) {
114
  }
115
  }
 
116
  }
117
  }
118
  }
47
  $hashInvoice = $insMessage['invoice_id'];
48
  $StringToHash = strtoupper(md5($hashOrder . $hashSid . $hashInvoice . $hashSecretWord));
49
 
50
+ if ($StringToHash != $insMessage['md5_hash'] && number_format($order->getBaseGrandTotal(), 2, '.', '') != $insMessage['invoice_list_amount']) {
51
+ $order->addStatusHistoryComment('Hash or total did not match!');
52
+ $order->save();
53
  die('Hash Incorrect');
54
+ } else {
55
+ if ($insMessage['message_type'] == 'FRAUD_STATUS_CHANGED') {
56
+ if ($insMessage['fraud_status'] == 'fail') {
 
57
  $order->setState(Mage_Sales_Model_Order::STATE_CANCELED, true)->addStatusHistoryComment('Order failed fraud review.')->save();
58
+ } else if ($insMessage['fraud_status'] == 'pass') {
59
+ $order->setState(Mage_Sales_Model_Order::STATE_PROCESSING, true)->addStatusHistoryComment('Order passed fraud review.')->save();
60
+ if ($invoice_on_fraud == '1') {
61
+ try {
62
+ if(!$order->canInvoice()) {
 
 
 
63
  Mage::throwException(Mage::helper('core')->__('Cannot create an invoice.'));
64
  }
65
+ $invoice = Mage::getModel('sales/service_order', $order)->prepareInvoice();
66
+ if (!$invoice->getTotalQty()) {
67
+ Mage::throwException(Mage::helper('core')->__('Cannot create an invoice without products.'));
68
+ }
69
+ $invoice->setRequestedCaptureCase(Mage_Sales_Model_Order_Invoice::CAPTURE_OFFLINE);
70
+ $invoice->register();
71
+ $transactionSave = Mage::getModel('core/resource_transaction')
72
+ ->addObject($invoice)
73
+ ->addObject($invoice->getOrder());
74
+ $transactionSave->save();
75
+ } catch (Mage_Core_Exception $e) {
76
+ echo $e;
77
+ }
 
 
78
  }
79
+ } else if ($insMessage['fraud_status'] == 'wait') {
80
+ $order->addStatusHistoryComment('Order undergoing additional fraud investigation.');
81
+ $order->save();
82
  }
83
+ } else if ($insMessage['message_type'] == 'ORDER_CREATED') {
84
+ if ($invoice_on_order == '1') {
85
+ try {
86
+ if(!$order->canInvoice()) {
 
 
 
 
 
 
 
 
 
87
  Mage::throwException(Mage::helper('core')->__('Cannot create an invoice.'));
88
  }
89
+ $invoice = Mage::getModel('sales/service_order', $order)->prepareInvoice();
90
+ if (!$invoice->getTotalQty()) {
91
+ Mage::throwException(Mage::helper('core')->__('Cannot create an invoice without products.'));
92
+ }
93
 
94
+ $invoice->setRequestedCaptureCase(Mage_Sales_Model_Order_Invoice::CAPTURE_OFFLINE);
95
+ $invoice->register();
96
+ $transactionSave = Mage::getModel('core/resource_transaction')
97
+ ->addObject($invoice)
98
+ ->addObject($invoice->getOrder());
99
+ $transactionSave->save();
100
+ } catch (Mage_Core_Exception $e) {
101
+ echo $e;
 
 
 
 
 
 
102
  }
103
  }
104
+ }
105
  }
106
  }
107
  }
app/code/local/Craig/Tco/controllers/RedirectController.php CHANGED
@@ -58,7 +58,7 @@ class Craig_Tco_RedirectController extends Mage_Core_Controller_Front_Action {
58
  $order->loadByIncrementId($session->getLastRealOrderId());
59
  $hashSecretWord = Mage::getStoreConfig('payment/tco/secret_word');
60
  $hashSid = Mage::getStoreConfig('payment/tco/sid');
61
- $hashTotal = $post['total'];
62
 
63
  if (Mage::getStoreConfig('payment/tco/demo') == '1') {
64
  $hashOrder = '1';
@@ -75,7 +75,9 @@ class Craig_Tco_RedirectController extends Mage_Core_Controller_Front_Action {
75
  $order->setData('ext_order_id',$post['order_number'] );
76
  $order->save();
77
  } else {
 
78
  $this->_redirect('checkout/onepage/success');
 
79
  $order->addStatusHistoryComment('Hash did not match, check secret word.');
80
  $order->save();
81
  }
58
  $order->loadByIncrementId($session->getLastRealOrderId());
59
  $hashSecretWord = Mage::getStoreConfig('payment/tco/secret_word');
60
  $hashSid = Mage::getStoreConfig('payment/tco/sid');
61
+ $hashTotal = number_format($order->getBaseGrandTotal(), 2, '.', '');
62
 
63
  if (Mage::getStoreConfig('payment/tco/demo') == '1') {
64
  $hashOrder = '1';
75
  $order->setData('ext_order_id',$post['order_number'] );
76
  $order->save();
77
  } else {
78
+ die($hashTotal);
79
  $this->_redirect('checkout/onepage/success');
80
+ $order->addStatusHistoryComment($hashTotal);
81
  $order->addStatusHistoryComment('Hash did not match, check secret word.');
82
  $order->save();
83
  }
app/code/local/Craig/Tco/etc/config.xml CHANGED
@@ -24,7 +24,7 @@
24
  <config>
25
  <modules>
26
  <Craig_Tco>
27
- <version>2.1.5</version>
28
  </Craig_Tco>
29
  </modules>
30
  <global>
24
  <config>
25
  <modules>
26
  <Craig_Tco>
27
+ <version>2.1.6</version>
28
  </Craig_Tco>
29
  </modules>
30
  <global>
package.xml CHANGED
@@ -1,18 +1,18 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Craig_Tco</name>
4
- <version>2.1.5</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>Official 2Checkout Payment Extension</description>
11
- <notes>Fixing missed quotes on tax code.</notes>
12
  <authors><author><name>Craig Christenson</name><user>auto-converted</user><email>christensoncraig@gmail.com</email></author></authors>
13
- <date>2012-08-11</date>
14
- <time>16:03:47</time>
15
- <contents><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><target name="magelocal"><dir name="Craig"><dir name="Tco"><dir name="Block"><file name="Form.php" hash="b552018543f57090c42784d939004dd4"/><file name="Info.php" hash="ceb4ec03e4de3e4f1dafaf5d7da9b982"/><file name="Redirect.php" hash="e2809d56d51bdc74367dad8da77ac563"/></dir><dir name="controllers"><file name="NotificationController.php" hash="2bbb8caf512b8bcdea2855842a56539b"/><file name="RedirectController.php" hash="197de0df037cf5ae45531ef735abfed1"/></dir><dir name="etc"><file name="config.xml" hash="8c68697c37fed191879b8e4eac4d672d"/><file name="system.xml" hash="4bf8199f530281ba446d9c943fcb6932"/></dir><dir name="Helper"><file name="Data.php" hash="de7680011db7d6821c1f68d70a8fa684"/></dir><dir name="Model"><file name="Checkout.php" hash="f31f811cccdcb8da39b5628a9cf3c008"/><file name="Observer.php" hash="727312c017289346a6c9a4aedb5fcc4f"/></dir></dir></dir></target></contents>
16
  <compatible/>
17
  <dependencies/>
18
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Craig_Tco</name>
4
+ <version>2.1.6</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>Official 2Checkout Payment Extension</description>
11
+ <notes>Updating INS logic to check order total</notes>
12
  <authors><author><name>Craig Christenson</name><user>auto-converted</user><email>christensoncraig@gmail.com</email></author></authors>
13
+ <date>2012-08-26</date>
14
+ <time>22:20:58</time>
15
+ <contents><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><target name="magelocal"><dir name="Craig"><dir name="Tco"><dir name="Block"><file name="Form.php" hash="b552018543f57090c42784d939004dd4"/><file name="Info.php" hash="ceb4ec03e4de3e4f1dafaf5d7da9b982"/><file name="Redirect.php" hash="e2809d56d51bdc74367dad8da77ac563"/></dir><dir name="controllers"><file name="NotificationController.php" hash="c978c760f0ee234a371ace1853353ccf"/><file name="RedirectController.php" hash="eebd0fcd99720550136e7c2e72a9cf90"/></dir><dir name="etc"><file name="config.xml" hash="631aaa705780764e46d68ddf020942d8"/><file name="system.xml" hash="4bf8199f530281ba446d9c943fcb6932"/></dir><dir name="Helper"><file name="Data.php" hash="de7680011db7d6821c1f68d70a8fa684"/></dir><dir name="Model"><file name="Checkout.php" hash="f31f811cccdcb8da39b5628a9cf3c008"/><file name="Observer.php" hash="727312c017289346a6c9a4aedb5fcc4f"/></dir></dir></dir></target></contents>
16
  <compatible/>
17
  <dependencies/>
18
  </package>