SalesTax_Connector - Version 2.0.0

Version Notes

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

Download this release

Release Info

Developer Hara Partners
Extension SalesTax_Connector
Version 2.0.0
Comparing to
See all releases


Version 2.0.0

Files changed (39) hide show
  1. app/code/local/Harapartners/SpeedTax/Block/Adminhtml/Log/Call/Index.php +1 -0
  2. app/code/local/Harapartners/SpeedTax/Block/Adminhtml/Log/Call/Index/Grid.php +3 -0
  3. app/code/local/Harapartners/SpeedTax/Block/Adminhtml/Log/Error/Index.php +2 -0
  4. app/code/local/Harapartners/SpeedTax/Block/Adminhtml/Log/Error/Index/Grid.php +1 -0
  5. app/code/local/Harapartners/SpeedTax/Block/Adminhtml/System/Config/Form/Field/Export.php +3 -0
  6. app/code/local/Harapartners/SpeedTax/Block/Adminhtml/System/Config/Form/Field/Ping.php +3 -0
  7. app/code/local/Harapartners/SpeedTax/Block/Checkout/Onepage/Shipping/Method/Available.php +2 -0
  8. app/code/local/Harapartners/SpeedTax/Helper/Data.php +2 -0
  9. app/code/local/Harapartners/SpeedTax/Model/Abstract.php +3 -0
  10. app/code/local/Harapartners/SpeedTax/Model/Adminhtml/Usregions.php +3 -0
  11. app/code/local/Harapartners/SpeedTax/Model/Checkout/Type/Multishipping.php +3 -0
  12. app/code/local/Harapartners/SpeedTax/Model/Log.php +3 -0
  13. app/code/local/Harapartners/SpeedTax/Model/Log/Call.php +3 -0
  14. app/code/local/Harapartners/SpeedTax/Model/Log/Error.php +3 -0
  15. app/code/local/Harapartners/SpeedTax/Model/Log/Mysql4/Call.php +3 -0
  16. app/code/local/Harapartners/SpeedTax/Model/Log/Mysql4/Call/Collection.php +3 -0
  17. app/code/local/Harapartners/SpeedTax/Model/Log/Mysql4/Error.php +3 -0
  18. app/code/local/Harapartners/SpeedTax/Model/Log/Mysql4/Error/Collection.php +3 -0
  19. app/code/local/Harapartners/SpeedTax/Model/Observer.php +3 -0
  20. app/code/local/Harapartners/SpeedTax/Model/Sales/Quote/Address.php +3 -0
  21. app/code/local/Harapartners/SpeedTax/Model/Session.php +3 -0
  22. app/code/local/Harapartners/SpeedTax/Model/Speedtax/Abstract.php +3 -0
  23. app/code/local/Harapartners/SpeedTax/Model/Speedtax/Address.php +3 -0
  24. app/code/local/Harapartners/SpeedTax/Model/Speedtax/Calculate.php +3 -0
  25. app/code/local/Harapartners/SpeedTax/Model/Speedtax/Exception/Address.php +3 -0
  26. app/code/local/Harapartners/SpeedTax/Model/Tax/Sales/Total/Quote/Tax.php +3 -0
  27. app/code/local/Harapartners/SpeedTax/controllers/Adminhtml/Log/CallController.php +3 -0
  28. app/code/local/Harapartners/SpeedTax/controllers/Adminhtml/Log/ErrorController.php +4 -0
  29. app/code/local/Harapartners/SpeedTax/controllers/Adminhtml/PingController.php +3 -0
  30. app/code/local/Harapartners/SpeedTax/etc/config.xml +202 -0
  31. app/code/local/Harapartners/SpeedTax/etc/system.xml +180 -0
  32. app/code/local/Harapartners/SpeedTax/lib/Credentials.inc +25 -0
  33. app/code/local/Harapartners/SpeedTax/lib/SpeedTaxApi.inc +963 -0
  34. app/code/local/Harapartners/SpeedTax/lib/SpeedTaxUtil.inc +263 -0
  35. app/code/local/Harapartners/SpeedTax/lib/WsSecurity.inc +31 -0
  36. app/code/local/Harapartners/SpeedTax/lib/WsSecurityTypes.inc +269 -0
  37. app/code/local/Harapartners/SpeedTax/sql/speedtax_setup/mysql4-install-2.0.0.php +30 -0
  38. app/etc/modules/Harapartners_SpeedTax.xml +24 -0
  39. package.xml +18 -0
app/code/local/Harapartners/SpeedTax/Block/Adminhtml/Log/Call/Index.php ADDED
@@ -0,0 +1 @@
 
1
+ <?php 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(); } }
app/code/local/Harapartners/SpeedTax/Block/Adminhtml/Log/Call/Index/Grid.php ADDED
@@ -0,0 +1,3 @@
 
 
 
1
+ Copyright Notice
2
+
3
+ <?php 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() )); } }
app/code/local/Harapartners/SpeedTax/Block/Adminhtml/Log/Error/Index.php ADDED
@@ -0,0 +1,2 @@
 
 
1
+ copyright notice
2
+ <?php 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(); } }
app/code/local/Harapartners/SpeedTax/Block/Adminhtml/Log/Error/Index/Grid.php ADDED
@@ -0,0 +1 @@
 
1
+ <?php 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() )); } }
app/code/local/Harapartners/SpeedTax/Block/Adminhtml/System/Config/Form/Field/Export.php ADDED
@@ -0,0 +1,3 @@
 
 
 
1
+ copyright notice
2
+
3
+ <?php 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; } }
app/code/local/Harapartners/SpeedTax/Block/Adminhtml/System/Config/Form/Field/Ping.php ADDED
@@ -0,0 +1,3 @@
 
 
 
1
+ copyright notice
2
+
3
+ <?php 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 ADDED
@@ -0,0 +1,2 @@
 
 
1
+ copyright notice
2
+ <?php 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')->eBJLtuSo()){ $resolvedAddress = Mage::getSingleton('speedtax/session')->XDhpYuYI(); $RGQeeGcs = $resolvedAddress->address.", ".$resolvedAddress->city.", ".$resolvedAddress->state." ".$resolvedAddress->zip; } return $MapsTZNK . parent::_toHtml(); } }
app/code/local/Harapartners/SpeedTax/Helper/Data.php ADDED
@@ -0,0 +1,2 @@
 
 
1
+ copyright notice
2
+ <?php 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'; } }
app/code/local/Harapartners/SpeedTax/Model/Abstract.php ADDED
@@ -0,0 +1,3 @@
 
 
 
1
+ copyright notice
2
+
3
+ <?php 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 ADDED
@@ -0,0 +1,3 @@
 
 
 
1
+ copyright notice
2
+
3
+ <?php 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 ADDED
@@ -0,0 +1,3 @@
 
 
 
1
+ copyright notice
2
+
3
+ <?php 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 ADDED
@@ -0,0 +1,3 @@
 
 
 
1
+ copyright notice
2
+
3
+ <?php 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 ADDED
@@ -0,0 +1,3 @@
 
 
 
1
+ copyright notice
2
+
3
+ <?php 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 ADDED
@@ -0,0 +1,3 @@
 
 
 
1
+ copyright notice
2
+
3
+ <?php 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 ADDED
@@ -0,0 +1,3 @@
 
 
 
1
+ copyright notice
2
+
3
+ <?php 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 ADDED
@@ -0,0 +1,3 @@
 
 
 
1
+ copyright notice
2
+
3
+ <?php 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 ADDED
@@ -0,0 +1,3 @@
 
 
 
1
+ copyright notice
2
+
3
+ <?php 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 ADDED
@@ -0,0 +1,3 @@
 
 
 
1
+ copyright notice
2
+
3
+ <?php 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 ADDED
@@ -0,0 +1,3 @@
 
 
 
