Version Notes
* Update API endpoints to use SmartCalcs v2.
* Clean up exception handling using Magento helper methods.
Download this release
Release Info
| Developer | TaxJar |
| Extension | Taxjar_Salestaxautomation |
| Version | 1.4.2 |
| Comparing to | |
| See all releases | |
Code changes from version 1.4.1 to 1.4.2
app/code/community/Taxjar/SalesTax/Model/Client.php
CHANGED
|
@@ -22,7 +22,12 @@ class Taxjar_SalesTax_Model_Client {
|
|
| 22 |
return json_decode($json, true);
|
| 23 |
}
|
| 24 |
else {
|
| 25 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 26 |
}
|
| 27 |
}
|
| 28 |
|
| 22 |
return json_decode($json, true);
|
| 23 |
}
|
| 24 |
else {
|
| 25 |
+
if ( $response->getStatus() == 403 ) {
|
| 26 |
+
Mage::throwException('Your last rate update was too recent. Please wait at least 5 minutes and try again.');
|
| 27 |
+
}
|
| 28 |
+
else {
|
| 29 |
+
Mage::throwException('Could not connect to TaxJar.');
|
| 30 |
+
}
|
| 31 |
}
|
| 32 |
}
|
| 33 |
|
app/code/community/Taxjar/SalesTax/Model/Debug.php
CHANGED
|
@@ -34,7 +34,7 @@ class Taxjar_SalesTax_Model_Debug {
|
|
| 34 |
$states = implode( ',', unserialize( Mage::getStoreConfig('taxjar/config/states') ) );
|
| 35 |
$apiUser = Mage::getModel('api/user');
|
| 36 |
$existingUserId = $apiUser->load('taxjar', 'username')->getUserId();
|
| 37 |
-
$pluginVersion = '1.4.
|
| 38 |
$phpMemory = @ini_get('memory_limit');
|
| 39 |
$phpVersion = @phpversion();
|
| 40 |
$magentoVersion = Mage::getVersion();
|
| 34 |
$states = implode( ',', unserialize( Mage::getStoreConfig('taxjar/config/states') ) );
|
| 35 |
$apiUser = Mage::getModel('api/user');
|
| 36 |
$existingUserId = $apiUser->load('taxjar', 'username')->getUserId();
|
| 37 |
+
$pluginVersion = '1.4.2';
|
| 38 |
$phpMemory = @ini_get('memory_limit');
|
| 39 |
$phpVersion = @phpversion();
|
| 40 |
$magentoVersion = Mage::getVersion();
|
app/code/community/Taxjar/SalesTax/Model/Observer.php
CHANGED
|
@@ -13,14 +13,14 @@ class Taxjar_SalesTax_Model_Observer {
|
|
| 13 |
* @param Varien_Event_Observer $observer
|
| 14 |
* @return void
|
| 15 |
*/
|
| 16 |
-
public function execute( $observer ) {
|
| 17 |
$session = Mage::getSingleton( 'adminhtml/session' );
|
| 18 |
$storeId = Mage::getModel('core/store')->load( $observer->getEvent()->getStore() )->getStoreId();
|
| 19 |
$apiKey = Mage::getStoreConfig('taxjar/config/apikey', $storeId);
|
| 20 |
$apiKey = preg_replace( '/\s+/', '', $apiKey );
|
| 21 |
|
| 22 |
if ( $apiKey ) {
|
| 23 |
-
$this->version = '
|
| 24 |
$client = Mage::getModel('taxjar/client');
|
| 25 |
$configuration = Mage::getModel('taxjar/configuration');
|
| 26 |
$regionId = Mage::getStoreConfig('shipping/origin/region_id', $storeId);
|
|
@@ -31,9 +31,10 @@ class Taxjar_SalesTax_Model_Observer {
|
|
| 31 |
|
| 32 |
if( isset( $this->regionCode ) ) {
|
| 33 |
$configJson = $client->getResource( $apiKey, $this->apiUrl( 'config' ) );
|
|
|
|
| 34 |
}
|
| 35 |
else {
|
| 36 |
-
|
| 37 |
}
|
| 38 |
|
| 39 |
if ( $debug ) {
|
|
@@ -41,7 +42,7 @@ class Taxjar_SalesTax_Model_Observer {
|
|
| 41 |
return;
|
| 42 |
}
|
| 43 |
|
| 44 |
-
if(
|
| 45 |
$dateUpdated = Mage::getStoreConfig('taxjar/config/last_update');
|
| 46 |
Mage::getSingleton('core/session')->addNotice("Your last rate update was too recent. Please wait at least 5 minutes and try again.");
|
| 47 |
return;
|
|
@@ -51,7 +52,7 @@ class Taxjar_SalesTax_Model_Observer {
|
|
| 51 |
$ratesJson = $client->getResource( $apiKey, $this->apiUrl( 'rates' ));
|
| 52 |
}
|
| 53 |
else {
|
| 54 |
-
|
| 55 |
}
|
| 56 |
|
| 57 |
Mage::getModel('core/config')
|
|
@@ -69,7 +70,7 @@ class Taxjar_SalesTax_Model_Observer {
|
|
| 69 |
}
|
| 70 |
else {
|
| 71 |
// We need to be able to store the file...
|
| 72 |
-
|
| 73 |
}
|
| 74 |
|
| 75 |
}
|
|
@@ -101,7 +102,7 @@ class Taxjar_SalesTax_Model_Observer {
|
|
| 101 |
$shippingTaxable = Mage::getStoreConfig('taxjar/config/freight_taxable');
|
| 102 |
$ratesJson = unserialize( file_get_contents( $filename ) );
|
| 103 |
|
| 104 |
-
foreach( $ratesJson as $rateJson ) {
|
| 105 |
$rateIdWithShippingId = $rate->create( $rateJson );
|
| 106 |
|
| 107 |
if ( $rateIdWithShippingId[0] ) {
|
|
@@ -133,13 +134,13 @@ class Taxjar_SalesTax_Model_Observer {
|
|
| 133 |
*/
|
| 134 |
private function apiUrl( $type ) {
|
| 135 |
$apiHost = 'https://api.taxjar.com/';
|
| 136 |
-
$prefix = $apiHost .
|
| 137 |
|
| 138 |
if ( $type == 'config' ) {
|
| 139 |
-
return $prefix . '
|
| 140 |
}
|
| 141 |
elseif ( $type == 'rates' ) {
|
| 142 |
-
return $prefix . '
|
| 143 |
}
|
| 144 |
}
|
| 145 |
|
| 13 |
* @param Varien_Event_Observer $observer
|
| 14 |
* @return void
|
| 15 |
*/
|
| 16 |
+
public function execute( $observer ) {
|
| 17 |
$session = Mage::getSingleton( 'adminhtml/session' );
|
| 18 |
$storeId = Mage::getModel('core/store')->load( $observer->getEvent()->getStore() )->getStoreId();
|
| 19 |
$apiKey = Mage::getStoreConfig('taxjar/config/apikey', $storeId);
|
| 20 |
$apiKey = preg_replace( '/\s+/', '', $apiKey );
|
| 21 |
|
| 22 |
if ( $apiKey ) {
|
| 23 |
+
$this->version = 'v2';
|
| 24 |
$client = Mage::getModel('taxjar/client');
|
| 25 |
$configuration = Mage::getModel('taxjar/configuration');
|
| 26 |
$regionId = Mage::getStoreConfig('shipping/origin/region_id', $storeId);
|
| 31 |
|
| 32 |
if( isset( $this->regionCode ) ) {
|
| 33 |
$configJson = $client->getResource( $apiKey, $this->apiUrl( 'config' ) );
|
| 34 |
+
$configJson = $configJson['configuration'];
|
| 35 |
}
|
| 36 |
else {
|
| 37 |
+
Mage::throwException("Please check that you have set a Region/State in Shipping Settings.");
|
| 38 |
}
|
| 39 |
|
| 40 |
if ( $debug ) {
|
| 42 |
return;
|
| 43 |
}
|
| 44 |
|
| 45 |
+
if( $configJson['wait_for_rates'] > 0 ) {
|
| 46 |
$dateUpdated = Mage::getStoreConfig('taxjar/config/last_update');
|
| 47 |
Mage::getSingleton('core/session')->addNotice("Your last rate update was too recent. Please wait at least 5 minutes and try again.");
|
| 48 |
return;
|
| 52 |
$ratesJson = $client->getResource( $apiKey, $this->apiUrl( 'rates' ));
|
| 53 |
}
|
| 54 |
else {
|
| 55 |
+
Mage::throwException("Please check that your zip code is a valid US zip code in Shipping Settings.");
|
| 56 |
}
|
| 57 |
|
| 58 |
Mage::getModel('core/config')
|
| 70 |
}
|
| 71 |
else {
|
| 72 |
// We need to be able to store the file...
|
| 73 |
+
Mage::throwException("Could not write to your Magento temp directory. Please check permissions for " . Mage::getBaseDir('tmp') . ".");
|
| 74 |
}
|
| 75 |
|
| 76 |
}
|
| 102 |
$shippingTaxable = Mage::getStoreConfig('taxjar/config/freight_taxable');
|
| 103 |
$ratesJson = unserialize( file_get_contents( $filename ) );
|
| 104 |
|
| 105 |
+
foreach( $ratesJson['rates'] as $rateJson ) {
|
| 106 |
$rateIdWithShippingId = $rate->create( $rateJson );
|
| 107 |
|
| 108 |
if ( $rateIdWithShippingId[0] ) {
|
| 134 |
*/
|
| 135 |
private function apiUrl( $type ) {
|
| 136 |
$apiHost = 'https://api.taxjar.com/';
|
| 137 |
+
$prefix = $apiHost . $this->version . '/plugins/magento/';
|
| 138 |
|
| 139 |
if ( $type == 'config' ) {
|
| 140 |
+
return $prefix . 'configuration/' . $this->regionCode;
|
| 141 |
}
|
| 142 |
elseif ( $type == 'rates' ) {
|
| 143 |
+
return $prefix . 'rates/' . $this->regionCode . '/' . $this->storeZip;
|
| 144 |
}
|
| 145 |
}
|
| 146 |
|
app/code/community/Taxjar/SalesTax/etc/config.xml
CHANGED
|
@@ -6,7 +6,7 @@
|
|
| 6 |
-->
|
| 7 |
<config>
|
| 8 |
<modules>
|
| 9 |
-
<Taxjar_SalesTax><version>1.4.
|
| 10 |
</modules>
|
| 11 |
<global>
|
| 12 |
<helpers>
|
| 6 |
-->
|
| 7 |
<config>
|
| 8 |
<modules>
|
| 9 |
+
<Taxjar_SalesTax><version>1.4.2</version></Taxjar_SalesTax>
|
| 10 |
</modules>
|
| 11 |
<global>
|
| 12 |
<helpers>
|
package.xml
CHANGED
|
@@ -1,18 +1,19 @@
|
|
| 1 |
<?xml version="1.0"?>
|
| 2 |
<package>
|
| 3 |
<name>Taxjar_Salestaxautomation</name>
|
| 4 |
-
<version>1.4.
|
| 5 |
<stability>stable</stability>
|
| 6 |
<license>MIT</license>
|
| 7 |
<channel>community</channel>
|
| 8 |
<extends/>
|
| 9 |
<summary>Easily collect sales tax without altering your Magento store’s checkout experience or performance.</summary>
|
| 10 |
<description>TaxJar for Magento allows you to install rates for multiple origin or destination-based states without affecting your store's checkout experience.</description>
|
| 11 |
-
<notes>*
|
|
|
|
| 12 |
<authors><author><name>TaxJar</name><user>taxjar</user><email>support@taxjar.com</email></author></authors>
|
| 13 |
-
<date>2015-11-
|
| 14 |
-
<time>22:
|
| 15 |
-
<contents><target name="magecommunity"><dir name="Taxjar"><dir name="SalesTax"><dir name="Helper"><file name="Data.php" hash="ac18fc627650990eac98f5627ff51749"/></dir><dir name="Model"><file name="Calculation.php" hash="8ed668d8db488d7e48bef11434f09060"/><file name="Client.php" hash="
|
| 16 |
<compatible/>
|
| 17 |
<dependencies><required><php><min>5.0.0</min><max>6.0.0</max></php></required></dependencies>
|
| 18 |
</package>
|
| 1 |
<?xml version="1.0"?>
|
| 2 |
<package>
|
| 3 |
<name>Taxjar_Salestaxautomation</name>
|
| 4 |
+
<version>1.4.2</version>
|
| 5 |
<stability>stable</stability>
|
| 6 |
<license>MIT</license>
|
| 7 |
<channel>community</channel>
|
| 8 |
<extends/>
|
| 9 |
<summary>Easily collect sales tax without altering your Magento store’s checkout experience or performance.</summary>
|
| 10 |
<description>TaxJar for Magento allows you to install rates for multiple origin or destination-based states without affecting your store's checkout experience.</description>
|
| 11 |
+
<notes>* Update API endpoints to use SmartCalcs v2.
|
| 12 |
+
* Clean up exception handling using Magento helper methods.</notes>
|
| 13 |
<authors><author><name>TaxJar</name><user>taxjar</user><email>support@taxjar.com</email></author></authors>
|
| 14 |
+
<date>2015-11-24</date>
|
| 15 |
+
<time>22:25:08</time>
|
| 16 |
+
<contents><target name="magecommunity"><dir name="Taxjar"><dir name="SalesTax"><dir name="Helper"><file name="Data.php" hash="ac18fc627650990eac98f5627ff51749"/></dir><dir name="Model"><file name="Calculation.php" hash="8ed668d8db488d7e48bef11434f09060"/><file name="Client.php" hash="c3677c1837c8f81739f709a746a5f475"/><file name="Comment.php" hash="d57814eb90d75a6929bdc648a31bb40d"/><file name="Configuration.php" hash="4cca6c1cd99a0feab9f359cdfddfb028"/><file name="Debug.php" hash="201787f4e6299ae21121d090c00f9588"/><file name="Observer.php" hash="c96e8ab8d03a00b70292fe0560cd0df3"/><file name="Rate.php" hash="1171640b851841ce6d325e21ce1b1601"/><file name="Rule.php" hash="0175c047a5d2052bb8ba21242981e9ac"/></dir><dir name="etc"><file name="adminhtml.xml" hash="4ea028ad6b00688d99531597e8d3c404"/><file name="config.xml" hash="5089b3da33e0d33550eb90520731953e"/><file name="system.xml" hash="8dc55519eef0349d487f4039eabda164"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Taxjar_SalesTax.xml" hash="60b211e28d8b9d4cc49d1dd746d4aa46"/></dir></target></contents>
|
| 17 |
<compatible/>
|
| 18 |
<dependencies><required><php><min>5.0.0</min><max>6.0.0</max></php></required></dependencies>
|
| 19 |
</package>
|
