Skip to main content
Avalara Help Center

Install and Configure Avalara AvaTax for Salesforce B2C Commerce QuickStart

After you activate AvaTax Update and set up your company profile, install and configure AvaTax Update for Salesforce B2C Commerce QuickStart. 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 QuickStart

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

SFRA

Use this section to add the SFRA (previously MFRA) to your AvaTax Update for Salesforce B2C Commerce QuickStart installation. Find additional details in our AvaTax Update for Salesforce B2C Commerce QuickStart SFRA integration guide.

Install SFRA

To install SFRA, import the appropriate cartridges and metadata, and then configure the AvaTax Reconciliation utility.

Import cartridges

  1. In UXStudio, go to File > Import > General > Existing Projects into workspace.
  2. Browse to the directory where you saved the bm_avatax, int_avatax_sfra, 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_sfra appears before app_storefront_base.

Import metadata

  1. In the Salesforce B2C Commerce QuickStart Business Manager, go to Administration > Site Development > Site Import & Export.
  2. Under Import & Export, click Upload, browse to the site-import.zip file (located in the metadata folder), and then click Upload.
  3. Select the site-import.zip file and click Import.

Configure the AvaTax Reconciliation utility

  1. Go to Administration > Sites > Manage Sites > Business Manager – Settings and add the bm_avatax cartridge you previously imported in the BM cartridge path.
  2. Go to Administration > Organization > Roles & Permissions and select the role to give access to.
  3. Go to the Business Manager Modules section, select the context for the site or organization, and click Apply.
  4. In the list of BM modules that display, select AvaTax and click Update. The new AvaTax Update module and its menu items appear under Merchant Tools.

Configure SFRA

Configure SFRA with AvaTax Update services and custom preferences.

Configure SFRA services for AvaTax Update

  1. In the Salesforce B2C Commerce QuickStart Business Manager, go to Administration > Operations > Services.
  2. Complete the following on the indicated tabs:
    • Credentials
      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 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 QuickStart Business Manager, select the desired site.
  2. Go to Merchant Tools > AvaTax > AvaTax Settings and select all appropriate settings for your company's storefront, including:
    Field Action
    Tax Calculation Select to start calculating taxes with AvaTax Update on your transactions. Enabled by default.
    Address Validation

    Select to validate shipping addresses during checkout using AvaTax Update. Enabled by default.

    AvaTax Update only validates addresses in the US and Canada.

    Save Transactions to AvaTax

    Select to save all orders to AvaTax Update.

    If not enabled, orders aren't saved to AvaTax Update, and features such as voiding and modifying transactions aren't available.

    Commit Transactions to AvaTax Select to have successful storefront orders marked as Committed when posted to AvaTax Update.
    Company Code Enter the AvaTax Update company code you created in AvaTax Update.
    Customer code Select the value that's sent as the customer code for authenticated customers. For guest customers, Salesforce B2C Commerce QuickStart sends the email ID they enter during checkout.
    Shipping Tax Code Enter the default tax code to use to calculate taxes for shipping. If not specified, freight code FR is used.
    Location Code 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.
    ShipFrom address fields Make sure the values in these fields match the address of the distributor. AvaTax Update uses this address to calculate taxes on all orders.
  3. Go to Merchant Tools > Site Preferences > Order > Order Access Settings, set Limit Storefront Order Access to No.
  4. Go to Merchant Tools > Site Preferences > Promotion > Discount Taxation and select the appropriate Promotion Preference.

Install the SGJC 

The AvaTax Update for Salesforce B2C Commerce QuickStart SGJC controller cartridge provides rapid integration for Salesforce B2C Commerce QuickStart 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 QuickStart

To install AvaTax Update for Salesforce B2C Commerce QuickStart, 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 QuickStart Business Manager:

  1. In the Salesforce B2C Commerce QuickStart 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 QuickStart 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 QuickStart 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 QuickStart 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 QuickStart 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 QuickStart 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?