1
+ copyright notice
2
+
3
+ <?php class Harapartners_SpeedTax_Model_Observer extends Mage_Core_Model_Abstract { public function xHiquKGh(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 gPsRLtJr(Varien_Event_Observer $PdTkCJKp) { $sRLVBLYD = $PdTkCJKp->getEvent()->getCreditmemo(); try { $qNxaFjve = Mage::getModel ( 'speedtax/speedtax_calculate' ); $qNxaFjve->tvPiWdAy($sRLVBLYD); } catch( Exception $e ) { throw new $e; } } }
app/code/local/Harapartners/SpeedTax/Model/Sales/Quote/Address.php ADDED
@@ -0,0 +1,3 @@
 
 
 
1
+ copyright notice
2
+
3
+ <?php 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->vDDfhMmk() || $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 ADDED
@@ -0,0 +1,3 @@
 
 
 
1
+ copyright notice
2
+
3
+ <?php class Harapartners_SpeedTax_Model_Session extends Mage_Core_Model_Session_Abstract { public function __construct() { $this->init('speedtax'); } }
app/code/local/Harapartners/SpeedTax/Model/Speedtax/Abstract.php ADDED
@@ -0,0 +1,3 @@
 
 
 
1
+ copyright notice
2
+
3
+ <?php 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 ADDED
@@ -0,0 +1,3 @@
 
 
 
1
+ copyright notice
2
+
3
+ <?php 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')->yqwVhAAT(true); break; case 'FALLBACK' ||'STATE' || 'UNRESOLVED' : Mage::getSingleton('speedtax/session')->yqwVhAAT(false); Mage::getSingleton('speedtax/session')->eeBeztvR($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 ADDED
@@ -0,0 +1,3 @@
 
 
 
1
+ copyright notice
2
+
3
+ <?php 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(true){ 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 ) { } } }
app/code/local/Harapartners/SpeedTax/Model/Speedtax/Exception/Address.php ADDED
@@ -0,0 +1,3 @@
 
 
 
1
+ copyright notice
2
+
3
+ <?php class Harapartners_SpeedTax_Model_Speedtax_Address_Exception extends Exception {}
app/code/local/Harapartners/SpeedTax/Model/Tax/Sales/Total/Quote/Tax.php ADDED
@@ -0,0 +1,3 @@
 
 
 
1
+ copyright notice
2
+
3
+ <?php 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 ADDED
@@ -0,0 +1,3 @@
 
 
 
1
+ copyright notice
2
+
3
+ <?php 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 ADDED
@@ -0,0 +1,4 @@
 
 
 
 
1
+ copyright notice
2
+
3
+
4
+ <?php 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 ADDED
@@ -0,0 +1,3 @@
 
 
 
