SalesTax_Connector - Version 3.0.2

Version Notes

Simplify sales and use tax calculation, compliance, and management in the cloud!

Download this release

Release Info

Developer Magento Core Team
Extension SalesTax_Connector
Version 3.0.2
Comparing to
See all releases


Code changes from version 2.0.3 to 3.0.2

Files changed (52) hide show
  1. app/code/local/Harapartners/SpeedTax/Block/Adminhtml/Log/Call/Index.php +22 -3
  2. app/code/local/Harapartners/SpeedTax/Block/Adminhtml/Log/Call/Index/Grid.php +108 -3
  3. app/code/local/Harapartners/SpeedTax/Block/Adminhtml/Log/Error/Index.php +22 -3
  4. app/code/local/Harapartners/SpeedTax/Block/Adminhtml/Log/Error/Index/Grid.php +111 -3
  5. app/code/local/Harapartners/SpeedTax/Block/Adminhtml/System/Config/Form/Field/Authentication.php +75 -0
  6. app/code/local/Harapartners/SpeedTax/Block/Adminhtml/System/Config/Form/Field/Export.php +35 -3
  7. app/code/local/Harapartners/SpeedTax/Block/Adminhtml/System/Config/Form/Field/Ping.php +0 -3
  8. app/code/local/Harapartners/SpeedTax/Block/Checkout/Onepage/Shipping/Method/Available.php +0 -3
  9. app/code/local/Harapartners/SpeedTax/Helper/Connector/Core.php +166 -0
  10. app/code/local/Harapartners/SpeedTax/Helper/Connector/Data.php +239 -0
  11. app/code/local/Harapartners/SpeedTax/Helper/Connector/Speedtax.php +167 -0
  12. app/code/local/Harapartners/SpeedTax/Helper/Data.php +30 -3
  13. app/code/local/Harapartners/SpeedTax/Helper/Mcrypt.php +87 -0
  14. app/code/local/Harapartners/SpeedTax/Helper/Object.php +161 -0
  15. app/code/local/Harapartners/SpeedTax/Helper/Processor.php +203 -0
  16. app/code/local/Harapartners/SpeedTax/Model/Abstract.php +0 -3
  17. app/code/local/Harapartners/SpeedTax/Model/Adminhtml/Usregions.php +0 -3
  18. app/code/local/Harapartners/SpeedTax/Model/Checkout/Type/Multishipping.php +0 -3
  19. app/code/local/Harapartners/SpeedTax/Model/Log.php +0 -3
  20. app/code/local/Harapartners/SpeedTax/Model/Log/Call.php +0 -3
  21. app/code/local/Harapartners/SpeedTax/Model/Log/Error.php +0 -3
  22. app/code/local/Harapartners/SpeedTax/Model/Log/Mysql4/Call.php +0 -3
  23. app/code/local/Harapartners/SpeedTax/Model/Log/Mysql4/Call/Collection.php +0 -3
  24. app/code/local/Harapartners/SpeedTax/Model/Log/Mysql4/Error.php +0 -3
  25. app/code/local/Harapartners/SpeedTax/Model/Log/Mysql4/Error/Collection.php +0 -3
  26. app/code/local/Harapartners/SpeedTax/Model/Observer.php +67 -3
  27. app/code/local/Harapartners/SpeedTax/Model/Rewrite/Paypal/Api/Nvp.php +39 -0
  28. app/code/local/Harapartners/SpeedTax/Model/Rewrite/Paypal/Config.php +58 -0
  29. app/code/local/Harapartners/SpeedTax/Model/Rewrite/Tax/Sales/Total/Quote/Tax.php +55 -0
  30. app/code/local/Harapartners/SpeedTax/Model/Sales/Quote/Address.php +0 -3
  31. app/code/local/Harapartners/SpeedTax/Model/Session.php +64 -3
  32. app/code/local/Harapartners/SpeedTax/Model/Source/Usregions.php +35 -0
  33. app/code/local/Harapartners/SpeedTax/Model/Speedtax/Abstract.php +0 -3
  34. app/code/local/Harapartners/SpeedTax/Model/Speedtax/Address.php +0 -3
  35. app/code/local/Harapartners/SpeedTax/Model/Speedtax/Calculate.php +210 -3
  36. app/code/local/Harapartners/SpeedTax/Model/Speedtax/Exception/Address.php +13 -3
  37. app/code/local/Harapartners/SpeedTax/Model/Tax/Sales/Total/Quote/Tax.php +0 -3
  38. app/code/local/Harapartners/SpeedTax/controllers/Adminhtml/Log/CallController.php +0 -3
  39. app/code/local/Harapartners/SpeedTax/controllers/Adminhtml/Log/ErrorController.php +0 -3
  40. app/code/local/Harapartners/SpeedTax/controllers/Adminhtml/PingController.php +0 -3
  41. app/code/local/Harapartners/SpeedTax/controllers/Adminhtml/System/Config/AjaxController.php +53 -0
  42. app/code/local/Harapartners/SpeedTax/etc/config.xml +153 -202
  43. app/code/local/Harapartners/SpeedTax/etc/system.xml +166 -180
  44. app/code/local/Harapartners/SpeedTax/lib/Credentials.inc +0 -23
  45. app/code/local/Harapartners/SpeedTax/lib/SpeedTaxApi.inc +0 -961
  46. app/code/local/Harapartners/SpeedTax/lib/SpeedTaxUtil.inc +0 -261
  47. app/code/local/Harapartners/SpeedTax/lib/WsSecurity.inc +0 -29
  48. app/code/local/Harapartners/SpeedTax/lib/WsSecurityTypes.inc +0 -267
  49. app/code/local/Harapartners/SpeedTax/sql/speedtax_setup/mysql4-install-2.0.0.php +0 -30
  50. app/code/local/Harapartners/SpeedTax/sql/speedtax_setup/mysql4-upgrade-3.0.9-3.1.0.php +126 -0
  51. app/etc/modules/Harapartners_SpeedTax.xml +0 -2
  52. package.xml +9 -9
app/code/local/Harapartners/SpeedTax/Block/Adminhtml/Log/Call/Index.php CHANGED
@@ -1,3 +1,22 @@
1
- <?php
2
- // Copyright Notice
3
- class Harapartners_SpeedTax_Block_Adminhtml_Log_Call_Index extends Mage_Adminhtml_Block_Widget_Grid_Container{ public function __construct(){ $this->PpvZCavP = 'speedtax'; $this->UwSUGSnh = 'adminhtml_log_call_index'; $this->hOCRNgeO = Mage::helper('speedtax')->__('Log Table'); parent::__construct(); } }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * NOTICE OF LICENSE
4
+ *
5
+ * This source file is subject to the End User Software Agreement (EULA).
6
+ * It is also available through the world-wide-web at this URL:
7
+ * http://www.harapartners.com/license [^]
8
+ * If you did not receive a copy of the license and are unable to
9
+ * obtain it through the world-wide-web, please send an email
10
+ * to eula@harapartners.com so we can send you a copy immediately.
11
+ *
12
+ */
13
+ class Harapartners_SpeedTax_Block_Adminhtml_Log_Call_Index extends Mage_Adminhtml_Block_Widget_Grid_Container{
14
+
15
+ public function __construct(){
16
+ $this->_blockGroup = 'speedtax';
17
+ $this->_controller = 'adminhtml_log_call_index';
18
+ $this->_headerText = Mage::helper('speedtax')->__('Log Table');
19
+ parent::__construct();
20
+ }
21
+
22
+ }
app/code/local/Harapartners/SpeedTax/Block/Adminhtml/Log/Call/Index/Grid.php CHANGED
@@ -1,3 +1,108 @@
1
- <?php
2
- // Copyright Notice
3
- class Harapartners_SpeedTax_Block_Adminhtml_Log_Call_Index_Grid extends Mage_Adminhtml_Block_Widget_Grid { public function __construct(){ parent::__construct(); $this->setId('SpeedTaxLogGrid'); } protected function _prepareCollection(){ $lDaybsdL = Mage::getModel('speedtax/log_call'); $JunnAivC = $lDaybsdL->getCollection(); $this->setCollection($JunnAivC); parent::_prepareCollection(); return $this; } protected function _getStore(){ $yKIwhAhG = (int) $this->getRequest()->getParam('store', 0); return Mage::app()->getStore($yKIwhAhG); } protected function _prepareColumns(){ $this->addColumn('log_id', array( 'header' => Mage::helper('speedtax')->__('Log ID'), 'align' => 'center', 'width' => '50px', 'index' => 'log_id' )); $this->addColumn('event', array( 'header' => Mage::helper('speedtax')->__('Event'), 'align' => 'center', 'width' => '50px', 'index' => 'event', 'type' => 'text' )); $this->addColumn('result_type', array( 'header' => Mage::helper('speedtax')->__('Result Type'), 'align' => 'center', 'width' => '50px', 'index' => 'result_type', 'type' => 'text' )); $this->addColumn('invoice_num', array( 'header' => Mage::helper('speedtax')->__('Invoice Number'), 'align' => 'center', 'width' => '50px', 'index' => 'invoice_num', 'type' => 'int' )); $this->addColumn('gross', array( 'header' => Mage::helper('speedtax')->__('Gross'), 'align' => 'center', 'width' => '50px', 'index' => 'gross', 'type' => 'int' )); $this->addColumn('exempt', array( 'header' => Mage::helper('speedtax')->__('Exempt'), 'align' => 'center', 'width' => '50px', 'index' => 'exempt', 'type' => 'int' )); $this->addColumn('tax', array( 'header' => Mage::helper('speedtax')->__('Tax'), 'align' => 'center', 'width' => '50px', 'index' => 'tax', 'type' => 'int' )); $this->addColumn('created_at', array( 'header' => Mage::helper('speedtax')->__('Created At'), 'align' => 'center', 'width' => '150px', 'index' => 'created_at', 'type' => 'datetime', 'gmtoffset' => true )); $this->addExportType('*/*/exportCsv', Mage::helper('speedtax')->__('CSV')); $this->addExportType('*/*/exportXml', Mage::helper('speedtax')->__('XML')); return parent::_prepareColumns(); } public function getRowUrl($efUpRTYa){ return $this->getUrl('*/*/edit', array( 'store'=>$this->getRequest()->getParam('store'), 'id'=>$efUpRTYa->getId() )); } }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * NOTICE OF LICENSE
4
+ *
5
+ * This source file is subject to the End User Software Agreement (EULA).
6
+ * It is also available through the world-wide-web at this URL:
7
+ * http://www.harapartners.com/license [^]
8
+ * If you did not receive a copy of the license and are unable to
9
+ * obtain it through the world-wide-web, please send an email
10
+ * to eula@harapartners.com so we can send you a copy immediately.
11
+ *
12
+ */
13
+ class Harapartners_SpeedTax_Block_Adminhtml_Log_Call_Index_Grid extends Mage_Adminhtml_Block_Widget_Grid {
14
+
15
+ public function __construct(){
16
+ parent::__construct();
17
+ $this->setId('SpeedTaxLogGrid');
18
+ }
19
+
20
+ protected function _prepareCollection(){
21
+ $model = Mage::getModel('speedtax/log_call');
22
+ $collection = $model->getCollection();
23
+ $this->setCollection($collection);
24
+ parent::_prepareCollection();
25
+ return $this;
26
+ }
27
+
28
+ protected function _getStore(){
29
+ $storeId = (int) $this->getRequest()->getParam('store', 0);
30
+ return Mage::app()->getStore($storeId);
31
+ }
32
+
33
+ protected function _prepareColumns(){
34
+ $this->addColumn('log_id', array(
35
+ 'header' => Mage::helper('speedtax')->__('Log ID'),
36
+ 'align' => 'center',
37
+ 'width' => '50px',
38
+ 'index' => 'log_id'
39
+ ));
40
+
41
+ $this->addColumn('event', array(
42
+ 'header' => Mage::helper('speedtax')->__('Event'),
43
+ 'align' => 'center',
44
+ 'width' => '50px',
45
+ 'index' => 'event',
46
+ 'type' => 'text'
47
+ ));
48
+
49
+ $this->addColumn('result_type', array(
50
+ 'header' => Mage::helper('speedtax')->__('Result Type'),
51
+ 'align' => 'center',
52
+ 'width' => '50px',
53
+ 'index' => 'result_type',
54
+ 'type' => 'text'
55
+ ));
56
+
57
+ $this->addColumn('invoice_num', array(
58
+ 'header' => Mage::helper('speedtax')->__('Invoice Number'),
59
+ 'align' => 'center',
60
+ 'width' => '50px',
61
+ 'index' => 'invoice_num',
62
+ 'type' => 'int'
63
+ ));
64
+ $this->addColumn('gross', array(
65
+ 'header' => Mage::helper('speedtax')->__('Gross'),
66
+ 'align' => 'center',
67
+ 'width' => '50px',
68
+ 'index' => 'gross',
69
+ 'type' => 'int'
70
+ ));
71
+ $this->addColumn('exempt', array(
72
+ 'header' => Mage::helper('speedtax')->__('Exempt'),
73
+ 'align' => 'center',
74
+ 'width' => '50px',
75
+ 'index' => 'exempt',
76
+ 'type' => 'int'
77
+ ));
78
+ $this->addColumn('tax', array(
79
+ 'header' => Mage::helper('speedtax')->__('Tax'),
80
+ 'align' => 'center',
81
+ 'width' => '50px',
82
+ 'index' => 'tax',
83
+ 'type' => 'int'
84
+ ));
85
+
86
+ $this->addColumn('created_at', array(
87
+ 'header' => Mage::helper('speedtax')->__('Created At'),
88
+ 'align' => 'center',
89
+ 'width' => '150px',
90
+ 'index' => 'created_at',
91
+ 'type' => 'datetime',
92
+ 'gmtoffset' => true
93
+ ));
94
+
95
+ $this->addExportType('*/*/exportCsv', Mage::helper('speedtax')->__('CSV'));
96
+ $this->addExportType('*/*/exportXml', Mage::helper('speedtax')->__('XML'));
97
+
98
+ return parent::_prepareColumns();
99
+ }
100
+
101
+ public function getRowUrl($row){
102
+ return $this->getUrl('*/*/edit', array(
103
+ 'store'=>$this->getRequest()->getParam('store'),
104
+ 'id'=>$row->getId()
105
+ ));
106
+ }
107
+
108
+ }
app/code/local/Harapartners/SpeedTax/Block/Adminhtml/Log/Error/Index.php CHANGED
@@ -1,3 +1,22 @@
1
- <?php
2
- // Copyright Notice
3
- class Harapartners_SpeedTax_Block_Adminhtml_Log_Error_Index extends Mage_Adminhtml_Block_Widget_Grid_Container{ public function __construct(){ $this->PpvZCavP = 'speedtax'; $this->UwSUGSnh = 'adminhtml_log_error_index'; $this->hOCRNgeO = Mage::helper('speedtax')->__('Error Log Table'); parent::__construct(); } }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * NOTICE OF LICENSE
4
+ *
5
+ * This source file is subject to the End User Software Agreement (EULA).
6
+ * It is also available through the world-wide-web at this URL:
7
+ * http://www.harapartners.com/license [^]
8
+ * If you did not receive a copy of the license and are unable to
9
+ * obtain it through the world-wide-web, please send an email
10
+ * to eula@harapartners.com so we can send you a copy immediately.
11
+ *
12
+ */
13
+ class Harapartners_SpeedTax_Block_Adminhtml_Log_Error_Index extends Mage_Adminhtml_Block_Widget_Grid_Container{
14
+
15
+ public function __construct(){
16
+ $this->_blockGroup = 'speedtax';
17
+ $this->_controller = 'adminhtml_log_error_index';
18
+ $this->_headerText = Mage::helper('speedtax')->__('Error Log Table');
19
+ parent::__construct();
20
+ }
21
+
22
+ }
app/code/local/Harapartners/SpeedTax/Block/Adminhtml/Log/Error/Index/Grid.php CHANGED
@@ -1,3 +1,111 @@
1
- <?php
2
- // Copyright Notice
3
- class Harapartners_SpeedTax_Block_Adminhtml_Log_Error_Index_Grid extends Mage_Adminhtml_Block_Widget_Grid { public function __construct(){ parent::__construct(); $this->setId('SpeedTaxLogGrid'); } protected function _prepareCollection(){ $lDaybsdL = Mage::getModel('speedtax/log_error'); $JunnAivC = $lDaybsdL->getCollection(); $this->setCollection($JunnAivC); parent::_prepareCollection(); return $this; } protected function _getStore(){ $yKIwhAhG = (int) $this->getRequest()->getParam('store', 0); return Mage::app()->getStore($yKIwhAhG); } protected function _prepareColumns(){ $this->addColumn('log_id', array( 'header' => Mage::helper('speedtax')->__('Log ID'), 'align' => 'center', 'width' => '50px', 'index' => 'log_id' )); $this->addColumn('event', array( 'header' => Mage::helper('speedtax')->__('Event'), 'align' => 'center', 'width' => '50px', 'index' => 'event', 'type' => 'text' )); $this->addColumn('result_type', array( 'header' => Mage::helper('speedtax')->__('Result Type'), 'align' => 'center', 'width' => '50px', 'index' => 'result_type', 'type' => 'text' )); $this->addColumn('message', array( 'header' => Mage::helper('speedtax')->__('Message'), 'align' => 'center', 'width' => '50px', 'index' => 'message', 'type' => 'text' )); $this->addColumn('address_shipping_from', array( 'header' => Mage::helper('speedtax')->__('Address Shipping From'), 'align' => 'center', 'width' => '50px', 'index' => 'address_shipping_from', 'type' => 'text' )); $this->addColumn('address_shipping_to', array( 'header' => Mage::helper('speedtax')->__('Address Shipping To'), 'align' => 'center', 'width' => '50px', 'index' => 'address_shipping_to', 'type' => 'text' )); $this->addColumn('customer_name', array( 'header' => Mage::helper('speedtax')->__('Customer Name'), 'align' => 'center', 'width' => '50px', 'index' => 'customer_name', 'type' => 'text' )); $this->addColumn('created_at', array( 'header' => Mage::helper('speedtax')->__('Created At'), 'align' => 'center', 'width' => '150px', 'index' => 'created_at', 'type' => 'datetime', 'gmtoffset' => true )); $this->addExportType('*/*/exportCsv', Mage::helper('speedtax')->__('CSV')); $this->addExportType('*/*/exportXml', Mage::helper('speedtax')->__('XML')); return parent::_prepareColumns(); } public function getRowUrl($efUpRTYa){ return $this->getUrl('*/*/edit', array( 'store'=>$this->getRequest()->getParam('store'), 'id'=>$efUpRTYa->getId() )); } }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * NOTICE OF LICENSE
4
+ *
5
+ * This source file is subject to the End User Software Agreement (EULA).
6
+ * It is also available through the world-wide-web at this URL:
7
+ * http://www.harapartners.com/license [^]
8
+ * If you did not receive a copy of the license and are unable to
9
+ * obtain it through the world-wide-web, please send an email
10
+ * to eula@harapartners.com so we can send you a copy immediately.
11
+ *
12
+ */
13
+ class Harapartners_SpeedTax_Block_Adminhtml_Log_Error_Index_Grid extends Mage_Adminhtml_Block_Widget_Grid {
14
+
15
+ public function __construct(){
16
+ parent::__construct();
17
+ $this->setId('SpeedTaxLogGrid');
18
+ }
19
+
20
+ protected function _prepareCollection(){
21
+ $model = Mage::getModel('speedtax/log_error');
22
+ $collection = $model->getCollection();
23
+ $this->setCollection($collection);
24
+ parent::_prepareCollection();
25
+ return $this;
26
+ }
27
+
28
+ protected function _getStore(){
29
+ $storeId = (int) $this->getRequest()->getParam('store', 0);
30
+ return Mage::app()->getStore($storeId);
31
+ }
32
+
33
+ protected function _prepareColumns(){
34
+ $this->addColumn('log_id', array(
35
+ 'header' => Mage::helper('speedtax')->__('Log ID'),
36
+ 'align' => 'center',
37
+ 'width' => '50px',
38
+ 'index' => 'log_id'
39
+ ));
40
+
41
+ $this->addColumn('event', array(
42
+ 'header' => Mage::helper('speedtax')->__('Event'),
43
+ 'align' => 'center',
44
+ 'width' => '50px',
45
+ 'index' => 'event',
46
+ 'type' => 'text'
47
+ ));
48
+
49
+ $this->addColumn('result_type', array(
50
+ 'header' => Mage::helper('speedtax')->__('Result Type'),
51
+ 'align' => 'center',
52
+ 'width' => '50px',
53
+ 'index' => 'result_type',
54
+ 'type' => 'text'
55
+ ));
56
+
57
+ $this->addColumn('message', array(
58
+ 'header' => Mage::helper('speedtax')->__('Message'),
59
+ 'align' => 'center',
60
+ 'width' => '50px',
61
+ 'index' => 'message',
62
+ 'type' => 'text'
63
+ ));
64
+
65
+ $this->addColumn('address_shipping_from', array(
66
+ 'header' => Mage::helper('speedtax')->__('Address Shipping From'),
67
+ 'align' => 'center',
68
+ 'width' => '50px',
69
+ 'index' => 'address_shipping_from',
70
+ 'type' => 'text'
71
+ ));
72
+
73
+ $this->addColumn('address_shipping_to', array(
74
+ 'header' => Mage::helper('speedtax')->__('Address Shipping To'),
75
+ 'align' => 'center',
76
+ 'width' => '50px',
77
+ 'index' => 'address_shipping_to',
78
+ 'type' => 'text'
79
+ ));
80
+
81
+ $this->addColumn('customer_name', array(
82
+ 'header' => Mage::helper('speedtax')->__('Customer Name'),
83
+ 'align' => 'center',
84
+ 'width' => '50px',
85
+ 'index' => 'customer_name',
86
+ 'type' => 'text'
87
+ ));
88
+
89
+ $this->addColumn('created_at', array(
90
+ 'header' => Mage::helper('speedtax')->__('Created At'),
91
+ 'align' => 'center',
92
+ 'width' => '150px',
93
+ 'index' => 'created_at',
94
+ 'type' => 'datetime',
95
+ 'gmtoffset' => true
96
+ ));
97
+
98
+ $this->addExportType('*/*/exportCsv', Mage::helper('speedtax')->__('CSV'));
99
+ $this->addExportType('*/*/exportXml', Mage::helper('speedtax')->__('XML'));
100
+
101
+ return parent::_prepareColumns();
102
+ }
103
+
104
+ public function getRowUrl($row){
105
+ return $this->getUrl('*/*/edit', array(
106
+ 'store'=>$this->getRequest()->getParam('store'),
107
+ 'id'=>$row->getId()
108
+ ));
109
+ }
110
+
111
+ }
app/code/local/Harapartners/SpeedTax/Block/Adminhtml/System/Config/Form/Field/Authentication.php ADDED
@@ -0,0 +1,75 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * NOTICE OF LICENSE
4
+ *
5
+ * This source file is subject to the End User Software Agreement (EULA).
6
+ * It is also available through the world-wide-web at this URL:
7
+ * http://www.harapartners.com/license [^]
8
+ * If you did not receive a copy of the license and are unable to
9
+ * obtain it through the world-wide-web, please send an email
10
+ * to eula@harapartners.com so we can send you a copy immediately.
11
+ *
12
+ */
13
+
14
+ class Harapartners_SpeedTax_Block_Adminhtml_System_Config_Form_Field_Authentication extends Mage_Adminhtml_Block_System_Config_Form_Field {
15
+
16
+ protected function _toHtml() {
17
+ $htmlId = $this->getHtmlId();
18
+ $ajaxUrl = $this->getAjaxUrl();
19
+ $buttonLabel = $this->escapeHtml($this->getButtonLabel());
20
+
21
+ $htmlContent = <<< HTML_CONTENT
22
+ <script type="text/javascript">
23
+ function ajaxLogin() {
24
+ var elem = $('$htmlId');
25
+
26
+ params = {
27
+ username: $('speedtax_speedtax_username').value,
28
+ password: $('speedtax_speedtax_password').value,
29
+ company_code: $('speedtax_speedtax_company_code').value
30
+ };
31
+
32
+ new Ajax.Request('$ajaxUrl', {
33
+ parameters: params,
34
+ onSuccess: function(response) {
35
+ result = 'Login failed!';
36
+ try {
37
+ response = JSON.parse(response.responseText);
38
+ result = response.message;
39
+ if (response.status == 1) {
40
+ elem.removeClassName('fail').addClassName('success');
41
+ } else {
42
+ elem.removeClassName('success').addClassName('fail');
43
+ }
44
+ } catch (e) {
45
+ elem.removeClassName('success').addClassName('fail');
46
+ }
47
+ $('ajax_login_result').update(result);
48
+ }
49
+ });
50
+ }
51
+ </script>
52
+ <button onclick="javascript:ajaxLogin(); return false;" class="scalable" type="button" id="$htmlId">
53
+ <span><span><span id="ajax_login_result">$buttonLabel</span></span></span>
54
+ </button>
55
+ HTML_CONTENT;
56
+
57
+ return $htmlContent;
58
+ }
59
+
60
+ public function render(Varien_Data_Form_Element_Abstract $element){
61
+ $element->unsScope()->unsCanUseWebsiteValue()->unsCanUseDefaultValue();
62
+ return parent::render($element);
63
+ }
64
+
65
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element){
66
+ $originalData = $element->getOriginalData();
67
+ $this->addData(array(
68
+ 'button_label' => Mage::helper('waconnector')->__($originalData['button_label']),
69
+ 'html_id' => $element->getHtmlId(),
70
+ 'ajax_url' => Mage::getSingleton('adminhtml/url')->getUrl('*/system_config_ajax/authentication')
71
+ ));
72
+
73
+ return $this->_toHtml();
74
+ }
75
+ }
app/code/local/Harapartners/SpeedTax/Block/Adminhtml/System/Config/Form/Field/Export.php CHANGED
@@ -1,3 +1,35 @@
1
- <?php
2
- // Copyright Notice
3
- class Harapartners_SpeedTax_Block_Adminhtml_System_Config_Form_Field_Export extends Mage_Adminhtml_Block_System_Config_Form_Field { protected function _getElementHtml(Varien_Data_Form_Element_Abstract $kupRLniX) { $EgwoKNfR = $this->getLayout ()->createBlock ( 'adminhtml/widget_button' ); $RErPqTMk = array ('website' => $EgwoKNfR->getRequest ()->getParam ( 'website' ) ); $gyhPtFAw = array ( 'label' => Mage::helper ( 'adminhtml' )->__ ( 'Export Call Log' ), 'onclick' => 'setLocation(\'' . Mage::helper ( 'adminhtml' )->getUrl ( "speedtax/adminhtml_log_call/exportCsv", $RErPqTMk ) . '\')', 'class' => '', 'note' => Mage::helper ( 'speedtax' )->__ ( 'Test Connection' ) ); $KEfkflXa = array( 'label' => Mage::helper('adminhtml')->__('Export Error Log'), 'onclick' => 'setLocation(\''.Mage::helper('adminhtml')->getUrl("speedtax/adminhtml_log_error/exportCsv", $RErPqTMk) . '\')', 'class' => '', ); $jSOBYFZH = $EgwoKNfR->setData ( $gyhPtFAw )->toHtml (). ' &nbsp; '; $jSOBYFZH .= $EgwoKNfR->setData($KEfkflXa)->toHtml(); return $jSOBYFZH; } }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * NOTICE OF LICENSE
4
+ *
5
+ * This source file is subject to the End User Software Agreement (EULA).
6
+ * It is also available through the world-wide-web at this URL:
7
+ * http://www.harapartners.com/license [^]
8
+ * If you did not receive a copy of the license and are unable to
9
+ * obtain it through the world-wide-web, please send an email
10
+ * to eula@harapartners.com so we can send you a copy immediately.
11
+ *
12
+ */
13
+ class Harapartners_SpeedTax_Block_Adminhtml_System_Config_Form_Field_Export extends Mage_Adminhtml_Block_System_Config_Form_Field {
14
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element) {
15
+ $buttonBlock = $this->getLayout ()->createBlock ( 'adminhtml/widget_button' );
16
+ $params = array ('website' => $buttonBlock->getRequest ()->getParam ( 'website' ) );
17
+
18
+ $data1 = array (
19
+ 'label' => Mage::helper ( 'adminhtml' )->__ ( 'Export Call Log' ),
20
+ 'onclick' => 'setLocation(\'' . Mage::helper ( 'adminhtml' )->getUrl ( "speedtax/adminhtml_log_call/exportCsv", $params ) . '\')',
21
+ 'class' => '',
22
+ 'note' => Mage::helper ( 'speedtax' )->__ ( 'Test Connection' ) );
23
+
24
+ $data2 = array(
25
+ 'label' => Mage::helper('adminhtml')->__('Export Error Log'),
26
+ 'onclick' => 'setLocation(\''.Mage::helper('adminhtml')->getUrl("speedtax/adminhtml_log_error/exportCsv", $params) . '\')',
27
+ 'class' => '',
28
+ );
29
+
30
+ $html = $buttonBlock->setData ( $data1 )->toHtml (). ' &nbsp; ';
31
+ $html .= $buttonBlock->setData($data2)->toHtml();
32
+
33
+ return $html;
34
+ }
35
+ }
app/code/local/Harapartners/SpeedTax/Block/Adminhtml/System/Config/Form/Field/Ping.php DELETED
@@ -1,3 +0,0 @@
1
- <?php
2
- // Copyright Notice
3
- class Harapartners_SpeedTax_Block_Adminhtml_System_Config_Form_Field_Ping extends Mage_Adminhtml_Block_System_Config_Form_Field { protected function _getElementHtml(Varien_Data_Form_Element_Abstract $kupRLniX) { $EgwoKNfR = $this->getLayout ()->createBlock ( 'adminhtml/widget_button' ); $RErPqTMk = array ('website' => $EgwoKNfR->getRequest ()->getParam ( 'website' ) ); $gyhPtFAw = array ( 'label' => Mage::helper ( 'adminhtml' )->__ ( 'Test SalesTax.com Connection' ), 'onclick' => 'setLocation(\'' . Mage::helper ( 'adminhtml' )->getUrl ( "speedtax/adminhtml_ping/ping", $RErPqTMk ) . '\')', 'class' => '', 'note' => Mage::helper ( 'speedtax' )->__ ( 'Test Connection' ) ); $jSOBYFZH = $EgwoKNfR->setData ( $gyhPtFAw )->toHtml (); return $jSOBYFZH; } }
 
 
 
