Comments (5)
+1
from craft-avatax.
Good idea @curtismorte! We'll add this.
from craft-avatax.
As a side note,
We're fighting two things here. The first is a quick way to shim up a database without the actual data (a la project configuration files /app/project/project.yaml
) and having environment specific configurations. While environment specific configurations are really what I am after, we still don't want configs being committed with keys. So thanks for adding the enhancement label.
Per the documentation you can get around this by:
- Installing the plugin, not specifying settings through the control panel, and committing your project config file to version control with empty values.
- Specifying an environment configuration file.
When you have an environment configuration file, you can't adjust settings via the control panel so the project config can't get updated ;)
An example configuration file: (/app/avatax.php
)
<?php
use craft\helpers\App;
/**
* Avatax plugin for Craft CMS 3.x
*
* Calculate and add sales tax to an order's base tax using Avalara's AvaTax service.
*
* @link http://surprisehighway.com
* @copyright Copyright (c) 2019 Surprise Highway
*/
/**
* Avatax config.php
*
* This file exists only as a template for the Avatax settings.
* It does nothing on its own.
*
* Don't edit this file, instead copy it to 'craft/config' as 'avatax.php'
* and make your changes there to override default settings.
*
* Once copied to 'craft/config', this file will be multi-environment aware as
* well, so you can have different settings groups for each environment, just as
* you do for 'general.php'
*/
return [
'*' => [
// Enable debugging - true or false
'debug' => false,
// The address you will be posting from.
'shipFromName' => '',
'shipFromStreet1' => '',
'shipFromStreet2' => '',
'shipFromStreet3' => '',
'shipFromCity' => '',
'shipFromState' => '',
'shipFromZipCode' => '',
'shipFromCountry' => '',
// The default Avalara Tax Code to use for Products.
'defaultTaxCode' => '',
// The default Avalara Tax Code to use for Shipping.
'defaultShippingCode' => 'FR',
// The default Avalara Tax Code to use for Discounts.
'defaultDiscountCode' => 'OD010000',
// Production account information.
'accountId' => App::env('AVALARA_ACCOUNT_ID'),
'licenseKey' => App::env('AVALARA_LICENSE_KEY'),
'companyCode' => App::env('AVALARA_COMPANY_CODE'),
// Sandbox account information.
'sandboxAccountId' => App::env('AVALARA_SANDBOX_ACCOUNT_ID'),,
'sandboxLicenseKey' => App::env('AVALARA_SANDBOX_LICENSE_KEY'),
'sandboxCompanyCode' => App::env('AVALARA_SANDBOX_COMPANY_CODE'),
// AvaTax options - true or false
'enableTaxCalculation' => true,
'enableCommitting' => false,
'enableAddressValidation' => true,
'enablePartialRefunds' => true,
],
'dev' => [
// Enable debugging - true or false
'debug' => true,
// Environment - 'production' or 'sandbox'.
'environment' => 'sandbox',
],
'stage' => [
// Environment - 'production' or 'sandbox'.
'environment' => 'sandbox',
],
'production' => [
// Environment - 'production' or 'sandbox'.
'environment' => 'production',
// AvaTax options - true or false
'enableCommitting' => true,
],
];
Remember Avalara sandbox accounts are actually different accounts that you must pay for (yeah don't worry, I'm not amazingly thrilled by this either) so if you want to use your production account for all environments that is fine, just make sure you have transaction committing turned off for any non-production environments. Note that you still get billed for your production usage because of this. Take a dive further into AvaTax sandbox environments to learn more. This is also not legal / tax advice ;)
from craft-avatax.
Should this have been closed? Ideally, this plugin would utilize https://craftcms.com/docs/3.x/extend/environmental-settings.html#autosuggest-inputs
from craft-avatax.
@knynkwl @curtismorte - Just pushed v2.1.4 which addresses these issues. In the plugin settings I've made the account info fields autosuggest fields that will suggest ENV variables.
On the project config side it turns out if you do something like 'accountId' => App::env('AVALARA_ACCOUNT_ID'),
the actual value is parsed and exposed in the project.yaml file. So instead I added the parseEnv logic to the plugin settings and you can instead now do something like this in your project config once your ENV variables are set up:
// Production account information from ENV.
'accountId' => '$AVATAX_ACCOUNT_ID',
'licenseKey' => '$AVATAX_LICENSE_KEY',
'companyCode' => '$AVATAX_COMPANY_CODE',
// Sandbox account information from ENV.
'sandboxAccountId' => '$AVATAX_SANDBOX_ACCOUNT_ID',
'sandboxLicenseKey' => '$AVATAX_SANDBOX_LICENSE_KEY',
'sandboxCompanyCode' => '$AVATAX_SANDBOX_COMPANY_CODE',
Updated in the readme here:
https://github.com/surprisehighway/craft-avatax#config-overrides
Great ideas all around, thanks!
from craft-avatax.
Related Issues (20)
- Use Craft Autosuggest fields to support env-based config HOT 1
- 400 Error when validating address with AJAX HOT 3
- Craft Commerce 3.0 Support HOT 4
- Provide setting to select when order is committed HOT 4
- TypeError - Arg 1 passed to validateAddress() must be an instance of craft\commerce\models\Address? HOT 3
- Cannot edit plugin settings HOT 3
- Is this plugin a custom integration? HOT 2
- Invalid address error results in uncaught exception HOT 2
- Request to avatax.com failed HOT 7
- Cart passing all items as non-taxable HOT 2
- SalesTaxService.php - Request could not be completed HOT 5
- $model is undefined - SalesTaxService.php HOT 1
- After install event breaking automated testing HOT 9
- Allowing Programmatic Tax Calculation HOT 5
- Error if the order is saved through console command in 2.1.7 version HOT 1
- Guzzle Error HOT 2
- Does this plugin support international fees? (Customs / VAT / etc). HOT 1
- Craftcms 4 compatibility HOT 1
- Commerce V4, Address Validation Fails - Calling Unknown Method SalesTaxService:getState() HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from craft-avatax.