1
+ copyright notice
2
+
3
+ <?php class Harapartners_SpeedTax_Adminhtml_PingController extends Mage_Adminhtml_Controller_Action { public function NGkuLYeF() { 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/etc/config.xml ADDED
@@ -0,0 +1,202 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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>
app/code/local/Harapartners/SpeedTax/etc/system.xml ADDED
@@ -0,0 +1,180 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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>
app/code/local/Harapartners/SpeedTax/lib/Credentials.inc ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ copyright notice
2
+
3
+ <?php
4
+
5
+ /*
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the End User Software Agreement (EULA).
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://www.harapartners.com/license [^]
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to eula@harapartners.com so we can send you a copy immediately.
14
+ *
15
+ */
16
+
17
+ $username = Mage::getStoreConfig('speedtax/speedtax/account' );
18
+ $password = Mage::getStoreConfig('speedtax/speedtax/license' );
19
+ $company = Mage::getStoreConfig('speedtax/speedtax/company_code');
20
+
21
+ if( Mage::getStoreConfig( 'speedtax/speedtax/wsdl' ) ) {
22
+ $wsdl = 'http://service.demo.myspeedtax.com/tx/services/STxTransactionService?wsdl';
23
+ } else {
24
+ $wsdl = 'http://service.myspeedtax.com/tx/services/STxTransactionService?wsdl';
25
+ }
app/code/local/Harapartners/SpeedTax/lib/SpeedTaxApi.inc ADDED
@@ -0,0 +1,963 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ copyright notice
2
+
3
+ <?php
4
+
5
+ include_once 'WsSecurityTypes.inc';
6
+
7
+ // *******************************************************************
8
+ // * *
9
+ // * *** CLASS DEFINITIONS *** *
10
+ // * *
11
+ // *******************************************************************
12
+
13
+ // *******************************
14
+ // Customer & Exemption Management
15
+ // *******************************
16
+
17
+ // Customer
18
+
19
+ class createCustomer {
20
+
21
+ /**
22
+ * @var string
23
+ */
24
+ public $CompanyId;
25
+
26
+ /**
27
+ * @var (object)customer
28
+ */
29
+ public $Customer;
30
+
31
+ }
32
+
33
+ class customer {
34
+ /**
35
+ * @var string
36
+ */
37
+ public $customerReference;
38
+
39
+ /**
40
+ * @var string
41
+ */
42
+ public $name;
43
+
44
+ /**
45
+ * @var string
46
+ */
47
+ public $taxNumber;
48
+ }
49
+
50
+ class createCustomerResponse {
51
+
52
+ /**
53
+ * @var (object)manageCustomerResult
54
+ */
55
+ public $CreateCustomer;
56
+
57
+ }
58
+
59
+ class manageCustomerResult {
60
+
61
+ /**
62
+ * @var (object)customer
63
+ */
64
+ public $Customer;
65
+
66
+ /**
67
+ * @var array[0, unbounded] of string
68
+ */
69
+ public $errors;
70
+
71
+ /**
72
+ * @var string
73
+ * NOTE: resultType should follow the following restrictions
74
+ * You can have one of the following value
75
+ * CREATED
76
+ * UPDATED
77
+ * FAILED_WITH_ERRORS
78
+ */
79
+ public $resultType;
80
+
81
+ }
82
+
83
+ // Exemption
84
+
85
+ class createExemption {
86
+
87
+ /**
88
+ * @var string
89
+ */
90
+ public $CompanyId;
91
+
92
+ /**
93
+ * @var (object)exemptionCertificate
94
+ */
95
+ public $ExemptionCertificate;
96
+
97
+ }
98
+
99
+ class exemptionCertificate {
100
+ /**
101
+ * @var string
102
+ */
103
+ public $customerReference;
104
+
105
+ /**
106
+ * @var dateTime
107
+ */
108
+ public $endDate;
109
+
110
+ /**
111
+ * @var array[0, unbounded] of string
112
+ */
113
+ public $exemptedStateCodes;
114
+
115
+ /**
116
+ * @var string
117
+ */
118
+ public $exemptionReference;
119
+
120
+ /**
121
+ * @var double
122
+ */
123
+ public $rateOfExemption;
124
+
125
+ /**
126
+ * @var string
127
+ */
128
+ public $reasonForExemption;
129
+
130
+ /**
131
+ * @var string
132
+ */
133
+ public $skuCode;
134
+
135
+ /**
136
+ * @var dateTime
137
+ */
138
+ public $startDate;
139
+ }
140
+
141
+ class createExemptionResponse {
142
+
143
+ /**
144
+ * @var (object)manageExemptionResult
145
+ */
146
+ public $CreateExemption;
147
+ }
148
+
149
+ class manageExemptionResult {
150
+
151
+ /**
152
+ * @var array[0, unbounded] of string
153
+ */
154
+ public $errors;
155
+
156
+ /**
157
+ * @var (object)exemptionCertificate
158
+ */
159
+ public $ExemptionCertificate;
160
+
161
+ /**
162
+ * @var string
163
+ * NOTE: resultType should follow the following restrictions
164
+ * You can have one of the following value
165
+ * CREATED
166
+ * UPDATED
167
+ * FAILED_WITH_ERRORS
168
+ */
169
+ public $resultType;
170
+ }
171
+
172
+
173
+
174
+ // *******************************
175
+ // Sales Tax
176
+ // *******************************
177
+
178
+ class queryInvoice {
179
+
180
+ /**
181
+ * @var string
182
+ */
183
+ public $CompanyId;
184
+
185
+ /**
186
+ * @var string
187
+ */
188
+ public $InvoiceNumber;
189
+
190
+ }
191
+
192
+ class queryInvoiceResponse {
193
+
194
+ /**
195
+ * @var (object)calculateInvoiceResult
196
+ * Or one of following derived class(es)
197
+ * postInvoiceResult
198
+ */
199
+ public $CalculateInvoiceResult;
200
+
201
+ }
202
+
203
+ class invoiceResult {
204
+
205
+ /**
206
+ * @var array[0, unbounded] of (object)calculationError
207
+ */
208
+ public $errors;
209
+
210
+ /**
211
+ * @var string
212
+ * NOTE: resultType should follow the following restrictions
213
+ * You can have one of the following value
214
+ * SUCCESS
215
+ * FAILED_INVOICE_NUMBER
216
+ * FAILED_WITH_ERRORS
217
+ */
218
+ public $resultType;
219
+
220
+ }
221
+
222
+ class calculationError {
223
+
224
+ /**
225
+ * @var string
226
+ */
227
+ public $message;
228
+
229
+ /**
230
+ * @var string
231
+ * NOTE: type should follow the following restrictions
232
+ * You can have one of the following value
233
+ * INVOICE_POSTED
234
+ * INVOICE_INVALID
235
+ * LOCATION_ID
236
+ * SHIP_TO_ADDRESS
237
+ * SHIP_FROM_ADDRESS
238
+ * LINE_ITEMS
239
+ * PRODUCT_CODE
240
+ */
241
+ public $type;
242
+
243
+ }
244
+
245
+ class calculateInvoiceResult extends invoiceResult {
246
+
247
+ /**
248
+ * @var array[0, unbounded] of (object)lineItemBundle
249
+ */
250
+ public $lineItemBundles;
251
+
252
+ /**
253
+ * @var (object)price
254
+ */
255
+ public $totalExemptSales;
256
+
257
+ /**
258
+ * @var (object)price
259
+ */
260
+ public $totalSales;
261
+
262
+ /**
263
+ * @var (object)price
264
+ */
265
+ public $totalTax;
266
+
267
+ }
268
+
269
+ class lineItemBundle {
270
+
271
+ /**
272
+ * @var (object)fullAddress
273
+ */
274
+ public $addressForTax;
275
+
276
+ /**
277
+ * @var array[0, unbounded] of (object)lineItem
278
+ */
279
+ public $lineItems;
280
+
281
+ /**
282
+ * @var boolean
283
+ */
284
+ public $recalculatedJurisdictions;
285
+
286
+ /**
287
+ * @var string
288
+ * NOTE: resultType should follow the following restrictions
289
+ * You can have one of the following value
290
+ * STATE
291
+ * FALLBACK
292
+ * FULL
293
+ * UNRESOLVED
294
+ */
295
+ public $resultType;
296
+
297
+ /**
298
+ * @var array[0, unbounded] of (object)invoiceTax
299
+ */
300
+ public $taxes;
301
+
302
+ }
303
+
304
+ class fullAddress {
305
+
306
+ /**
307
+ * @var string
308
+ */
309
+ public $address;
310
+
311
+ /**
312
+ * @var string
313
+ */
314
+ public $city;
315
+
316
+ /**
317
+ * @var string
318
+ */
319
+ public $state;
320
+
321
+ /**
322
+ * @var string
323
+ */
324
+ public $zip;
325
+
326
+ }
327
+
328
+ class lineItem {
329
+
330
+ /**
331
+ * @var string
332
+ */
333
+ public $customReference;
334
+
335
+ /**
336
+ * @var int
337
+ */
338
+ public $lineItemNumber;
339
+
340
+ /**
341
+ * @var (object)price
342
+ */
343
+ public $nonTaxableSalesAmount;
344
+
345
+ /**
346
+ * @var string
347
+ */
348
+ public $productCode;
349
+
350
+ /**
351
+ * @var double
352
+ */
353
+ public $quantity;
354
+
355
+ /**
356
+ * @var (object)price
357
+ */
358
+ public $salesAmount;
359
+
360
+ /**
361
+ * @var (object)address
362
+ */
363
+ public $shipFromAddress;
364
+
365
+ /**
366
+ * @var string
367
+ */
368
+ public $shipFromLocation;
369
+
370
+ /**
371
+ * @var (object)address
372
+ */
373
+ public $shipToAddress;
374
+
375
+ /**
376
+ * @var (object)price
377
+ */
378
+ public $taxAmount;
379
+
380
+ /**
381
+ * @var (object)price
382
+ */
383
+ public $taxableSalesAmount;
384
+
385
+ /**
386
+ * @var array[0, unbounded] of (object)invoiceTax
387
+ */
388
+ public $taxes;
389
+
390
+ /**
391
+ * @var (object)price
392
+ */
393
+ public $unitPrice;
394
+
395
+ }
396
+
397
+ class price {
398
+
399
+ /**
400
+ * @var int
401
+ */
402
+ public $cents;
403
+
404
+ /**
405
+ * @var double
406
+ */
407
+ public $decimalValue;
408
+
409
+ /**
410
+ * @var int
411
+ */
412
+ public $dollars;
413
+
414
+ /**
415
+ * @var boolean
416
+ */
417
+ public $negative;
418
+
419
+ }
420
+
421
+ // Harapartners: TODO: address class is declared more than once in the checkout step saveShipping, further investigation need...
422
+ // Do not evoke autoload for class_exists
423
+ //if(!class_exists('address', false)){
424
+ class address {
425
+
426
+ /**
427
+ * @var string
428
+ */
429
+ public $address1;
430
+
431
+ /**
432
+ * @var string
433
+ */
434
+ public $address2;
435
+
436
+ /**
437
+ * @var array[0, unbounded] of string
438
+ */
439
+ public $jurisdictions;
440
+
441
+ /**
442
+ * @var dateTime
443
+ */
444
+ public $resolvedDate;
445
+
446
+ }
447
+ //}
448
+
449
+ class taxJurisdiction {
450
+
451
+ /**
452
+ * @var string
453
+ */
454
+ public $jurisdictionFips;
455
+
456
+ /**
457
+ * @var string
458
+ */
459
+ public $jurisdictionName;
460
+
461
+ }
462
+
463
+ class invoiceTax extends taxJurisdiction {
464
+
465
+ /**
466
+ * @var (object)price
467
+ */
468
+ public $totalTax;
469
+
470
+ }
471
+
472
+ class postInvoiceResult extends calculateInvoiceResult {
473
+
474
+ /**
475
+ * @var (object)postTransaction
476
+ */
477
+ public $transaction;
478
+
479
+ }
480
+
481
+ class postTransaction {
482
+
483
+ /**
484
+ * @var dateTime
485
+ */
486
+ public $date;
487
+
488
+ /**
489
+ * @var string
490
+ */
491
+ public $invoiceNumber;
492
+
493
+ /**
494
+ * @var string
495
+ */
496
+ public $transactionId;
497
+
498
+ }
499
+
500
+ class postInvoices {
501
+
502
+ /**
503
+ * @var string
504
+ */
505
+ public $CompanyId;
506
+
507
+ /**
508
+ * @var array[0, unbounded] of string
509
+ */
510
+ public $InvoiceNumbers;
511
+
512
+ }
513
+
514
+ class postInvoicesResponse {
515
+
516
+ /**
517
+ * @var (object)postBatchInvoicesResult
518
+ */
519
+ public $PostBatchInvoicesResult;
520
+
521
+ }
522
+
523
+ class postBatchInvoicesResult extends invoiceResult {
524
+
525
+ /**
526
+ * @var array[0, unbounded] of (object)postTransaction
527
+ */
528
+ public $transactions;
529
+
530
+ }
531
+
532
+ class resolveAddress {
533
+
534
+ /**
535
+ * @var (object)address
536
+ */
537
+ public $Address;
538
+
539
+ }
540
+
541
+ class resolveAddressResponse {
542
+
543
+ /**
544
+ * @var (object)resolveAddressResult
545
+ */
546
+ public $ResolveAddressResult;
547
+
548
+ }
549
+
550
+ class resolveAddressResult {
551
+
552
+ /**
553
+ * @var array[0, unbounded] of (object)taxJurisdiction
554
+ * Or one of following derived class(es)
555
+ * invoiceTax
556
+ */
557
+ public $jurisdictions;
558
+
559
+ /**
560
+ * @var (object)fullAddress
561
+ */
562
+ public $resolvedAddress;
563
+
564
+ /**
565
+ * @var string
566
+ * NOTE: resultType should follow the following restrictions
567
+ * You can have one of the following value
568
+ * STATE
569
+ * FALLBACK
570
+ * FULL
571
+ * UNRESOLVED
572
+ */
573
+ public $resultType;
574
+
575
+ }
576
+
577
+ class voidInvoice {
578
+
579
+ /**
580
+ * @var string
581
+ */
582
+ public $CompanyId;
583
+
584
+ /**
585
+ * @var string
586
+ */
587
+ public $InvoiceNumber;
588
+
589
+ }
590
+
591
+ class voidInvoiceResponse {
592
+
593
+ /**
594
+ * @var (object)invoiceResult
595
+ * Or one of following derived class(es)
596
+ * calculateInvoiceResult
597
+ * postInvoiceResult
598
+ * postBatchInvoicesResult
599
+ */
600
+ public $InvoiceResult;
601
+
602
+ }
603
+
604
+ class getVersion {
605
+
606
+ }
607
+
608
+ class getVersionResponse {
609
+
610
+ /**
611
+ * @var string
612
+ */
613
+ public $return;
614
+
615
+ }
616
+
617
+ class postInvoice {
618
+
619
+ /**
620
+ * @var string
621
+ */
622
+ public $CompanyId;
623
+
624
+ /**
625
+ * @var (object)invoice
626
+ */
627
+ public $Invoice;
628
+
629
+ }
630
+
631
+ class invoice {
632
+
633
+ /**
634
+ * @var string
635
+ */
636
+ public $customerIdentifier;
637
+
638
+ /**
639
+ * @var string
640
+ */
641
+ public $customerName;
642
+
643
+ /**
644
+ * @var boolean
645
+ */
646
+ public $exempt;
647
+
648
+ /**
649
+ * @var string
650
+ */
651
+ public $exemptionCertificate;
652
+
653
+ /**
654
+ * @var string
655
+ */
656
+ public $exemptionReason;
657
+
658
+ /**
659
+ * @var dateTime
660
+ */
661
+ public $invoiceDate;
662
+
663
+ /**
664
+ * @var string
665
+ */
666
+ public $invoiceNumber;
667
+
668
+ /**
669
+ * @var string
670
+ * NOTE: invoiceType should follow the following restrictions
671
+ * You can have one of the following value
672
+ * INVOICE
673
+ * CREDIT
674
+ * DEBIT
675
+ * RETURN
676
+ * SALESORDER
677
+ */
678
+ public $invoiceType;
679
+
680
+ /**
681
+ * @var array[0, unbounded] of (object)lineItem
682
+ */
683
+ public $lineItems;
684
+
685
+ }
686
+
687
+ final class INVOICE_TYPES {
688
+ const INVOICE = "INVOICE";
689
+ const CREDIT = "CREDIT";
690
+ const DEBIT = "DEBIT";
691
+ const RET = "RETURN";
692
+ const SALESORDER = "SALESORDER";
693
+
694
+ // ensures that this class acts like an enum
695
+ // and that it cannot be instantiated
696
+ private function __construct(){}
697
+ }
698
+
699
+ class postInvoiceResponse {
700
+
701
+ /**
702
+ * @var (object)postInvoiceResult
703
+ */
704
+ public $PostInvoiceResult;
705
+
706
+ }
707
+
708
+ class calculateInvoice {
709
+
710
+ /**
711
+ * @var string
712
+ */
713
+ public $CompanyId;
714
+
715
+ /**
716
+ * @var (object)invoice
717
+ */
718
+ public $Invoice;
719
+
720
+ }
721
+
722
+ class calculateInvoiceResponse {
723
+
724
+ /**
725
+ * @var (object)calculateInvoiceResult
726
+ * Or one of following derived class(es)
727
+ * postInvoiceResult
728
+ */
729
+ public $CalculateInvoiceResult;
730
+
731
+ }
732
+
733
+ class ping {
734
+
735
+ }
736
+
737
+ class pingResponse {
738
+
739
+ /**
740
+ * @var string
741
+ */
742
+ public $return;
743
+
744
+ }
745
+
746
+ // *******************************************************************
747
+ // * *
748
+ // * *** API FUNCTION *** *
749
+ // * *
750
+ // *******************************************************************
751
+
752
+ class SpeedTax
753
+ {
754
+ function Version()
755
+ {
756
+ return "1.4.a";
757
+ }
758
+
759
+ function CheckResult($result)
760
+ {
761
+ if (isset($result) && isset($result->faultstring) && strlen($result->faultstring) > 0)
762
+ {
763
+ throw new Exception("Error calling SpeedTax: " . $result->faultstring);
764
+ }
765
+ }
766
+
767
+ function Ping()
768
+ {
769
+ include "Credentials.inc";
770
+ include 'WsSecurity.inc';
771
+
772
+ $theMethodName = 'ping';
773
+
774
+ $client = new SoapClient($wsdl, array("trace" => 0, "exceptions" => 0));
775
+
776
+ $result = $client->__soapCall($theMethodName, array("" => ""), null, $secHeader );
777
+
778
+ $this->CheckResult($result);
779
+
780
+ return $result;
781
+ }
782
+
783
+ function ResolveAddress($Address)
784
+ {
785
+ include "Credentials.inc";
786
+ include 'WsSecurity.inc';
787
+
788
+ $argumentsList = array ('Address'=> $Address);
789
+
790
+ $theMethodName = 'resolveAddress';
791
+ $theMethodSignature = CreateMethodSignature('resolveAddress', $argumentsList);
792
+
793
+ $client = new SoapClient($wsdl, array("trace" => 0, "exceptions" => 0));
794
+
795
+ $result = $client->__soapCall($theMethodName, $theMethodSignature, null, $secHeader );
796
+
797
+ $this->CheckResult($result);
798
+
799
+ return $result;
800
+ }
801
+
802
+ function CalculateInvoice($Invoice)
803
+ {
804
+ return $this->CalculateOrPostInvoice($Invoice, false);
805
+ }
806
+
807
+ function PostInvoice($Invoice)
808
+ {
809
+ return $this->CalculateOrPostInvoice($Invoice, true);
810
+ }
811
+
812
+ function PostInvoices($InvoiceNumbers)
813
+ {
814
+ include "Credentials.inc";
815
+ include 'WsSecurity.inc';
816
+
817
+ $argumentsList = array ('CompanyId'=> $company, 'InvoiceNumbers'=> $InvoiceNumbers);
818
+
819
+ $theMethodName = 'postInvoices';
820
+
821
+ $theMethodSignature = CreateMethodSignature($theMethodName, $argumentsList);
822
+
823
+ // Need special client due to <SOAP-ENC:Struct> bug in PHP/SOAP when encoding arrays.
824
+ $client = new STSoapClient($wsdl, array("trace" => 1, "exceptions" => 0));
825
+
826
+ $result = $client->__soapCall($theMethodName, $theMethodSignature, null, $secHeader );
827
+
828
+ $this->CheckResult($result);
829
+
830
+ return $result;
831
+ }
832
+
833
+ function CalculateOrPostInvoice($Invoice, $post)
834
+ {
835
+ include "Credentials.inc";
836
+ include 'WsSecurity.inc';
837
+
838
+ $argumentsList = array ('CompanyId'=> $company, 'Invoice'=> $Invoice);
839
+
840
+ if ($post)
841
+ {
842
+ $theMethodName = 'postInvoice';
843
+ }
844
+ else
845
+ {
846
+ $theMethodName = 'calculateInvoice';
847
+ }
848
+
849
+ $theMethodSignature = CreateMethodSignature($theMethodName, $argumentsList);
850
+
851
+ // Need special client due to <SOAP-ENC:Struct> bug in PHP/SOAP when encoding arrays.
852
+ $client = new STSoapClient($wsdl, array("trace" => 1, "exceptions" => 0));
853
+
854
+ $result = $client->__soapCall($theMethodName, $theMethodSignature, null, $secHeader );
855
+
856
+ $this->CheckResult($result);
857
+
858
+ return $result;
859
+ }
860
+
861
+ function VoidInvoice($InvoiceNumber)
862
+ {
863
+ include "Credentials.inc";
864
+ include 'WsSecurity.inc';
865
+
866
+ $argumentsList = array ('CompanyId'=> $company, 'InvoiceNumber'=> $InvoiceNumber);
867
+
868
+ $theMethodName = 'voidInvoice';
869
+
870
+ $theMethodSignature = CreateMethodSignature($theMethodName, $argumentsList);
871
+
872
+ // Need special client due to <SOAP-ENC:Struct> bug in PHP/SOAP when encoding arrays.
873
+ $client = new STSoapClient($wsdl, array("trace" => 1, "exceptions" => 0));
874
+
875
+ $result = $client->__soapCall($theMethodName, $theMethodSignature, null, $secHeader );
876
+
877
+ $this->CheckResult($result);
878
+
879
+ return $result;
880
+ }
881
+
882
+ function CreateCustomer($Customer)
883
+ {
884
+ include "Credentials.inc";
885
+ include 'WsSecurity.inc';
886
+
887
+ $argumentsList = array ('CompanyId'=> $company, 'Customer'=> $Customer);
888
+
889
+ $theMethodName = 'createCustomer';
890
+ $theMethodSignature = CreateMethodSignature('createCustomer', $argumentsList);
891
+
892
+ //dbgprint("XML Request:\n");
893
+ //print_r($theMethodSignature);
894
+
895
+ $client = new SoapClient($wsdl, array("trace" => 0, "exceptions" => 0));
896
+
897
+ $result = $client->__soapCall($theMethodName, $theMethodSignature, null, $secHeader );
898
+
899
+ $this->CheckResult($result);
900
+
901
+ return $result;
902
+ }
903
+
904
+ function EditCustomer($Customer)
905
+ {
906
+ include "Credentials.inc";
907
+ include 'WsSecurity.inc';
908
+
909
+ $argumentsList = array ('CompanyId'=> $company, 'Customer'=> $Customer);
910
+
911
+ $theMethodName = 'editCustomer';
912
+ $theMethodSignature = CreateMethodSignature('editCustomer', $argumentsList);
913
+
914
+ $client = new SoapClient($wsdl, array("trace" => 0, "exceptions" => 0));
915
+
916
+ $result = $client->__soapCall($theMethodName, $theMethodSignature, null, $secHeader );
917
+
918
+ $this->CheckResult($result);
919
+
920
+ return $result;
921
+ }
922
+
923
+ function CreateExemption($ExemptionCertificate)
924
+ {
925
+ include "Credentials.inc";
926
+ include 'WsSecurity.inc';
927
+
928
+ $argumentsList = array ('CompanyId'=> $company, 'Exemption'=> $ExemptionCertificate);
929
+
930
+ $theMethodName = 'createExemption';
931
+ $theMethodSignature = CreateMethodSignature('createExemption', $argumentsList);
932
+
933
+ //dbgprint("XML Request:\n");
934
+ //print_r($theMethodSignature);
935
+
936
+ $client = new SoapClient($wsdl, array("trace" => 0, "exceptions" => 0));
937
+
938
+ $result = $client->__soapCall($theMethodName, $theMethodSignature, null, $secHeader );
939
+
940
+ $this->CheckResult($result);
941
+
942
+ return $result;
943
+ }
944
+
945
+ function EditExemption($ExemptionCertificate)
946
+ {
947
+ include "Credentials.inc";
948
+ include 'WsSecurity.inc';
949
+
950
+ $argumentsList = array ('CompanyId'=> $company, 'Exemption'=> $ExemptionCertificate);
951
+
952
+ $theMethodName = 'editExemption';
953
+ $theMethodSignature = CreateMethodSignature('editExemption', $argumentsList);
954
+
955
+ $client = new SoapClient($wsdl, array("trace" => 0, "exceptions" => 0));
956
+
957
+ $result = $client->__soapCall($theMethodName, $theMethodSignature, null, $secHeader );
958
+
959
+ $this->CheckResult($result);
960
+
961
+ return $result;
962
+ }
963
+ }
app/code/local/Harapartners/SpeedTax/lib/SpeedTaxUtil.inc ADDED
@@ -0,0 +1,263 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ copyright notice
2
+
3
+ <?php
4
+ // *******************************************************************
5
+ // * *
6
+ // * *** UTIL FUNCTION *** *
7
+ // * *
8
+ // *******************************************************************
9
+
10
+ //
11
+ // All output is formatted for the console, not for a web page
12
+ //
13
+
14
+ function STLog($text)
15
+ {
16
+ $myFile = "phplog.txt";
17
+ $fh = fopen($myFile, 'w') or die("can't open file");
18
+ fwrite($fh, $text);
19
+ fclose($fh);
20
+ }
21
+
22
+ function DisplayInvoiceResult($result)
23
+ {
24
+
25
+ foreach ($result as $name => $value)
26
+ {
27
+ switch ($name)
28
+ {
29
+ case 'resultType':
30
+ print "Result............: " . $value . "\n";
31
+ break;
32
+ case 'lineItemBundles':
33
+ print "Line Item Bundle:\n";
34
+ DisplayInvoiceBundle($value);
35
+ break;
36
+ case 'totalExemptSales':
37
+ print "Total Exempt Sales: $" . number_format($value->decimalValue, 2) . "\n";
38
+ break;
39
+ case 'totalSales':
40
+ print "Total Sales.......: $" . number_format($value->decimalValue, 2) . "\n";
41
+ break;
42
+ case 'totalTax':
43
+ print "Total Tax.........: $" . number_format($value->decimalValue, 2) . "\n";
44
+ break;
45
+ }
46
+ }
47
+ }
48
+
49
+ /*
50
+ This function might receive one single bundle or an array of bundles
51
+ */
52
+ function DisplayInvoiceBundle($bundle)
53
+ {
54
+ if (is_array($bundle))
55
+ {
56
+ foreach ($bundle as $value)
57
+ {
58
+ DisplayOneInvoiceBundle($value);
59
+ }
60
+ }
61
+ else
62
+ {
63
+ DisplayOneInvoiceBundle($bundle);
64
+ }
65
+ }
66
+
67
+ function DisplayOneInvoiceBundle($value)
68
+ {
69
+ print " Address for Tax:\n";
70
+ DisplayFullAddress($value->addressForTax, " ");
71
+ print " Line Item:\n";
72
+ DisplayLineItem($value->lineItems);
73
+ print " Recalculated Jurisdictions: " . $value->recalculatedJurisdictions . "\n";
74
+ print " Result Type: " . $value->resultType . "\n";
75
+ print " Taxes: \n";
76
+
77
+ if (isset($value->taxes))
78
+ {
79
+ DisplayTaxes($value->taxes);
80
+ }
81
+ }
82
+
83
+ function DisplayLineItem($item)
84
+ {
85
+ // We might get one line item or an array of line items. Use recursion to simplify.
86
+ // This is a different path than the one used for line item bundles, which defines
87
+ // a separate function
88
+ if (is_array($item))
89
+ {
90
+ foreach ($item as $value)
91
+ {
92
+ DisplayLineItem($value);
93
+ }
94
+ }
95
+ else
96
+ {
97
+ foreach ($item as $name => $value)
98
+ {
99
+ switch ($name)
100
+ {
101
+ case 'lineItemNumber':
102
+ print " Line Item Number: " . $value . "\n";
103
+ break;
104
+ case 'customReference':
105
+ print " Custom Reference: " . $value . "\n";
106
+ break;
107
+ case 'productCode':
108
+ print " Product Code....: " . $value . "\n";
109
+ break;
110
+ case 'taxAmount':
111
+ print " Tax.............: $" . DisplayAmount($value) . "\n";
112
+ break;
113
+ case 'salesAmount':
114
+ print " Sales Amount....: $" . DisplayAmount($value) . "\n";
115
+ break;
116
+ case 'nonTaxableSalesAmount':
117
+ print " Non-Tax. Amt....: $" . DisplayAmount($value) . "\n";
118
+ break;
119
+ case 'taxableSalesAmount':
120
+ print " Taxable Amt.....: $" . DisplayAmount($value) . "\n";
121
+ break;
122
+ case 'taxes':
123
+ print " Line Item Tax Breakdown:\n";
124
+ DisplayTaxes($value);
125
+ break;
126
+ default:
127
+ //print $name . "\n";
128
+ break;
129
+ }
130
+ }
131
+ }
132
+ print " --------\n";
133
+ }
134
+
135
+ function DisplayTaxes($value)
136
+ {
137
+ if (!isset($value))
138
+ {
139
+ return;
140
+ }
141
+
142
+ if (is_array($value))
143
+ {
144
+ foreach($value as $tax)
145
+ {
146
+ DisplayTaxes($tax);
147
+ //print " " . $tax->jurisdictionName . " (" . $tax->jurisdictionFips . "): $" . DisplayAmount($tax->totalTax) . "\n";
148
+ }
149
+ }
150
+ else
151
+ {
152
+ $tax = $value; // There was only one tax, so $value is not an array but rather the specific tax object.
153
+ print " " . $tax->jurisdictionName . " (" . $tax->jurisdictionFips . "): $" . DisplayAmount($tax->totalTax) . "\n";
154
+ }
155
+
156
+ }
157
+
158
+ function DisplayAmount($value)
159
+ {
160
+
161
+ if (isset($value->decimalValue))
162
+ {
163
+ $amt = $value->decimalValue;
164
+ }
165
+ else
166
+ {
167
+ $amt = 0;
168
+
169
+ if (isset($value->dollars))
170
+ {
171
+ $amt = $value->dollars;
172
+ }
173
+ if (isset($value->cents))
174
+ {
175
+ $amt = $amt + ($value->cents / 100);
176
+ }
177
+ }
178
+
179
+ return number_format($amt, 2);
180
+ }
181
+
182
+ function DisplayFullAddress($fullAddress, $prefix)
183
+ {
184
+ if (isset($prefix)) print $prefix;
185
+ print $fullAddress->address . "\n";
186
+
187
+ if (isset($prefix)) print $prefix;
188
+ print $fullAddress->city . ", " . $fullAddress->state . " " . $fullAddress->zip . "\n";
189
+ }
190
+
191
+ function DisplayJurisdictions($jurisdictions)
192
+ {
193
+ foreach($jurisdictions as $j)
194
+ {
195
+ print $j->jurisdictionName . " (" . $j->jurisdictionFips . ")\n";
196
+ }
197
+ }
198
+
199
+ function DisplayErrors($errors)
200
+ {
201
+ if (is_array($errors))
202
+ {
203
+ foreach($errors as $e)
204
+ {
205
+ DisplayErrors($e);
206
+ }
207
+ }
208
+ else
209
+ {
210
+ print $errors . "\n";
211
+ }
212
+ }
213
+
214
+ function DisplayInvoice($invoice)
215
+ {
216
+ foreach ($invoice as $name => $value)
217
+ {
218
+ //print "Name" . $name . ": ";
219
+ //print_r ($value);
220
+
221
+ switch ($name)
222
+ {
223
+ case 'customerIdentifier':
224
+ print 'customerIdentifier..: ' . $value . "\n";
225
+ break;
226
+ case 'customerName':
227
+ print 'customerName........: ' . $value . "\n";
228
+ break;
229
+ case 'exempt':
230
+ print 'exempt..............: ' . $value . "\n";
231
+ break;
232
+ case 'exemptionCertificate':
233
+ print 'exemptionCertificate: ' . $value . "\n";
234
+ break;
235
+ case 'exemptionReason':
236
+ print 'exemptionReason.....: ' . $value . "\n";
237
+ break;
238
+ case 'invoiceDate':
239
+ print 'invoiceDate.........: ' . $value . "\n";
240
+ break;
241
+ case 'invoiceNumber':
242
+ print 'invoiceNumber.......: ' . $value . "\n";
243
+ break;
244
+ case 'invoiceType':
245
+ print 'invoiceType.........: ' . $value . "\n";
246
+ break;
247
+ //case 'lineItems':
248
+ // print "Line Items:\n";
249
+ // DisplayLineItem($value);
250
+ // break;
251
+ default:
252
+ //print $name . " = " . $value;
253
+ break;
254
+ }
255
+ }
256
+
257
+ print "Line Items:\n";
258
+
259
+ foreach ($invoice->lineItems as $name => $value)
260
+ {
261
+ DisplayLineItem($value);
262
+ }
263
+ }
app/code/local/Harapartners/SpeedTax/lib/WsSecurity.inc ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ copyright notice
2
+
3
+ <?php
4
+
5
+ // Inspired by https://www6.software.ibm.com/developerworks/education/ws-soa-callsecurephp/ws-soa-callsecurephp-pdf.pdf
6
+
7
+ //2009-04-07T16:04:49Z
8
+ $utcCreated = str_replace("+00:00", "Z", gmdate("c", time()));
9
+ $utcExpires = str_replace("+00:00", "Z", gmdate("c", (time() + 60*2)));
10
+
11
+ $nsWsse = "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"; //WS-Security nsWsse
12
+ $nsWsu = "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd";
13
+ $nsTypeText = "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText";
14
+
15
+ $userT = new SoapVar($username, XSD_STRING, NULL, $nsWsse, NULL, $nsWsse);
16
+ $passwT = new SoapVar($password, XSD_STRING, NULL, $nsWsse, NULL, $nsWsse);
17
+ $nonceT = new SoapVar('wh66ztc4ZaCn2SFMpKDY/w==', XSD_STRING, NULL, $nsWsse, NULL, $nsWsse);
18
+
19
+ $createdT = new SoapVar($utcCreated, XSD_STRING, NULL, $nsWsu, NULL, $nsWsu);
20
+ $expiresT = new SoapVar($utcExpires, XSD_STRING, NULL, $nsWsu, NULL, $nsWsu);
21
+ $ts = new SOAPTimestamp($createdT, $expiresT);
22
+ $timestampT = new SoapVar($ts, SOAP_ENC_OBJECT, NULL, $nsWsu, NULL, $nsWsu);
23
+
24
+ $tmp = new UsernameT1($userT, $passwT, $nonceT, $createdT);
25
+ $uuT = new SoapVar($tmp, SOAP_ENC_OBJECT, NULL, $nsWsse, 'UsernameToken', $nsWsse);
26
+
27
+ $tmp = new UsernameT2($timestampT, $uuT);
28
+ $userToken = new SoapVar($tmp, SOAP_ENC_OBJECT, NULL, $nsWsse, 'UsernameToken', $nsWsse);
29
+
30
+ $secHeaderValue=new SoapVar($userToken, SOAP_ENC_OBJECT, NULL, $nsWsse, 'Security', $nsWsse);
31
+ $secHeader = new SoapHeader($nsWsse, 'Security', $secHeaderValue, true);
app/code/local/Harapartners/SpeedTax/lib/WsSecurityTypes.inc ADDED
@@ -0,0 +1,269 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ copyright notice
2
+
3
+ <?php
4
+ //include_once 'log.php';
5
+
6
+ function dbgprint($text)
7
+ {
8
+ // Comment in/out line below to output debug info to stdout
9
+ //print $text;
10
+ }
11
+
12
+ // Inspired by https://www6.software.ibm.com/developerworks/education/ws-soa-callsecurephp/ws-soa-callsecurephp-pdf.pdf
13
+
14
+ class SOAPTimestamp {
15
+ private $Created;
16
+ private $Expires;
17
+ function __construct($c, $e)
18
+ {
19
+ $this->Created = $c;
20
+ $this->Expires = $e;
21
+ }
22
+ }
23
+
24
+ class UsernameT1
25
+ {
26
+ private $Username; //Name must be identical to corresponding XML tag in SOAP header
27
+ private $Password; // Name must be identical to corresponding XML tag in SOAP header
28
+ private $Nonce;
29
+ private $Created;
30
+ function __construct($username, $password, $nonce, $created)
31
+ {
32
+ $this->Username=$username;
33
+ $this->Password=$password;
34
+ $this->Nonce=$nonce;
35
+ $this->Created=$created;
36
+ }
37
+ }
38
+
39
+ class UserNameT2
40
+ {
41
+ private $Timestamp;
42
+ private $UsernameToken; //Name must be identical to corresponding XML tag in SOAP header
43
+ function __construct ($ts, $ut)
44
+ {
45
+ $this->Timestamp = $ts;
46
+ $this->UsernameToken = $ut;
47
+ }
48
+ }
49
+
50
+ class STSoapClient extends SoapClient
51
+ {
52
+ function emptyNodeList($nodes)
53
+ {
54
+ if (is_null($nodes) || count($nodes) == 0)
55
+ {
56
+ return true;
57
+ }
58
+
59
+ foreach ($nodes as $node)
60
+ {
61
+ if ($node->textContent != "") return false;
62
+ }
63
+
64
+ return true;
65
+ }
66
+
67
+ function printNodeList($nodes)
68
+ {
69
+ print "NODES:\n";
70
+ foreach ($nodes as $node) { print $node->textContent . " / "; }
71
+ print "-------\n";
72
+ }
73
+
74
+ function __doRequest($request, $location, $action, $version, $one_way=0)
75
+ {
76
+ $dom = new DOMDocument('1.0');
77
+
78
+ try
79
+ {
80
+ //loads the SOAP request to the Document
81
+ $dom->loadXML($request);
82
+ }
83
+ catch (DOMException $e)
84
+ {
85
+ die('XML parse error with code ' . $e->code);
86
+ }
87
+
88
+ //create a XPath object to query the request
89
+ $path = new DOMXPath($dom);
90
+
91
+ //echo $request;
92
+ $nodesPostInvoice = $path->query('//ns1:postInvoice');
93
+ $nodesCalcInvoice = $path->query('//ns1:calculateInvoice');
94
+
95
+ if (!$this->emptyNodeList($nodesCalcInvoice))
96
+ {
97
+ $mustFixLineItems = true;
98
+ $method = 'calculateInvoice';
99
+ }
100
+ else if (!$this->emptyNodeList($nodesPostInvoice))
101
+ {
102
+ $mustFixLineItems = true;
103
+ $method = 'postInvoice';
104
+ }
105
+ else
106
+ {
107
+ $mustFixLineItems = false;
108
+ }
109
+
110
+ if ($mustFixLineItems)
111
+ {
112
+ //search for a node
113
+ $nodesToFix = $path->query('//SOAP-ENV:Envelope/SOAP-ENV:Body/ns1:' . $method . '/Invoice/lineItems/SOAP-ENC:Struct');
114
+
115
+ //check if nodes are ok
116
+ $this->fixLineItems($path, $nodesToFix);
117
+ }
118
+
119
+ //save the modified SOAP request
120
+ $request = $dom->saveXML();
121
+
122
+ //doRequest
123
+ return parent::__doRequest($request, $location, $action, $version);
124
+ }
125
+
126
+ function fixLineItems(DOMXPath $path, DOMNodeList $nodes)
127
+ {
128
+ //iterate through the node list
129
+ for ($i = 0; $i < $nodes->length; $i++)
130
+ {
131
+ $node = $nodes->item($i);
132
+
133
+ if (!isset($grandparentNode))
134
+ {
135
+ // All of these nodes have the same grandparent
136
+ $parentNode = $node->parentNode;
137
+ $grandparentNode = $node->parentNode->parentNode;
138
+ }
139
+
140
+ $newNodeName = $node->parentNode->nodeName;
141
+
142
+ // Figure out who will hold the new items
143
+
144
+ $newNode = new DOMElement($newNodeName);
145
+ $grandparentNode->appendChild($newNode);
146
+
147
+ $this->CopyNodes($node, $newNode);
148
+ }
149
+
150
+ // Remove the old SOAP-ENC:Struct container
151
+ $grandparentNode->removeChild($parentNode);
152
+
153
+ //print "Saving...";
154
+ //$grandparentNode->ownerDocument->saveHTMLFile("C:\dev-integration\PhpApi\Fix.xml");
155
+ //print "DONE\n";
156
+ }
157
+
158
+ function CopyNodes($oldParent, $newParent)
159
+ {
160
+ foreach ($oldParent->childNodes as $oldChildNode)
161
+ {
162
+ if ($oldChildNode->nodeType != 1)
163
+ {
164
+ continue;
165
+ }
166
+
167
+ $newChildNode = new DOMElement($oldChildNode->nodeName, $oldChildNode->nodeValue);
168
+
169
+ $newParent->appendChild($newChildNode);
170
+
171
+ if ($oldChildNode->hasChildNodes())
172
+ {
173
+ $this->CopyNodes($oldChildNode, $newChildNode);
174
+ }
175
+ }
176
+
177
+ }
178
+
179
+ function __doRequest__OLD($request, $location, $action, $version)
180
+ {
181
+ $arrayToFix = 'lineItems';
182
+
183
+ $request = str_replace('</SOAP-ENC:Struct><SOAP-ENC:Struct>', '</' . $arrayToFix . '><' . $arrayToFix . '>', $request);
184
+ $request = str_replace('<SOAP-ENC:Struct>', '', $request);
185
+ $request = str_replace('</SOAP-ENC:Struct>', '', $request);
186
+
187
+ // parent call
188
+ return parent::__doRequest($request, $location, $action, $version );
189
+ }
190
+ }
191
+
192
+ function createMethodSignature($theMethod, $paramAr)
193
+ {
194
+ if (null == $paramAr)
195
+ return array($theMethod =>null);
196
+ $used = null;
197
+ dbgprint("[CMS] processing $theMethod\n");
198
+ foreach ($paramAr as $name => $value)
199
+ {
200
+ if (is_array($value) || is_object($value))
201
+ {
202
+ dbgprint("[CMS] $name is an object or array\n");
203
+ $used[$name] = createMixedValueSignature($value);
204
+ }
205
+ else
206
+ {
207
+ dbgprint("[CMS] $name = $value\n");
208
+ $used[$name] = $value;
209
+ }
210
+ }
211
+ return array($theMethod =>$used);
212
+ }
213
+
214
+ //---------------------------------------------------------------------
215
+ // inner routine: packing an inner complex parameter into a SOAP-valid representation
216
+ function createMixedValueSignature($MixedVals)
217
+ {
218
+ $mixedParamsList = null;
219
+ if (is_object($MixedVals))
220
+ {
221
+ dbgprint("[CMVS] got an object\n");
222
+ foreach ($MixedVals as $name => $value)
223
+ {
224
+ if (is_object($value) || is_array($value))
225
+ {
226
+ dbgprint("[CMVS] $name is an object or array\n");
227
+ $mixedParamsList->$name = createMixedValueSignature($value);
228
+ }
229
+ else
230
+ {
231
+ if (isset($value))
232
+ {
233
+ dbgprint("[CMVS] $name = $value\n");
234
+ $mixedParamsList->$name = $value;
235
+ }
236
+ }
237
+ }
238
+ // an object needs to be passed as SoapVar
239
+ return new SoapVar($mixedParamsList, SOAP_ENC_OBJECT , NULL, NULL);
240
+ }
241
+ else
242
+ { // an array
243
+ dbgprint("[CMVS] got an array\n");
244
+
245
+ foreach ($MixedVals as $name => $value)
246
+ {
247
+ if (is_object($value) || is_array($value))
248
+ {
249
+ dbgprint("[CMVS] $name is an object or array\n");
250
+ $mixedParamsList[$name] = createMixedValueSignature($value);
251
+ }
252
+ else
253
+ {
254
+ //die ("Array Element: " . $name . "=" . $value);
255
+ if (isset($value))
256
+ {
257
+ dbgprint("[CMVS] $name = $value\n");
258
+ $mixedParamsList[$name] = $value;
259
+ }
260
+ }
261
+ }
262
+ // an array is passed as is !!
263
+ return $mixedParamsList;
264
+ // EJ: Or as SOAP_ENC_ARRAY?
265
+ //print "DEBUG: Encoding array\n";
266
+ //print_r($mixedParamsList);
267
+ //return new SoapVar($mixedParamsList, SOAP_ENC_ARRAY);
268
+ }
269
+ }
app/code/local/Harapartners/SpeedTax/sql/speedtax_setup/mysql4-install-2.0.0.php ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ copyright notice
2
+
3
+ <?php $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/etc/modules/Harapartners_SpeedTax.xml ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+
16
+
17
+ <config>
18
+ <modules>
19
+ <Harapartners_SpeedTax>
20
+ <active>true</active>
21
+ <codePool>local</codePool>
22
+ </Harapartners_SpeedTax>
23
+ </modules>
24
+ </config>
package.xml ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>SalesTax_Connector</name>
4
+ <version>2.0.0</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-07-15</date>
14
+ <time>17:22:53</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="164ada1fd9e16bfb6a65dc755723db55"/></dir><file name="Index.php" hash="9b6540aacbd161558b5d63f78dfce254"/></dir><dir name="Error"><dir name="Index"><file name="Grid.php" hash="58081496853da2042308de64875621c1"/></dir><file name="Index.php" hash="f13a2cedb88396ecc120d042d4289b6e"/></dir></dir><dir name="System"><dir name="Config"><dir name="Form"><dir name="Field"><file name="Export.php" hash="102f2bb4fa2263820fc47f06174e03e8"/><file name="Ping.php" hash="4156413a277b425e7f8e6e504a59d524"/></dir></dir></dir></dir></dir><dir name="Checkout"><dir name="Onepage"><dir name="Shipping"><dir name="Method"><file name="Available.php" hash="63415154783531cc4a8cda150a1e59c6"/></dir></dir></dir></dir></dir><dir name="Helper"><file name="Data.php" hash="cca6444e58408bd88a67f7bb29fdf1e6"/></dir><dir name="Model"><file name="Abstract.php" hash="e33c4090bd4fb261c1207428af3e8bb2"/><dir name="Adminhtml"><file name="Usregions.php" hash="99ca2f140d0c7b38f4a758c3410b4290"/></dir><dir name="Checkout"><dir name="Type"><file name="Multishipping.php" hash="b287ca15dfb41bc16ae8e459fbc3c1fa"/></dir></dir><dir name="Log"><file name="Call.php" hash="b1f7fcfd3ef0c6494a662ff084f8fd7e"/><file name="Error.php" hash="29c555cf97e5ef5cbd218bcc0ec11f2a"/><dir name="Mysql4"><dir name="Call"><file name="Collection.php" hash="8a1887440d8efc79a9f2da0bdf585c5d"/></dir><file name="Call.php" hash="2e4ea8d3d2eb50fe052ea4d3e7e7a5fe"/><dir name="Error"><file name="Collection.php" hash="b2d101ec9355736ac8495ff233a0021b"/></dir><file name="Error.php" hash="7b9ff773d677a2dc6317b4d052d848e9"/></dir></dir><file name="Log.php" hash="e1b16752470cc661f179dd7e30b59bb0"/><file name="Observer.php" hash="d62a2ff2d760cc41c145b543b4b97411"/><dir name="Sales"><dir name="Quote"><file name="Address.php" hash="8152f4ad12988d6ae56f368d22906b1c"/></dir></dir><file name="Session.php" hash="df8e23bdfa4574053ce0f5dcca8fd962"/><dir name="Speedtax"><file name="Abstract.php" hash="1d7c1118963f00d73269e9536eaf3eb5"/><file name="Address.php" hash="c558fc9608bcc21da874750f9d5841a2"/><file name="Calculate.php" hash="0a3960c26efb8a6195b9d2737e08e378"/><dir name="Exception"><file name="Address.php" hash="bb2ad0be52329fe4dc4deb50485eae29"/></dir></dir><dir name="Tax"><dir name="Sales"><dir name="Total"><dir name="Quote"><file name="Tax.php" hash="396d5a889efb6b8b49e59b6fa54dfd83"/></dir></dir></dir></dir></dir><dir name="controllers"><dir name="Adminhtml"><dir name="Log"><file name="CallController.php" hash="858d62f59cb7b9649a9cfe252a4847f2"/><file name="ErrorController.php" hash="faa2499f262eb292b4efae794dd8ab51"/></dir><file name="PingController.php" hash="6c5f49b5078d8cbcef61177847c99910"/></dir></dir><dir name="etc"><file name="config.xml" hash="badc3caa0a566da2c1da2c8164a0f6e8"/><file name="system.xml" hash="0f787644d761de0fa87aac6fbdd8b8d0"/></dir><dir name="lib"><file name="Credentials.inc" hash="1bb03b43c6adb56e6ea39378aaa95c09"/><file name="SpeedTaxApi.inc" hash="438c2f5a6546f42c57b38a19a12326f0"/><file name="SpeedTaxUtil.inc" hash="a2bf5068a618ad8d6a0b100abef5c7c5"/><file name="WsSecurity.inc" hash="adc23ea90abf3a9e8dabd2147232bc6f"/><file name="WsSecurityTypes.inc" hash="d2de8ce7b4420b7100d09800d1e93a32"/></dir><dir name="sql"><dir name="speedtax_setup"><file name="mysql4-install-2.0.0.php" hash="a2a4c73ab5096cab3051cd598ee65bbc"/></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>