public async Task <IActionResult> DownloadCertificate(int id)
        {
            var customer = await _workContext.GetCurrentCustomerAsync();

            if (!await _customerService.IsRegisteredAsync(customer))
            {
                return(Challenge());
            }

            //ensure that Avalara tax provider is active
            if (!await _taxPluginManager.IsPluginActiveAsync(AvalaraTaxDefaults.SystemName, customer))
            {
                return(RedirectToRoute("CustomerInfo"));
            }

            if (!_avalaraTaxSettings.EnableCertificates)
            {
                return(RedirectToRoute("CustomerInfo"));
            }

            //ACL
            if (_avalaraTaxSettings.CustomerRoleIds.Any())
            {
                var customerRoleIds = await _customerService.GetCustomerRoleIdsAsync(customer);

                if (!customerRoleIds.Intersect(_avalaraTaxSettings.CustomerRoleIds).Any())
                {
                    return(RedirectToRoute("CustomerInfo"));
                }
            }

            //try to get a file by the identifier
            var file = await _avalaraTaxManager.DownloadCertificateAsync(id);

            if (file is null)
            {
                return(InvokeHttp404());
            }

            return(File(file.Data, file.ContentType, file.Filename?.Split(';')?.FirstOrDefault() ?? "certificate"));
        }