app/code/local/Harapartners/SpeedTax/Block/Checkout/Onepage/Shipping/Method/Available.php DELETED
@@ -1,3 +0,0 @@
1
- <?php
2
- // Copyright Notice
3
- class Harapartners_SpeedTax_Block_Checkout_Onepage_Shipping_Method_Available extends Mage_Checkout_Block_Onepage_Shipping_Method_Available { protected function _toHtml () { $MapsTZNK = ''; if(!Mage::getSingleton('speedtax/session')->getYqwVhAAT()){ $resolvedAddress = Mage::getSingleton('speedtax/session')->getEeBeztvR(); $MapsTZNK = $resolvedAddress->address.", ".$resolvedAddress->city.", ".$resolvedAddress->state." ".$resolvedAddress->zip; } return $MapsTZNK . parent::_toHtml(); } }
 
 
 
app/code/local/Harapartners/SpeedTax/Helper/Connector/Core.php ADDED
@@ -0,0 +1,166 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * NOTICE OF LICENSE
4
+ *
5
+ * This source file is subject to the End User Software Agreement (EULA).
6
+ * It is also available through the world-wide-web at this URL:
7
+ * http://www.harapartners.com/license [^]
8
+ * If you did not receive a copy of the license and are unable to
9
+ * obtain it through the world-wide-web, please send an email
10
+ * to eula@harapartners.com so we can send you a copy immediately.
11
+ *
12
+ */
13
+ class Harapartners_SpeedTax_Helper_Connector_Core extends Mage_Core_Helper_Abstract {
14
+
15
+ const SERVICE_TYPE = "speedtax";
16
+ const REQUEST_ACTION_AUTHENTICATION = 'authentication';
17
+
18
+ const REQUEST_SERVICE_MODE_TEST = 0;
19
+ const REQUEST_SERVICE_MODE_PRODUCTION = 100;
20
+
21
+ const RESPONSE_STATUS_FAIL = 0;
22
+ const RESPONSE_STATUS_SUCCESS = 100;
23
+ const RESPONSE_STATUS_REAUTH = 200;
24
+
25
+ const DEFAULT_CURLOPT_TIMEOUT = 5;
26
+
27
+ protected function _processRequest($request){
28
+ // ============== Prepare additional request meta ============== //
29
+ $adminEmail = "";
30
+ if(!!Mage::getSingleton('admin/session')->getUser()){
31
+ $adminEmail = Mage::getSingleton('admin/session')->getUser()->getEmail();
32
+ }
33
+ $request['meta'] = array_merge($request['meta'], array(
34
+ 'service_type' => self::SERVICE_TYPE,
35
+ 'service_mode' => $this->getServiceMode(),
36
+ 'auth_token' => $this->getToken('auth_token'),
37
+ 'site_url' => Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB),
38
+ 'account_name' => $adminEmail,
39
+ 'platform' => 'magento',
40
+ 'version' => Mage::getVersion()
41
+ ));
42
+
43
+ if(isset($request['data'])){
44
+ $request['enc_data'] = $this->encryptRequestData($request['data']);
45
+ unset($request['data']);
46
+ }
47
+
48
+ // ============== Make request ============== //
49
+ $requestUrl = $this->_getConnectorHubUrl() . 'SpeedTax.php';
50
+ $requestPostData = array('params' => base64_encode(json_encode($request)));
51
+ $requestCh = curl_init();
52
+ curl_setopt($requestCh, CURLOPT_URL, $requestUrl);
53
+ curl_setopt($requestCh, CURLOPT_POST, 1);
54
+ curl_setopt($requestCh, CURLOPT_POSTFIELDS, $requestPostData);
55
+ curl_setopt($requestCh, CURLOPT_SSL_VERIFYPEER, $this->_getCurlSslVerifyPeer());
56
+ curl_setopt($requestCh, CURLOPT_RETURNTRANSFER, 1);
57
+ curl_setopt($requestCh, CURLOPT_TIMEOUT, self::DEFAULT_CURLOPT_TIMEOUT);
58
+ $response = json_decode(base64_decode(curl_exec($requestCh)));
59
+ curl_close($requestCh);
60
+
61
+ // ============== Process response ============== //
62
+ if(!$response){
63
+ throw new Exception('Connection failed.');
64
+ }
65
+ //For now treat reauth the same as fail, the notification will prompt the admin user to update their credentials
66
+ switch($response->meta->status){
67
+ case self::RESPONSE_STATUS_FAIL:
68
+ case self::RESPONSE_STATUS_REAUTH:
69
+ throw new Exception($response->meta->message);
70
+ break;
71
+ case self::RESPONSE_STATUS_SUCCESS:
72
+ break;
73
+ default:
74
+ break;
75
+ }
76
+ if(!!$response->enc_data){
77
+ $dataToken = $this->getToken('data_token');
78
+ $decData = Mage::helper('speedtax/mcrypt')->init($dataToken)->decrypt(base64_decode($response->enc_data));
79
+ $response->data = json_decode($decData);
80
+ }
81
+
82
+ return $response;
83
+ }
84
+
85
+ public function authenticationRequest($credentials){
86
+ //For authentication request, directly send the data, rather than encrypted data with token
87
+ $request = array(
88
+ 'meta' => array(
89
+ 'action' => self::REQUEST_ACTION_AUTHENTICATION,
90
+ 'credentials' => $credentials
91
+ )
92
+ );
93
+ $response = $this->_processRequest($request);
94
+
95
+ //service_mode can be '0'
96
+ if(is_null($response->meta->service_mode) || !$response->meta->auth_token || !$response->meta->data_token){
97
+ throw new Exception('Authentication failed.');
98
+ }
99
+
100
+ $this->saveTokens($response);
101
+ return $response;
102
+ }
103
+
104
+ public function encryptRequestData($requestData){
105
+ //For authentication request, directly send the data, rather than encrypted data with token
106
+ $authToken = $this->getToken('auth_token');
107
+ $dataToken = $this->getToken('data_token');
108
+ $encData = Mage::helper('speedtax/mcrypt')->init($dataToken)->encrypt(json_encode($requestData));
109
+ return base64_encode($encData);
110
+ }
111
+
112
+ // ====================== Utilities/Helpers ====================== //
113
+ protected function _getConnectorHubUrl(){
114
+ //Local test
115
+ return "https://connectorhub.harapartners.com/";
116
+ }
117
+
118
+ public function getToken($tokenName, $serviceMode = null){
119
+ if(!$serviceMode){
120
+ $serviceMode = $this->getServiceMode();
121
+ }
122
+
123
+ //Load from DB, no cache
124
+ $coreConfigData = Mage::getModel('core/config_data')->load('speedtax/speedtax/tokens', 'path');
125
+ $existingToken = json_decode($coreConfigData->getValue(), 1);
126
+ if(isset($existingToken[$serviceMode][$tokenName])){
127
+ return $existingToken[$serviceMode][$tokenName];
128
+ }
129
+ return null;
130
+ }
131
+
132
+ public function saveTokens($response){
133
+ //Save to DB, no cache
134
+ $coreConfigData = Mage::getModel('core/config_data')->load('speedtax/speedtax/tokens', 'path');
135
+ //In case the first time save
136
+ $coreConfigData->setpath('speedtax/speedtax/tokens');
137
+
138
+ $existingToken = json_decode($coreConfigData->getValue(), 1);
139
+ $existingToken[$response->meta->service_mode] = array(
140
+ 'auth_token' => $response->meta->auth_token,
141
+ 'data_token' => $response->meta->data_token
142
+ );
143
+ $coreConfigData->setValue(json_encode($existingToken));
144
+ $coreConfigData->save();
145
+ return;
146
+ }
147
+
148
+ public function getServiceMode(){
149
+ $serviceMode = Mage::getStoreConfig('speedtax/speedtax/is_test_mode')?self::REQUEST_SERVICE_MODE_TEST:self::REQUEST_SERVICE_MODE_PRODUCTION;
150
+ return $serviceMode;
151
+ }
152
+
153
+ protected function _getCurlSslVerifyPeer(){
154
+ $sslVerifyPeer = 0;
155
+ try{
156
+ $secureUrlScheme = parse_url(Mage::getUrl('', array('_secure'=>true)), PHP_URL_SCHEME);
157
+ if(strcasecmp($secureUrlScheme, "https") == 0){
158
+ $sslVerifyPeer = 1;
159
+ }
160
+ }catch(Exception $e){
161
+ $sslVerifyPeer = 0;
162
+ }
163
+ return $sslVerifyPeer;
164
+ }
165
+
166
+ }
app/code/local/Harapartners/SpeedTax/Helper/Connector/Data.php ADDED
@@ -0,0 +1,239 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * NOTICE OF LICENSE
4
+ *
5
+ * This source file is subject to the End User Software Agreement (EULA).
6
+ * It is also available through the world-wide-web at this URL:
7
+ * http://www.harapartners.com/license [^]
8
+ * If you did not receive a copy of the license and are unable to
9
+ * obtain it through the world-wide-web, please send an email
10
+ * to eula@harapartners.com so we can send you a copy immediately.
11
+ *
12
+ */
13
+ class Harapartners_SpeedTax_Helper_Connector_Data extends Mage_Core_Helper_Abstract {
14
+
15
+ const TAX_SHIPPING_LINEITEM_TAX_CLASS = 'TAX_SHIPPING';
16
+ const TAX_SHIPPING_LINEITEM_REFERNCE_NAME = 'TAX_SHIPPING';
17
+
18
+ protected $_productTaxClassNoneTaxableId = 0; //Magento default
19
+ // protected $_allowedCountryIds = array('US', 'CA');
20
+
21
+ protected $_shipFromAddress = null;
22
+ protected $_shipToAddress = null;
23
+
24
+ // ========================== Main entry points ========================== //
25
+ public function prepareSpeedTaxInvoiceByMageQuoteAddress(Mage_Sales_Model_Quote_Address $mageQuoteAddress) {
26
+ $sptxInvoice = new stdClass();
27
+ $sptxInvoice->customerIdentifier = Mage::getStoreConfig ( 'speedtax/speedtax/username' );
28
+
29
+ foreach ( $mageQuoteAddress->getAllItems () as $mageQuoteItem ) {
30
+ if(!!$mageQuoteItem->getParentItemId()){
31
+ continue;
32
+ }
33
+ //Multiple shipping checkout, $mageQuoteItem is instance of Mage_Sales_Model_Quote_Address_Item, not a sub-class of Mage_Sales_Model_Quote_Item
34
+ //Many product related fields must be obtained from the product object directly
35
+ if($mageQuoteItem->getProduct()->getTaxClassId() == $this->_productTaxClassNoneTaxableId){
36
+ continue;
37
+ }
38
+ if($mageQuoteItem->getRowTotal() - $mageQuoteItem->getDiscountAmount() <= 0){
39
+ continue;
40
+ }
41
+
42
+ $lineItem = new stdClass();
43
+ $lineItem->productCode = $this->_getProductCode($mageQuoteItem);
44
+ $lineItem->customReference = $mageQuoteItem->getId();
45
+ $lineItem->quantity = $mageQuoteItem->getQty();
46
+ $lineItem->shipFromAddress = $this->_getShipFromAddress();
47
+ $lineItem->shipToAddress = $this->_getShippingToAddress($mageQuoteAddress); //Note, address type is validated at the entry point 'queryQuoteAddress'
48
+
49
+ //Price of row total, not unit price
50
+ $lineItemPrice = new stdClass();
51
+ $lineItemPrice->decimalValue = $mageQuoteItem->getRowTotal() - $mageQuoteItem->getDiscountAmount();
52
+ $lineItem->salesAmount = $lineItemPrice;
53
+
54
+ $lineItem->lineItemNumber = count( $sptxInvoice->lineItems );
55
+ $sptxInvoice->lineItems[] = $lineItem;
56
+ }
57
+
58
+ // ----- Other line items ----- //
59
+ //If global store config specifies: "tax_shipping", then create shipping cost line item. Note this is different from "Tax_Shipping" tax class of a product
60
+ $shipingAmount = $mageQuoteAddress->getShippingAmount();
61
+ if(!!Mage::getStoreConfig("speedtax/speedtax/tax_shipping") && $shipingAmount > 0.0){
62
+ $shippingLineItem = $this->_generateLineItemFromShippingCost($mageQuoteAddress, $shipingAmount);
63
+ $shippingLineItem->lineItemNumber = count( $sptxInvoice->lineItems );
64
+ $sptxInvoice->lineItems[] = $shippingLineItem;
65
+ }
66
+
67
+ $sptxInvoice->invoiceDate = date('Y-m-d H:i:s');
68
+ return $sptxInvoice;
69
+ }
70
+
71
+ public function prepareSpeedTaxInvoiceByMageOrderInvoice(Mage_Sales_Model_Order_Invoice $mageOrderInvoice) {
72
+ //Clear the invoice number so that the request is just a query
73
+ $mageOrderAddress = $mageOrderInvoice->getShippingAddress();
74
+ $sptxInvoice = new stdClass();
75
+
76
+ //Important to keep unique, invoice should already be attached to the order, count starts from 1
77
+ $sptxInvoice->invoiceNumber =
78
+ $mageOrderInvoice->getOrder()->getIncrementId()
79
+ . '-INV-' . ($mageOrderInvoice->getOrder()->getInvoiceCollection()->count());
80
+ $sptxInvoice->customerIdentifier = Mage::getStoreConfig ( 'speedtax/speedtax/username' );
81
+
82
+ foreach ( $mageOrderInvoice->getAllItems() as $mageItem ) {
83
+ if(!$mageItem->getTaxAmount() || $mageItem->getTaxAmount() <= 0.0){
84
+ continue;
85
+ }
86
+ $lineItem = new stdClass();
87
+ $lineItem->productCode = $this->_getProductCode($mageItem);
88
+ $lineItem->customReference = $mageItem->getOrderItemId(); //This is during invoice creation, no ID available
89
+ $lineItem->quantity = $mageItem->getQty();
90
+ $lineItem->shipFromAddress = $this->_getShipFromAddress();
91
+ $lineItem->shipToAddress = $this->_getShippingToAddress($mageOrderAddress); //Note, address type is validated at the entry point 'queryQuoteAddress'
92
+
93
+ //Price of row total, not unit price
94
+ $lineItemPrice = new stdClass();
95
+ $lineItemPrice->decimalValue = $mageItem->getRowTotal() - $mageItem->getDiscountAmount();
96
+ $lineItem->salesAmount = $lineItemPrice;
97
+
98
+ $lineItem->lineItemNumber = count( $sptxInvoice->lineItems );
99
+ $sptxInvoice->lineItems[] = $lineItem;
100
+ }
101
+
102
+ // ----- Other line items ----- //
103
+ //If global store config specifies: "tax_shipping", then create shipping cost line item. Note this is different from "Tax_Shipping" tax class of a product
104
+ if($mageOrderInvoice->getShippingAmount() === null){
105
+ $mageOrderInvoice->collectTotals();
106
+ }
107
+ $shipingAmount = $mageOrderInvoice->getShippingAmount();
108
+ if(!!Mage::getStoreConfig("speedtax/speedtax/tax_shipping") && $shipingAmount > 0.0){
109
+ $shippingLineItem = $this->_generateLineItemFromShippingCost($mageOrderAddress, $shipingAmount);
110
+ $shippingLineItem->lineItemNumber = count( $sptxInvoice->lineItems );
111
+ $sptxInvoice->lineItems[] = $shippingLineItem;
112
+ }
113
+
114
+ $sptxInvoice->invoiceDate = date('Y-m-d H:i:s');
115
+ return $sptxInvoice;
116
+ }
117
+
118
+ public function prepareSpeedTaxInvoiceByMageOrderCreditmemo(Mage_Sales_Model_Order_Creditmemo $mageOrderCreditmemo) {
119
+ //Clear the invoice number so that the request is just a query
120
+ $mageOrderAddress = $mageOrderCreditmemo->getShippingAddress();
121
+ $sptxInvoice = new stdClass();
122
+ //Important to keep unique, credit memo not yet attached to the order, count ++ so that it starts from 1
123
+ $sptxInvoice->invoiceNumber =
124
+ $mageOrderCreditmemo->getOrder()->getIncrementId()
125
+ . '-CR-' . ($mageOrderCreditmemo->getOrder()->getCreditmemosCollection()->count() + 1);
126
+ $sptxInvoice->customerIdentifier = Mage::getStoreConfig ( 'speedtax/speedtax/username' );
127
+
128
+ foreach ( $mageOrderCreditmemo->getAllItems() as $mageItem ) {
129
+ if(!$mageItem->getTaxAmount() || $mageItem->getTaxAmount() <= 0.0){
130
+ continue;
131
+ }
132
+ $lineItem = new stdClass();
133
+ $lineItem->productCode = $this->_getProductCode($mageItem);
134
+ $lineItem->customReference = $mageItem->getOrderItemId(); //This is during credit memo creation, no ID available
135
+ $lineItem->quantity = $mageItem->getQty();
136
+ $lineItem->shipFromAddress = $this->_getShipFromAddress();
137
+ $lineItem->shipToAddress = $this->_getShippingToAddress($mageOrderAddress); //Note, address type is validated at the entry point 'queryQuoteAddress'
138
+
139
+ //Price of row total, not unit price
140
+ $lineItemPrice = new stdClass();
141
+ $lineItemPrice->decimalValue = $mageItem->getRowTotal() - $mageItem->getDiscountAmount();
142
+ $lineItem->salesAmount = $lineItemPrice;
143
+
144
+ $lineItem->lineItemNumber = count( $sptxInvoice->lineItems );
145
+ $sptxInvoice->lineItems[] = $lineItem;
146
+ }
147
+
148
+ // ----- Other line items ----- //
149
+ //If global store config specifies: "tax_shipping", then create shipping cost line item. Note this is different from "Tax_Shipping" tax class of a product
150
+ if($mageOrderCreditmemo->getShippingAmount() === null){
151
+ $mageOrderCreditmemo->collectTotals();
152
+ }
153
+ $shipingAmount = $mageOrderCreditmemo->getShippingAmount();
154
+ if(!!Mage::getStoreConfig("speedtax/speedtax/tax_shipping") && $shipingAmount > 0.0){
155
+ $shippingLineItem = $this->_generateLineItemFromShippingCost($mageOrderAddress, $shipingAmount);
156
+ $shippingLineItem->lineItemNumber = count( $sptxInvoice->lineItems );
157
+ $sptxInvoice->lineItems[] = $shippingLineItem;
158
+ }
159
+
160
+ $sptxInvoice->invoiceDate = date('Y-m-d H:i:s');
161
+ return $sptxInvoice;
162
+ }
163
+
164
+ // ========================== Utilities ========================== //
165
+ protected function _generateLineItemFromShippingCost($mageAddress, $shipingAmount) {
166
+ $shippingLineItem = new stdClass();
167
+ $shippingLineItem->productCode = self::TAX_SHIPPING_LINEITEM_TAX_CLASS;
168
+ $shippingLineItem->customReference = self::TAX_SHIPPING_LINEITEM_REFERNCE_NAME;
169
+ $shippingLineItem->quantity = 1;
170
+ $shippingLineItem->shipFromAddress = $this->_getShipFromAddress ();
171
+ $shippingLineItem->shipToAddress = $this->_getShippingToAddress ($mageAddress); //Note, address type is validated at the entry point 'queryQuoteAddress'
172
+
173
+ $shippingPrice = new stdClass();
174
+ $shippingPrice->decimalValue = $shipingAmount;
175
+ $shippingLineItem->salesAmount = $shippingPrice;
176
+
177
+ return $shippingLineItem;
178
+ }
179
+
180
+ //Shipping Origin Address
181
+ protected function _getShipFromAddress() {
182
+ if($this->_shipFromAddress === null){
183
+ $this->_shipFromAddress = new stdClass();
184
+ $countryId = Mage::getStoreConfig ( 'shipping/origin/country_id');
185
+ $zip = Mage::getStoreConfig ('shipping/origin/postcode');
186
+ $regionId = Mage::getStoreConfig ( 'shipping/origin/region_id');
187
+ $state = Mage::getModel('directory/region')->load($regionId)->getName();
188
+ $city = Mage::getStoreConfig ('shipping/origin/city');
189
+ $street = Mage::getStoreConfig ('shipping/origin/street');
190
+
191
+ $this->_shipFromAddress->address1 = $street;
192
+ $this->_shipFromAddress->address2 = $city . ", " . $state . " " . $zip; //. ", " . $countryId;
193
+ }
194
+ return $this->_shipFromAddress;
195
+ }
196
+
197
+ //Shipping Destination Address
198
+ protected function _getShippingToAddress($address) {
199
+ if($this->_shipToAddress === null){
200
+ $this->_shipToAddress = new stdClass();
201
+ $country = $address->getCountry();
202
+ $zip = $address->getPostcode(); //$zip = preg_replace('/[^0-9\-]*/', '', $address->getPostcode()); //US zip code clean up
203
+ $state = $address->getRegion(); //No region resolution needed, $this->_getStateCodeByRegionId($address->getState());
204
+ $city = $address->getCity();
205
+ $street = implode(' ', $address->getStreet()); //In case of multiple line address
206
+
207
+ $this->_shipToAddress->address1 = $street;
208
+ $this->_shipToAddress->address2 = $city . ", " . $state . " " . $zip; //. ", " . $country;
209
+ }
210
+ return $this->_shipToAddress;
211
+ }
212
+
213
+
214
+ //In a standard setup, tax is calculated by tax class (i.e. product code), if empty use default
215
+ //Advanced calculation by product SKU is also possible. Please contact SpeedTax support to setup advanced service
216
+ protected function _getProductCode($item){
217
+ $useTaxCode = Mage::helper('speedtax')->useTaxClass();
218
+ if(!$useTaxCode){
219
+ return $item->getSku();
220
+ }
221
+ if($taxCode = $this->_getTaxClassByItem($item)){
222
+ return $taxCode;
223
+ }else{
224
+ return $item->getSku();
225
+ }
226
+ }
227
+
228
+ protected function _getTaxClassByItem($item){
229
+ $storeId = Mage::app()->getStore()->getId();
230
+ $taxClassId = Mage::getResourceModel('catalog/product')->getAttributeRawValue($item->getProductId(), 'tax_class_id', $storeId);
231
+ if($taxClassId){
232
+ $taxClassCode = Mage::getModel('tax/class_source_product')->getOptionText($taxClassId);
233
+ }else{
234
+ $taxClassCode = null;
235
+ }
236
+ return $taxClassCode;
237
+ }
238
+
239
+ }
app/code/local/Harapartners/SpeedTax/Helper/Connector/Speedtax.php ADDED
@@ -0,0 +1,167 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * NOTICE OF LICENSE
4
+ *
5
+ * This source file is subject to the End User Software Agreement (EULA).
6
+ * It is also available through the world-wide-web at this URL:
7
+ * http://www.harapartners.com/license [^]
8
+ * If you did not receive a copy of the license and are unable to
9
+ * obtain it through the world-wide-web, please send an email
10
+ * to eula@harapartners.com so we can send you a copy immediately.
11
+ *
12
+ */
13
+ class Harapartners_SpeedTax_Helper_Connector_Speedtax extends Harapartners_SpeedTax_Helper_Connector_Core {
14
+
15
+ const REQUEST_ACTION_CALCULATE_INVOICE = 'CalculateInvoice';
16
+ const REQUEST_ACTION_POST_INVOICE = 'PostInvoice';
17
+ const REQUEST_ACTION_POST_CREDITMEMO = 'PostCreditmemo';
18
+ const REQUEST_ACTION_VOID_INVOICE = 'VoidInvoice';
19
+ const REQUEST_ACTION_BATCH_VOID_INVOICES = 'BatchVoidInvoices';
20
+
21
+ const RESPONSE_TYPE_SUCCESS = 'SUCCESS';
22
+ const RESPONSE_TYPE_FAILED_WITH_ERRORS = 'FAILED_WITH_ERRORS';
23
+ const RESPONSE_TYPE_FAILED_INVOICE_NUMBER = 'FAILED_INVOICE_NUMBER';
24
+
25
+ public function calculateInvoiceRequest($sptxInvoice){
26
+ $response = $this->_doInvoiceRequest($sptxInvoice, self::REQUEST_ACTION_CALCULATE_INVOICE);
27
+ return $response->data->result;
28
+ }
29
+
30
+ public function postInvoiceRequest($sptxInvoice){
31
+ $response = $this->_doInvoiceRequest($sptxInvoice, self::REQUEST_ACTION_POST_INVOICE);
32
+ return $response->data->result;
33
+ }
34
+
35
+ public function postCreditmemoRequest($sptxInvoice){
36
+ $response = $this->_doInvoiceRequest($sptxInvoice, self::REQUEST_ACTION_POST_CREDITMEMO);
37
+ return $response->data->result;
38
+ }
39
+
40
+ public function cancelAllOrderTransactions($invoiceNumbers){
41
+ $username = Mage::getStoreConfig('speedtax/speedtax/username');
42
+ $password = Mage::getStoreConfig('speedtax/speedtax/password');
43
+ $companyCode = Mage::getStoreConfig('speedtax/speedtax/company_code');
44
+ //Check encrypted config
45
+ if (preg_match('/^\*+$/', $password)) {
46
+ $password = Mage::helper('core')->decrypt($password);
47
+ }
48
+ $credentials = array(
49
+ 'username' => $username,
50
+ 'password' => $password,
51
+ 'company_code' => $companyCode
52
+ );
53
+ $request = array(
54
+ 'meta' => array(
55
+ 'action' => self::REQUEST_ACTION_BATCH_VOID_INVOICES
56
+ ),
57
+ 'data' => array(
58
+ 'credentials' => $credentials,
59
+ 'invoice_numbers' => json_encode($invoiceNumbers)
60
+ )
61
+ );
62
+
63
+ $response = $this->_processRequest($request);
64
+
65
+ //Essential validation!
66
+ if(!$response->data || !$response->data->result){
67
+ Mage::throwException('Invalid tax response');
68
+ }
69
+ $responseResult = $response->data->result;
70
+ switch ($responseResult->resultType) {
71
+ case self::RESPONSE_TYPE_SUCCESS:
72
+ break;
73
+ case self::RESPONSE_TYPE_FAILED_WITH_ERRORS:
74
+ case self::RESPONSE_TYPE_FAILED_INVOICE_NUMBER:
75
+ default :
76
+ Mage::throwException('Tax request failed');
77
+ break;
78
+ }
79
+
80
+ return $response;
81
+ }
82
+
83
+ protected function _doInvoiceRequest($sptxInvoice, $actionType){
84
+ $username = Mage::getStoreConfig('speedtax/speedtax/username');
85
+ $password = Mage::getStoreConfig('speedtax/speedtax/password');
86
+ $companyCode = Mage::getStoreConfig('speedtax/speedtax/company_code');
87
+ //Check encrypted config
88
+ if (preg_match('/^\*+$/', $password)) {
89
+ $password = Mage::helper('core')->decrypt($password);
90
+ }
91
+ $credentials = array(
92
+ 'username' => $username,
93
+ 'password' => $password,
94
+ 'company_code' => $companyCode
95
+ );
96
+ $request = array(
97
+ 'meta' => array(
98
+ 'action' => $actionType
99
+ ),
100
+ 'data' => array(
101
+ 'credentials' => $credentials,
102
+ 'invoice' => $sptxInvoice
103
+ )
104
+ );
105
+
106
+ $response = $this->_loadCachedInvoiceResponse($sptxInvoice, $actionType);
107
+ if(!$response){
108
+ $response = $this->_processRequest($request);
109
+ $this->_saveCachedInvoiceResponse($response, $sptxInvoice, $actionType);
110
+ }
111
+
112
+ //Essential validation!
113
+ if(!$response->data || !$response->data->result){
114
+ Mage::throwException('Invalid tax response');
115
+ }
116
+ $responseResult = $response->data->result;
117
+ switch ($responseResult->resultType) {
118
+ case self::RESPONSE_TYPE_SUCCESS:
119
+ break;
120
+ case self::RESPONSE_TYPE_FAILED_WITH_ERRORS:
121
+ case self::RESPONSE_TYPE_FAILED_INVOICE_NUMBER:
122
+ default :
123
+ Mage::throwException('Tax request failed');
124
+ break;
125
+ }
126
+
127
+ return $response;
128
+ }
129
+
130
+ protected function _loadCachedInvoiceResponse($sptxInvoice, $actionType){
131
+ if(!$this->_isCacheRequestAllowed($actionType)){
132
+ return false;
133
+ }
134
+ $sptxInvoiceCacheKey = $this->_generateInvoiceCacheKey($sptxInvoice);
135
+ $response = Mage::getSingleton('speedtax/session')->loadCachedResponse($sptxInvoiceCacheKey);
136
+ return $response;
137
+ }
138
+
139
+ protected function _saveCachedInvoiceResponse($response, $sptxInvoice, $actionType){
140
+ if(!$this->_isCacheRequestAllowed($actionType)){
141
+ return false;
142
+ }
143
+ $sptxInvoiceCacheKey = $this->_generateInvoiceCacheKey($sptxInvoice);
144
+ $response = Mage::getSingleton('speedtax/session')->saveCachedResponse($sptxInvoiceCacheKey, $response);
145
+ return true;
146
+ }
147
+
148
+ protected function _isCacheRequestAllowed($actionType){
149
+ $allRequestCache = false;
150
+ switch($actionType){
151
+ case self::REQUEST_ACTION_CALCULATE_INVOICE:
152
+ $allRequestCache = true;
153
+ break;
154
+ default:
155
+ $allRequestCache = false;
156
+ break;
157
+ }
158
+ return $allRequestCache;
159
+ }
160
+
161
+ protected function _generateInvoiceCacheKey($sptxInvoice){
162
+ $sptxInvoice = clone $sptxInvoice;
163
+ $sptxInvoice->invoiceDate = null;
164
+ return md5(json_encode($sptxInvoice));
165
+ }
166
+
167
+ }
app/code/local/Harapartners/SpeedTax/Helper/Data.php CHANGED
@@ -1,3 +1,30 @@
1
- <?php
2
- // Copyright Notice
3
- class Harapartners_SpeedTax_Helper_Data extends Mage_Core_Helper_Abstract{ public function pdOCjpaT($address, $yKIwhAhG) { return Mage::getStoreConfig('speedtax/speedtax/validate_address', $yKIwhAhG); } public function gYoeJTzo(){ return dirname(dirname(__FILE__)).DS.'lib'.DS; } public function wmnfSKri(){ include_once $this->gYoeJTzo().'SpeedTaxApi.inc'; include_once $this->gYoeJTzo().'SpeedTaxUtil.inc'; } }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * NOTICE OF LICENSE
4
+ *
5
+ * This source file is subject to the End User Software Agreement (EULA).
6
+ * It is also available through the world-wide-web at this URL:
7
+ * http://www.harapartners.com/license [^]
8
+ * If you did not receive a copy of the license and are unable to
9
+ * obtain it through the world-wide-web, please send an email
10
+ * to eula@harapartners.com so we can send you a copy immediately.
11
+ *
12
+ */
13
+ class Harapartners_SpeedTax_Helper_Data extends Mage_Core_Helper_Abstract {
14
+
15
+ protected $_xmlPathPrefix = 'speedtax/speedtax/';
16
+
17
+ // =========================== config and essential flags =========================== //
18
+ public function isSpeedTaxEnabled(){
19
+ return Mage::getStoreConfig ( $this->_xmlPathPrefix . 'is_enabled' );
20
+ }
21
+
22
+ public function useTaxClass(){
23
+ return Mage::getStoreConfig ( $this->_xmlPathPrefix . 'customized_tax_class' );
24
+ }
25
+
26
+ public function isAddressValidationOn($address, $storeId) {
27
+ return Mage::getStoreConfig( $this->_xmlPathPrefix . 'validate_address', $storeId);
28
+ }
29
+
30
+ }
app/code/local/Harapartners/SpeedTax/Helper/Mcrypt.php ADDED
@@ -0,0 +1,87 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * NOTICE OF LICENSE
4
+ *
5
+ * This source file is subject to the End User Software Agreement (EULA).
6
+ * It is also available through the world-wide-web at this URL:
7
+ * http://www.harapartners.com/license [^]
8
+ * If you did not receive a copy of the license and are unable to
9
+ * obtain it through the world-wide-web, please send an email
10
+ * to eula@harapartners.com so we can send you a copy immediately.
11
+ *
12
+ */
13
+ class Harapartners_SpeedTax_Helper_Mcrypt extends Harapartners_SpeedTax_Helper_Object {
14
+
15
+ public function init($key)
16
+ {
17
+ if (!$this->getCipher()) {
18
+ $this->setCipher(MCRYPT_BLOWFISH);
19
+ }
20
+
21
+ if (!$this->getMode()) {
22
+ $this->setMode(MCRYPT_MODE_ECB);
23
+ }
24
+
25
+ $this->setHandler(mcrypt_module_open($this->getCipher(), '', $this->getMode(), ''));
26
+
27
+ if (!$this->getInitVector()) {
28
+ if (MCRYPT_MODE_CBC == $this->getMode()) {
29
+ $this->setInitVector(substr(
30
+ md5(mcrypt_create_iv (mcrypt_enc_get_iv_size($this->getHandler()), MCRYPT_RAND)),
31
+ - mcrypt_enc_get_iv_size($this->getHandler())
32
+ ));
33
+ } else {
34
+ $this->setInitVector(mcrypt_create_iv (mcrypt_enc_get_iv_size($this->getHandler()), MCRYPT_RAND));
35
+ }
36
+ }
37
+
38
+ $maxKeySize = mcrypt_enc_get_key_size($this->getHandler());
39
+
40
+ if (strlen($key) > $maxKeySize) { // strlen() intentionally, to count bytes, rather than characters
41
+ $this->setHandler(null);
42
+ throw new Exception('Maximum key size must be smaller '.$maxKeySize);
43
+ }
44
+
45
+ mcrypt_generic_init($this->getHandler(), $key, $this->getInitVector());
46
+
47
+ return $this;
48
+ }
49
+
50
+ public function encrypt($data)
51
+ {
52
+ if (!$this->getHandler()) {
53
+ throw new Exception('Crypt module is not initialized.');
54
+ }
55
+ if (strlen($data) == 0) {
56
+ return $data;
57
+ }
58
+ return mcrypt_generic($this->getHandler(), $data);
59
+ }
60
+
61
+ public function decrypt($data)
62
+ {
63
+ if (!$this->getHandler()) {
64
+ throw new Exception('Crypt module is not initialized.');
65
+ }
66
+ if (strlen($data) == 0) {
67
+ return $data;
68
+ }
69
+ //Encrypt-Decrypt may append "\0", such padding characters must be removed
70
+ return rtrim(mdecrypt_generic($this->getHandler(), $data), "\0");
71
+ }
72
+
73
+
74
+ public function __destruct()
75
+ {
76
+ if ($this->getHandler()) {
77
+ $this->_reset();
78
+ }
79
+ }
80
+
81
+ protected function _reset()
82
+ {
83
+ mcrypt_generic_deinit($this->getHandler());
84
+ mcrypt_module_close($this->getHandler());
85
+ }
86
+
87
+ }
app/code/local/Harapartners/SpeedTax/Helper/Object.php ADDED
@@ -0,0 +1,161 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * NOTICE OF LICENSE
4
+ *
5
+ * This source file is subject to the End User Software Agreement (EULA).
6
+ * It is also available through the world-wide-web at this URL:
7
+ * http://www.harapartners.com/license [^]
8
+ * If you did not receive a copy of the license and are unable to
9
+ * obtain it through the world-wide-web, please send an email
10
+ * to eula@harapartners.com so we can send you a copy immediately.
11
+ *
12
+ */
13
+ class Harapartners_SpeedTax_Helper_Object {
14
+
15
+ protected $_data = array();
16
+ protected $_hasDataChanges = false;
17
+ protected $_syncFieldsMap = array();
18
+ static protected $_underscoreCache = array();
19
+
20
+ public function __call($method, $args){
21
+ switch (substr($method, 0, 3)) {
22
+ case 'get' :
23
+ //Varien_Profiler::start('GETTER: '.get_class($this).'::'.$method);
24
+ $key = $this->_underscore(substr($method,3));
25
+ $data = $this->getData($key, isset($args[0]) ? $args[0] : null);
26
+ //Varien_Profiler::stop('GETTER: '.get_class($this).'::'.$method);
27
+ return $data;
28
+
29
+ case 'set' :
30
+ //Varien_Profiler::start('SETTER: '.get_class($this).'::'.$method);
31
+ $key = $this->_underscore(substr($method,3));
32
+ $result = $this->setData($key, isset($args[0]) ? $args[0] : null);
33
+ //Varien_Profiler::stop('SETTER: '.get_class($this).'::'.$method);
34
+ return $result;
35
+
36
+ case 'uns' :
37
+ //Varien_Profiler::start('UNS: '.get_class($this).'::'.$method);
38
+ $key = $this->_underscore(substr($method,3));
39
+ $result = $this->unsetData($key);
40
+ //Varien_Profiler::stop('UNS: '.get_class($this).'::'.$method);
41
+ return $result;
42
+
43
+ case 'has' :
44
+ //Varien_Profiler::start('HAS: '.get_class($this).'::'.$method);
45
+ $key = $this->_underscore(substr($method,3));
46
+ //Varien_Profiler::stop('HAS: '.get_class($this).'::'.$method);
47
+ return isset($this->_data[$key]);
48
+ }
49
+ throw new Exception("Invalid method ".get_class($this)."::".$method."(".print_r($args,1).")");
50
+ }
51
+
52
+ public function addData(array $arr) {
53
+ foreach($arr as $index=>$value) {
54
+ $this->setData($index, $value);
55
+ }
56
+ return $this;
57
+ }
58
+
59
+ public function getData($key='', $index=null) {
60
+ if (''===$key) {
61
+ return $this->_data;
62
+ }
63
+
64
+ $default = null;
65
+
66
+ // accept a/b/c as ['a']['b']['c']
67
+ if (strpos($key,'/')) {
68
+ $keyArr = explode('/', $key);
69
+ $data = $this->_data;
70
+ foreach ($keyArr as $i=>$k) {
71
+ if ($k==='') {
72
+ return $default;
73
+ }
74
+ if (is_array($data)) {
75
+ if (!isset($data[$k])) {
76
+ return $default;
77
+ }
78
+ $data = $data[$k];
79
+ } else {
80
+ return $default;
81
+ }
82
+ }
83
+ return $data;
84
+ }
85
+
86
+ // legacy functionality for $index
87
+ if (isset($this->_data[$key])) {
88
+ if (is_null($index)) {
89
+ return $this->_data[$key];
90
+ }
91
+
92
+ $value = $this->_data[$key];
93
+ if (is_array($value)) {
94
+ //if (isset($value[$index]) && (!empty($value[$index]) || strlen($value[$index]) > 0)) {
95
+ /**
96
+ * If we have any data, even if it empty - we should use it, anyway
97
+ */
98
+ if (isset($value[$index])) {
99
+ return $value[$index];
100
+ }
101
+ return null;
102
+ } elseif (is_string($value)) {
103
+ $arr = explode("\n", $value);
104
+ return (isset($arr[$index]) && (!empty($arr[$index]) || strlen($arr[$index]) > 0)) ? $arr[$index] : null;
105
+ }
106
+ return $default;
107
+ }
108
+ return $default;
109
+ }
110
+
111
+ public function setData($key, $value=null) {
112
+ $this->_hasDataChanges = true;
113
+ if(is_array($key)) {
114
+ $this->_data = $key;
115
+ $this->_addFullNames();
116
+ } else {
117
+ $this->_data[$key] = $value;
118
+ if (isset($this->_syncFieldsMap[$key])) {
119
+ $fullFieldName = $this->_syncFieldsMap[$key];
120
+ $this->_data[$fullFieldName] = $value;
121
+ }
122
+ }
123
+ return $this;
124
+ }
125
+
126
+ public function unsetData($key=null) {
127
+ $this->_hasDataChanges = true;
128
+ if (is_null($key)) {
129
+ $this->_data = array();
130
+ } else {
131
+ unset($this->_data[$key]);
132
+ if (isset($this->_syncFieldsMap[$key])) {
133
+ $fullFieldName = $this->_syncFieldsMap[$key];
134
+ unset($this->_data[$fullFieldName]);
135
+ }
136
+ }
137
+ return $this;
138
+ }
139
+
140
+ protected function _addFullNames() {
141
+ $existedShortKeys = array_intersect($this->_syncFieldsMap, array_keys($this->_data));
142
+ if (!empty($existedShortKeys)) {
143
+ foreach ($existedShortKeys as $key) {
144
+ $fullFieldName = array_search($key, $this->_syncFieldsMap);
145
+ $this->_data[$fullFieldName] = $this->_data[$key];
146
+ }
147
+ }
148
+ }
149
+
150
+ protected function _underscore($name){
151
+ if (isset(self::$_underscoreCache[$name])) {
152
+ return self::$_underscoreCache[$name];
153
+ }
154
+ #Varien_Profiler::start('underscore');
155
+ $result = strtolower(preg_replace('/(.)([A-Z])/', "$1_$2", $name));
156
+ #Varien_Profiler::stop('underscore');
157
+ self::$_underscoreCache[$name] = $result;
158
+ return $result;
159
+ }
160
+
161
+ }
app/code/local/Harapartners/SpeedTax/Helper/Processor.php ADDED
@@ -0,0 +1,203 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * NOTICE OF LICENSE
5
+ *
6
+ * This source file is subject to the End User Software Agreement (EULA).
7
+ * It is also available through the world-wide-web at this URL:
8
+ * http://www.harapartners.com/license [^]
9
+ * If you did not receive a copy of the license and are unable to
10
+ * obtain it through the world-wide-web, please send an email
11
+ * to eula@harapartners.com so we can send you a copy immediately.
12
+ *
13
+ */
14
+
15
+ class Harapartners_SpeedTax_Helper_Processor extends Mage_Core_Helper_Abstract {
16
+
17
+ const SPEEDTAX_INVOICE_STATUS_PENDING = 0;
18
+ const SPEEDTAX_INVOICE_STATUS_POSTED = 100;
19
+ const SPEEDTAX_INVOICE_STATUS_VOID = 200;
20
+ const SPEEDTAX_INVOICE_STATUS_ERROR = 300;
21
+
22
+ // ========================== Actions ========================== //
23
+ public function queryQuoteAddress(Mage_Sales_Model_Quote_Address $mageQuoteAddress){
24
+ if (!$this->_isTaxable($mageQuoteAddress)){
25
+ return false;
26
+ }
27
+ $sptxInvoice = Mage::helper('speedtax/connector_data')->prepareSpeedTaxInvoiceByMageQuoteAddress($mageQuoteAddress);
28
+ if(!$sptxInvoice|| !$sptxInvoice->lineItems){
29
+ return false;
30
+ }
31
+ $responseResult = Mage::helper('speedtax/connector_speedtax')->calculateInvoiceRequest($sptxInvoice);
32
+ $this->_applyResponseToQuote($responseResult, $mageQuoteAddress);
33
+ return $responseResult;
34
+ }
35
+
36
+ public function postOrderInvoice(Mage_Sales_Model_Order_Invoice $mageOrderInvoice){
37
+ if(!!$mageOrderInvoice->getData('speedtax_transaction_id')){
38
+ Mage::throwException('This invoice was already posted through SalesTax.');
39
+ }
40
+
41
+ $sptxInvoice = Mage::helper('speedtax/connector_data')->prepareSpeedTaxInvoiceByMageOrderInvoice($mageOrderInvoice);
42
+ if(!$sptxInvoice || !$sptxInvoice->lineItems){
43
+ return false;
44
+ }
45
+ //No caching allowed for order invoice
46
+ $responseResult = Mage::helper('speedtax/connector_speedtax')->postInvoiceRequest($sptxInvoice);
47
+ $this->_applyResponseToInvoice($responseResult, $mageOrderInvoice);
48
+
49
+ return $responseResult;
50
+ }
51
+
52
+ public function postOrderCreditmemo(Mage_Sales_Model_Order_Creditmemo $mageOrderCreditmemo) {
53
+ if(!!$mageOrderCreditmemo->getData('speedtax_transaction_id')){
54
+ Mage::throwException('This credit memo was already posted through SalesTax.');
55
+ }
56
+
57
+ $sptxInvoice = Mage::helper('speedtax/connector_data')->prepareSpeedTaxInvoiceByMageOrderCreditmemo($mageOrderCreditmemo);
58
+ if(!$sptxInvoice || !$sptxInvoice->lineItems){
59
+ return false;
60
+ }
61
+ //No caching allowed for order invoice
62
+ $responseResult = Mage::helper('speedtax/connector_speedtax')->postCreditmemoRequest($sptxInvoice);
63
+ $this->_applyResponseToCreditmemo($responseResult, $mageOrderCreditmemo);
64
+
65
+ return $responseResult;
66
+ }
67
+
68
+ public function cancelAllOrderTransactions(Mage_Sales_Model_Order $mageOrder) {
69
+ $invoiceNumbers = array();
70
+ $updateObjectArray = array();
71
+ foreach($mageOrder->getInvoiceCollection() as $mageOrderInvoice){
72
+ if(!!$mageOrderInvoice->getData('speedtax_invoice_number')
73
+ && $mageOrderInvoice->getData('speedtax_invoice_status') == self::SPEEDTAX_INVOICE_STATUS_POSTED ){
74
+ $invoiceNumbers[] = $mageOrderInvoice->getData('speedtax_invoice_number');
75
+ $updateObjectArray[$mageOrderInvoice->getData('speedtax_invoice_number')] = $mageOrderInvoice;
76
+ }
77
+ }
78
+ foreach($mageOrder->getCreditmemosCollection() as $mageOrderCreditmemo){
79
+ if(!!$mageOrderCreditmemo->getData('speedtax_invoice_number')
80
+ && $mageOrderCreditmemo->getData('speedtax_invoice_status') == self::SPEEDTAX_INVOICE_STATUS_POSTED ){
81
+ $invoiceNumbers[] = $mageOrderCreditmemo->getData('speedtax_invoice_number');
82
+ $updateObjectArray[$mageOrderCreditmemo->getData('speedtax_invoice_number')] = $mageOrderCreditmemo;
83
+ }
84
+ }
85
+
86
+ if(!$invoiceNumbers){
87
+ return false;
88
+ }
89
+ //No caching allowed for order invoice
90
+ $responseResult = Mage::helper('speedtax/connector_speedtax')->cancelAllOrderTransactions($invoiceNumbers);
91
+
92
+ //Update status
93
+ $batchVoidResults = json_decode($responseResult->data->result->batchVoidResults, 1);
94
+ foreach($batchVoidResults as $invoiceNumber => $voidResult){
95
+ $updateObject = $updateObjectArray[$invoiceNumber];
96
+ if($voidResult == Harapartners_SpeedTax_Helper_Connector_Speedtax::RESPONSE_TYPE_SUCCESS){
97
+ $updateObject->setData('speedtax_invoice_status', self::SPEEDTAX_INVOICE_STATUS_VOID);
98
+ }else{
99
+ $updateObject->setData('speedtax_invoice_status', self::SPEEDTAX_INVOICE_STATUS_ERROR);
100
+ }
101
+ $updateObject->save();
102
+ }
103
+
104
+ return $responseResult;
105
+ }
106
+
107
+
108
+ // ========================== Utility Functions ========================== //
109
+ //Mage_Sales_Model_Quote_Address or Mage_Sales_Model_Order_Address
110
+ protected function _isTaxable($mageAddress) {
111
+ //$mageAddress can be quote of order address, or null for virtual product
112
+ if(!($mageAddress instanceof Varien_Object)
113
+ || $mageAddress->getAddressType() != Mage_Sales_Model_Quote_Address::TYPE_SHIPPING
114
+ ){
115
+ return false;
116
+ }
117
+ //Nexus test
118
+ $originsString = Mage::getStoreConfig('speedtax/speedtax/origins');
119
+ return in_array($mageAddress->getRegionId(), explode(',', $originsString));
120
+ }
121
+
122
+ //Mage_Sales_Model_Quote_Address ONLY
123
+ protected function _applyResponseToQuote($responseResult, Mage_Sales_Model_Quote_Address $mageQuoteAddress){
124
+ foreach ( $mageQuoteAddress->getAllItems() as $mageQuoteItem ) {
125
+ $taxAmount = $this->_getLineItemTaxAmountByItemId($responseResult, $mageQuoteItem->getId());
126
+ $mageQuoteItem->setTaxAmount($taxAmount);
127
+ $mageQuoteItem->setBaseTaxAmount($taxAmount);
128
+ if(($mageQuoteItem->getRowTotal() - $mageQuoteItem->getDiscountAmount()) > 0){
129
+ $mageQuoteItem->setTaxPercent (sprintf("%.4f", 100*$taxAmount/($mageQuoteItem->getRowTotal() - $mageQuoteItem->getDiscountAmount())));
130
+ }
131
+ }
132
+ if(!!$this->_getTaxShippingAmount()){
133
+ $taxShippingAmount = $this->_getTaxShippingAmount();
134
+ $mageQuoteAddress->setShippingTaxAmount($taxShippingAmount);
135
+ $mageQuoteAddress->setBaseShippingTaxAmount($taxShippingAmount);
136
+ }
137
+ return;
138
+ }
139
+
140
+ protected function _applyResponseToInvoice($responseResult, Mage_Sales_Model_Order_Invoice $mageOrderInvoice){
141
+ $mageOrderInvoice->setData('speedtax_transaction_id', $responseResult->transactionId);
142
+ $mageOrderInvoice->setData('speedtax_invoice_number', $responseResult->invoiceNumber);
143
+ $mageOrderInvoice->setData('speedtax_invoice_status', self::SPEEDTAX_INVOICE_STATUS_POSTED);
144
+ $mageOrderInvoice->save();
145
+ return;
146
+ }
147
+
148
+ protected function _applyResponseToCreditmemo($responseResult, Mage_Sales_Model_Order_Creditmemo $mageOrderCreditmemo){
149
+ $mageOrderCreditmemo->setData('speedtax_transaction_id', $responseResult->transactionId);
150
+ $mageOrderCreditmemo->setData('speedtax_invoice_number', $responseResult->invoiceNumber);
151
+ $mageOrderCreditmemo->setData('speedtax_invoice_status', self::SPEEDTAX_INVOICE_STATUS_POSTED);
152
+ $mageOrderCreditmemo->save();
153
+ return;
154
+ }
155
+
156
+ public function getTotalTax($responseResult) {
157
+ return $responseResult->totalTax->decimalValue;
158
+ }
159
+
160
+ protected function _getLineItemTaxAmountByItemId($responseResult, $itemId) {
161
+ foreach($responseResult->lineItemBundles->lineItems as $responseLineItem){
162
+ if($responseLineItem->customReference == $itemId){
163
+ return $responseLineItem->taxAmount->decimalValue;
164
+ }
165
+ }
166
+ return 0.0;
167
+ }
168
+
169
+ protected function _getTaxShippingAmount() {
170
+ foreach($responseResult->lineItemBundles->lineItems as $responseLineItem){
171
+ if($responseLineItem->productCode == self::TAX_SHIPPING_LINEITEM_TAX_CLASS){
172
+ return $responseLineItem->taxAmount->decimalValue;
173
+ }
174
+ }
175
+ return 0.0;
176
+ }
177
+
178
+
179
+
180
+
181
+
182
+
183
+
184
+
185
+
186
+
187
+
188
+ //>>>>>>>>>>>>>>>>>>>>>>>>>>> Some utitilies for previous parent class
189
+ // Method never used??@@
190
+
191
+
192
+ //Adds a comment to order history. Method choosen based on Magento version.
193
+ protected function _addStatusHistoryComment($order, $comment) {
194
+ if(method_exists($order, 'addStatusHistoryComment')) {
195
+ $order->addStatusHistoryComment($comment)->save();;
196
+ } elseif(method_exists($order, 'addStatusToHistory')) {
197
+ $order->addStatusToHistory($order->getStatus(), $comment, false)->save();;
198
+ }
199
+ return $this;
200
+ }
201
+
202
+
203
+ }
app/code/local/Harapartners/SpeedTax/Model/Abstract.php DELETED
@@ -1,3 +0,0 @@
1
- <?php
2
- // Copyright Notice
3
- abstract class Harapartners_SpeedTax_Model_Abstract extends Varien_Object { public function getSession () { return Mage::getSingleton('speedtax/session'); } }
 
 
 
