protected void lnkTestConnection_Click(object sender, EventArgs e) { var settings = new AvalaraSettings(); settings.Merge(HccApp.CurrentStore.Settings.TaxProviderSettingsGet(ProviderId)); settings.Account = txtAccount.Text.Trim(); settings.LicenseKey = txtLicenseKey.Text.Trim(); settings.CompanyCode = txtCompanyCode.Text.Trim(); settings.ServiceUrl = txtUrl.Text.Trim(); settings.DebugMode = chkDebug.Checked; settings.ShippingTaxCode = txtShippingTaxCode.Text.Trim(); settings.TaxExemptCode = txtTaxExemptCode.Text.Trim(); // Save Settings HccApp.CurrentStore.Settings.TaxProviderSettingsSet(ProviderId, settings); HccApp.AccountServices.Stores.Update(HccApp.CurrentStore); var avalaraProvider = Commerce.Taxes.Providers.TaxProviders.Find(ProviderId, HccApp.CurrentStore); if (avalaraProvider.TestConnection(HccApp.CurrentRequestContext)) { msg.ShowOk(Localization.GetString("AvataxConnectionSuccess")); } else { msg.ShowWarning(Localization.GetString("AvataxConnectionFail")); } }
public TaxCalculatorAvalara_Brasseler(IOrderLineUtilities orderLineUtilities, ICustomerOrderUtilities customerOrderUtilities, IUnitOfWorkFactory unitOfWorkFactory, TaxesSettings taxesSettings, AvalaraSettings avalaraSettings) { this.orderLineUtilities = orderLineUtilities; this.customerOrderUtilities = customerOrderUtilities; this.UnitOfWork = unitOfWorkFactory.GetUnitOfWork(); this.TaxesSettings = taxesSettings; this.customSettings = new CustomSettings(); this.AvalaraSettings = avalaraSettings; }
public override void LoadData() { var settings = new AvalaraSettings(); settings.Merge(HccApp.CurrentStore.Settings.TaxProviderSettingsGet(ProviderId)); txtAccount.Text = settings.Account; txtLicenseKey.Text = settings.LicenseKey; txtCompanyCode.Text = settings.CompanyCode; txtUrl.Text = settings.ServiceUrl; chkDebug.Checked = settings.DebugMode; txtShippingTaxCode.Text = settings.ShippingTaxCode; txtTaxExemptCode.Text = settings.TaxExemptCode; }
public override void SaveData() { var settings = new AvalaraSettings(); settings.Merge(HccApp.CurrentStore.Settings.TaxProviderSettingsGet(ProviderId)); settings.Account = txtAccount.Text.Trim(); settings.LicenseKey = txtLicenseKey.Text.Trim(); settings.CompanyCode = txtCompanyCode.Text.Trim(); settings.ServiceUrl = txtUrl.Text.Trim(); settings.DebugMode = chkDebug.Checked; settings.ShippingTaxCode = txtShippingTaxCode.Text.Trim(); settings.TaxExemptCode = txtTaxExemptCode.Text.Trim(); // Save Settings HccApp.CurrentStore.Settings.TaxProviderSettingsSet(ProviderId, settings); HccApp.AccountServices.Stores.Update(HccApp.CurrentStore); }
private void MigrateAvalaraTaxProviderSetting() { // 1.10.0: Avalara tax provider implementation has been changed for tax provider approach where end user can create their own tax provider any time. var context = new HccRequestContext(); var accountServices = Factory.CreateService <AccountService>(context); var stores = accountServices.Stores.FindAllPaged(1, int.MaxValue); foreach (var store in stores) { context.CurrentStore = store; var result = TaxProviders.AvailableProviders(); var avalaraProvider = result.FirstOrDefault(p => p.ProviderName == "Avalara"); var currentProvider = TaxProviders.CurrentTaxProvider(store); if (avalaraProvider != null) { var storesettings = context.CurrentStore.Settings; if (storesettings.Avalara.Enabled) { var settings = new AvalaraSettings(); settings.Merge(context.CurrentStore.Settings.TaxProviderSettingsGet(avalaraProvider.ProviderId)); if (string.IsNullOrEmpty(settings.LicenseKey)) { settings.Account = storesettings.Avalara.Account; settings.LicenseKey = storesettings.Avalara.LicenseKey; settings.CompanyCode = storesettings.Avalara.CompanyCode; settings.ServiceUrl = storesettings.Avalara.ServiceUrl; settings.DebugMode = storesettings.Avalara.DebugMode; settings.ShippingTaxCode = storesettings.Avalara.ShippingTaxCode; settings.TaxExemptCode = storesettings.Avalara.TaxExemptCode; // Save Settings context.CurrentStore.Settings.TaxProviderSettingsSet(avalaraProvider.ProviderId, settings); accountServices.Stores.Update(context.CurrentStore); if (currentProvider == null) { var taxProviderSetting = store.Settings.AllSettings.FirstOrDefault( s => s.SettingName == "TaxProvidersEnabled"); taxProviderSetting.SettingValue = avalaraProvider.ProviderId; var settingsRepo = Factory.CreateRepo <StoreSettingsRepository>(context); settingsRepo.Update(taxProviderSetting); } } } var avalraSettings = store.Settings.AllSettings.FindAll(s => s.SettingName.ToLower().StartsWith("avalara")); foreach (var item in avalraSettings) { var settingsRepo = Factory.CreateRepo <StoreSettingsRepository>(context); settingsRepo.Delete(item.Id); } } CacheManager.ClearForStore(context.CurrentStore.Id); } }