Skip to main content
Avalara Help Center

Install and Configure Avalara AvaTax for Salesforce B2C Commerce

After you activate AvaTax Update and set up your company profile, install and configure AvaTax Update for your accounting software. During configuration, customize your setup to fit your unique business needs for things like:

  • Tax calculation settings for various tax types
  • Product taxability settings

Alter these settings when your business needs change.

Find steps to install and configure the SiteGenesis JavaScript Controller (SGJC) after the StoreFront Reference Architecture (SFRA) sections.

Download the AvaTax Update integration for Salesforce B2C Commerce

Find and download the AvaTax Update integration from the Salesforce B2C Commerce marketplace.

SFRA

Use this section to add the SFRA (previously MFRA) to your AvaTax Update for Salesforce B2C Commerce installation.

Install SFRA

To install SFRA, import the appropriate cartridges and customizations.

Import the int_avatax_mfra and int_avatax_svcclient

  1. In UXStudio, go to File > Import > General > Existing Projects Into Workspace.
  2. Browse to the directory where you saved the int_avatax_mfra and int_avatax_svcclient cartridges, select them, and then click Finish.
  3. When prompted to link the cartridges to the sandbox, click OK.
  4. Go to Business Manager > Administration > Manage Sites, modify the site path, and then make sure the cartridge name int_avatax_mfra appears before your SFRA cartridge.

Import the system object customizations

  1. In the Salesforce B2C Commerce Business Manager, go to Administration > Sites Development > Import & Export.
  2. Under Import & Export, click Upload, browse to the avatax_mfra_metadata.xml file (located within int_avatax folder), and then click Upload.
  3. Click << Back at the bottom of the page.
  4. Under Meta Data, click Import, select the avatax_mfra_metadata.xml file, and then click Next.
  5. When validation completes, click Next.

Configure SFRA

Configure SFRA with AvaTax Update services and custom preferences.

Configure SFRA services for AvaTax Update

  1. In the Salesforce B2C Commerce Business Manager, go to Administration > Operations > Import & Export.
  2. Under Import & Export, click Upload, browse to the avatax_mfra_service.xml file, and then click Upload.
  3. Click << Back at the bottom of the page.
  4. Under Services, click Import, select the avatax_mfra_service.xml file, and then click Next.
  5. When validation completes, click Next.
  6. Complete the following on the indicated tabs:
    • Credential
      Field Action
      Name Enter credentials.avatax.rest
      URL
      • User
      • Password

      Enter your AvaTax Update username and password.

      Alternately, enter your AvaTax Update account ID in User and AvaTax Update license key in Password.

    • Profile

      Field Action
      Name Enter profile.avatax.rest
      Connection Timeout (ms) We recommend you enter 20,000
      All other fields Enter 0
    • Service

      Field Action
      Name Enter avatax.rest.all
      Type Select HTTP
      Enabled Select this option to enable the AvaTax Update for SFRA
      Service Mode Select Live
      Communication Log Enable Select this option
      Profile Select profile.avatax.rest
      Credentials Select credentials.avatax.rest

Configure AvaTax Update site preferences for SFRA

  1. In the Salesforce B2C Commerce Business Manager, from the tabs across the top of the page, select the desired site.
  2. Click Site Preferences, and then click Custom Preferences.
  3. Fill in all of the site preferences, including:
    Field Action
    Enable AvaTax Select Yes to start calculating taxes with AvaTax Update on your transactions. Enabled by default.
    Enable Address Validation Select Yes to validate addresses using AvaTax Update. Enabled by default.
    Enable Test Pipelines Select Yes to enable access to AvaTaxTest pipelines on the storefront. Enabled by default.
    AvaTax Company Code Enter your AvaTax Update company code to save transactions to companies configured in AvaTax Update
    AvaTax Default Shipping Method Tax Code (Tax) Enter the default tax code to send when a shipping method has no tax class ID
    AvaTax ShipFrom location code Complete this field only if a location code is configured for a company in AvaTax Update with a valid distributor address. If anything is entered in this field, it's used for tax calculation on all your transactions and is given priority over all other ship from address fields.
    • Avatax ShipFrom City
    • Avatax ShipFrom StateCode
    • Avatax ShipFrom ZipCode
    • Avatax ShipFrom Country Code
    Make sure the values in these fields match the address of the distributor

Install the SGJC 

The AvaTax Update for Salesforce B2C Commerce SGJC controller cartridge provides rapid integration for Salesforce B2C Commerce implementations. The self-contained cartridge easily integrates into any project. It can be configured in the Business Manager and contains all elements necessary to perform a successful best practices implementation.

Install the AvaTax Update integration for Salesforce B2C Commerce

To install AvaTax Update for Salesforce B2C Commerce, complete all the steps in this section.