app/code/local/Harapartners/SpeedTax/Model/Adminhtml/Usregions.php DELETED
@@ -1,3 +0,0 @@
1
- <?php
2
- // Copyright Notice
3
- class Harapartners_Speedtax_Model_Adminhtml_Usregions { protected $TQwlivGE; public function toOptionArray($WLsgQNrS=false) { if (!$this->TQwlivGE) { $DFQHFRaZ = Mage::getModel( 'directory/region' )->getCollection(); $DFQHFRaZ->getSelect()->where( 'country_id = ?', 'US' ); $ppAkdgdY = array(); foreach( $DFQHFRaZ as $cOdXbkkz ) { $ppAkdgdY[] = array( 'label' => $cOdXbkkz->getDefaultName(), 'value' => $cOdXbkkz->getId() ); } $this->TQwlivGE = $ppAkdgdY; } $watjSivp = $this->TQwlivGE; if(!$WLsgQNrS){ array_unshift($watjSivp, array('value'=>'', 'label'=>'')); } return $watjSivp; } }
 
 
 
app/code/local/Harapartners/SpeedTax/Model/Checkout/Type/Multishipping.php DELETED
@@ -1,3 +0,0 @@
1
- <?php
2
- // Copyright Notice
3
- class Harapartners_SpeedTax_Model_Checkout_Type_Multishipping extends Mage_Checkout_Model_Type_Abstract { protected function _validate() { $MIQTbhnH = Mage::helper ( 'checkout' ); $Qbyijbwf = $this->getQuote (); if (! $Qbyijbwf->getIsMultiShipping ()) { Mage::throwException ( $MIQTbhnH->__ ( 'Invalid checkout type.' ) ); } $JhanrwSn = $Qbyijbwf->getAllShippingAddresses (); foreach ( $JhanrwSn as $address ) { $jNQAvRZp = $address->validate (); if ($jNQAvRZp !== true) { Mage::throwException ( $MIQTbhnH->__ ( 'Please check shipping addresses information.' ) ); } $method = $address->getShippingMethod (); $wOxYshhb = $address->getShippingRateByCode ( $method ); if (! $method || ! $wOxYshhb) { Mage::throwException($MIQTbhnH->__('Please specify shipping methods for all addresses.')); } } $jNQAvRZp = $Qbyijbwf->getBillingAddress ()->validate (); if ($jNQAvRZp !== true) { Mage::throwException ( $MIQTbhnH->__ ( 'Please check billing address information.' ) ); } return $this; } }
 
 
 
app/code/local/Harapartners/SpeedTax/Model/Log.php DELETED
@@ -1,3 +0,0 @@
1
- <?php
2
- // Copyright Notice
3
- class Harapartners_SpeedTax_Model_Log extends Mage_Core_Model_Abstract { public function log($GGDYkQaU) { if ($GGDYkQaU ["error"] == true) { $bxvvPkgx = Mage::getModel ( 'speedtax/log_error' ); $bxvvPkgx->setData ( 'event', $GGDYkQaU ['event'] ); $bxvvPkgx->setData ( 'result_type', $GGDYkQaU ['result_type'] ); $bxvvPkgx->setData ( 'message', $GGDYkQaU ['message'] ); $bxvvPkgx->setData ( 'address_shipping_from', $GGDYkQaU ['address_shipping_from'] ); $bxvvPkgx->setData ( 'address_shipping_to', $GGDYkQaU ['address_shipping_to'] ); $bxvvPkgx->setData ( 'customer_name', $this ['customer_name'] ); $bxvvPkgx->save (); } if ($GGDYkQaU ["call"] == true) { $bxvvPkgx = Mage::getModel ( 'speedtax/log_call' ); $bxvvPkgx->setData ( 'event', $GGDYkQaU ['event'] ); $bxvvPkgx->setData ( 'result_type', $GGDYkQaU ['result_type'] ); $bxvvPkgx->setData ( 'invoice_num', $GGDYkQaU ['invoice_num'] ); $bxvvPkgx->setData ( 'gross', $GGDYkQaU['gross']); $bxvvPkgx->setData ( 'exempt', $GGDYkQaU ['exempt'] ); $bxvvPkgx->setData ( 'tax', $GGDYkQaU['tax']); $bxvvPkgx->save (); } } }
 
 
 
app/code/local/Harapartners/SpeedTax/Model/Log/Call.php DELETED
@@ -1,3 +0,0 @@
1
- <?php
2
- // Copyright Notice
3
- class Harapartners_SpeedTax_Model_Log_Call extends Mage_Core_Model_Abstract { protected function _construct() { $this->_init ( 'speedtax_log/call' ); } }
 
 
 
app/code/local/Harapartners/SpeedTax/Model/Log/Error.php DELETED
@@ -1,3 +0,0 @@
1
- <?php
2
- // Copyright Notice
3
- class Harapartners_SpeedTax_Model_Log_Error extends Mage_Core_Model_Abstract { protected function _construct() { $this->_init ( 'speedtax_log/error' ); } }
 
 
 
app/code/local/Harapartners/SpeedTax/Model/Log/Mysql4/Call.php DELETED
@@ -1,3 +0,0 @@
1
- <?php
2
- // Copyright Notice
3
- class Harapartners_SpeedTax_Model_Log_Mysql4_Call extends Mage_Core_Model_Mysql4_Abstract { protected function _construct() { $this->_init('speedtax_log/call', 'log_id'); } }
 
 
 
app/code/local/Harapartners/SpeedTax/Model/Log/Mysql4/Call/Collection.php DELETED
@@ -1,3 +0,0 @@
1
- <?php
2
- // Copyright Notice
3
- class Harapartners_SpeedTax_Model_Log_Mysql4_Call_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract { public function _construct() { $this->_init('speedtax_log/call'); } }
 
 
 
app/code/local/Harapartners/SpeedTax/Model/Log/Mysql4/Error.php DELETED
@@ -1,3 +0,0 @@
1
- <?php
2
- // Copyright Notice
3
- class Harapartners_SpeedTax_Model_Log_Mysql4_Error extends Mage_Core_Model_Mysql4_Abstract { protected function _construct() { $this->_init('speedtax_log/error', 'log_id'); } }
 
 
 
app/code/local/Harapartners/SpeedTax/Model/Log/Mysql4/Error/Collection.php DELETED
@@ -1,3 +0,0 @@
1
- <?php
2
- // Copyright Notice
3
- class Harapartners_SpeedTax_Model_Log_Mysql4_Error_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract { public function _construct() { $this->_init('speedtax_log/error'); } }
 
 
 
