Skip to content

Saleor Core: the high performance, composable, headless commerce API.

Added optional HTTPS settings for the taxes fetch + error logging

NyanKiyoshifb0ac0cb10d5
diff --git a/docs/guides/taxes.rst b/docs/guides/taxes.rst
index 2218cdf99c..d24c3975e9 100644
--- a/docs/guides/taxes.rst
+++ b/docs/guides/taxes.rst
@@ -35,8 +35,17 @@ You can preview tax rates in dashboard ``Taxes`` tab. It lists all countries tax
Fetching taxes
--------------
- Assuming one provided valid ``VATLAYER_ACCESS_KEY``, taxes can be fetched via following command:
+ Assuming you have provided a valid ``VATLAYER_ACCESS_KEY``, taxes can be fetched via following command:
.. code-block:: console
$ python manage.py get_vat_rates
+
+
+ If you do not have a VatLayer API key, you can get one by `subscribing for free here <https://vatlayer.com/signup?plan=9>`_.
+
+
+ .. warning::
+
+ By default, Saleor is making requests to the VatLayer API through HTTP (insecure),
+ if you are using a paid VatLayer subscription, you may want to set the settings ``VATLAYER_USE_HTTPS`` to ``True``.
diff --git a/saleor/dashboard/taxes/views.py b/saleor/dashboard/taxes/views.py
index 37041688d5..60f3b580ba 100644
--- a/saleor/dashboard/taxes/views.py
+++ b/saleor/dashboard/taxes/views.py
@@ -1,3 +1,5 @@
+import logging
+
from django.conf import settings
from django.contrib import messages
from django.contrib.auth.decorators import permission_required
@@ -16,6 +18,8 @@ from ...dashboard.taxes.filters import TaxFilter
from ...dashboard.taxes.forms import TaxesConfigurationForm
from ...dashboard.views import staff_member_required
+logger = logging.getLogger(__name__)
+
@staff_member_required
def tax_list(request):
@@ -63,10 +67,12 @@ def fetch_tax_rates(request):
msg = pgettext_lazy(
'Dashboard message', 'Tax rates updated successfully')
messages.success(request, msg)
- except ImproperlyConfigured:
+ except ImproperlyConfigured as exc:
+ logger.exception(exc)
msg = pgettext_lazy(
'Dashboard message',
- 'Could not fetch tax rates. You have not supplied a valid API '
- 'Access Key')
+ 'Could not fetch tax rates. '
+ 'Make sure you have supplied a valid API Access Key.<br/>'
+ 'Check the server logs for more information about this error.')
messages.warning(request, msg)
return redirect('dashboard:taxes')
diff --git a/saleor/settings.py b/saleor/settings.py
index e4922189d2..cb353e7276 100644
--- a/saleor/settings.py
+++ b/saleor/settings.py
@@ -319,7 +319,9 @@ OPENEXCHANGERATES_API_KEY = os.environ.get('OPENEXCHANGERATES_API_KEY')
# VAT configuration
# Enabling vat requires valid vatlayer access key.
+# If you are subscribed to a paid vatlayer plan, you can enable HTTPS.
VATLAYER_ACCESS_KEY = os.environ.get('VATLAYER_ACCESS_KEY')
+VATLAYER_USE_HTTPS = get_bool_from_env('VATLAYER_USE_HTTPS', False)
ACCOUNT_ACTIVATION_DAYS = 3