Import the int_avatax cartridge and add SOAP services

  1. In  UXStudio, go to File > Import > General > Existing Projects Into Workspace.
  2. Browse to the directory where you saved the int_avatax cartridge, select it, and then click Finish.
  3. Browse to the root directory of your storefront cartridge and open package.json. (If the file doesn't exist, create it.)
  4. Add the following line to it:
    "init": ["int_avatax/cartridge/scripts/avatax/services/soapServiceInit.ds"]

    clipboard_ed77881cacda868786df465a9f12b9910.png

Import site preferences and custom objects

To import the system object customizations into the Salesforce B2C Commerce Business Manager:

  1. In the Salesforce B2C Commerce Business Manager, go to Administration > Sites Development > Import & Export.
  2. Under Import & Export, click Upload, browse to the avatax_metadata.xml file, and then click Upload.
  3. Click << Back at the bottom of the page.
  4. Under Meta Data, click Import, select the avatax_metadata.xml file, and then click Next.
  5. When validation completes, click Next.

Configure the SGJC

Add the AvaTax Update cartridge to your storefront cartridge path, configure AvaTax Update custom preferences and services, and then add custom code to your cartridges.

Append int_avatax to the effective cartridge path

  1. In the Salesforce B2C Commerce Business Manager, go to Administration > Sites > Manage Sites, and then select the desired site.
  2. On the Settings tab, append :int_avatax to Cartridges.
  3. Click Apply.

Configure AvaTax Update custom preferences

  1. In the Salesforce B2C Commerce Business Manager, from the tabs across the top of the page, select the desired site.
  2. Click Site Preferences, and then click Custom Preferences.
  3. Fill in all of the site preferences, including:
    Field Action
    Enable AvaTax Select Yes to start calculating taxes with AvaTax Update on your transactions. Enabled by default.
    Enable Address Validation Select Yes to validate addresses using AvaTax Update. Enabled by default.
    Enable Test Pipelines Select Yes to enable access to AvaTaxTest pipelines on the storefront. Enabled by default.
    Save transactions to AvaTax Select Yes to save uncommitted transactions to AvaTax Update.
    On successful payment commit transaction to AvaTax If Save transactions to AvaTax is set to Yes, select Yes to commit uncommitted transactions to AvaTax Update when marked as Paid. Disabled by default.
    AVS Excluded Countries Upload a CSV of country codes to exclude when validating addresses  
    AvaTax Company Code Enter your AvaTax Update company code to save transactions to companies configured in AvaTax Update
    Customer Code Select the attribute to use as the customer code. If a customer completes their transaction as a guest, the customer email is used regardless of what's selected here.
    Custom attribute for customer code If the source selected for Customer Code is Use another attribute from 'Profile' System object, enter 
    AvaTax Default Shipping Method Tax Code (Tax) Enter the default tax code to send when a shipping method has no tax class ID
    AvaTax Default Product Tax Code (Tax) Enter the default tax code to send when a product has no tax class ID
    • Avatax ShipFrom City
    • Avatax ShipFrom StateCode
    • Avatax ShipFrom ZipCode
    • Avatax ShipFrom Country Code
    Make sure the values in these fields match the address of the distributor

Add AvaTax Update tax and address validation services

  1. In the Salesforce B2C Commerce Business Manager, go to Administration > Operations > Services.
  2. On the Credentials tab, click New, fill in the following for tax services, and then click Apply:
    Field Action
    Name Enter a name of your choice
    URL
    • User
    • Password

    Enter your AvaTax Update username and password.

    Alternately, enter your AvaTax Update account ID in User and AvaTax Update license key in Password.

  3. On the Credentials tab, click New, fill in the following for address validation services, and then click Apply:
    Field Action
    Name Enter a name of your choice
    URL
    • User
    • Password

    Enter your AvaTax Update username and password.

    Alternately, enter your AvaTax Update account ID in User and AvaTax Update license key in Password.

  4. On the Profiles tab, click New.
  5. Enter a name for the tax service profile, fill out the other settings, and then click Apply.
  6. Repeat steps 4-5 for the address validation service profile.
  7. On the Services tab, click New, fill in the following, and then click Apply:
    Field Action
    Name Enter avatax.soap.GetTax
    Type Select SOAP
    • Profile
    • Credentials
    Choose the profile and credentials you created for the tax service
  8. On the Services tab, click New, fill in the following, and then click Apply:
    Field Action
    Name Enter avatax.soap.CancelTax
    Type Select SOAP
    • Profile
    • Credentials
    Choose the profile and credentials you created for the tax service
  9. On the Services tab, click New, fill in the following, and then click Apply:
    Field Action
    Name Enter avatax.soap.PostTax
    Type Select SOAP
    • Profile
    • Credentials
    Choose the profile and credentials you created for the tax service
  10. On the Services tab, click New, fill in the following, and then click Apply:
    Field Action
    Name Enter avatax.soap.ValidateAddress
    Type Select SOAP
    • Profile
    • Credentials
    Choose the profile and credentials you created for the address validation service

Add custom code to SGJC

Modify Salesforce B2C Commerce SGJCs to finish integrating with AvaTax Update.

  1. In CartMode.js, add the blue, bolded code to the following modules and functions:
    1. Include the Site module by adding:
      /**
       * Model for cart functionality. Creates a CartModel class with payment, shipping, and product
       * helper methods.
       * @module models/CartModel
       */
      var Transaction = require('dw/system/Transaction');
      var Site = require('dw/system/Site');
    2. Include the avataxApp module by adding:
      var lineItem;
      var app = require('~/cartridge/scripts/app');
      var ProductList = app.getModel('ProductList');
      var avataxApp = require('int_avatax/cartridge/scripts/app');
    3. To the calculate function add:
      calculate: function () {
      if(Site.getCurrent().preferences.custom.hasOwnProperty('ATEnable') && Site.getCurrent().getCustomPreferenceValue('ATEnable')) {
           avataxApp.getController('Avatax').CalculateTaxes(this.object);

      dw.system.HookMgr.callHook('dw.ocapi.shop.basket.calculate', 'calculate', this.object);
      },
    4. In the createOrder function, add orderNo as a parameter and include orderNo in the OrderMgr.createOrder call:
      createOrder: function (OrderNo) {
      var basket = this.object;
      var order;
      try {
            order = Transaction.wrap(function () {
                      return OrderMgr.createOrder(basket,OrderNo);
                       });
  2. In COPlaceOrder.js, add the blue, bolded code to the start function:
    1. After the check that the billing module is fulfilled, add:

      if (!session.forms.billing.fulfilled.value) {
          app.getController('COCustomer').Start();
          return {};
      }

      Var OrderNo = orderMgr.createOrderNo(); 

      session.custom.NoCall = false;
      session.custom.OrderNo = OrderNo;
      session.custom.finalCall = true;


      Transaction.wrap(function () {
          cart.calculate();
      });

    2. Pass OrderNo to the cart.createOrder() function:
       // Creates a new order. This will internally ReserveInventoryForOrder and will create a new Order with status
      // 'Created'.
           var order = cart.createOrder(OrderNo);
  3. In COShipping.js, add the blue, bolded code to the following functions:
    1. In the selectShippingMethod function, before the cart is calculated, set the NoCall variable to false:
      applicableShippingMethods = cart.getApplicableShippingMethods(address);    
      session.custom.NoCall = false;
      Transaction.wrap(function () {
      cart.updateShipmentShippingMethod(cart.getDefaultShipment().getID(),   request.httpParameterMap.shippingMethodID.stringValue, null, applicableShippingMethods);
              cart.calculate();
      });
    2. In the updateShippingMethodList function, assign the NoCall variable to true before looping through the shipping methods and to false after the loop is complete, before the cart is calculated:

      Transaction.begin();
          
          session.custom.NoCall = true;

          for (i = 0; i < applicableShippingMethods.length; i++) {
              method = applicableShippingMethods[i];

              cart.updateShipmentShippingMethod(cart.getDefaultShipment().getID(), method.getID(), method, applicableShippingMethods);
              cart.calculate();
              shippingCosts.put(method.getID(), cart.preCalculateShipping(method));
          } 
          session.custom.NoCall = false;

          Transaction.rollback();

          Transaction.wrap(function () {
              cart.updateShipmentShippingMethod(cart.getDefaultShipment().getID(), currentShippingMethod.getID(), currentShippingMethod, applicableShippingMethods);
              cart.calculate();
          });

  4. In calculate.js, require the Site module and add the following blue, bolded conditional statement around calculateTax() to avoid calling it if AvaTax Update is enabled:

    Var Site = require('dw/system/Site');

    and add the following conditional statement around calculateTax() to avoid calling it if Avatax is enabled:
     if(!Site.getCurrent().getCustomPreferenceValue('ATEnable')) {
                 calculateTax(basket);
        }

Test the connection with AvaTax Update

Navigate to the connection test address to make sure you're properly connecting to AvaTax Update.

  1. In the Salesforce B2C Commerce Business Manager, go to Storefront.
  2. In the browser address bar, at the end of the URL, replace Home-Show with Test-Connect, and then press Enter. For example:
    Change http://realmURL/ on/demandware.store/Sites-mysite-Site/default/Home-Show
    to http://realmURL/on/demandware.store/Sites-mysite-Site/default/Test-Connect
  • Was this article helpful?