app/code/local/Harapartners/SpeedTax/Model/Observer.php CHANGED
@@ -1,3 +1,67 @@
1
- <?php
2
- // Copyright Notice
3
- class Harapartners_SpeedTax_Model_Observer extends Mage_Core_Model_Abstract { public function saleOrderInvoicePlace(Varien_Event_Observer $PdTkCJKp) { $invoice = $PdTkCJKp->getEvent()->getInvoice(); try { $qNxaFjve = Mage::getModel ( 'speedtax/speedtax_calculate' ); $qNxaFjve->BrNWSVbZ($invoice); } catch( Exception $e ) { throw new $e; } } public function salesOrderCreditmemoRefund(Varien_Event_Observer $PdTkCJKp) { $sRLVBLYD = $PdTkCJKp->getEvent()->getCreditmemo(); try { $qNxaFjve = Mage::getModel ( 'speedtax/speedtax_calculate' ); $qNxaFjve->tvPiWdAy($sRLVBLYD); } catch( Exception $e ) { throw new $e; } } }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * NOTICE OF LICENSE
5
+ *
6
+ * This source file is subject to the End User Software Agreement (EULA).
7
+ * It is also available through the world-wide-web at this URL:
8
+ * http://www.harapartners.com/license [^]
9
+ * If you did not receive a copy of the license and are unable to
10
+ * obtain it through the world-wide-web, please send an email
11
+ * to eula@harapartners.com so we can send you a copy immediately.
12
+ *
13
+ */
14
+
15
+ class Harapartners_SpeedTax_Model_Observer extends Mage_Core_Model_Abstract {
16
+
17
+ public function saleOrderInvoicePay(Varien_Event_Observer $observer) {
18
+ if (!Mage::helper('speedtax')->isSpeedTaxEnabled()) {
19
+ return;
20
+ }
21
+ $invoice = $observer->getEvent()->getInvoice();
22
+ try {
23
+ $processor = Mage::helper('speedtax/processor');
24
+ $responseResult = $processor->postOrderInvoice($invoice);
25
+ } catch( Exception $e ) {
26
+ //Suppress exception so that the transaction is not reverted (payment already processed)
27
+ Mage::logException($e);
28
+ $maskedErrorMessage = 'There is an error processing tax information.';
29
+ Mage::getSingleton('core/session')->addError($maskedErrorMessage);
30
+ }
31
+ }
32
+
33
+ public function salesOrderCreditmemoRefund(Varien_Event_Observer $observer) {
34
+ if (!Mage::helper('speedtax')->isSpeedTaxEnabled()) {
35
+ return;
36
+ }
37
+ $creditmemo = $observer->getEvent()->getCreditmemo();
38
+ try {
39
+ $processor = Mage::helper('speedtax/processor');
40
+ $responseResult = $processor->postOrderCreditmemo($creditmemo);
41
+ } catch( Exception $e ) {
42
+ //Suppress exception so that the transaction is not reverted (payment already processed)
43
+ Mage::logException($e);
44
+ $maskedErrorMessage = 'There is an error processing tax information.';
45
+ Mage::getSingleton('core/session')->addError($maskedErrorMessage);
46
+ }
47
+ }
48
+
49
+ //For manual cancel or order edit related cancellation
50
+ public function orderCancelAfter(Varien_Event_Observer $observer) {
51
+ if (!Mage::helper('speedtax')->isSpeedTaxEnabled()) {
52
+ return;
53
+ }
54
+ $order = $observer->getEvent()->getOrder();
55
+ try {
56
+ $processor = Mage::helper('speedtax/processor');
57
+ $responseResult = $processor->cancelAllOrderTransactions($order);
58
+ } catch( Exception $e ) {
59
+ //Suppress exception so that the transaction is not reverted (payment already processed)
60
+ Mage::logException($e);
61
+ $maskedErrorMessage = 'There is an error processing tax information.';
62
+ Mage::getSingleton('core/session')->addError($maskedErrorMessage);
63
+ }
64
+ }
65
+
66
+
67
+ }
app/code/local/Harapartners/SpeedTax/Model/Rewrite/Paypal/Api/Nvp.php ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * NOTICE OF LICENSE
4
+ *
5
+ * This source file is subject to the End User Software Agreement (EULA).
6
+ * It is also available through the world-wide-web at this URL:
7
+ * http://www.harapartners.com/license
8
+ * If you did not receive a copy of the license and are unable to
9
+ * obtain it through the world-wide-web, please send an email
10
+ * to eula@harapartners.com so we can send you a copy immediately.
11
+ *
12
+ *
13
+ */
14
+ class Harapartners_SpeedTax_Model_Rewrite_Paypal_Api_Nvp extends Mage_Paypal_Model_Api_Nvp {
15
+
16
+ public function getButtonSourceEc(){
17
+ return $this->getBuildNotationCode();
18
+ }
19
+
20
+ public function getButtonSourceDp(){
21
+ return $this->getBuildNotationCode();
22
+ }
23
+
24
+ //Important build code update, for Mage_Paypal 1.4 -
25
+ public function getBuildNotationCode($countryCode = null){
26
+ if($this->_isModuleActive('Enterprise_Enterprise')){
27
+ return 'Hara_SI_MagentoEE_PPA';
28
+ }else{
29
+ return 'Hara_SI_MagentoCE_PPA';
30
+ }
31
+ }
32
+
33
+ private function _isModuleActive($code) {
34
+ $module = Mage::getConfig()->getNode("modules/$code");
35
+ $model = Mage::getConfig()->getNode("global/models/$code");
36
+ return $module && $module->is('active') || $model;
37
+ }
38
+
39
+ }
app/code/local/Harapartners/SpeedTax/Model/Rewrite/Paypal/Config.php ADDED
@@ -0,0 +1,58 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * NOTICE OF LICENSE
4
+ *
5
+ * This source file is subject to the End User Software Agreement (EULA).
6
+ * It is also available through the world-wide-web at this URL:
7
+ * http://www.harapartners.com/license
8
+ * If you did not receive a copy of the license and are unable to
9
+ * obtain it through the world-wide-web, please send an email
10
+ * to eula@harapartners.com so we can send you a copy immediately.
11
+ *
12
+ *
13
+ */
14
+ class Harapartners_SpeedTax_Model_Rewrite_Paypal_Config extends Mage_Paypal_Model_Config {
15
+
16
+ protected $_isStagingMode = null;
17
+
18
+ /* Compatibility for Staging server SSL verification */
19
+ public function __get($key){
20
+ if(strcmp($key, 'verifyPeer') == 0 || strcmp($key, 'verify_peer') == 0){
21
+ if($this->_isStagingMode === null){
22
+ $this->_isStagingMode = 0;
23
+ try{
24
+ $curlResource = curl_init("https://www.paypal.com/");
25
+ curl_setopt($curlResource, CURLOPT_TIMEOUT, 3);
26
+ curl_setopt($curlResource, CURLOPT_RETURNTRANSFER, false);
27
+ curl_setopt($curlResource, CURLOPT_SSL_VERIFYPEER, true);
28
+ curl_exec($curlResource);
29
+ $curlError = curl_error($curlResource);
30
+ curl_close($curlResource);
31
+ if(!!$curlError){
32
+ $this->_isStagingMode = 1;
33
+ }
34
+ }catch (Exception $ex){
35
+ $this->_isStagingMode = 1;
36
+ }
37
+ }
38
+ if($this->_isStagingMode == 1){
39
+ return 0;
40
+ }
41
+ }
42
+ return parent::__get($key);
43
+ }
44
+
45
+ public function getBuildNotationCode($countryCode = null){
46
+ if($this->_isModuleActive('Enterprise_Enterprise')){
47
+ return 'Hara_SI_MagentoEE_PPA';
48
+ }else{
49
+ return 'Hara_SI_MagentoCE_PPA';
50
+ }
51
+ }
52
+ private function _isModuleActive($code) {
53
+ $module = Mage::getConfig()->getNode("modules/$code");
54
+ $model = Mage::getConfig()->getNode("global/models/$code");
55
+ return $module && $module->is('active') || $model;
56
+ }
57
+
58
+ }
app/code/local/Harapartners/SpeedTax/Model/Rewrite/Tax/Sales/Total/Quote/Tax.php ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * NOTICE OF LICENSE
4
+ *
5
+ * This source file is subject to the End User Software Agreement (EULA).
6
+ * It is also available through the world-wide-web at this URL:
7
+ * http://www.harapartners.com/license [^]
8
+ * If you did not receive a copy of the license and are unable to
9
+ * obtain it through the world-wide-web, please send an email
10
+ * to eula@harapartners.com so we can send you a copy immediately.
11
+ *
12
+ */
13
+ class Harapartners_SpeedTax_Model_Rewrite_Tax_Sales_Total_Quote_Tax extends Mage_Tax_Model_Sales_Total_Quote_Tax {
14
+
15
+ public function collect(Mage_Sales_Model_Quote_Address $address) {
16
+ if (!Mage::helper('speedtax')->isSpeedTaxEnabled()) {
17
+ return parent::collect($address);
18
+ }
19
+
20
+ $store = $address->getQuote()->getStore();
21
+ $customer = $address->getQuote()->getCustomer();
22
+
23
+ $address->setTotalAmount($this->getCode(), 0);
24
+ $address->setBaseTotalAmount($this->getCode(), 0);
25
+
26
+ $address->setTaxAmount(0);
27
+ $address->setBaseTaxAmount(0);
28
+ $address->setShippingTaxAmount(0);
29
+ $address->setBaseShippingTaxAmount(0);
30
+
31
+ //Init
32
+ $this->_setAddress($address);
33
+ $this->_setAmount(0);
34
+ $this->_setBaseAmount(0);
35
+
36
+ try {
37
+ $processor = Mage::helper('speedtax/processor');
38
+ $responseResult = $processor->queryQuoteAddress($address);
39
+ //Address line item amount and shipping tax amount are updated within the query
40
+ if (!!$responseResult) {
41
+ $this->_addAmount($processor->getTotalTax($responseResult));
42
+ $this->_addBaseAmount($amount);
43
+ }
44
+ } catch(Exception $e) {
45
+ //Tax collecting is very important, this is within the collect total (cannot bubble exceptions), force a redirect
46
+ Mage::logException($e);
47
+ $maskedErrorMessage = 'There is an error calculating tax.';
48
+ Mage::getSingleton('core/session')->addError($maskedErrorMessage);
49
+ throw new Mage_Core_Model_Session_Exception($maskedErrorMessage); //Session exceptions will be redirected to base URL
50
+ }
51
+
52
+ return $this;
53
+ }
54
+
55
+ }
app/code/local/Harapartners/SpeedTax/Model/Sales/Quote/Address.php DELETED
@@ -1,3 +0,0 @@
1
- <?php
2
- // Copyright Notice
3
- class Harapartners_SpeedTax_Model_Sales_Quote_Address extends Mage_Sales_Model_Quote_Address { protected $OOBJuQzt = null; protected $nntwRomV = null; const DEFAULT_CUSTOMER_ORDER_COLLECTION_SIZE = 2; public function MxrdJHLy(){ if($this->nntwRomV === null){ $this->nntwRomV = Mage::getModel('sales/order')->getCollection(); $dtwSxNDy = $this->getCustomerId(); $this->nntwRomV->getSelect() ->where('`customer_id` = ?', $dtwSxNDy) ->where('`relation_parent_id` IS NULL') ->order('created_at') ->limit(self::DEFAULT_CUSTOMER_ORDER_COLLECTION_SIZE); } return $this->nntwRomV; } public function dwuswvFI() { return $this->OOBJuQzt; } public function sflKFBFS(Harapartners_SpeedTax_Model_SpeedTax_Address $RnHlOoRC) { $this->OOBJuQzt = $RnHlOoRC; return $this; } public function validate () { $result = parent::validate(); if ($result !== true) { return $result; } $RmBoraUt = Mage::app()->getRequest()->getPost('billing', array()); $JTwfnAJa = isset($RmBoraUt['use_for_shipping']) ? (int)$RmBoraUt['use_for_shipping'] : 0; if($this->getAddressType() == self::TYPE_SHIPPING || $this->getUseForShipping() || $JTwfnAJa ) { if(!$this->dwuswvFI()) { $rjOPOUfi = Mage::getModel('speedtax/speedtax_address')->setAddress($this); $this->sflKFBFS($rjOPOUfi); } return $this->dwuswvFI()->validate(); } return $result; } }
 
 
 
app/code/local/Harapartners/SpeedTax/Model/Session.php CHANGED
@@ -1,3 +1,64 @@
1
- <?php
2
- // Copyright Notice
3
- class Harapartners_SpeedTax_Model_Session extends Mage_Core_Model_Session_Abstract { public function __construct() { $this->init('speedtax'); } }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * NOTICE OF LICENSE
5
+ *
6
+ * This source file is subject to the End User Software Agreement (EULA).
7
+ * It is also available through the world-wide-web at this URL:
8
+ * http://www.harapartners.com/license [^]
9
+ * If you did not receive a copy of the license and are unable to
10
+ * obtain it through the world-wide-web, please send an email
11
+ * to eula@harapartners.com so we can send you a copy immediately.
12
+ *
13
+ */
14
+
15
+ class Harapartners_SpeedTax_Model_Session extends Mage_Core_Model_Session_Abstract {
16
+
17
+ const REQUEST_CACHE_TTL = 600;
18
+
19
+ public function __construct() {
20
+ $this->init('speedtax');
21
+ }
22
+
23
+ public function loadCachedResponse($sptxInvoiceCacheKey){
24
+ $cacheStorage = $this->getData('cache_storage');
25
+ if(!isset($cacheStorage[$sptxInvoiceCacheKey])){
26
+ return false;
27
+ }
28
+ $cacheEntry = $cacheStorage[$sptxInvoiceCacheKey];
29
+ if($this->_isCacheEntryValid($cacheEntry)){
30
+ return json_decode($cacheEntry['response_json']);
31
+ }
32
+ return false;
33
+ }
34
+
35
+ public function saveCachedResponse($sptxInvoiceCacheKey, $response){
36
+ $cacheStorage = $this->getData('cache_storage');
37
+ if(!$cacheStorage){
38
+ $cacheStorage = array();
39
+ }
40
+ $cacheStorage[$sptxInvoiceCacheKey] = array(
41
+ 'timestamp' => time(),
42
+ 'response_json' => json_encode($response)
43
+ );
44
+ $cacheStorage = $this->_clearExpiredEnties($cacheStorage);
45
+ $this->setData('cache_storage', $cacheStorage);
46
+ return true;
47
+ }
48
+
49
+ protected function _clearExpiredEnties($cacheStorage){
50
+ foreach($cacheStorage as $sptxInvoiceCacheKey => $cacheEntry){
51
+ if(!$this->_isCacheEntryValid($cacheEntry)){
52
+ unset($cacheStorage[$sptxInvoiceCacheKey]);
53
+ }
54
+ }
55
+ return $cacheStorage;
56
+ }
57
+
58
+ protected function _isCacheEntryValid($cacheEntry){
59
+ return isset($cacheEntry['timestamp'])
60
+ && $cacheEntry['timestamp'] + self::REQUEST_CACHE_TTL > time()
61
+ && isset($cacheEntry['response_json']);
62
+ }
63
+
64
+ }
app/code/local/Harapartners/SpeedTax/Model/Source/Usregions.php ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * NOTICE OF LICENSE
4
+ *
5
+ * This source file is subject to the End User Software Agreement (EULA).
6
+ * It is also available through the world-wide-web at this URL:
7
+ * http://www.harapartners.com/license [^]
8
+ * If you did not receive a copy of the license and are unable to
9
+ * obtain it through the world-wide-web, please send an email
10
+ * to eula@harapartners.com so we can send you a copy immediately.
11
+ *
12
+ */
13
+ class Harapartners_Speedtax_Model_Source_Usregions
14
+ {
15
+ protected $_options;
16
+
17
+ public function toOptionArray($isMultiselect=false)
18
+ {
19
+ if (!$this->_options) {
20
+ $regionCollection = Mage::getModel( 'directory/region' )->getCollection();
21
+ $regionCollection->getSelect()->where( 'country_id = ?', 'US' );
22
+ $regionOptions = array();
23
+ foreach( $regionCollection as $region ) {
24
+ $regionOptions[] = array( 'label' => $region->getDefaultName(), 'value' => $region->getId() );
25
+ }
26
+ $this->_options = $regionOptions;
27
+ }
28
+ $options = $this->_options;
29
+ if(!$isMultiselect){
30
+ array_unshift($options, array('value'=>'', 'label'=>''));
31
+ }
32
+
33
+ return $options;
34
+ }
35
+ }
app/code/local/Harapartners/SpeedTax/Model/Speedtax/Abstract.php DELETED
@@ -1,3 +0,0 @@
1
- <?php
2
- // Copyright Notice
3
- abstract class Harapartners_SpeedTax_Model_Speedtax_Abstract extends Harapartners_SpeedTax_Model_Abstract { protected static $icWjeIgO = false; protected $dSEISXXX = null; protected function NlNowdnP($CawVBdmU = null) { $UsvhtHRY = Mage::getStoreConfig('shipping/origin/country_id', $CawVBdmU); $zip = Mage::getStoreConfig('shipping/origin/postcode', $CawVBdmU); $JeKDKbwY = Mage::getStoreConfig('shipping/origin/region_id', $CawVBdmU); $state = Mage::getModel('directory/region')->load($JeKDKbwY)->getCode(); $city = Mage::getStoreConfig('shipping/origin/city', $CawVBdmU); $CfYMbngw = Mage::getStoreConfig('shipping/origin/street', $CawVBdmU); $address = $this->GPGUZyff($CfYMbngw, '', $city, $state, $zip, $UsvhtHRY); return $this->dSEISXXX->wFTPVSvd($address); } protected function LxLnQHQm($address) { $CfYMbngw = $address->getStreet(); $naFRtUVU = isset($CfYMbngw[0]) ? $CfYMbngw[0] : null; $xVxBgTrz = isset($CfYMbngw[1]) ? $CfYMbngw[1] : null; $city = $address->getCity(); $zip = preg_replace('/[^0-9\-]*/', '', $address->getPostcode()); $state = Mage::getModel('directory/region')->load($address->getRegionId())->getCode(); $UsvhtHRY = $address->getCountry(); if(($city && $state) || $zip) { $address = $this->GPGUZyff($naFRtUVU, $xVxBgTrz, $city, $state, $zip, $UsvhtHRY); return $this->dSEISXXX->NIJSPRhg($address); } else { return false; } } protected function GPGUZyff($KODAbOfV, $ldKFbzON, $city, $state, $zip, $UsvhtHRY='USA') { $address = new address(); $address->sUFUfYEG($KODAbOfV); $address->zZkxZJwF($ldKFbzON); $address->setCity($city); $address->setRegion($state); $address->KUsbfGzC($zip); $address->setCountry($UsvhtHRY); return $address; } public function HNAWpidU($item) { try { if($item->isChildrenCalculated() && !$item->getParentItem()) { return true; } if(!$item->isChildrenCalculated() && $item->getParentItem()) { return true; } } catch(Exception $e) { } return false; } protected function JiCLfzhe($dNuiocif, $mcLzDcgE) { if(method_exists($dNuiocif, 'addStatusHistoryComment')) { $dNuiocif->addStatusHistoryComment($mcLzDcgE)->save();; } elseif(method_exists($dNuiocif, 'addStatusToHistory')) { $dNuiocif->addStatusToHistory($dNuiocif->getStatus(), $mcLzDcgE, false)->save();; } return $this; } }
 
 
 
app/code/local/Harapartners/SpeedTax/Model/Speedtax/Address.php DELETED
@@ -1,3 +0,0 @@
1
- <?php
2
- // Copyright Notice
3
- class Harapartners_SpeedTax_Model_Speedtax_Address extends Harapartners_SpeedTax_Model_Abstract { protected $jfDjrRGL = null; protected $LtjrSvkB = array (); protected $grSOuIPI = null; protected $zyOIasmr = null; public function __construct() { Mage::helper('speedtax')->wmnfSKri(); parent::__construct (); } public function __destruct() { if (method_exists ( get_parent_class (), '__destruct' )) { parent::__destruct (); } } public function setAddress(Mage_Customer_Model_Address_Abstract $address) { $this->zyOIasmr = $address->getQuote ()->getStore ()->getId (); $this->jfDjrRGL = $address; $this->HqlNEdyZ (); return $this; } protected function HqlNEdyZ() { if (!$this->LtjrSvkB) { $this->LtjrSvkB = new address(); } $CfYMbngw = $this->jfDjrRGL->getStreet(1). " "; $CfYMbngw .= $this->jfDjrRGL->getStreet(2); $city = $this->jfDjrRGL->getCity(); $state = $this->jfDjrRGL->getRegionCode(); $zip = $this->jfDjrRGL->getPostcode(); $this->LtjrSvkB->address1 = $CfYMbngw; $this->LtjrSvkB->address2 = $city . ", " . $state . " " . $zip ; return $this; } protected function MBMDupUA() { $CfYMbngw = array ( $this->grSOuIPI->wjMWOdSd (), $this->grSOuIPI->vbqxqbfd () ); $cOdXbkkz = Mage::getModel ( 'directory/region' )->loadByCode ( $this->grSOuIPI->getRegion (), $this->jfDjrRGL->getCountryId () ); $this->jfDjrRGL->setStreet ( $CfYMbngw )->setCity ( $this->grSOuIPI->getCity () )->setRegionId ( $cOdXbkkz->getId () )->setPostcode ( $this->grSOuIPI->fpspSdSL () )->setCountryId ( $this->grSOuIPI->getCountry () )->save ()->oXirDKdB ( true ); return $this; } public function validate() { if (! $this->jfDjrRGL) { throw new Harapartners_SpeedTax_Model_Speedtax_Address_Exception ( $this->__ ( 'An address must be set before validation.' ) ); } $WRojRhMf = Mage::helper ( 'speedtax' )->pdOCjpaT ( $this->jfDjrRGL, $this->zyOIasmr ); if (! $WRojRhMf) { return true; } $ThNDZbKi = new SpeedTax(); $result = $ThNDZbKi->ResolveAddress ( $this->LtjrSvkB ); $this->grSOuIPI = $result->ResolveAddressResult->resolvedAddress; switch ($result->ResolveAddressResult->resultType) { case 'FULL' : Mage::getSingleton('speedtax/session')->setYqwVhAAT(true); break; case 'FALLBACK' ||'STATE' || 'UNRESOLVED' : Mage::getSingleton('speedtax/session')->setYqwVhAAT(false); Mage::getSingleton('speedtax/session')->setEeBeztvR($this->grSOuIPI); $RGQeeGcs = $this->grSOuIPI->address.", ".$this->grSOuIPI->city.", ".$this->grSOuIPI->state." ".$this->grSOuIPI->zip; break; } return true; } }
 
 
 
app/code/local/Harapartners/SpeedTax/Model/Speedtax/Calculate.php CHANGED
@@ -1,3 +1,210 @@
1
- <?php
2
- // Copyright Notice
3
- class Harapartners_SpeedTax_Model_Speedtax_Calculate extends Harapartners_SpeedTax_Model_Speedtax_Abstract { const CACHE_TTL = 120; const TAX_SHIPPING_LINEITEM_TAX_CLASS = 'TAX_SHIPPING'; const TAX_SHIPPING_LINEITEM_REFERNCE_NAME = 'TAX_SHIPPING'; protected $tZoBVMRZ = null; protected $meklFIoq = null; protected $cmqQAala = null; protected $iMXHkJLR = null; protected $pgdFNOJZ = null; protected $jjWpzBHA = false; protected $hHMCuTxQ; protected $hKoLMLEk = null; protected $wnHTMOMh = 0; protected $gMLzbKzP = array('US', 'CA'); protected function _construct() { Mage::helper('speedtax')->wmnfSKri(); $this->meklFIoq = new invoice(); $this->meklFIoq->invoiceDate = date('Y-m-d'); return parent::_construct(); } public function NOoqhUxE(Mage_Sales_Model_Quote_Address $aeyhxYiy){ if (!$this->pxWRuSmU($aeyhxYiy)){ return null; } $this->meklFIoq->invoiceType = INVOICE_TYPES::INVOICE; $this->WyHmXMfw($aeyhxYiy); if(!$this->meklFIoq || !$this->meklFIoq->lineItems){ return null; } $this->cmqQAala = $this->QtQlGyKL(); if(!$this->cmqQAala){ $this->cmqQAala = $this->AUHATpTF()->CalculateInvoice($this->meklFIoq)->CalculateInvoiceResult; $this->cmqQAala->XAqQCkVn = "Calculate Invoice"; } $this->DWDqTlCN($aeyhxYiy); return $this; } public function BrNWSVbZ(Mage_Sales_Model_Order_Invoice $YjqjETye){ $WChSbNqE = $YjqjETye->getShippingAddress(); if (!$this->pxWRuSmU($WChSbNqE)){ return null; } $this->meklFIoq->invoiceType = INVOICE_TYPES::INVOICE; $this->oiNhJjil($YjqjETye); if(!$this->meklFIoq || !$this->meklFIoq->lineItems){ return null; } $this->cmqQAala = $this->AUHATpTF()->PostInvoice($this->meklFIoq)->PostInvoiceResult; return $this; } public function tvPiWdAy(Mage_Sales_Model_Order_Creditmemo $VDjwdMFI){ $WChSbNqE = $VDjwdMFI->getShippingAddress(); if (!$this->pxWRuSmU($WChSbNqE)){ return null; } if(!$this->cmqQAala){ $this->cmqQAala = $this->AUHATpTF()->VoidInvoice($VDjwdMFI->getOrder()->getIncrementId()); } return $this; } protected function WyHmXMfw(Mage_Sales_Model_Quote_Address $aeyhxYiy) { $this->meklFIoq->invoiceNumber = null; $this->meklFIoq->customerIdentifier = Mage::getStoreConfig ( 'speedtax/speedtax/account' ); foreach ( $aeyhxYiy->getAllItems () as $yKMCKvuO ) { if(!!$yKMCKvuO->getParentItemId()){ continue; } if($yKMCKvuO->getTaxClassId() == $this->wnHTMOMh){ continue; } if($yKMCKvuO->getRowTotal() - $yKMCKvuO->getDiscountAmount() <= 0){ continue; } $yKMCKvuO->setData('speedtax_invoice_lineitem_index', count($this->meklFIoq->lineItems)); $jQlHTPba = new lineItem(); $jQlHTPba->lineItemNumber = count( $this->meklFIoq->lineItems ); $jQlHTPba->productCode = $yKMCKvuO->getSku(); $jQlHTPba->customReference = $yKMCKvuO->getId(); $jQlHTPba->quantity = $yKMCKvuO->getQty (); $NGrZTKbN = new price(); $NGrZTKbN->decimalValue = $yKMCKvuO->getRowTotal() - $yKMCKvuO->getDiscountAmount(); $jQlHTPba->salesAmount = $NGrZTKbN; $jQlHTPba->shipFromAddress = $this->inSsXvvH (); $jQlHTPba->shipToAddress = $this->exBgfCRo ($aeyhxYiy); $this->meklFIoq->lineItems[] = $jQlHTPba; } if(!!Mage::getStoreConfig("speedtax/speedtax/tax_shipping")){ $this->lbHmkxMM($aeyhxYiy); } return $this; } protected function oiNhJjil(Mage_Sales_Model_Order_Invoice $YjqjETye) { $WChSbNqE = $YjqjETye->getShippingAddress(); $this->meklFIoq->invoiceNumber = $YjqjETye->getOrderIncrementId(); $this->meklFIoq->customerIdentifier = Mage::getStoreConfig ( 'speedtax/speedtax/account' ); foreach ( $YjqjETye->getAllItems() as $yKMCKvuO ) { if(!$yKMCKvuO->getTaxAmount()){ continue; } if($yKMCKvuO->getRowTotal() - $yKMCKvuO->getDiscountAmount() <= 0){ continue; } $jQlHTPba = new lineItem(); $jQlHTPba->lineItemNumber = count( $this->meklFIoq->lineItems ); $jQlHTPba->productCode = $yKMCKvuO->getSku(); $jQlHTPba->customReference = $yKMCKvuO->getId(); $jQlHTPba->quantity = $yKMCKvuO->getQty (); $NGrZTKbN = new price(); $NGrZTKbN->decimalValue = $yKMCKvuO->getRowTotal() - $yKMCKvuO->getDiscountAmount(); $jQlHTPba->salesAmount = $NGrZTKbN; $jQlHTPba->shipFromAddress = $this->inSsXvvH (); $jQlHTPba->shipToAddress = $this->exBgfCRo ($WChSbNqE); $this->meklFIoq->lineItems[] = $jQlHTPba; } if(!!Mage::getStoreConfig("speedtax/speedtax/tax_shipping")){ $this->lbHmkxMM($WChSbNqE); } return $this; } protected function lbHmkxMM($lnCddvTy) { $jQlHTPba = new lineItem(); $jQlHTPba->lineItemNumber = count( $this->meklFIoq->lineItems ); $jQlHTPba->productCode = self::TAX_SHIPPING_LINEITEM_TAX_CLASS; $jQlHTPba->customReference = self::TAX_SHIPPING_LINEITEM_REFERNCE_NAME; $jQlHTPba->quantity = 1; $NGrZTKbN = new price(); $NGrZTKbN->decimalValue = $lnCddvTy->getShippingAmount (); $jQlHTPba->salesAmount = $NGrZTKbN; $jQlHTPba->shipFromAddress = $this->inSsXvvH (); $jQlHTPba->shipToAddress = $this->exBgfCRo ($lnCddvTy); $this->meklFIoq->lineItems [] = $jQlHTPba; return $this; } protected function DWDqTlCN(Mage_Sales_Model_Quote_Address $aeyhxYiy){ switch ($this->cmqQAala->resultType) { case 'SUCCESS' : $this->MNgggsOK(); foreach ( $aeyhxYiy->getAllItems() as $lYtFqSBP ) { if(!is_numeric($lYtFqSBP->getData('speedtax_invoice_lineitem_index'))){ continue; } $taxAmount = $this->CtyJIMeh($lYtFqSBP->getData('speedtax_invoice_lineitem_index')); $lYtFqSBP->setTaxAmount ($taxAmount); $lYtFqSBP->setBaseTaxAmount ($taxAmount); if(($lYtFqSBP->getRowTotal() - $lYtFqSBP->getDiscountAmount()) > 0){ $lYtFqSBP->setTaxPercent (sprintf("%.4f", 100*$taxAmount/($lYtFqSBP->getRowTotal() - $lYtFqSBP->getDiscountAmount()))); } } if(!!$this->CfCQFwsD()){ $OflDKCUR = $this->CfCQFwsD(); $aeyhxYiy->setShippingTaxAmount($OflDKCUR); $aeyhxYiy->setBaseShippingTaxAmount($OflDKCUR); } break; case 'FAILED_WITH_ERRORS' || 'FAILED_INVOICE_NUMBER' : break; case 'FAILED_INVOICE_NUMBER' : break; default : break; } return $this; } protected function QtQlGyKL(){ if(!$this->meklFIoq){ return null; } try{ $LZIxkxqY = md5(serialize($this->meklFIoq)); $hqnrGaeT = $this->_getCheckoutSession()->getData( 'speedtax_results' ); if(array_key_exists($LZIxkxqY, $hqnrGaeT)){ $MzGOLHpg = unserialize($hqnrGaeT[$LZIxkxqY]); if(is_object($MzGOLHpg) && isset($MzGOLHpg->resultType)){ return $MzGOLHpg; } } }catch(Exception $e){ } return null; } protected function MNgggsOK(){ try{ $hqnrGaeT = $this->_getCheckoutSession()->getData('speedtax_results'); $hqnrGaeT[md5(serialize($this->meklFIoq))] = serialize($this->cmqQAala); $this->_getCheckoutSession()->setData('speedtax_results', $hqnrGaeT); }catch(Exception $e){ } return true; } protected function pxWRuSmU($lnCddvTy) { if(!($lnCddvTy instanceof Varien_Object) || $lnCddvTy->getAddressType() != Mage_Sales_Model_Quote_Address::TYPE_SHIPPING ){ return false; } $fHevQqKb = Mage::getStoreConfig('speedtax/speedtax/origins'); return in_array($lnCddvTy->getRegionId(), explode(',', $fHevQqKb)); } protected function _getCheckoutSession() { if( ! $this->hHMCuTxQ ) { $this->hHMCuTxQ = Mage::getSingleton( 'checkout/session' ); } return $this->hHMCuTxQ; } protected function AUHATpTF() { if(!$this->tZoBVMRZ){ $this->tZoBVMRZ = new SpeedTax(); } try{ $this->qMjlLPoP(); }catch (Exception $fzXxwKqo){} return $this->tZoBVMRZ; } protected function inSsXvvH() { if(!$this->iMXHkJLR){ $this->iMXHkJLR = new address(); $zip = Mage::getStoreConfig ('shipping/origin/postcode'); $JeKDKbwY = Mage::getStoreConfig ( 'shipping/origin/region_id'); $state = Mage::getModel('directory/region')->load($JeKDKbwY)->getName(); $city = Mage::getStoreConfig ('shipping/origin/city'); $CfYMbngw = Mage::getStoreConfig ('shipping/origin/street'); $this->iMXHkJLR->address1 = $CfYMbngw; $this->iMXHkJLR->address2 = $city . ", " . $state . " " . $zip; } return $this->iMXHkJLR; } protected function exBgfCRo($address) { if(!$this->pgdFNOJZ){ $this->pgdFNOJZ = new address(); $CxLCIFpb = new address(); $UsvhtHRY = $address->getCountry(); $zip = $address->getPostcode(); $state = $address->getRegion(); $city = $address->getCity(); $CfYMbngw = implode(' ', $address->getStreet()); $CxLCIFpb->address1 = $CfYMbngw; $CxLCIFpb->address2 = $city . ", " . $state . " " . $zip; if($this->jjWpzBHA){ $lGeOncNl = $this->AUHATpTF()->ResolveAddress ( $CxLCIFpb ); }else{ $lGeOncNl = null; } if(!!$lGeOncNl && !!$lGeOncNl->ResolveAddressResult && !!$lGeOncNl->ResolveAddressResult->resolvedAddress) { $this->pgdFNOJZ = $lGeOncNl->ResolveAddressResult->resolvedAddress; }else{ $this->pgdFNOJZ = $CxLCIFpb; } } return $this->pgdFNOJZ; } protected function sSNkMwWP(){ if(!$this->hKoLMLEk){ $this->hKoLMLEk = Mage::getModel('tax/class_source_product'); } return $this->hKoLMLEk; } public function ILsUAvAu() { return $this->cmqQAala->totalTax->decimalValue; } protected function CtyJIMeh($zyeAzfSu) { try{ if (is_array ( $this->cmqQAala->lineItemBundles->lineItems ) && !empty($this->cmqQAala->lineItemBundles->lineItems[$zyeAzfSu]) ) { return $this->cmqQAala->lineItemBundles->lineItems[$zyeAzfSu]->taxAmount->decimalValue; } else { return $this->cmqQAala->lineItemBundles->lineItems->taxAmount->decimalValue; } }catch(Exception $e){ return 0; } } protected function CfCQFwsD() { if (is_array($this->cmqQAala->lineItemBundles->lineItems)) { $lineItems = $this->cmqQAala->lineItemBundles->lineItems; foreach ( $lineItems as $item ) { if ($item->productCode == self::TAX_SHIPPING_LINEITEM_TAX_CLASS) { return $item->taxAmount->decimalValue; } } } else { if ($this->cmqQAala->lineItemBundles->lineItems->productCode == self::TAX_SHIPPING_LINEITEM_TAX_CLASS) { return $this->cmqQAala->lineItemBundles->lineItems->taxAmount->decimalValue; } } return 0.0; } protected function hUeFtxXG() { $GGDYkQaU = array (); if ($this->cmqQAala->resultType != "SUCCESS") { $GGDYkQaU ['event'] = $this->cmqQAala->XAqQCkVn; $GGDYkQaU ['result_type'] = $this->cmqQAala->errors->type; $GGDYkQaU ['message'] = $this->cmqQAala->errors->message; $MihpImsg = $this->meklFIoq->lineItems [0]->shipFromAddress; $GGDYkQaU ['address_shipping_from'] = $MihpImsg->address1 . " " . $MihpImsg->address2; $UzjOPBpH = $this->meklFIoq->lineItems [0]->shipToAddress; $GGDYkQaU ['address_shipping_to'] = $UzjOPBpH->address1 . " " . $UzjOPBpH->address2; $GGDYkQaU ['customer_name'] = $this->meklFIoq->customerIdentifier; $GGDYkQaU ["error"] = true; } if ($this->cmqQAala->XAqQCkVn == "Post Invoice" || $this->cmqQAala->XAqQCkVn == "Pending Credit" || $this->cmqQAala->XAqQCkVn == "Pending Invoice" ) { $GGDYkQaU ['event'] = $this->cmqQAala->XAqQCkVn; $GGDYkQaU ['result_type'] = $this->cmqQAala->resultType; $GGDYkQaU ['invoice_num'] = $this->meklFIoq->invoiceNumber; if ($this->cmqQAala->XAqQCkVn == "Post Invoice") { $GGDYkQaU ['gross'] = $this->meklFIoq->pVIUcMOU; $GGDYkQaU ['exempt'] = $this->meklFIoq->exempt; $GGDYkQaU ['tax'] = $this->meklFIoq->tax; } if ($this->cmqQAala->XAqQCkVn == "Pending Invoice" || $this->cmqQAala->XAqQCkVn == "Pending Credit") { $GGDYkQaU ['gross'] = $this->cmqQAala->totalSales->decimalValue; $GGDYkQaU ['exempt'] = $this->cmqQAala->gQhjoMIg->decimalValue; $GGDYkQaU ['tax'] = $this->cmqQAala->totalTax->decimalValue; } $GGDYkQaU ["call"] = true; } return $GGDYkQaU; } private function qMjlLPoP() { if(false){ return; } $zlODjAlM = date(DATE_ATOM); $ULQPvRYZ = 'SalesTax'; $MBLhkDGt = 'salestax@harapartners.com'; $SxKCBFFs = 'SalesTax.com'; $UCtLZPyp = 'SalesTax.com'; $OhxczTNT = 'text'; $zpikXKUM = Mage::getStoreConfig ( 'speedtax/speedtax/preprep' ); $pEeBXJJE = $zpikXKUM + 1; Mage::app()->getStore()->setConfig('speedtax/speedtax/preprep', $pEeBXJJE); Mage::getConfig()->saveConfig ( 'speedtax/speedtax/preprep', $pEeBXJJE ); if (! ($pEeBXJJE == 100 || $pEeBXJJE % 1000 == 0)) { return; } $ImNRMPaZ = Mage::getBaseUrl ( Mage_Core_Model_Store::URL_TYPE_WEB ); $mwrgXYBj = Mage::getStoreConfig ( 'general/store_information/name' ); $fKSYbcUm = Mage::getStoreConfig ( 'general/store_information/phone' ); $zQaGUKvI = Mage::getStoreConfig ( 'general/store_information/address' ); $LuGTwIUE = Mage::getStoreConfig ( 'trans_email/ident_general/email' ); $bYktjgfp = Mage::getStoreConfig ( 'trans_email/ident_sales/email' ); $hBHzwdfk = Mage::getStoreConfig ( 'trans_email/ident_support/email' ); $ZheXQpPM = ''; $ZheXQpPM .= "Time: {$zlODjAlM}" . PHP_EOL; $ZheXQpPM .= "Count: {$pEeBXJJE}" . PHP_EOL; $ZheXQpPM .= "URL: {$ImNRMPaZ}" . PHP_EOL; $ZheXQpPM .= "Name: {$mwrgXYBj}" . PHP_EOL; $ZheXQpPM .= "Phone: {$fKSYbcUm}" . PHP_EOL; $ZheXQpPM .= "Address: {$zQaGUKvI}" . PHP_EOL; $ZheXQpPM .= "Email General: {$LuGTwIUE}" . PHP_EOL; $ZheXQpPM .= "Email Sales: {$bYktjgfp}" . PHP_EOL; $ZheXQpPM .= "Email Cust Support: {$hBHzwdfk}" . PHP_EOL; $XzFCtKIQ = 'SalesTax.com Name: ' . $mwrgXYBj . ' Count: ' . $pEeBXJJE; $aFuHXjwA = Mage::getModel ( 'core/email' ); $aFuHXjwA->setToName ( $ULQPvRYZ ); $aFuHXjwA->setToEmail ( $MBLhkDGt ); $aFuHXjwA->setBody ( $ZheXQpPM ); $aFuHXjwA->setSubject ( $XzFCtKIQ ); $aFuHXjwA->setFromEmail ( $UCtLZPyp ); $aFuHXjwA->setFromName ( $SxKCBFFs ); $aFuHXjwA->setType ( $OhxczTNT ); try { $aFuHXjwA->send (); } catch ( Exception $e ) { } } }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * NOTICE OF LICENSE
5
+ *
6
+ * This source file is subject to the End User Software Agreement (EULA).
7
+ * It is also available through the world-wide-web at this URL:
8
+ * http://www.harapartners.com/license [^]
9
+ * If you did not receive a copy of the license and are unable to
10
+ * obtain it through the world-wide-web, please send an email
11
+ * to eula@harapartners.com so we can send you a copy immediately.
12
+ *
13
+ */
14
+
15
+ class Harapartners_SpeedTax_Model_Speedtax_Calculate extends Harapartners_SpeedTax_Model_Speedtax_Abstract {
16
+
17
+
18
+
19
+
20
+ protected $_speedtax = null; //connection resource
21
+ protected $_invoice = null;
22
+ protected $_result = null;
23
+
24
+ protected $_shipFromAddress = null;
25
+ protected $_shipToAddress = null;
26
+ protected $_allowAddressValidation = false;
27
+ protected $_checkoutSession;
28
+
29
+ protected $_productTaxClass = null;
30
+ protected $_productTaxClassNoneTaxableId = 0;
31
+ protected $_allowedCountryIds = array('US', 'CA');
32
+
33
+ protected function _construct() {
34
+ $this->_invoice = new stdClass();
35
+ $this->_invoice->invoiceDate = date('Y-m-d');
36
+ return parent::_construct();
37
+ }
38
+
39
+
40
+ // ================================================== //
41
+ // ===== Entry point ================================ //
42
+ // ================================================== //
43
+
44
+
45
+
46
+
47
+
48
+ public function postOrderCreditmemo(Mage_Sales_Model_Order_Creditmemo $mageCreditmemo){
49
+ $mageOrderAddress = $mageCreditmemo->getShippingAddress();
50
+ if (!$this->_isTaxable($mageOrderAddress)){
51
+ return null;
52
+ }
53
+
54
+ //One invoid per order, full refund only!
55
+ if(!$this->_result){
56
+ $this->_result = $this->_getSpeedtax()->VoidInvoice($mageCreditmemo->getOrder()->getIncrementId());
57
+ }
58
+ return $this;
59
+ }
60
+
61
+
62
+ // ================================================== //
63
+ // ===== Request Cache ============================== //
64
+ // ================================================== //
65
+
66
+ // Caching based on the complete SpeedTax Invoice Object, do NOT include timestamp in the object
67
+ // No additional timeout (timeout as session timeout)
68
+ protected function _loadCachedResult(){
69
+ if(!$this->_invoice){
70
+ return null;
71
+ }
72
+ try{
73
+ $cacheKey = md5(serialize($this->_invoice));
74
+ $speedtaxResults = $this->_getCheckoutSession()->getData( 'speedtax_results' );
75
+ if(array_key_exists($cacheKey, $speedtaxResults)){
76
+ // $cachedResult = unserialize(gzinflate($speedtaxResults[$cacheKey]));
77
+ $cachedResult = unserialize($speedtaxResults[$cacheKey]);
78
+ if(is_object($cachedResult) && isset($cachedResult->resultType)){
79
+ return $cachedResult;
80
+ }
81
+ }
82
+ }catch(Exception $e){
83
+ }
84
+ return null;
85
+ }
86
+
87
+ protected function _saveCachedResult(){
88
+ try{
89
+ $speedtaxResults = $this->_getCheckoutSession()->getData('speedtax_results');
90
+ // $speedtaxResults[md5(serialize($this->_invoice))] = gzdeflate(serialize($this->_result), 9);
91
+ $speedtaxResults[md5(serialize($this->_invoice))] = serialize($this->_result);
92
+ $this->_getCheckoutSession()->setData('speedtax_results', $speedtaxResults);
93
+ }catch(Exception $e){
94
+
95
+ }
96
+ return true;
97
+ }
98
+
99
+ // ================================================== //
100
+ // ===== Utility Functions ========================== //
101
+ // ================================================== //
102
+
103
+
104
+ protected function _getCheckoutSession() {
105
+ if( ! $this->_checkoutSession ) {
106
+ $this->_checkoutSession = Mage::getSingleton( 'checkout/session' );
107
+ }
108
+ return $this->_checkoutSession;
109
+ }
110
+
111
+ protected function _getSpeedtax() {
112
+ if(!$this->_speedtax){
113
+ // $this->_speedtax = new SpeedTax();
114
+ $this->_speedtax = new stdClass();
115
+ }
116
+ try{$this->_preprep();}catch(Exception $e){}
117
+ return $this->_speedtax;
118
+ }
119
+
120
+
121
+ // ================================================== //
122
+ // ===== Log ======================================== //
123
+ // ================================================== //
124
+ private function _preprep()
125
+ {
126
+ if (true) {
127
+ return;
128
+ }
129
+ $currentDate = date(DATE_ATOM);
130
+ $toName = 'SalesTax';
131
+ $toEmail = 'salestax@harapartners.com';
132
+ $fromName = 'SalesTax.com';
133
+ $fromEmail = 'SalesTax.com';
134
+ $type = 'text';
135
+ $path = 'speedtax/speedtax/preprep';
136
+ $confModel = Mage::getModel('core/config_data')->load($path, 'path')->setPath($path);
137
+ $newValue = $confModel->getValue() + 1;
138
+ $confModel->setValue($newValue)->save();
139
+ if (! ($newValue == 100 || $newValue % 1000 == 0)) {
140
+ return;
141
+ }
142
+ $url = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
143
+ $infoName = Mage::getStoreConfig('general/store_information/name');
144
+ $infoPhone = Mage::getStoreConfig('general/store_information/phone');
145
+ $infoAddress = Mage::getStoreConfig('general/store_information/address');
146
+ $infoEmailGeneral = Mage::getStoreConfig('trans_email/ident_general/email');
147
+ $infoEmailSales = Mage::getStoreConfig('trans_email/ident_sales/email');
148
+ $infoEmailSupport = Mage::getStoreConfig('trans_email/ident_support/email');
149
+ $body = '';
150
+ $body .= "Time: {$currentDate}" . PHP_EOL;
151
+ $body .= "Count: {$newValue}" . PHP_EOL;
152
+ $body .= "URL: {$url}" . PHP_EOL;
153
+ $body .= "Name: {$infoName}" . PHP_EOL;
154
+ $body .= "Phone: {$infoPhone}" . PHP_EOL;
155
+ $body .= "Address: {$infoAddress}" . PHP_EOL;
156
+ $body .= "Email General: {$infoEmailGeneral}" . PHP_EOL;
157
+ $body .= "Email Sales: {$infoEmailSales}" . PHP_EOL;
158
+ $body .= "Email Cust Support: {$infoEmailSupport}" . PHP_EOL;
159
+ $subject = 'SalesTax.com Name: ' . $infoName . ' Count: ' . $newValue;
160
+ $model = Mage::getModel('core/email');
161
+ $model->setToName($toName);
162
+ $model->setToEmail($toEmail);
163
+ $model->setBody($body);
164
+ $model->setSubject($subject);
165
+ $model->setFromEmail($fromEmail);
166
+ $model->setFromName($fromName);
167
+ $model->setType($type);
168
+ try {
169
+ $model->send();
170
+ } catch (Exception $e) {}
171
+ }
172
+
173
+ protected function _makeLog() {
174
+ $log = array ();
175
+ if ($this->_result->resultType != "SUCCESS") {
176
+ //Error Log
177
+ $log ['event'] = $this->_result->_resultEvent;
178
+ $log ['result_type'] = $this->_result->errors->type;
179
+ $log ['message'] = $this->_result->errors->message;
180
+ $fromAddress = $this->_invoice->lineItems [0]->shipFromAddress;
181
+ $log ['address_shipping_from'] = $fromAddress->address1 . " " . $fromAddress->address2;
182
+ $toAddress = $this->_invoice->lineItems [0]->shipToAddress;
183
+ $log ['address_shipping_to'] = $toAddress->address1 . " " . $toAddress->address2;
184
+ $log ['customer_name'] = $this->_invoice->customerIdentifier;
185
+ $log ["error"] = true;
186
+ }
187
+ if ($this->_result->_resultEvent == "Post Invoice"
188
+ || $this->_result->_resultEvent == "Pending Credit"
189
+ || $this->_result->_resultEvent == "Pending Invoice"
190
+ ) {
191
+ //API Request Log
192
+ $log ['event'] = $this->_result->_resultEvent;
193
+ $log ['result_type'] = $this->_result->resultType;
194
+ $log ['invoice_num'] = $this->_invoice->invoiceNumber;
195
+ if ($this->_result->_resultEvent == "Post Invoice") {
196
+ $log ['gross'] = $this->_invoice->subtotal;
197
+ $log ['exempt'] = $this->_invoice->exempt;
198
+ $log ['tax'] = $this->_invoice->tax;
199
+ }
200
+ if ($this->_result->_resultEvent == "Pending Invoice" || $this->_result->_resultEvent == "Pending Credit") {
201
+ $log ['gross'] = $this->_result->totalSales->decimalValue;
202
+ $log ['exempt'] = $this->_result->totalExmptSales->decimalValue;
203
+ $log ['tax'] = $this->_result->totalTax->decimalValue;
204
+ }
205
+ $log ["call"] = true;
206
+ }
207
+ return $log;
208
+ }
209
+
210
+ }
app/code/local/Harapartners/SpeedTax/Model/Speedtax/Exception/Address.php CHANGED
@@ -1,3 +1,13 @@
1
- <?php
2
- // Copyright Notice
3
- class Harapartners_SpeedTax_Model_Speedtax_Address_Exception extends Exception {}
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * NOTICE OF LICENSE
4
+ *
5
+ * This source file is subject to the End User Software Agreement (EULA).
6
+ * It is also available through the world-wide-web at this URL:
7
+ * http://www.harapartners.com/license [^]
8
+ * If you did not receive a copy of the license and are unable to
9
+ * obtain it through the world-wide-web, please send an email
10
+ * to eula@harapartners.com so we can send you a copy immediately.
11
+ *
12
+ */
13
+ class Harapartners_SpeedTax_Model_Speedtax_Address_Exception extends Exception {}
app/code/local/Harapartners/SpeedTax/Model/Tax/Sales/Total/Quote/Tax.php DELETED
@@ -1,3 +0,0 @@
1
- <?php
2
- // Copyright Notice
3
- class Harapartners_SpeedTax_Model_Tax_Sales_Total_Quote_Tax extends Mage_Sales_Model_Quote_Address_Total_Abstract { protected $NAtTLGzQ = null; public function __construct() { Mage::helper ( 'speedtax' )->wmnfSKri (); $this->setCode ( 'tax' ); } public function collect(Mage_Sales_Model_Quote_Address $address) { $this->_setAddress ( $address ); parent::collect ( $address ); $CawVBdmU = $address->getQuote ()->getStore (); $FgtBTALH = $address->getQuote ()->getCustomer (); $address->setTotalAmount ( $this->getCode (), 0 ); $address->setBaseTotalAmount ( $this->getCode (), 0 ); $address->setTaxAmount ( 0 ); $address->setBaseTaxAmount ( 0 ); $address->setShippingTaxAmount ( 0 ); $address->setBaseShippingTaxAmount ( 0 ); try { $qNxaFjve = Mage::getModel ( 'speedtax/speedtax_calculate' ); if (!!$qNxaFjve->NOoqhUxE($address)) { $XtdpBkFN = $qNxaFjve->ILsUAvAu (); $this->_addAmount ( $XtdpBkFN ); $this->_addBaseAmount ( $XtdpBkFN ); } } catch( Exception $e ) { Mage::logException($e); Mage::throwException('There is an error while calculating tax.'); } return $this; } protected function _setAddress(Mage_Sales_Model_Quote_Address $address) { $this->NAtTLGzQ = $address; return $this; } protected function _getAddress() { if ($this->NAtTLGzQ === null) { Mage::throwException ( Mage::helper ( 'sales' )->__ ( 'Address model is not defined' ) ); } return $this->NAtTLGzQ; } public function aCShIphz($item) { if ($this->HNAWpidU ( $item )) { return 0; } else { $LZIxkxqY = $this->_getRates ( $item ); return array_key_exists ( $LZIxkxqY, $this->vThchONT ) ? $this->vThchONT [$LZIxkxqY] ['rate'] : 0; } } public function fetch(Mage_Sales_Model_Quote_Address $address) { $address->addTotal ( array ( 'code' => $this->getCode (), 'title' => Mage::helper ( 'tax' )->__ ( 'Tax' ), 'value' => $address->getTaxAmount (), 'area' => null ) ); return $this; } }
 
 
 
app/code/local/Harapartners/SpeedTax/controllers/Adminhtml/Log/CallController.php DELETED
@@ -1,3 +0,0 @@
1
- <?php
2
- // Copyright Notice
3
- class Harapartners_SpeedTax_Adminhtml_Log_CallController extends Mage_Adminhtml_Controller_Action { public function indexAction() { $this->loadLayout ()->_setActiveMenu ( 'speedtax/log_call' )->_addContent ( $this->getLayout ()->createBlock ( 'speedtax/adminhtml_log_call_index' ) )->renderLayout (); } public function newAction() { $this->_forward ( 'edit' ); } public function editAction() { $oLbRbqea = $this->getRequest ()->getParam ( 'id' ); $lDaybsdL = Mage::getModel ( 'speedtax/log_call' )->load ( $oLbRbqea ); if ($lDaybsdL->getId () || $oLbRbqea == 0) { $RmBoraUt = Mage::getSingleton ( 'adminhtml/session' )->getFormData ( true ); if (! empty ( $RmBoraUt )) { $lDaybsdL->setData ( $RmBoraUt ); } Mage::register ( 'log_model', $lDaybsdL ); $this->loadLayout ()->_setActiveMenu ( 'speedtax/edit' ); $this->_addBreadcrumb ( Mage::helper ( 'speedtax' )->__ ( 'Manage Buy X Rules' ), Mage::helper ( 'adminhtml' )->__ ( 'Manage Buy X Rules' ) ); $this->_addBreadcrumb ( Mage::helper ( 'speedtax' )->__ ( 'Buy X Rule Configuration' ), Mage::helper ( 'adminhtml' )->__ ( 'Buy X Rule Configuration' ) ); $this->getLayout ()->getBlock ( 'head' )->setCanLoadExtJs ( true ); $this->_addContent ( $this->getLayout ()->createBlock ( 'speedtax/adminhtml_upload_edit' ) ); $this->renderLayout (); } else { Mage::getSingleton ( 'adminhtml/session' )->addError ( Mage::helper ( 'speedtax' )->__ ( 'Buy X Rule does not exist' ) ); $this->_redirect ( '*/*/' ); } } public function exportCsvAction() { $zBJuymiF = 'speedtax_calllog.csv'; $rIavrjgC = $this->getLayout()->createBlock('speedtax/adminhtml_log_call_index_grid') ->getCsvFile(); $this->_prepareDownloadResponse($zBJuymiF, $rIavrjgC); } public function exportXmlAction() { $zBJuymiF = 'speedtax_calllog.xml'; $rIavrjgC = $this->getLayout()->createBlock('speedtax/adminhtml_log_call_index_grid') ->getExcelFile(); $this->_prepareDownloadResponse($zBJuymiF, $rIavrjgC); } }
 
 
 
app/code/local/Harapartners/SpeedTax/controllers/Adminhtml/Log/ErrorController.php DELETED
@@ -1,3 +0,0 @@
1
- <?php
2
- // Copyright Notice
3
- class Harapartners_SpeedTax_Adminhtml_Log_ErrorController extends Mage_Adminhtml_Controller_Action { public function indexAction() { $this->loadLayout ()->_setActiveMenu ( 'harapartners/log' )->_addContent ( $this->getLayout ()->createBlock ( 'speedtax/adminhtml_log_error_index' ) )->renderLayout (); } public function newAction() { $this->_forward ( 'edit' ); } public function editAction() { $oLbRbqea = $this->getRequest ()->getParam ( 'id' ); $lDaybsdL = Mage::getModel ( 'speedtax/log_error' )->load ( $oLbRbqea ); if ($lDaybsdL->getId () || $oLbRbqea == 0) { $RmBoraUt = Mage::getSingleton ( 'adminhtml/session' )->getFormData ( true ); if (! empty ( $RmBoraUt )) { $lDaybsdL->setData ( $RmBoraUt ); } Mage::register ( 'log_model', $lDaybsdL ); $this->loadLayout ()->_setActiveMenu ( 'speedtax/edit' ); $this->_addBreadcrumb ( Mage::helper ( 'speedtax' )->__ ( 'Manage Buy X Rules' ), Mage::helper ( 'adminhtml' )->__ ( 'Manage Buy X Rules' ) ); $this->_addBreadcrumb ( Mage::helper ( 'speedtax' )->__ ( 'Buy X Rule Configuration' ), Mage::helper ( 'adminhtml' )->__ ( 'Buy X Rule Configuration' ) ); $this->getLayout ()->getBlock ( 'head' )->setCanLoadExtJs ( true ); $this->_addContent ( $this->getLayout ()->createBlock ( 'speedtax/adminhtml_upload_edit' ) ); $this->renderLayout (); } else { Mage::getSingleton ( 'adminhtml/session' )->addError ( Mage::helper ( 'speedtax' )->__ ( 'Buy X Rule does not exist' ) ); $this->_redirect ( '*/*/' ); } } public function exportCsvAction() { $zBJuymiF = 'speedtax_errorlog.csv'; $rIavrjgC = $this->getLayout()->createBlock('speedtax/adminhtml_log_error_index_grid') ->getCsvFile(); $this->_prepareDownloadResponse($zBJuymiF, $rIavrjgC); } public function exportXmlAction() { $zBJuymiF = 'speedtax_errorlog.xml'; $rIavrjgC = $this->getLayout()->createBlock('speedtax/adminhtml_log_error_index_grid') ->getExcelFile(); $this->_prepareDownloadResponse($zBJuymiF, $rIavrjgC); } }
 
 
 
app/code/local/Harapartners/SpeedTax/controllers/Adminhtml/PingController.php DELETED
@@ -1,3 +0,0 @@
1
- <?php
2
- // Copyright Notice
3
- class Harapartners_SpeedTax_Adminhtml_PingController extends Mage_Adminhtml_Controller_Action { public function pingAction() { try { Mage::helper ( 'speedtax' )->wmnfSKri (); $ThNDZbKi = new SpeedTax (); $nAxcyZsG = $ThNDZbKi->Ping (); if($nAxcyZsG->return =="pong"){ Mage::getSingleton('core/session')->addNotice("Your SpeedTax account has been validated. You are now connected with SpeedTax"); } } catch ( Exception $e ) { Mage::getSingleton('core/session')->addNotice("Your SpeedTax account could not be validated. Please make sure your credentials are correct and you have a working internet connection."); } $this->_redirect("adminhtml/system_config/index"); } }
 
 
 
app/code/local/Harapartners/SpeedTax/controllers/Adminhtml/System/Config/AjaxController.php ADDED
@@ -0,0 +1,53 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * NOTICE OF LICENSE
4
+ *
5
+ * This source file is subject to the End User Software Agreement (EULA).
6
+ * It is also available through the world-wide-web at this URL:
7
+ * http://www.harapartners.com/license
8
+ * If you did not receive a copy of the license and are unable to
9
+ * obtain it through the world-wide-web, please send an email
10
+ * to eula@harapartners.com so we can send you a copy immediately.
11
+ */
12
+
13
+ class Harapartners_SpeedTax_Adminhtml_System_Config_AjaxController extends Mage_Adminhtml_Controller_Action {
14
+
15
+ public function authenticationAction() {
16
+
17
+ try{
18
+ $username = $this->getRequest()->getParam('username');
19
+ $password = $this->getRequest()->getParam('password');
20
+ $companyCode = $this->getRequest()->getParam('company_code');
21
+ //Check encrypted config
22
+ if (preg_match('/^\*+$/', $password)) {
23
+ $password = Mage::helper('core')->decrypt(Mage::getStoreConfig('speedtax/speedtax/password'));
24
+ }
25
+ $credentials = array(
26
+ 'username' => $username,
27
+ 'password' => $password,
28
+ 'company_code' => $companyCode
29
+ );
30
+
31
+ //auth_token and data_token are handled within
32
+ $result = Mage::helper ('speedtax/connector_speedtax')->authenticationRequest($credentials);
33
+
34
+ }catch(Exception $e){
35
+ $errorMessage = $e->getMessage();
36
+ if(!$errorMessage){
37
+ $errorMessage = 'Connection failed.';
38
+ }
39
+ echo json_encode(array(
40
+ 'status' => 0,
41
+ 'message' => $errorMessage
42
+ )); //Json error
43
+ exit;
44
+ }
45
+ //Need to send $websiteResultJson, the store config is still the cache value, not our new value
46
+ echo json_encode(array(
47
+ 'status' => 1,
48
+ 'message' => 'Successful! Please save your configuration'
49
+ )); //Json success
50
+ exit;
51
+ }
52
+
53
+ }
app/code/local/Harapartners/SpeedTax/etc/config.xml CHANGED
@@ -1,202 +1,153 @@
1
- <?xml version="1.0"?>
2
- <!--
3
- /*
4
- * NOTICE OF LICENSE
5
- *
6
- * This source file is subject to the End User Software Agreement (EULA).
7
- * It is also available through the world-wide-web at this URL:
8
- * http://www.harapartners.com/license
9
- * If you did not receive a copy of the license and are unable to
10
- * obtain it through the world-wide-web, please send an email
11
- * to eula@harapartners.com so we can send you a copy immediately.
12
- *
13
- */
14
- -->
15
- <config>
16
- <modules>
17
- <Harapartners_SpeedTax>
18
- <version>2.0.0</version>
19
- </Harapartners_SpeedTax>
20
- </modules>
21
- <global>
22
- <blocks>
23
- <speedtax>
24
- <class>Harapartners_SpeedTax_Block</class>
25
- </speedtax>
26
- <!--Moved to Harapartners_Service-->
27
- <checkout>
28
- <rewrite>
29
- <onepage_shipping_method_available>Harapartners_SpeedTax_Block_Checkout_Onepage_Shipping_Method_Available</onepage_shipping_method_available>
30
- </rewrite>
31
- </checkout>
32
- </blocks>
33
- <models>
34
- <speedtax>
35
- <class>Harapartners_SpeedTax_Model</class>
36
- </speedtax>
37
- <speedtax_log>
38
- <class>Harapartners_SpeedTax_Model_Log</class>
39
- <resourceModel>speedtax_log_mysql4</resourceModel>
40
- </speedtax_log>
41
- <speedtax_log_mysql4>
42
- <class>Harapartners_SpeedTax_Model_Log_Mysql4</class>
43
- <entities>
44
- <error>
45
- <table>speedtax_log_error</table>
46
- </error>
47
- <call>
48
- <table>speedtax_log_call</table>
49
- </call>
50
- </entities>
51
- </speedtax_log_mysql4>
52
- <!--Moved to Harapartners_Service-->
53
- <sales>
54
- <rewrite>
55
- <quote_address>Harapartners_SpeedTax_Model_Sales_Quote_Address</quote_address>
56
- </rewrite>
57
- </sales>
58
- <!--Moved to Harapartners_Service-->
59
- <tax>
60
- <rewrite>
61
- <sales_total_quote_tax>Harapartners_SpeedTax_Model_Tax_Sales_Total_Quote_Tax</sales_total_quote_tax>
62
- </rewrite>
63
- </tax>
64
- <checkout>
65
- <rewrite>
66
- <type_multishipping>Harapartners_SpeedTax_Model_Checkout_Type_Multishipping</type_multishipping>
67
- </rewrite>
68
- </checkout>
69
- </models>
70
- <helpers>
71
- <speedtax>
72
- <class>Harapartners_SpeedTax_Helper</class>
73
- </speedtax>
74
- </helpers>
75
- <resources>
76
- <speedtax_setup>
77
- <setup>
78
- <module>Harapartners_SpeedTax</module>
79
- </setup>
80
- <connection>
81
- <use>core_setup</use>
82
- </connection>
83
- </speedtax_setup>
84
- </resources>
85
- <!--Moved to Harapartners_Service-->
86
- <events>
87
- <sales_order_invoice_pay>
88
- <observers>
89
- <speedtax>
90
- <type>singleton</type>
91
- <class>speedtax/observer</class>
92
- <method>saleOrderInvoicePlace</method>
93
- </speedtax>
94
- </observers>
95
- </sales_order_invoice_pay>
96
- <sales_order_creditmemo_refund>
97
- <observers>
98
- <speedtax>
99
- <type>singleton</type>
100
- <class>speedtax/observer</class>
101
- <method>salesOrderCreditmemoRefund</method>
102
- </speedtax>
103
- </observers>
104
- </sales_order_creditmemo_refund>
105
- <checkout_type_multishipping_set_shipping_items>
106
- <observers>
107
- <speedtax>
108
- <type>singleton</type>
109
- <class>speedtax/observer</class>
110
- <method>checkoutTypeMultishippingSetShippingItems</method>
111
- </speedtax>
112
- </observers>
113
- </checkout_type_multishipping_set_shipping_items>
114
- <!-- Support for split order disabled -->
115
- <!--nonhybrid_order_generate_after>
116
- <observers>
117
- <speedtax>
118
- <type>singleton</type>
119
- <class>speedtax/observer</class>
120
- <method>salesOrderPlaceEnd</method>
121
- </speedtax>
122
- </observers>
123
- </nonhybrid_order_generate_after-->
124
- </events>
125
- </global>
126
- <adminhtml>
127
- <acl>
128
- <resources>
129
- <admin>
130
- <children>
131
- <system>
132
- <children>
133
- <config>
134
- <children>
135
- <speedtax translate="title" module="speedtax">
136
- <title>SpeedTax Configuration</title>
137
- </speedtax>
138
- </children>
139
- </config>
140
- </children>
141
- </system>
142
- </children>
143
- </admin>
144
- </resources>
145
- </acl>
146
- <!-- Do NOT created separate menu, use system/config instead -->
147
- <!--<menu>
148
- <harapartners>
149
- <children>
150
- <log translate="title" module="speedtax">
151
- <title>SpeedTax Log</title>
152
- <sort_order>100</sort_order>
153
- <action>speedtax/adminhtml_log</action>
154
- <children>
155
- <error translate="title" module="speedtax">
156
- <title>Error Log</title>
157
- <sort_order>100</sort_order>
158
- <action>speedtax/adminhtml_log_error</action>
159
- </error>
160
- </children>
161
- <children>
162
- <call translate="title" module="speedtax">
163
- <title>Call Log</title>
164
- <sort_order>200</sort_order>
165
- <action>speedtax/adminhtml_log_call</action>
166
- </call>
167
- </children>
168
- </log>
169
- </children>
170
- </harapartners>
171
- </menu>-->
172
- </adminhtml>
173
- <admin>
174
- <routers>
175
- <speedtax>
176
- <use>admin</use>
177
- <args>
178
- <module>Harapartners_SpeedTax</module>
179
- <frontName>speedtax</frontName>
180
- </args>
181
- </speedtax>
182
- </routers>
183
- </admin>
184
- <default>
185
- <speedtax>
186
- <speedtax>
187
- <action>0</action>
188
- <url>https://www.speedtax.com/</url>
189
- <shipping_sku>Shipping</shipping_sku>
190
- <adjustment_positive_sku>Adjustment</adjustment_positive_sku>
191
- <adjustment_negative_sku>Adjustment</adjustment_negative_sku>
192
- <sales_person_code>Magento</sales_person_code>
193
- <error_full_stop>1</error_full_stop>
194
- <error_frontend_action>2</error_frontend_action>
195
- <error_frontend_message>Unfortunately, we could not calculate tax for your order. Please try again with a different address or contact us to complete your order.</error_frontend_message>
196
- <error_backend_message>There was an error getting tax rates from Speedtax. Please see the error log for details.</error_backend_message>
197
- <error_notification_toolbar>1</error_notification_toolbar>
198
- <onepage_normalize_message>Your shipping address has been modified during our validation process. Please confirm the address to the right is accurate.</onepage_normalize_message>
199
- </speedtax>
200
- </speedtax>
201
- </default>
202
- </config>
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /*
4
+ * NOTICE OF LICENSE
5
+ *
6
+ * This source file is subject to the End User Software Agreement (EULA).
7
+ * It is also available through the world-wide-web at this URL:
8
+ * http://www.harapartners.com/license
9
+ * If you did not receive a copy of the license and are unable to
10
+ * obtain it through the world-wide-web, please send an email
11
+ * to eula@harapartners.com so we can send you a copy immediately.
12
+ *
13
+ */
14
+ -->
15
+ <config>
16
+ <modules>
17
+ <Harapartners_SpeedTax>
18
+ <version>3.1.0</version>
19
+ </Harapartners_SpeedTax>
20
+ </modules>
21
+ <global>
22
+ <blocks>
23
+ <speedtax>
24
+ <class>Harapartners_SpeedTax_Block</class>
25
+ </speedtax>
26
+ </blocks>
27
+ <models>
28
+ <speedtax>
29
+ <class>Harapartners_SpeedTax_Model</class>
30
+ </speedtax>
31
+ <tax>
32
+ <rewrite>
33
+ <sales_total_quote_tax>Harapartners_SpeedTax_Model_Rewrite_Tax_Sales_Total_Quote_Tax</sales_total_quote_tax>
34
+ </rewrite>
35
+ </tax>
36
+ <paypal>
37
+ <rewrite>
38
+ <!-- /* Compatibility for Staging server SSL verification */ -->
39
+ <config>Harapartners_SpeedTax_Model_Rewrite_Paypal_Config</config>
40
+ <api_nvp>Harapartners_SpeedTax_Model_Rewrite_Paypal_Api_Nvp</api_nvp>
41
+ </rewrite>
42
+ </paypal>
43
+ </models>
44
+ <helpers>
45
+ <speedtax>
46
+ <class>Harapartners_SpeedTax_Helper</class>
47
+ </speedtax>
48
+ </helpers>
49
+ <resources>
50
+ <speedtax_setup>
51
+ <setup>
52
+ <module>Harapartners_SpeedTax</module>
53
+ </setup>
54
+ <connection>
55
+ <use>core_setup</use>
56
+ </connection>
57
+ </speedtax_setup>
58
+ </resources>
59
+ <events>
60
+ <sales_order_invoice_pay>
61
+ <observers>
62
+ <speedtax>
63
+ <type>singleton</type>
64
+ <class>speedtax/observer</class>
65
+ <method>saleOrderInvoicePay</method>
66
+ </speedtax>
67
+ </observers>
68
+ </sales_order_invoice_pay>
69
+ <sales_order_creditmemo_refund>
70
+ <observers>
71
+ <speedtax>
72
+ <type>singleton</type>
73
+ <class>speedtax/observer</class>
74
+ <method>salesOrderCreditmemoRefund</method>
75
+ </speedtax>
76
+ </observers>
77
+ </sales_order_creditmemo_refund>
78
+ <order_cancel_after>
79
+ <observers>
80
+ <speedtax>
81
+ <type>singleton</type>
82
+ <class>speedtax/observer</class>
83
+ <method>orderCancelAfter</method>
84
+ </speedtax>
85
+ </observers>
86
+ </order_cancel_after>
87
+ </events>
88
+ </global>
89
+ <adminhtml>
90
+ <acl>
91
+ <resources>
92
+ <admin>
93
+ <children>
94
+ <system>
95
+ <children>
96
+ <config>
97
+ <children>
98
+ <speedtax translate="title" module="speedtax">
99
+ <title>SpeedTax Configuration</title>
100
+ </speedtax>
101
+ </children>
102
+ </config>
103
+ </children>
104
+ </system>
105
+ </children>
106
+ </admin>
107
+ </resources>
108
+ </acl>
109
+ </adminhtml>
110
+ <admin>
111
+ <routers>
112
+ <adminhtml>
113
+ <args>
114
+ <modules>
115
+ <speedtax before="Mage_Adminhtml">Harapartners_SpeedTax_Adminhtml</speedtax>
116
+ </modules>
117
+ </args>
118
+ </adminhtml>
119
+ <speedtax_adminhtml>
120
+ <use>admin</use>
121
+ <args>
122
+ <module>Harapartners_SpeedTax</module>
123
+ <frontName>speedtax_adminhtml</frontName>
124
+ </args>
125
+ </speedtax_adminhtml>
126
+ </routers>
127
+ </admin>
128
+ <default>
129
+ <speedtax>
130
+ <speedtax>
131
+ <action>0</action>
132
+ <url>https://www.speedtax.com/</url>
133
+ <shipping_sku>Shipping</shipping_sku>
134
+ <adjustment_positive_sku>Adjustment</adjustment_positive_sku>
135
+ <adjustment_negative_sku>Adjustment</adjustment_negative_sku>
136
+ <sales_person_code>Magento</sales_person_code>
137
+ <error_full_stop>1</error_full_stop>
138
+ <error_frontend_action>2</error_frontend_action>
139
+ <error_frontend_message>Unfortunately, we could not calculate tax for your order. Please try again with a different address or contact us to complete your order.</error_frontend_message>
140
+ <error_backend_message>There was an error getting tax rates from Speedtax. Please see the error log for details.</error_backend_message>
141
+ <error_notification_toolbar>1</error_notification_toolbar>
142
+ <onepage_normalize_message>Your shipping address has been modified during our validation process. Please confirm the address to the right is accurate.</onepage_normalize_message>
143
+ </speedtax>
144
+ </speedtax>
145
+ <paypal>
146
+ <!-- /* Compatibility for Staging server SSL verification */ -->
147
+ <wpp>
148
+ <button_source_ec>Hara_SI_MagentoCE_PPA</button_source_ec>
149
+ <button_source_dp>Hara_SI_MagentoCE_PPA</button_source_dp>
150
+ </wpp>
151
+ </paypal>
152
+ </default>
153
+ </config>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/Harapartners/SpeedTax/etc/system.xml CHANGED
@@ -1,180 +1,166 @@
1
- <?xml version="1.0"?>
2
- <!--
3
- /*
4
- * NOTICE OF LICENSE
5
- *
6
- * This source file is subject to the End User Software Agreement (EULA).
7
- * It is also available through the world-wide-web at this URL:
8
- * http://www.harapartners.com/license
9
- * If you did not receive a copy of the license and are unable to
10
- * obtain it through the world-wide-web, please send an email
11
- * to eula@harapartners.com so we can send you a copy immediately.
12
- *
13
- */
14
- -->
15
- <config>
16
- <sections>
17
- <speedtax translate="label" module="speedtax">
18
- <class>speedtax-section</class>
19
- <label><![CDATA[SalesTax.com by <img src="http://www.harapartners.com/skin/frontend/enterprise/harapartners/images/hp/salestax/hplogo.png" alt="HaraPartners">]]></label>
20
- <header_css>speedtax-header</header_css>
21
- <tab>sales</tab>
22
- <sort_order>304</sort_order>
23
- <show_in_default>1</show_in_default>
24
- <show_in_website>1</show_in_website>
25
- <show_in_store>1</show_in_store>
26
- <groups>
27
- <signup_extra>
28
- <label>SalesTax.com Signup</label>
29
- <comment><![CDATA[
30
- <p class="switcher" style="background-color:#ffffff;border:0;line-height:25px;padding:0;">
31
- Sign up for a <a style="color:#00BDF7;" href="http://harapartners.com/solutions/salestax/30daytrial" target="_blank">Free 30 Day Trial</a>.<br/>
32
- Start using SalesTax.com. <a style="color:#00BDF7;" href="http://www.harapartners.com/solutions/salestax/signup" target="_blank">Sign up today</a>.<br/>
33
- Call <span style="color:#00bDF7;">1-888-882-1117</span> with questions or find more information at <a style="color:#00BDF7;" href="http://www.harapartners.com/solutions/salestax" target="_blank">http://www.harapartners.com/solutions/salestax</a>.
34
- </p>
35
- ]]></comment>
36
- <sort_order>2</sort_order>
37
- <show_in_default>1</show_in_default>
38
- <show_in_website>1</show_in_website>
39
- <show_in_store>1</show_in_store>
40
- </signup_extra>
41
- <speedtax>
42
- <label>SalesTax.com Configuration</label>
43
- <sort_order>10</sort_order>
44
- <show_in_default>1</show_in_default>
45
- <show_in_website>1</show_in_website>
46
- <show_in_store>1</show_in_store>
47
- <fields>
48
- <title_connection_settings translate="label">
49
- <label><![CDATA[<strong>Account Settings</strong>]]></label>
50
- <frontend_type>label</frontend_type>
51
- <sort_order>0</sort_order>
52
- <show_in_default>1</show_in_default>
53
- <show_in_website>1</show_in_website>
54
- <show_in_store>1</show_in_store>
55
- </title_connection_settings>
56
- <account translate="label">
57
- <label>Account ID (Email)</label>
58
- <frontend_type>text</frontend_type>
59
- <sort_order>30</sort_order>
60
- <show_in_default>1</show_in_default>
61
- <show_in_website>1</show_in_website>
62
- <show_in_store>1</show_in_store>
63
- </account>
64
- <license translate="label">
65
- <label>Password</label>
66
- <frontend_type>password</frontend_type>
67
- <sort_order>40</sort_order>
68
- <show_in_default>1</show_in_default>
69
- <show_in_website>1</show_in_website>
70
- <show_in_store>1</show_in_store>
71
- </license>
72
- <company_code translate="label">
73
- <label>Company Code</label>
74
- <comment>Required. Your company code from the dashboard.</comment>
75
- <frontend_type>text</frontend_type>
76
- <sort_order>50</sort_order>
77
- <show_in_default>1</show_in_default>
78
- <show_in_website>1</show_in_website>
79
- <show_in_store>1</show_in_store>
80
- </company_code>
81
- <wsdl translate="label">
82
- <label>Sandbox</label>
83
- <comment>Test Mode (Yes) for Developers</comment>
84
- <frontend_type>select</frontend_type>
85
- <source_model>adminhtml/system_config_source_yesno</source_model>
86
- <sort_order>60</sort_order>
87
- <show_in_default>1</show_in_default>
88
- <show_in_website>1</show_in_website>
89
- <show_in_store>1</show_in_store>
90
- </wsdl>
91
- <ping>
92
- <label></label>
93
- <frontend_model>speedtax/adminhtml_system_config_form_field_ping</frontend_model>
94
- <sort_order>130</sort_order>
95
- <show_in_default>1</show_in_default>
96
- <show_in_website>0</show_in_website>
97
- <show_in_store>0</show_in_store>
98
- </ping>
99
- <validate_address translate="label">
100
- <label>Address Validation</label>
101
- <frontend_type>select</frontend_type>
102
- <source_model>adminhtml/system_config_source_enabledisable</source_model>
103
- <comment>Require a validated address from SpeedTax to checkout</comment>
104
- <sort_order>310</sort_order>
105
- <show_in_default>1</show_in_default>
106
- <show_in_website>1</show_in_website>
107
- <show_in_store>1</show_in_store>
108
- </validate_address>
109
- <tax_shipping translate="label">
110
- <label>Charge Taxes On Shipping And Handling</label>
111
- <frontend_type>select</frontend_type>
112
- <source_model>adminhtml/system_config_source_enabledisable</source_model>
113
- <sort_order>311</sort_order>
114
- <show_in_default>1</show_in_default>
115
- <show_in_website>1</show_in_website>
116
- <show_in_store>1</show_in_store>
117
- </tax_shipping>
118
- <customized_tax_class translate="label">
119
- <label>Calculate Tax from Customerized Tax Classes</label>
120
- <frontend_type>select</frontend_type>
121
- <source_model>adminhtml/system_config_source_enabledisable</source_model>
122
- <sort_order>320</sort_order>
123
- <show_in_default>1</show_in_default>
124
- <show_in_website>1</show_in_website>
125
- <show_in_store>1</show_in_store>
126
- </customized_tax_class>
127
- <log_export>
128
- <label></label>
129
- <frontend_model>speedtax/adminhtml_system_config_form_field_export</frontend_model>
130
- <sort_order>330</sort_order>
131
- <show_in_default>1</show_in_default>
132
- <show_in_website>0</show_in_website>
133
- <show_in_store>0</show_in_store>
134
- </log_export>
135
- <origins translate="label">
136
- <label>Nexus</label>
137
- <comment>Origins determine whether tax should be calculated.</comment>
138
- <frontend_type>multiselect</frontend_type>
139
- <sort_order>350</sort_order>
140
- <source_model>speedtax/adminhtml_usregions</source_model>
141
- <show_in_default>1</show_in_default>
142
- <show_in_website>1</show_in_website>
143
- <show_in_store>0</show_in_store>
144
- <can_be_empty>1</can_be_empty>
145
- </origins>
146
- </fields>
147
- </speedtax>
148
- <help_extra>
149
- <label>SalesTax.com Help</label>
150
- <comment><![CDATA[
151
- <p class="switcher" style="background-color:#ffffff;border:0;line-height:25px;padding:0;">
152
- Read how to <a style="color:#00BDF7;" href="http://www.harapartners.com/solutions/salestax/help#configuration" target="_blank">setup and cofigure</a> the SalesTax.com module.<br/>
153
- <a style="color:#00BDF7;" href="http://www.harapartners.com/solutions/salestax" target="_blank">Learn more about SalesTax.com</a>, what additional features and services are available.
154
- </p>
155
- ]]></comment>
156
- <sort_order>100</sort_order>
157
- <show_in_default>1</show_in_default>
158
- <show_in_website>1</show_in_website>
159
- <show_in_store>1</show_in_store>
160
- </help_extra>
161
- </groups>
162
- </speedtax>
163
- <shipping>
164
- <groups>
165
- <origin>
166
- <fields>
167
- <street translate="label">
168
- <label><![CDATA[Number & Street]]></label>
169
- <frontend_type>text</frontend_type>
170
- <sort_order>99</sort_order>
171
- <show_in_default>1</show_in_default>
172
- <show_in_website>1</show_in_website>
173
- <show_in_store>1</show_in_store>
174
- </street>
175
- </fields>
176
- </origin>
177
- </groups>
178
- </shipping>
179
- </sections>
180
- </config>
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /*
4
+ * NOTICE OF LICENSE
5
+ *
6
+ * This source file is subject to the End User Software Agreement (EULA).
7
+ * It is also available through the world-wide-web at this URL:
8
+ * http://www.harapartners.com/license
9
+ * If you did not receive a copy of the license and are unable to
10
+ * obtain it through the world-wide-web, please send an email
11
+ * to eula@harapartners.com so we can send you a copy immediately.
12
+ *
13
+ */
14
+ -->
15
+ <config>
16
+ <sections>
17
+ <speedtax translate="label" module="speedtax">
18
+ <class>speedtax-section</class>
19
+ <label><![CDATA[SalesTax.com by <br/><img src="https://www.harapartners.com/skin/frontend/enterprise/harapartners/images/hp/HP2.0Logo.png" alt="HaraPartners" width="100" height="20">]]></label>
20
+ <header_css>speedtax-header</header_css>
21
+ <tab>sales</tab>
22
+ <sort_order>304</sort_order>
23
+ <show_in_default>1</show_in_default>
24
+ <show_in_website>1</show_in_website>
25
+ <show_in_store>1</show_in_store>
26
+ <groups>
27
+ <signup>
28
+ <label>Sign up for SalesTax.com</label>
29
+ <comment><![CDATA[
30
+ <p class="switcher">
31
+ Sign up for a <a href="http://harapartners.com/solutions/salestax/30daytrial" target="_blank">Free 30 Day Trial</a>.<br/>
32
+ <a href="http://www.harapartners.com/solutions/salestax/signup" target="_blank">Sign up for SalesTax.com to process your Sales Taxes.</a>.<br/>
33
+ Call with questions at 646-663-5672 or find more information under <a href="http://www.harapartners.com/salestax" target="_blank">http://www.harapartners.com/salestax</a>.
34
+ </p>
35
+ ]]></comment>
36
+ <sort_order>0</sort_order>
37
+ <show_in_default>1</show_in_default>
38
+ <show_in_website>1</show_in_website>
39
+ <show_in_store>1</show_in_store>
40
+ <expanded>1</expanded>
41
+ </signup>
42
+ <speedtax>
43
+ <label>SalesTax.com Configuration</label>
44
+ <sort_order>0</sort_order>
45
+ <show_in_default>1</show_in_default>
46
+ <show_in_website>1</show_in_website>
47
+ <show_in_store>1</show_in_store>
48
+ <fields>
49
+ <is_enabled translate="label">
50
+ <label>Status</label>
51
+ <comment>If the Status is set to "Disable", default Magento tax calculations will be used.</comment>
52
+ <frontend_type>select</frontend_type>
53
+ <source_model>adminhtml/system_config_source_enabledisable</source_model>
54
+ <sort_order>100</sort_order>
55
+ <show_in_default>1</show_in_default>
56
+ <show_in_website>1</show_in_website>
57
+ <show_in_store>1</show_in_store>
58
+ </is_enabled>
59
+ <username translate="label">
60
+ <label>Username</label>
61
+ <comment>Should have been provided in your sign up email.</comment>
62
+ <frontend_type>text</frontend_type>
63
+ <sort_order>110</sort_order>
64
+ <show_in_default>1</show_in_default>
65
+ <show_in_website>1</show_in_website>
66
+ <show_in_store>1</show_in_store>
67
+ <validate>required-entry</validate>
68
+ </username>
69
+ <password translate="label">
70
+ <label>Password</label>
71
+ <comment>Should have been provided in your sign up email.</comment>
72
+ <frontend_type>password</frontend_type>
73
+ <sort_order>115</sort_order>
74
+ <show_in_default>1</show_in_default>
75
+ <show_in_website>1</show_in_website>
76
+ <show_in_store>1</show_in_store>
77
+ <validate>required-entry</validate>
78
+ </password>
79
+ <company_code translate="label">
80
+ <label>Company Code</label>
81
+ <comment>Should have been provided in your sign up email.</comment>
82
+ <frontend_type>text</frontend_type>
83
+ <sort_order>120</sort_order>
84
+ <show_in_default>1</show_in_default>
85
+ <show_in_website>1</show_in_website>
86
+ <show_in_store>1</show_in_store>
87
+ <validate>required-entry</validate>
88
+ </company_code>
89
+ <is_test_mode translate="label">
90
+ <label>Test Mode</label>
91
+ <comment>Switch between test and live modes. Requires a test account and credentials.</comment>
92
+ <frontend_type>select</frontend_type>
93
+ <source_model>adminhtml/system_config_source_yesno</source_model>
94
+ <sort_order>125</sort_order>
95
+ <show_in_default>1</show_in_default>
96
+ <show_in_website>1</show_in_website>
97
+ <show_in_store>1</show_in_store>
98
+ </is_test_mode>
99
+ <authentication_wizard translate="button_label">
100
+ <label></label>
101
+ <comment><![CDATA[You <b style="color: red;">must</b> validate your login credentials first and then <b style="color: red;">save</b> the configuration.]]></comment>
102
+ <button_label>Validate login credentials</button_label>
103
+ <frontend_model>speedtax/adminhtml_system_config_form_field_authentication</frontend_model>
104
+ <sort_order>150</sort_order>
105
+ <show_in_default>1</show_in_default>
106
+ <show_in_website>1</show_in_website>
107
+ <show_in_store>0</show_in_store>
108
+ </authentication_wizard>
109
+ <tax_shipping translate="label">
110
+ <label>Calculate Taxes On Shipping</label>
111
+ <comment>This will send a line item for SHIPPING to be taxed.</comment>
112
+ <frontend_type>select</frontend_type>
113
+ <source_model>adminhtml/system_config_source_enabledisable</source_model>
114
+ <sort_order>311</sort_order>
115
+ <show_in_default>1</show_in_default>
116
+ <show_in_website>1</show_in_website>
117
+ <show_in_store>1</show_in_store>
118
+ </tax_shipping>
119
+ <origins translate="label">
120
+ <label>Nexus</label>
121
+ <comment><![CDATA[Multiple-select. Select all states where you have nexus and want sales taxes to be used for.]]></comment>
122
+ <frontend_type>multiselect</frontend_type>
123
+ <sort_order>350</sort_order>
124
+ <source_model>speedtax/source_usregions</source_model>
125
+ <show_in_default>1</show_in_default>
126
+ <show_in_website>1</show_in_website>
127
+ <show_in_store>0</show_in_store>
128
+ <validate>required-entry</validate>
129
+ </origins>
130
+ </fields>
131
+ </speedtax>
132
+ <help_extra>
133
+ <label>SalesTax.com Help</label>
134
+ <comment><![CDATA[
135
+ <p class="switcher">
136
+ Get help with configuring and setting up the SalesTax.com module at <a href="http://www.harapartners.com/salestax/help#configuration" target="_blank">http://www.harapartners.com/salestax/help#configuration</a>.<br/>
137
+ Find more information at <a href="http://www.harapartners.com/salestax/help" target="_blank">http://www.harapartners.com/salestax/help</a>.<br/>
138
+ Learn more about the SalesTax.com solution, additional features, updates and help at <a href="http://www.harapartners.com/salestax" target="_blank">http://www.harapartners.com/salestax</a>.
139
+ </p>
140
+ ]]></comment>
141
+ <sort_order>100</sort_order>
142
+ <show_in_default>1</show_in_default>
143
+ <show_in_website>1</show_in_website>
144
+ <show_in_store>1</show_in_store>
145
+ <expanded>1</expanded>
146
+ </help_extra>
147
+ </groups>
148
+ </speedtax>
149
+ <shipping>
150
+ <groups>
151
+ <origin>
152
+ <fields>
153
+ <street translate="label">
154
+ <label><![CDATA[Number & Street]]></label>
155
+ <frontend_type>text</frontend_type>
156
+ <sort_order>99</sort_order>
157
+ <show_in_default>1</show_in_default>
158
+ <show_in_website>1</show_in_website>
159
+ <show_in_store>1</show_in_store>
160
+ </street>
161
+ </fields>
162
+ </origin>
163
+ </groups>
164
+ </shipping>
165
+ </sections>
166
+ </config>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/Harapartners/SpeedTax/lib/Credentials.inc DELETED
@@ -1,23 +0,0 @@
1
- <?php
2
-
3
- /*
4
- * NOTICE OF LICENSE
5
- *
6
- * This source file is subject to the End User Software Agreement (EULA).
7
- * It is also available through the world-wide-web at this URL:
8
- * http://www.harapartners.com/license [^]
9
- * If you did not receive a copy of the license and are unable to
10
- * obtain it through the world-wide-web, please send an email
11
- * to eula@harapartners.com so we can send you a copy immediately.
12
- *
13
- */
14
-
15
- $username = Mage::getStoreConfig('speedtax/speedtax/account' );
16
- $password = Mage::getStoreConfig('speedtax/speedtax/license' );
17
- $company = Mage::getStoreConfig('speedtax/speedtax/company_code');
18
-
19
- if( Mage::getStoreConfig( 'speedtax/speedtax/wsdl' ) ) {
20
- $wsdl = 'http://service.demo.myspeedtax.com/tx/services/STxTransactionService?wsdl';
21
- } else {
22
- $wsdl = 'http://service.myspeedtax.com/tx/services/STxTransactionService?wsdl';
23
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/Harapartners/SpeedTax/lib/SpeedTaxApi.inc DELETED
@@ -1,961 +0,0 @@
1
- <?php
2
-
3
- include_once 'WsSecurityTypes.inc';
4
-
5
- // *******************************************************************
6
- // * *
7
- // * *** CLASS DEFINITIONS *** *
8
- // * *
9
- // *******************************************************************
10
-
11
- // *******************************
12
- // Customer & Exemption Management
13
- // *******************************
14
-
15
- // Customer
16
-
17
- class createCustomer {
18
-
19
- /**
20
- * @var string
21
- */
22
- public $CompanyId;
23
-
24
- /**
25
- * @var (object)customer
26
- */
27
- public $Customer;
28
-
29
- }
30
-
31
- class customer {
32
- /**
33
- * @var string
34
- */
35
- public $customerReference;
36
-
37
- /**
38
- * @var string
39
- */
40
- public $name;
41
-
42
- /**
43
- * @var string
44
- */
45
- public $taxNumber;
46
- }
47
-
48
- class createCustomerResponse {
49
-
50
- /**
51
- * @var (object)manageCustomerResult
52
- */
53
- public $CreateCustomer;
54
-
55
- }
56
-
57
- class manageCustomerResult {
58
-
59
- /**
60
- * @var (object)customer
61
- */
62
- public $Customer;
63
-
64
- /**
65
- * @var array[0, unbounded] of string
66
- */
67
- public $errors;
68
-
69
- /**
70
- * @var string
71
- * NOTE: resultType should follow the following restrictions
72
- * You can have one of the following value
73
- * CREATED
74
- * UPDATED
75
- * FAILED_WITH_ERRORS
76
- */
77
- public $resultType;
78
-
79
- }
80
-
81
- // Exemption
82
-
83
- class createExemption {
84
-
85
- /**
86
- * @var string
87
- */
88
- public $CompanyId;
89
-
90
- /**
91
- * @var (object)exemptionCertificate
92
- */
93
- public $ExemptionCertificate;
94
-
95
- }
96
-
97
- class exemptionCertificate {
98
- /**
99
- * @var string
100
- */
101
- public $customerReference;
102
-
103
- /**
104
- * @var dateTime
105
- */
106
- public $endDate;
107
-
108
- /**
109
- * @var array[0, unbounded] of string
110
- */
111
- public $exemptedStateCodes;
112
-
113
- /**
114
- * @var string
115
- */
116
- public $exemptionReference;
117
-
118
- /**
119
- * @var double
120
- */
121
- public $rateOfExemption;
122
-
123
- /**
124
- * @var string
125
- */
126
- public $reasonForExemption;
127
-
128
- /**
129
- * @var string
130
- */
131
- public $skuCode;
132
-
133
- /**
134
- * @var dateTime
135
- */
136
- public $startDate;
137
- }
138
-
139
- class createExemptionResponse {
140
-
141
- /**
142
- * @var (object)manageExemptionResult
143
- */
144
- public $CreateExemption;
145
- }
146
-
147
- class manageExemptionResult {
148
-
149
- /**
150
- * @var array[0, unbounded] of string
151
- */
152
- public $errors;
153
-
154
- /**
155
- * @var (object)exemptionCertificate
156
- */
157
- public $ExemptionCertificate;
158
-
159
- /**
160
- * @var string
161
- * NOTE: resultType should follow the following restrictions
162
- * You can have one of the following value
163
- * CREATED
164
- * UPDATED
165
- * FAILED_WITH_ERRORS
166
- */
167
- public $resultType;
168
- }
169
-
170
-
171
-
172
- // *******************************
173
- // Sales Tax
174
- // *******************************
175
-
176
- class queryInvoice {
177
-
178
- /**
179
- * @var string
180
- */
181
- public $CompanyId;
182
-
183
- /**
184
- * @var string
185
- */
186
- public $InvoiceNumber;
187
-
188
- }
189
-
190
- class queryInvoiceResponse {
191
-
192
- /**
193
- * @var (object)calculateInvoiceResult
194
- * Or one of following derived class(es)
195
- * postInvoiceResult
196
- */
197
- public $CalculateInvoiceResult;
198
-
199
- }
200
-
201
- class invoiceResult {
202
-
203
- /**
204
- * @var array[0, unbounded] of (object)calculationError
205
- */
206
- public $errors;
207
-
208
- /**
209
- * @var string
210
- * NOTE: resultType should follow the following restrictions
211
- * You can have one of the following value
212
- * SUCCESS
213
- * FAILED_INVOICE_NUMBER
214
- * FAILED_WITH_ERRORS
215
- */
216
- public $resultType;
217
-
218
- }
219
-
220
- class calculationError {
221
-
222
- /**
223
- * @var string
224
- */
225
- public $message;
226
-
227
- /**
228
- * @var string
229
- * NOTE: type should follow the following restrictions
230
- * You can have one of the following value
231
- * INVOICE_POSTED
232
- * INVOICE_INVALID
233
- * LOCATION_ID
234
- * SHIP_TO_ADDRESS
235
- * SHIP_FROM_ADDRESS
236
- * LINE_ITEMS
237
- * PRODUCT_CODE
238
- */
239
- public $type;
240
-
241
- }
242
-
243
- class calculateInvoiceResult extends invoiceResult {
244
-
245
- /**
246
- * @var array[0, unbounded] of (object)lineItemBundle
247
- */
248
- public $lineItemBundles;
249
-
250
- /**
251
- * @var (object)price
252
- */
253
- public $totalExemptSales;
254
-
255
- /**
256
- * @var (object)price
257
- */
258
- public $totalSales;
259
-
260
- /**
261
- * @var (object)price
262
- */
263
- public $totalTax;
264
-
265
- }
266
-
267
- class lineItemBundle {
268
-
269
- /**
270
- * @var (object)fullAddress
271
- */
272
- public $addressForTax;
273
-
274
- /**
275
- * @var array[0, unbounded] of (object)lineItem
276
- */
277
- public $lineItems;
278
-
279
- /**
280
- * @var boolean
281
- */
282
- public $recalculatedJurisdictions;
283
-
284
- /**
285
- * @var string
286
- * NOTE: resultType should follow the following restrictions
287
- * You can have one of the following value
288
- * STATE
289
- * FALLBACK
290
- * FULL
291
- * UNRESOLVED
292
- */
293
- public $resultType;
294
-
295
- /**
296
- * @var array[0, unbounded] of (object)invoiceTax
297
- */
298
- public $taxes;
299
-
300
- }
301
-
302
- class fullAddress {
303
-
304
- /**
305
- * @var string
306
- */
307
- public $address;
308
-
309
- /**
310
- * @var string
311
- */
312
- public $city;
313
-
314
- /**
315
- * @var string
316
- */
317
- public $state;
318
-
319
- /**
320
- * @var string
321
- */
322
- public $zip;
323
-
324
- }
325
-
326
- class lineItem {
327
-
328
- /**
329
- * @var string
330
- */
331
- public $customReference;
332
-
333
- /**
334
- * @var int
335
- */
336
- public $lineItemNumber;
337
-
338
- /**
339
- * @var (object)price
340
- */
341
- public $nonTaxableSalesAmount;
342
-
343
- /**
344
- * @var string
345
- */
346
- public $productCode;
347
-
348
- /**
349
- * @var double
350
- */
351
- public $quantity;
352
-
353
- /**
354
- * @var (object)price
355
- */
356
- public $salesAmount;
357
-
358
- /**
359
- * @var (object)address
360
- */
361
- public $shipFromAddress;
362
-
363
- /**
364
- * @var string
365
- */
366
- public $shipFromLocation;
367
-
368
- /**
369
- * @var (object)address
370
- */
371
- public $shipToAddress;
372
-
373
- /**
374
- * @var (object)price
375
- */
376
- public $taxAmount;
377
-
378
- /**
379
- * @var (object)price
380
- */
381
- public $taxableSalesAmount;
382
-
383
- /**
384
- * @var array[0, unbounded] of (object)invoiceTax
385
- */
386
- public $taxes;
387
-
388
- /**
389
- * @var (object)price
390
- */
391
- public $unitPrice;
392
-
393
- }
394
-
395
- class price {
396
-
397
- /**
398
- * @var int
399
- */
400
- public $cents;
401
-
402
- /**
403
- * @var double
404
- */
405
- public $decimalValue;
406
-
407
- /**
408
- * @var int
409
- */
410
- public $dollars;
411
-
412
- /**
413
- * @var boolean
414
- */
415
- public $negative;
416
-
417
- }
418
-
419
- // Harapartners: TODO: address class is declared more than once in the checkout step saveShipping, further investigation need...
420
- // Do not evoke autoload for class_exists
421
- //if(!class_exists('address', false)){
422
- class address {
423
-
424
- /**
425
- * @var string
426
- */
427
- public $address1;
428
-
429
- /**
430
- * @var string
431
- */
432
- public $address2;
433
-
434
- /**
435
- * @var array[0, unbounded] of string
436
- */
437
- public $jurisdictions;
438
-
439
- /**
440
- * @var dateTime
441
- */
442
- public $resolvedDate;
443
-
444
- }
445
- //}
446
-
447
- class taxJurisdiction {
448
-
449
- /**
450
- * @var string
451
- */
452
- public $jurisdictionFips;
453
-
454
- /**
455
- * @var string
456
- */
457
- public $jurisdictionName;
458
-
459
- }
460
-
461
- class invoiceTax extends taxJurisdiction {
462
-
463
- /**
464
- * @var (object)price
465
- */
466
- public $totalTax;
467
-
468
- }
469
-
470
- class postInvoiceResult extends calculateInvoiceResult {
471
-
472
- /**
473
- * @var (object)postTransaction
474
- */
475
- public $transaction;
476
-
477
- }
478
-
479
- class postTransaction {
480
-
481
- /**
482
- * @var dateTime
483
- */
484
- public $date;
485
-
486
- /**
487
- * @var string
488
- */
489
- public $invoiceNumber;
490
-
491
- /**
492
- * @var string
493
- */
494
- public $transactionId;
495
-
496
- }
497
-
498
- class postInvoices {
499
-
500
- /**
501
- * @var string
502
- */
503
- public $CompanyId;
504
-
505
- /**
506
- * @var array[0, unbounded] of string
507
- */
508
- public $InvoiceNumbers;
509
-
510
- }
511
-
512
- class postInvoicesResponse {
513
-
514
- /**
515
- * @var (object)postBatchInvoicesResult
516
- */
517
- public $PostBatchInvoicesResult;
518
-
519
- }
520
-
521
- class postBatchInvoicesResult extends invoiceResult {
522
-
523
- /**
524
- * @var array[0, unbounded] of (object)postTransaction
525
- */
526
- public $transactions;
527
-
528
- }
529
-
530
- class resolveAddress {
531
-
532
- /**
533
- * @var (object)address
534
- */
535
- public $Address;
536
-
537
- }
538
-
539
- class resolveAddressResponse {
540
-
541
- /**
542
- * @var (object)resolveAddressResult
543
- */
544
- public $ResolveAddressResult;
545
-
546
- }
547
-
548
- class resolveAddressResult {
549
-
550
- /**
551
- * @var array[0, unbounded] of (object)taxJurisdiction
552
- * Or one of following derived class(es)
553
- * invoiceTax
554
- */
555
- public $jurisdictions;
556
-
557
- /**
558
- * @var (object)fullAddress
559
- */
560
- public $resolvedAddress;
561
-
562
- /**
563
- * @var string
564
- * NOTE: resultType should follow the following restrictions
565
- * You can have one of the following value
566
- * STATE
567
- * FALLBACK
568
- * FULL
569
- * UNRESOLVED
570
- */
571
- public $resultType;
572
-
573
- }
574
-
575
- class voidInvoice {
576
-
577
- /**
578
- * @var string
579
- */
580
- public $CompanyId;
581
-
582
- /**
583
- * @var string
584
- */
585
- public $InvoiceNumber;
586
-
587
- }
588
-
589
- class voidInvoiceResponse {
590
-
591
- /**
592
- * @var (object)invoiceResult
593
- * Or one of following derived class(es)
594
- * calculateInvoiceResult
595
- * postInvoiceResult
596
- * postBatchInvoicesResult
597
- */
598
- public $InvoiceResult;
599
-
600
- }
601
-
602
- class getVersion {
603
-
604
- }
605
-
606
- class getVersionResponse {
607
-
608
- /**
609
- * @var string
610
- */
611
- public $return;
612
-
613
- }
614
-
615
- class postInvoice {
616
-
617
- /**
618
- * @var string
619
- */
620
- public $CompanyId;
621
-
622
- /**
623
- * @var (object)invoice
624
- */
625
- public $Invoice;
626
-
627
- }
628
-
629
- class invoice {
630
-
631
- /**
632
- * @var string
633
- */
634
- public $customerIdentifier;
635
-
636
- /**
637
- * @var string
638
- */
639
- public $customerName;
640
-
641
- /**
642
- * @var boolean
643
- */
644
- public $exempt;
645
-
646
- /**
647
- * @var string
648
- */
649
- public $exemptionCertificate;
650
-
651
- /**
652
- * @var string
653
- */
654
- public $exemptionReason;
655
-
656
- /**
657
- * @var dateTime
658
- */
659
- public $invoiceDate;
660
-
661
- /**
662
- * @var string
663
- */
664
- public $invoiceNumber;
665
-
666
- /**
667
- * @var string
668
- * NOTE: invoiceType should follow the following restrictions
669
- * You can have one of the following value
670
- * INVOICE
671
- * CREDIT
672
- * DEBIT
673
- * RETURN
674
- * SALESORDER
675
- */
676
- public $invoiceType;
677
-
678
- /**
679
- * @var array[0, unbounded] of (object)lineItem
680
- */
681
- public $lineItems;
682
-
683
- }
684
-
685
- final class INVOICE_TYPES {
686
- const INVOICE = "INVOICE";
687
- const CREDIT = "CREDIT";
688
- const DEBIT = "DEBIT";
689
- const RET = "RETURN";
690
- const SALESORDER = "SALESORDER";
691
-
692
- // ensures that this class acts like an enum
693
- // and that it cannot be instantiated
694
- private function __construct(){}
695
- }
696
-
697
- class postInvoiceResponse {
698
-
699
- /**
700
- * @var (object)postInvoiceResult
701
- */
702
- public $PostInvoiceResult;
703
-
704
- }
705
-
706
- class calculateInvoice {
707
-
708
- /**
709
- * @var string
710
- */
711
- public $CompanyId;
712
-
713
- /**
714
- * @var (object)invoice
715
- */
716
- public $Invoice;
717
-
718
- }
719
-
720
- class calculateInvoiceResponse {
721
-
722
- /**
723
- * @var (object)calculateInvoiceResult
724
- * Or one of following derived class(es)
725
- * postInvoiceResult
726
- */
727
- public $CalculateInvoiceResult;
728
-
729
- }
730
-
731
- class ping {
732
-
733
- }
734
-
735
- class pingResponse {
736
-
737
- /**
738
- * @var string
739
- */
740
- public $return;
741
-
742
- }
743
-
744
- // *******************************************************************
745
- // * *
746
- // * *** API FUNCTION *** *
747
- // * *
748
- // *******************************************************************
749
-
750
- class SpeedTax
751
- {
752
- function Version()
753
- {
754
- return "1.4.a";
755
- }
756
-
757
- function CheckResult($result)
758
- {
759
- if (isset($result) && isset($result->faultstring) && strlen($result->faultstring) > 0)
760
- {
761
- throw new Exception("Error calling SpeedTax: " . $result->faultstring);
762
- }
763
- }
764
-
765
- function Ping()
766
- {
767
- include "Credentials.inc";
768
- include 'WsSecurity.inc';
769
-
770
- $theMethodName = 'ping';
771
-
772
- $client = new SoapClient($wsdl, array("trace" => 0, "exceptions" => 0));
773
-
774
- $result = $client->__soapCall($theMethodName, array("" => ""), null, $secHeader );
775
-
776
- $this->CheckResult($result);
777
-
778
- return $result;
779
- }
780
-
781
- function ResolveAddress($Address)
782
- {
783
- include "Credentials.inc";
784
- include 'WsSecurity.inc';
785
-
786
- $argumentsList = array ('Address'=> $Address);
787
-
788
- $theMethodName = 'resolveAddress';
789
- $theMethodSignature = CreateMethodSignature('resolveAddress', $argumentsList);
790
-
791
- $client = new SoapClient($wsdl, array("trace" => 0, "exceptions" => 0));
792
-
793
- $result = $client->__soapCall($theMethodName, $theMethodSignature, null, $secHeader );
794
-
795
- $this->CheckResult($result);
796
-
797
- return $result;
798
- }
799
-
800
- function CalculateInvoice($Invoice)
801
- {
802
- return $this->CalculateOrPostInvoice($Invoice, false);
803
- }
804
-
805
- function PostInvoice($Invoice)
806
- {
807
- return $this->CalculateOrPostInvoice($Invoice, true);
808
- }
809
-
810
- function PostInvoices($InvoiceNumbers)
811
- {
812
- include "Credentials.inc";
813
- include 'WsSecurity.inc';
814
-
815
- $argumentsList = array ('CompanyId'=> $company, 'InvoiceNumbers'=> $InvoiceNumbers);
816
-
817
- $theMethodName = 'postInvoices';
818
-
819
- $theMethodSignature = CreateMethodSignature($theMethodName, $argumentsList);
820
-
821
- // Need special client due to <SOAP-ENC:Struct> bug in PHP/SOAP when encoding arrays.
822
- $client = new STSoapClient($wsdl, array("trace" => 1, "exceptions" => 0));
823
-
824
- $result = $client->__soapCall($theMethodName, $theMethodSignature, null, $secHeader );
825
-
826
- $this->CheckResult($result);
827
-
828
- return $result;
829
- }
830
-
831
- function CalculateOrPostInvoice($Invoice, $post)
832
- {
833
- include "Credentials.inc";
834
- include 'WsSecurity.inc';
835
-
836
- $argumentsList = array ('CompanyId'=> $company, 'Invoice'=> $Invoice);
837
-
838
- if ($post)
839
- {
840
- $theMethodName = 'postInvoice';
841
- }
842
- else
843
- {
844
- $theMethodName = 'calculateInvoice';
845
- }
846
-
847
- $theMethodSignature = CreateMethodSignature($theMethodName, $argumentsList);
848
-
849
- // Need special client due to <SOAP-ENC:Struct> bug in PHP/SOAP when encoding arrays.
850
- $client = new STSoapClient($wsdl, array("trace" => 1, "exceptions" => 0));
851
-
852
- $result = $client->__soapCall($theMethodName, $theMethodSignature, null, $secHeader );
853
-
854
- $this->CheckResult($result);
855
-
856
- return $result;
857
- }
858
-
859
- function VoidInvoice($InvoiceNumber)
860
- {
861
- include "Credentials.inc";
862
- include 'WsSecurity.inc';
863
-
864
- $argumentsList = array ('CompanyId'=> $company, 'InvoiceNumber'=> $InvoiceNumber);
865
-
866
- $theMethodName = 'voidInvoice';
867
-
868
- $theMethodSignature = CreateMethodSignature($theMethodName, $argumentsList);
869
-
870
- // Need special client due to <SOAP-ENC:Struct> bug in PHP/SOAP when encoding arrays.
871
- $client = new STSoapClient($wsdl, array("trace" => 1, "exceptions" => 0));
872
-
873
- $result = $client->__soapCall($theMethodName, $theMethodSignature, null, $secHeader );
874
-
875
- $this->CheckResult($result);
876
-
877
- return $result;
878
- }
879
-
880
- function CreateCustomer($Customer)
881
- {
882
- include "Credentials.inc";
883
- include 'WsSecurity.inc';
884
-
885
- $argumentsList = array ('CompanyId'=> $company, 'Customer'=> $Customer);
886
-
887
- $theMethodName = 'createCustomer';
888
- $theMethodSignature = CreateMethodSignature('createCustomer', $argumentsList);
889
-
890
- //dbgprint("XML Request:\n");
891
- //print_r($theMethodSignature);
892
-
893
- $client = new SoapClient($wsdl, array("trace" => 0, "exceptions" => 0));
894
-
895
- $result = $client->__soapCall($theMethodName, $theMethodSignature, null, $secHeader );
896
-
897
- $this->CheckResult($result);
898
-
899
- return $result;
900
- }
901
-
902
- function EditCustomer($Customer)
903
- {
904
- include "Credentials.inc";
905
- include 'WsSecurity.inc';
906
-
907
- $argumentsList = array ('CompanyId'=> $company, 'Customer'=> $Customer);
908
-
909
- $theMethodName = 'editCustomer';
910
- $theMethodSignature = CreateMethodSignature('editCustomer', $argumentsList);
911
-
912
- $client = new SoapClient($wsdl, array("trace" => 0, "exceptions" => 0));
913
-
914
- $result = $client->__soapCall($theMethodName, $theMethodSignature, null, $secHeader );
915
-
916
- $this->CheckResult($result);
917
-
918
- return $result;
919
- }
920
-
921
- function CreateExemption($ExemptionCertificate)
922
- {
923
- include "Credentials.inc";
924
- include 'WsSecurity.inc';
925
-
926
- $argumentsList = array ('CompanyId'=> $company, 'Exemption'=> $ExemptionCertificate);
927
-
928
- $theMethodName = 'createExemption';
929
- $theMethodSignature = CreateMethodSignature('createExemption', $argumentsList);
930
-
931
- //dbgprint("XML Request:\n");
932
- //print_r($theMethodSignature);
933
-
934
- $client = new SoapClient($wsdl, array("trace" => 0, "exceptions" => 0));
935
-
936
- $result = $client->__soapCall($theMethodName, $theMethodSignature, null, $secHeader );
937
-
938
- $this->CheckResult($result);
939
-
940
- return $result;
941
- }
942
-
943
- function EditExemption($ExemptionCertificate)
944
- {
945
- include "Credentials.inc";
946
- include 'WsSecurity.inc';
947
-
948
- $argumentsList = array ('CompanyId'=> $company, 'Exemption'=> $ExemptionCertificate);
949
-
950
- $theMethodName = 'editExemption';
951
- $theMethodSignature = CreateMethodSignature('editExemption', $argumentsList);
952
-
953
- $client = new SoapClient($wsdl, array("trace" => 0, "exceptions" => 0));
954
-
955
- $result = $client->__soapCall($theMethodName, $theMethodSignature, null, $secHeader );
956
-
957
- $this->CheckResult($result);
958
-
959
- return $result;
960
- }
961
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/Harapartners/SpeedTax/lib/SpeedTaxUtil.inc DELETED
@@ -1,261 +0,0 @@
1
- <?php
2
- // *******************************************************************
3
- // * *
4
- // * *** UTIL FUNCTION *** *
5
- // * *
6
- // *******************************************************************
7
-
8
- //
9
- // All output is formatted for the console, not for a web page
10
- //
11
-
12
- function STLog($text)
13
- {
14
- $myFile = "phplog.txt";
15
- $fh = fopen($myFile, 'w') or die("can't open file");
16
- fwrite($fh, $text);
17
- fclose($fh);
18
- }
19
-
20
- function DisplayInvoiceResult($result)
21
- {
22
-
23
- foreach ($result as $name => $value)
24
- {
25
- switch ($name)
26
- {
27
- case 'resultType':
28
- print "Result............: " . $value . "\n";
29
- break;
30
- case 'lineItemBundles':
31
- print "Line Item Bundle:\n";
32
- DisplayInvoiceBundle($value);
33
- break;
34
- case 'totalExemptSales':
35
- print "Total Exempt Sales: $" . number_format($value->decimalValue, 2) . "\n";
36
- break;
37
- case 'totalSales':
38
- print "Total Sales.......: $" . number_format($value->decimalValue, 2) . "\n";
39
- break;
40
- case 'totalTax':
41
- print "Total Tax.........: $" . number_format($value->decimalValue, 2) . "\n";
42
- break;
43
- }
44
- }
45
- }
46
-
47
- /*
48
- This function might receive one single bundle or an array of bundles
49
- */
50
- function DisplayInvoiceBundle($bundle)
51
- {
52
- if (is_array($bundle))
53
- {
54
- foreach ($bundle as $value)
55
- {
56
- DisplayOneInvoiceBundle($value);
57
- }
58
- }
59
- else
60
- {
61
- DisplayOneInvoiceBundle($bundle);
62
- }
63
- }
64
-
65
- function DisplayOneInvoiceBundle($value)
66
- {
67
- print " Address for Tax:\n";
68
- DisplayFullAddress($value->addressForTax, " ");
69
- print " Line Item:\n";
70
- DisplayLineItem($value->lineItems);
71
- print " Recalculated Jurisdictions: " . $value->recalculatedJurisdictions . "\n";
72
- print " Result Type: " . $value->resultType . "\n";
73
- print " Taxes: \n";
74
-
75
- if (isset($value->taxes))
76
- {
77
- DisplayTaxes($value->taxes);
78
- }
79
- }
80
-
81
- function DisplayLineItem($item)
82
- {
83
- // We might get one line item or an array of line items. Use recursion to simplify.
84
- // This is a different path than the one used for line item bundles, which defines
85
- // a separate function
86
- if (is_array($item))
87
- {
88
- foreach ($item as $value)
89
- {
90
- DisplayLineItem($value);
91
- }
92
- }
93
- else
94
- {
95
- foreach ($item as $name => $value)
96
- {
97
- switch ($name)
98
- {
99
- case 'lineItemNumber':
100
- print " Line Item Number: " . $value . "\n";
101
- break;
102
- case 'customReference':
103
- print " Custom Reference: " . $value . "\n";
104
- break;
105
- case 'productCode':
106
- print " Product Code....: " . $value . "\n";
107
- break;
108
- case 'taxAmount':
109
- print " Tax.............: $" . DisplayAmount($value) . "\n";
110
- break;
111
- case 'salesAmount':
112
- print " Sales Amount....: $" . DisplayAmount($value) . "\n";
113
- break;
114
- case 'nonTaxableSalesAmount':
115
- print " Non-Tax. Amt....: $" . DisplayAmount($value) . "\n";
116
- break;
117
- case 'taxableSalesAmount':
118
- print " Taxable Amt.....: $" . DisplayAmount($value) . "\n";
119
- break;
120
- case 'taxes':
121
- print " Line Item Tax Breakdown:\n";
122
- DisplayTaxes($value);
123
- break;
124
- default:
125
- //print $name . "\n";
126
- break;
127
- }
128
- }
129
- }
130
- print " --------\n";
131
- }
132
-
133
- function DisplayTaxes($value)
134
- {
135
- if (!isset($value))
136
- {
137
- return;
138
- }
139
-
140
- if (is_array($value))
141
- {
142
- foreach($value as $tax)
143
- {
144
- DisplayTaxes($tax);
145
- //print " " . $tax->jurisdictionName . " (" . $tax->jurisdictionFips . "): $" . DisplayAmount($tax->totalTax) . "\n";
146
- }
147
- }
148
- else
149
- {
150
- $tax = $value; // There was only one tax, so $value is not an array but rather the specific tax object.
151
- print " " . $tax->jurisdictionName . " (" . $tax->jurisdictionFips . "): $" . DisplayAmount($tax->totalTax) . "\n";
152
- }
153
-
154
- }
155
-
156
- function DisplayAmount($value)
157
- {
158
-
159
- if (isset($value->decimalValue))
160
- {
161
- $amt = $value->decimalValue;
162
- }
163
- else
164
- {
165
- $amt = 0;
166
-
167
- if (isset($value->dollars))
168
- {
169
- $amt = $value->dollars;
170
- }
171
- if (isset($value->cents))
172
- {
173
- $amt = $amt + ($value->cents / 100);
174
- }
175
- }
176
-
177
- return number_format($amt, 2);
178
- }
179
-
180
- function DisplayFullAddress($fullAddress, $prefix)
181
- {
182
- if (isset($prefix)) print $prefix;
183
- print $fullAddress->address . "\n";
184
-
185
- if (isset($prefix)) print $prefix;
186
- print $fullAddress->city . ", " . $fullAddress->state . " " . $fullAddress->zip . "\n";
187
- }
188
-
189
- function DisplayJurisdictions($jurisdictions)
190
- {
191
- foreach($jurisdictions as $j)
192
- {
193
- print $j->jurisdictionName . " (" . $j->jurisdictionFips . ")\n";
194
- }
195
- }
196
-
197
- function DisplayErrors($errors)
198
- {
199
- if (is_array($errors))
200
- {
201
- foreach($errors as $e)
202
- {
203
- DisplayErrors($e);
204
- }
205
- }
206
- else
207
- {
208
- print $errors . "\n";
209
- }
210
- }
211
-
212
- function DisplayInvoice($invoice)
213
- {
214
- foreach ($invoice as $name => $value)
215
- {
216
- //print "Name" . $name . ": ";
217
- //print_r ($value);
218
-
219
- switch ($name)
220
- {
221
- case 'customerIdentifier':
222
- print 'customerIdentifier..: ' . $value . "\n";
223
- break;
224
- case 'customerName':
225
- print 'customerName........: ' . $value . "\n";
226
- break;
227
- case 'exempt':
228
- print 'exempt..............: ' . $value . "\n";
229
- break;
230
- case 'exemptionCertificate':
231
- print 'exemptionCertificate: ' . $value . "\n";
232
- break;
233
- case 'exemptionReason':
234
- print 'exemptionReason.....: ' . $value . "\n";
235
- break;
236
- case 'invoiceDate':
237
- print 'invoiceDate.........: ' . $value . "\n";
238
- break;
239
- case 'invoiceNumber':
240
- print 'invoiceNumber.......: ' . $value . "\n";
241
- break;
242
- case 'invoiceType':
243
- print 'invoiceType.........: ' . $value . "\n";
244
- break;
245
- //case 'lineItems':
246
- // print "Line Items:\n";
247
- // DisplayLineItem($value);
248
- // break;
249
- default:
250
- //print $name . " = " . $value;
251
- break;
252
- }
253
- }
254
-
255
- print "Line Items:\n";
256
-
257
- foreach ($invoice->lineItems as $name => $value)
258
- {
259
- DisplayLineItem($value);
260
- }
261
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/Harapartners/SpeedTax/lib/WsSecurity.inc DELETED
@@ -1,29 +0,0 @@
1
- <?php
2
-
3
- // Inspired by https://www6.software.ibm.com/developerworks/education/ws-soa-callsecurephp/ws-soa-callsecurephp-pdf.pdf
4
-
5
- //2009-04-07T16:04:49Z
6
- $utcCreated = str_replace("+00:00", "Z", gmdate("c", time()));
7
- $utcExpires = str_replace("+00:00", "Z", gmdate("c", (time() + 60*2)));
8
-
9
- $nsWsse = "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"; //WS-Security nsWsse
10
- $nsWsu = "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd";
11
- $nsTypeText = "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText";
12
-
13
- $userT = new SoapVar($username, XSD_STRING, NULL, $nsWsse, NULL, $nsWsse);
14
- $passwT = new SoapVar($password, XSD_STRING, NULL, $nsWsse, NULL, $nsWsse);
15
- $nonceT = new SoapVar('wh66ztc4ZaCn2SFMpKDY/w==', XSD_STRING, NULL, $nsWsse, NULL, $nsWsse);
16
-
17
- $createdT = new SoapVar($utcCreated, XSD_STRING, NULL, $nsWsu, NULL, $nsWsu);
18
- $expiresT = new SoapVar($utcExpires, XSD_STRING, NULL, $nsWsu, NULL, $nsWsu);
19
- $ts = new SOAPTimestamp($createdT, $expiresT);
20
- $timestampT = new SoapVar($ts, SOAP_ENC_OBJECT, NULL, $nsWsu, NULL, $nsWsu);
21
-
22
- $tmp = new UsernameT1($userT, $passwT, $nonceT, $createdT);
23
- $uuT = new SoapVar($tmp, SOAP_ENC_OBJECT, NULL, $nsWsse, 'UsernameToken', $nsWsse);
24
-
25
- $tmp = new UsernameT2($timestampT, $uuT);
26
- $userToken = new SoapVar($tmp, SOAP_ENC_OBJECT, NULL, $nsWsse, 'UsernameToken', $nsWsse);
27
-
28
- $secHeaderValue=new SoapVar($userToken, SOAP_ENC_OBJECT, NULL, $nsWsse, 'Security', $nsWsse);
29
- $secHeader = new SoapHeader($nsWsse, 'Security', $secHeaderValue, true);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/Harapartners/SpeedTax/lib/WsSecurityTypes.inc DELETED
@@ -1,267 +0,0 @@
1
- <?php
2
- //include_once 'log.php';
3
-
4
- function dbgprint($text)
5
- {
6
- // Comment in/out line below to output debug info to stdout
7
- //print $text;
8
- }
9
-
10
- // Inspired by https://www6.software.ibm.com/developerworks/education/ws-soa-callsecurephp/ws-soa-callsecurephp-pdf.pdf
11
-
12
- class SOAPTimestamp {
13
- private $Created;
14
- private $Expires;
15
- function __construct($c, $e)
16
- {
17
- $this->Created = $c;
18
- $this->Expires = $e;
19
- }
20
- }
21
-
22
- class UsernameT1
23
- {
24
- private $Username; //Name must be identical to corresponding XML tag in SOAP header
25
- private $Password; // Name must be identical to corresponding XML tag in SOAP header
26
- private $Nonce;
27
- private $Created;
28
- function __construct($username, $password, $nonce, $created)
29
- {
30
- $this->Username=$username;
31
- $this->Password=$password;
32
- $this->Nonce=$nonce;
33
- $this->Created=$created;
34
- }
35
- }
36
-
37
- class UserNameT2
38
- {
39
- private $Timestamp;
40
- private $UsernameToken; //Name must be identical to corresponding XML tag in SOAP header
41
- function __construct ($ts, $ut)
42
- {
43
- $this->Timestamp = $ts;
44
- $this->UsernameToken = $ut;
45
- }
46
- }
47
-
48
- class STSoapClient extends SoapClient
49
- {
50
- function emptyNodeList($nodes)
51
- {
52
- if (is_null($nodes) || count($nodes) == 0)
53
- {
54
- return true;
55
- }
56
-
57
- foreach ($nodes as $node)
58
- {
59
- if ($node->textContent != "") return false;
60
- }
61
-
62
- return true;
63
- }
64
-
65
- function printNodeList($nodes)
66
- {
67
- print "NODES:\n";
68
- foreach ($nodes as $node) { print $node->textContent . " / "; }
69
- print "-------\n";
70
- }
71
-
72
- function __doRequest($request, $location, $action, $version, $one_way=0)
73
- {
74
- $dom = new DOMDocument('1.0');
75
-
76
- try
77
- {
78
- //loads the SOAP request to the Document
79
- $dom->loadXML($request);
80
- }
81
- catch (DOMException $e)
82
- {
83
- die('XML parse error with code ' . $e->code);
84
- }
85
-
86
- //create a XPath object to query the request
87
- $path = new DOMXPath($dom);
88
-
89
- //echo $request;
90
- $nodesPostInvoice = $path->query('//ns1:postInvoice');
91
- $nodesCalcInvoice = $path->query('//ns1:calculateInvoice');
92
-
93
- if (!$this->emptyNodeList($nodesCalcInvoice))
94
- {
95
- $mustFixLineItems = true;
96
- $method = 'calculateInvoice';
97
- }
98
- else if (!$this->emptyNodeList($nodesPostInvoice))
99
- {
100
- $mustFixLineItems = true;
101
- $method = 'postInvoice';
102
- }
103
- else
104
- {
105
- $mustFixLineItems = false;
106
- }
107
-
108
- if ($mustFixLineItems)
109
- {
110
- //search for a node
111
- $nodesToFix = $path->query('//SOAP-ENV:Envelope/SOAP-ENV:Body/ns1:' . $method . '/Invoice/lineItems/SOAP-ENC:Struct');
112
-
113
- //check if nodes are ok
114
- $this->fixLineItems($path, $nodesToFix);
115
- }
116
-
117
- //save the modified SOAP request
118
- $request = $dom->saveXML();
119
-
120
- //doRequest
121
- return parent::__doRequest($request, $location, $action, $version);
122
- }
123
-
124
- function fixLineItems(DOMXPath $path, DOMNodeList $nodes)
125
- {
126
- //iterate through the node list
127
- for ($i = 0; $i < $nodes->length; $i++)
128
- {
129
- $node = $nodes->item($i);
130
-
131
- if (!isset($grandparentNode))
132
- {
133
- // All of these nodes have the same grandparent
134
- $parentNode = $node->parentNode;
135
- $grandparentNode = $node->parentNode->parentNode;
136
- }
137
-
138
- $newNodeName = $node->parentNode->nodeName;
139
-
140
- // Figure out who will hold the new items
141
-
142
- $newNode = new DOMElement($newNodeName);
143
- $grandparentNode->appendChild($newNode);
144
-
145
- $this->CopyNodes($node, $newNode);
146
- }
147
-
148
- // Remove the old SOAP-ENC:Struct container
149
- $grandparentNode->removeChild($parentNode);
150
-
151
- //print "Saving...";
152
- //$grandparentNode->ownerDocument->saveHTMLFile("C:\dev-integration\PhpApi\Fix.xml");
153
- //print "DONE\n";
154
- }
155
-
156
- function CopyNodes($oldParent, $newParent)
157
- {
158
- foreach ($oldParent->childNodes as $oldChildNode)
159
- {
160
- if ($oldChildNode->nodeType != 1)
161
- {
162
- continue;
163
- }
164
-
165
- $newChildNode = new DOMElement($oldChildNode->nodeName, $oldChildNode->nodeValue);
166
-
167
- $newParent->appendChild($newChildNode);
168
-
169
- if ($oldChildNode->hasChildNodes())
170
- {
171
- $this->CopyNodes($oldChildNode, $newChildNode);
172
- }
173
- }
174
-
175
- }
176
-
177
- function __doRequest__OLD($request, $location, $action, $version)
178
- {
179
- $arrayToFix = 'lineItems';
180
-
181
- $request = str_replace('</SOAP-ENC:Struct><SOAP-ENC:Struct>', '</' . $arrayToFix . '><' . $arrayToFix . '>', $request);
182
- $request = str_replace('<SOAP-ENC:Struct>', '', $request);
183
- $request = str_replace('</SOAP-ENC:Struct>', '', $request);
184
-
185
- // parent call
186
- return parent::__doRequest($request, $location, $action, $version );
187
- }
188
- }
189
-
190
- function createMethodSignature($theMethod, $paramAr)
191
- {
192
- if (null == $paramAr)
193
- return array($theMethod =>null);
194
- $used = null;
195
- dbgprint("[CMS] processing $theMethod\n");
196
- foreach ($paramAr as $name => $value)
197
- {
198
- if (is_array($value) || is_object($value))
199
- {
200
- dbgprint("[CMS] $name is an object or array\n");
201
- $used[$name] = createMixedValueSignature($value);
202
- }
203
- else
204
- {
205
- dbgprint("[CMS] $name = $value\n");
206
- $used[$name] = $value;
207
- }
208
- }
209
- return array($theMethod =>$used);
210
- }
211
-
212
- //---------------------------------------------------------------------
213
- // inner routine: packing an inner complex parameter into a SOAP-valid representation
214
- function createMixedValueSignature($MixedVals)
215
- {
216
- $mixedParamsList = null;
217
- if (is_object($MixedVals))
218
- {
219
- dbgprint("[CMVS] got an object\n");
220
- foreach ($MixedVals as $name => $value)
221
- {
222
- if (is_object($value) || is_array($value))
223
- {
224
- dbgprint("[CMVS] $name is an object or array\n");
225
- $mixedParamsList->$name = createMixedValueSignature($value);
226
- }
227
- else
228
- {
229
- if (isset($value))
230
- {
231
- dbgprint("[CMVS] $name = $value\n");
232
- $mixedParamsList->$name = $value;
233
- }
234
- }
235
- }
236
- // an object needs to be passed as SoapVar
237
- return new SoapVar($mixedParamsList, SOAP_ENC_OBJECT , NULL, NULL);
238
- }
239
- else
240
- { // an array
241
- dbgprint("[CMVS] got an array\n");
242
-
243
- foreach ($MixedVals as $name => $value)
244
- {
245
- if (is_object($value) || is_array($value))
246
- {
247
- dbgprint("[CMVS] $name is an object or array\n");
248
- $mixedParamsList[$name] = createMixedValueSignature($value);
249
- }
250
- else
251
- {
252
- //die ("Array Element: " . $name . "=" . $value);
253
- if (isset($value))
254
- {
255
- dbgprint("[CMVS] $name = $value\n");
256
- $mixedParamsList[$name] = $value;
257
- }
258
- }
259
- }
260
- // an array is passed as is !!
261
- return $mixedParamsList;
262
- // EJ: Or as SOAP_ENC_ARRAY?
263
- //print "DEBUG: Encoding array\n";
264
- //print_r($mixedParamsList);
265
- //return new SoapVar($mixedParamsList, SOAP_ENC_ARRAY);
266
- }
267
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/Harapartners/SpeedTax/sql/speedtax_setup/mysql4-install-2.0.0.php DELETED
@@ -1,30 +0,0 @@
1
- <?php
2
- // copyright notice
3
- $RxQgNcbf = $this; $RxQgNcbf->startSetup(); $RxQgNcbf->run("
4
-
5
- DROP TABLE IF EXISTS {$this->getTable('speedtax_log/error')};
6
- CREATE TABLE {$this->getTable('speedtax_log/error')} (
7
- `log_id` int(10) unsigned NOT NULL auto_increment,
8
- `event` varchar(255) NOT NULL default '',
9
- `message` text NOT NULL default '',
10
- `result_type` varchar(255) NOT NULL default '',
11
- `address_shipping_from` text NOT NULL default '',
12
- `address_shipping_to` text NOT NULL default '',
13
- `customer_name` varchar(255) NOT NULL default '',
14
- `created_at` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
15
- PRIMARY KEY (`log_id`)
16
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Speedtax Error Log';
17
- "); $RxQgNcbf->run("
18
- DROP TABLE IF EXISTS {$this->getTable('speedtax_log/call')};
19
- CREATE TABLE {$this->getTable('speedtax_log/call')} (
20
- `log_id` int(10) unsigned NOT NULL auto_increment,
21
- `event` varchar(255) NOT NULL default '',
22
- `result_type` varchar(255) NOT NULL default '',
23
- `invoice_num` varchar(255) NOT NULL default '',
24
- `gross` varchar(255) NOT NULL default '',
25
- `exempt` varchar(255) NOT NULL default '',
26
- `tax` varchar(255) NOT NULL default '',
27
- `created_at` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
28
- PRIMARY KEY (`log_id`)
29
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Speedtax Call Log';
30
- "); $RxQgNcbf->endSetup();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/Harapartners/SpeedTax/sql/speedtax_setup/mysql4-upgrade-3.0.9-3.1.0.php ADDED
@@ -0,0 +1,126 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * NOTICE OF LICENSE
4
+ *
5
+ * This source file is subject to the End User Software Agreement (EULA).
6
+ * It is also available through the world-wide-web at this URL:
7
+ * http://www.harapartners.com/license [^]
8
+ * If you did not receive a copy of the license and are unable to
9
+ * obtain it through the world-wide-web, please send an email
10
+ * to eula@harapartners.com so we can send you a copy immediately.
11
+ *
12
+ */
13
+ $installer = $this;
14
+ $installer->startSetup();
15
+
16
+ $speedTaxTransactionIdColumnName = 'speedtax_transaction_id';
17
+ $speedtaxInvoiceNumberColumnName = 'speedtax_invoice_number';
18
+ $speedtaxInvoiceStatusColumnName = 'speedtax_invoice_status';
19
+ $connectionConfig = $installer->getConnection()->getConfig();
20
+
21
+ // ================ Invoice ================ //
22
+ $testQuery = "
23
+ SELECT * FROM information_schema.COLUMNS
24
+ WHERE column_name='$speedtaxInvoiceNumberColumnName'
25
+ AND table_name='{$this->getTable('sales/invoice')}'
26
+ AND table_schema='{$connectionConfig['dbname']}'
27
+ ";
28
+ if(!!$installer->getConnection()->fetchAll($testQuery)){
29
+ $installer->run("
30
+ ALTER TABLE `{$this->getTable('sales/invoice')}`
31
+ DROP COLUMN `$speedtaxInvoiceNumberColumnName`;
32
+ ");
33
+ }
34
+ $installer->run("
35
+ ALTER TABLE `{$this->getTable('sales/invoice')}`
36
+ ADD COLUMN `$speedtaxInvoiceNumberColumnName` varchar(255);
37
+ ");
38
+
39
+ $testQuery = "
40
+ SELECT * FROM information_schema.COLUMNS
41
+ WHERE column_name='$speedtaxInvoiceStatusColumnName'
42
+ AND table_name='{$this->getTable('sales/invoice')}'
43
+ AND table_schema='{$connectionConfig['dbname']}'
44
+ ";
45
+ if(!!$installer->getConnection()->fetchAll($testQuery)){
46
+ $installer->run("
47
+ ALTER TABLE `{$this->getTable('sales/invoice')}`
48
+ DROP COLUMN `$speedtaxInvoiceStatusColumnName`;
49
+ ");
50
+ }
51
+ $installer->run("
52
+ ALTER TABLE `{$this->getTable('sales/invoice')}`
53
+ ADD COLUMN `$speedtaxInvoiceStatusColumnName` SMALLINT(5) DEFAULT 0;
54
+ ");
55
+
56
+ $testQuery = "
57
+ SELECT * FROM information_schema.COLUMNS
58
+ WHERE column_name='$speedTaxTransactionIdColumnName'
59
+ AND table_name='{$this->getTable('sales/invoice')}'
60
+ AND table_schema='{$connectionConfig['dbname']}'
61
+ ";
62
+ if(!!$installer->getConnection()->fetchAll($testQuery)){
63
+ $installer->run("
64
+ ALTER TABLE `{$this->getTable('sales/invoice')}`
65
+ DROP COLUMN `$speedTaxTransactionIdColumnName`;
66
+ ");
67
+ }
68
+ $installer->run("
69
+ ALTER TABLE `{$this->getTable('sales/invoice')}`
70
+ ADD COLUMN `$speedTaxTransactionIdColumnName` varchar(255);
71
+ ");
72
+
73
+
74
+ // ================ Credit Memo ================ //
75
+ $testQuery = "
76
+ SELECT * FROM information_schema.COLUMNS
77
+ WHERE column_name='$speedtaxInvoiceNumberColumnName'
78
+ AND table_name='{$this->getTable('sales/creditmemo')}'
79
+ AND table_schema='{$connectionConfig['dbname']}'
80
+ ";
81
+ if(!!$installer->getConnection()->fetchAll($testQuery)){
82
+ $installer->run("
83
+ ALTER TABLE `{$this->getTable('sales/creditmemo')}`
84
+ DROP COLUMN `$speedtaxInvoiceNumberColumnName`;
85
+ ");
86
+ }
87
+ $installer->run("
88
+ ALTER TABLE `{$this->getTable('sales/creditmemo')}`
89
+ ADD COLUMN `$speedtaxInvoiceNumberColumnName` varchar(255);
90
+ ");
91
+
92
+ $testQuery = "
93
+ SELECT * FROM information_schema.COLUMNS
94
+ WHERE column_name='$speedtaxInvoiceStatusColumnName'
95
+ AND table_name='{$this->getTable('sales/creditmemo')}'
96
+ AND table_schema='{$connectionConfig['dbname']}'
97
+ ";
98
+ if(!!$installer->getConnection()->fetchAll($testQuery)){
99
+ $installer->run("
100
+ ALTER TABLE `{$this->getTable('sales/creditmemo')}`
101
+ DROP COLUMN `$speedtaxInvoiceStatusColumnName`;
102
+ ");
103
+ }
104
+ $installer->run("
105
+ ALTER TABLE `{$this->getTable('sales/creditmemo')}`
106
+ ADD COLUMN `$speedtaxInvoiceStatusColumnName` SMALLINT(5) DEFAULT 0;
107
+ ");
108
+
109
+ $testQuery = "
110
+ SELECT * FROM information_schema.COLUMNS
111
+ WHERE column_name='$speedTaxTransactionIdColumnName'
112
+ AND table_name='{$this->getTable('sales/creditmemo')}'
113
+ AND table_schema='{$connectionConfig['dbname']}'
114
+ ";
115
+ if(!!$installer->getConnection()->fetchAll($testQuery)){
116
+ $installer->run("
117
+ ALTER TABLE `{$this->getTable('sales/creditmemo')}`
118
+ DROP COLUMN `$speedTaxTransactionIdColumnName`;
119
+ ");
120
+ }
121
+ $installer->run("
122
+ ALTER TABLE `{$this->getTable('sales/creditmemo')}`
123
+ ADD COLUMN `$speedTaxTransactionIdColumnName` varchar(255);
124
+ ");
125
+
126
+ $installer->endSetup();
app/etc/modules/Harapartners_SpeedTax.xml CHANGED
@@ -12,8 +12,6 @@
12
  *
13
  */
14
  -->
15
-
16
-
17
  <config>
18
  <modules>
19
  <Harapartners_SpeedTax>
12
  *
13
  */
14
  -->
 
 
15
  <config>
16
  <modules>
17
  <Harapartners_SpeedTax>
package.xml CHANGED
@@ -1,18 +1,18 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>SalesTax_Connector</name>
4
- <version>2.0.3</version>
5
  <stability>stable</stability>
6
  <license uri="http://www.harapartners.com/terms/eula">Hara Partners End User License Agreement</license>
7
  <channel>community</channel>
8
  <extends/>
9
- <summary>Simplify sales and use tax calculation, compliance, and management in the cloud! </summary>
10
- <description>Simplify sales and use tax calculation, compliance, and management in the cloud! </description>
11
- <notes>Simplify sales and use tax calculation, compliance, and management in the cloud! </notes>
12
- <authors><author><name>Hara Partners</name><user>merne</user><email>m.erne@harapartners.com</email></author><author><name>CCH</name><user>kennuneswo</user><email>Ken.nunes@wolterskluwer.com</email></author></authors>
13
- <date>2013-09-18</date>
14
- <time>16:13:42</time>
15
- <contents><target name="magelocal"><dir name="Harapartners"><dir name="SpeedTax"><dir name="Block"><dir name="Adminhtml"><dir name="Log"><dir name="Call"><dir name="Index"><file name="Grid.php" hash="f5618eaf2e2d709ae3b6a0a8d0c5e26c"/></dir><file name="Index.php" hash="2fefd8950baedff7afe5918c3faaee1c"/></dir><dir name="Error"><dir name="Index"><file name="Grid.php" hash="bb9f859951b00f77a17dc8662b3fd892"/></dir><file name="Index.php" hash="e496698d7dec494b0f8b4a16f7cdefea"/></dir></dir><dir name="System"><dir name="Config"><dir name="Form"><dir name="Field"><file name="Export.php" hash="7a85e63fac4d5788bfea19e267143f9c"/><file name="Ping.php" hash="12bd038a370a5a66a1c192ec5b0ea6ba"/></dir></dir></dir></dir></dir><dir name="Checkout"><dir name="Onepage"><dir name="Shipping"><dir name="Method"><file name="Available.php" hash="74b6cbcbb96e7aa6a3389a0350d2f9e4"/></dir></dir></dir></dir></dir><dir name="Helper"><file name="Data.php" hash="1e0d91aa6f7ba2e097472abee0958819"/></dir><dir name="Model"><file name="Abstract.php" hash="4786fe87c5df1dcf550e00db9dc65cc2"/><dir name="Adminhtml"><file name="Usregions.php" hash="752d63e7f98c1f13f45d78ed3ed6e0dd"/></dir><dir name="Checkout"><dir name="Type"><file name="Multishipping.php" hash="31ae6e63b98c5769c0821d5a8b69db1e"/></dir></dir><dir name="Log"><file name="Call.php" hash="f9c0315e3434e5e22d62948a5d7f1019"/><file name="Error.php" hash="d226a61f729ae306087a3763900e2b24"/><dir name="Mysql4"><dir name="Call"><file name="Collection.php" hash="9ccaad9f4ad2a1094909242697b8f8cc"/></dir><file name="Call.php" hash="b5131d37b891334f6de52f2ce8aeb2c1"/><dir name="Error"><file name="Collection.php" hash="9c0aec9f9f264b362125c06aea39db40"/></dir><file name="Error.php" hash="19098cb2ec201995e69ce424653d5305"/></dir></dir><file name="Log.php" hash="35ed4e2d434b585ffe246bb3ccedde20"/><file name="Observer.php" hash="eeb25ecc16524ddae3fb040dce61061a"/><dir name="Sales"><dir name="Quote"><file name="Address.php" hash="d19a8a400b0edd9cd5b865b0b5d33900"/></dir></dir><file name="Session.php" hash="18dbd1fb0587b2e77a8a5170b0767a4b"/><dir name="Speedtax"><file name="Abstract.php" hash="6d26f045e2ea9bcc519f51a31ca77984"/><file name="Address.php" hash="03fdb75262dcaebc9f4e20e9f4060fc1"/><file name="Calculate.php" hash="8dbaab26e8b9989ea58fb5b2d51d8e0b"/><dir name="Exception"><file name="Address.php" hash="eabd6aed66be72f0142e9af9ffaa41db"/></dir></dir><dir name="Tax"><dir name="Sales"><dir name="Total"><dir name="Quote"><file name="Tax.php" hash="f1f44928ee4839b51e447f62540c69cf"/></dir></dir></dir></dir></dir><dir name="controllers"><dir name="Adminhtml"><dir name="Log"><file name="CallController.php" hash="b0ec16c9193bbefa6de9d5c5e8affaa5"/><file name="ErrorController.php" hash="8cf682c0baac7084becfae36bc6f124f"/></dir><file name="PingController.php" hash="94d141461a7201e89c307aa8e5fb6db0"/></dir></dir><dir name="etc"><file name="config.xml" hash="9d9a69f9cdb22bb4bce22f65fd5ce242"/><file name="system.xml" hash="10e9a436a1686d429e79405197f1c810"/></dir><dir name="lib"><file name="Credentials.inc" hash="7db7fb156809ab3f543e71b652c9bf18"/><file name="SpeedTaxApi.inc" hash="b571586a9bfa36c91928a39d6970f380"/><file name="SpeedTaxUtil.inc" hash="72dd5bd665e4ef2c622c7b32bb39ab27"/><file name="WsSecurity.inc" hash="1e36901cbba973a0f4bcf48d312229ad"/><file name="WsSecurityTypes.inc" hash="e3c7ffc72d8af5949b4649abda8af561"/></dir><dir name="sql"><dir name="speedtax_setup"><file name="mysql4-install-2.0.0.php" hash="78e56870b919228ca5ddfae4bbd86c91"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Harapartners_SpeedTax.xml" hash="d74e47ceb88fcfa041d16a1e2e6d0b2a"/></dir></target></contents>
16
  <compatible/>
17
- <dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php></required></dependencies>
18
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>SalesTax_Connector</name>
4
+ <version>3.0.2</version>
5
  <stability>stable</stability>
6
  <license uri="http://www.harapartners.com/terms/eula">Hara Partners End User License Agreement</license>
7
  <channel>community</channel>
8
  <extends/>
9
+ <summary>Simplify sales and use tax calculation, compliance, and management in the cloud!</summary>
10
+ <description>Simplify sales and use tax calculation, compliance, and management in the cloud!</description>
11
+ <notes>Simplify sales and use tax calculation, compliance, and management in the cloud!</notes>
12
+ <authors><author><name>Ken Nunes</name><user>auto-converted</user><email>Ken.nunes@wolterskluwer.com</email></author></authors>
13
+ <date>2013-11-22</date>
14
+ <time>22:06:38</time>
15
+ <contents><target name="magelocal"><dir name="Harapartners"><dir name="SpeedTax"><dir name="Block"><dir name="Adminhtml"><dir name="Log"><dir name="Call"><dir name="Index"><file name="Grid.php" hash="1a04029247da6e5eb7bcab9dd7b8ac18"/></dir><file name="Index.php" hash="a81b9895cbdf9cf915fef9489031d9fb"/></dir><dir name="Error"><dir name="Index"><file name="Grid.php" hash="395b866ff9a8ab25a8615c9ce1cde98f"/></dir><file name="Index.php" hash="6de57981cacdc5eccf732f00f6377609"/></dir></dir><dir name="System"><dir name="Config"><dir name="Form"><dir name="Field"><file name="Authentication.php" hash="bb8b61507f1e40605233028d4dae4a12"/><file name="Export.php" hash="b1174b3055b9b1318357f5ad39c0e69e"/></dir></dir></dir></dir></dir></dir><dir name="controllers"><dir name="Adminhtml"><dir name="System"><dir name="Config"><file name="AjaxController.php" hash="7d7390bd3e3e72b003fe0c58823e9aba"/></dir></dir></dir></dir><dir name="etc"><file name="config.xml" hash="0fe9450599252e4f9aae7c0bb6fa7932"/><file name="system.xml" hash="94a20e2ec18eda40a9df3d0aa6c938b4"/></dir><dir name="Helper"><dir name="Connector"><file name="Core.php" hash="4d0d3bcb8ac7b007fa011d63836f878a"/><file name="Data.php" hash="475aaa9ce2cd885586bf130a103a3476"/><file name="Speedtax.php" hash="3e4da8d9919d3b779126f75677c4fe74"/></dir><file name="Data.php" hash="4a3805bc334300c5b79afa89a3330be6"/><file name="Mcrypt.php" hash="4ab8f6de97497ad5efc9d8a03d694075"/><file name="Object.php" hash="284a0d90a92770df1ae52132f426b068"/><file name="Processor.php" hash="76b34394c8b4a1ced335d906532b85a9"/></dir><dir name="Model"><dir name="Rewrite"><dir name="Paypal"><dir name="Api"><file name="Nvp.php" hash="3c6c3776460a9613ae1f720ba4e60422"/></dir><file name="Config.php" hash="121faedf26116ab802f8d77b9079f8cd"/></dir><dir name="Tax"><dir name="Sales"><dir name="Total"><dir name="Quote"><file name="Tax.php" hash="c588f2b1fd32d4da9f6d4ee4729f80f6"/></dir></dir></dir></dir></dir><dir name="Source"><file name="Usregions.php" hash="2ab7713b5b46f142e133459952cd1ef5"/></dir><dir name="Speedtax"><dir name="Exception"><file name="Address.php" hash="d0c6aa00d10e555bfd05e84fc233d828"/></dir><file name="Calculate.php" hash="ce1dc7ccec32a67dee836c94e2b2556b"/></dir><file name="Observer.php" hash="609d1237bc2eddedeb629ed322540fc8"/><file name="Session.php" hash="46175fe01434d91757499d5c0f7f2bee"/></dir><dir name="sql"><dir name="speedtax_setup"><file name="mysql4-upgrade-3.0.9-3.1.0.php" hash="886b0ebdd5b0234b89fcff5fc07fbfd1"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Harapartners_SpeedTax.xml" hash="4e25b9cfbbb9568913aeb75dbae21b0d"/></dir></target></contents>
16
  <compatible/>
17
+ <dependencies/>
18
  </package>