Avatax Connector App

Using The REST API To Build a Connector

Avalara’s new REST API
v2 now offers a
wide variety of functionality for integrating ERP systems with AvaTax.
In the new REST API, you can now add companies, estimate tax on the fly,
validate addresses, and more! For today’s article, we will focus on
building a web application to showcase how to use the new REST API to
build a connector.

Core Functionality

I am writing today’s example using Microsoft’s C# and MVC40 libraries
to demonstrate the following features of AvaTax

Basic Authentication

Address Validation

Generate Tax on an Invoice

I will be using two open source libraries, the Newtonsoft Json.Net
library to parse JSON results, and the RestSharp library to make REST
API calls.

Address Validation

Now we’re ready to begin work. This is one of the most important steps
for ERP integration. Simply speaking, for accurate tax calculation, we
need accurate addresses - Source and Destination addresses. But AvaTax
doesn’t stop at two address locations - now that technology is pushing
the boundaries of online businesses, REST API also offers multiple
addresses tax calculation on each line item of an invoice.

To get there, we first need to validate the address with AvaTax engine
and confirm that the address is “real” address – because a simple
mistake in the address can easily result in incorrect tax calculation.
I’ve written this function using a ‘ref’ parameter so that I can simply
call it and it will fix up my address for me.

Now that we have defined our models, all that remains is to fill-in the data and post the query to AvaTax. For my project today, I will limit my tax calculations to one line item per invoice; but you can easily change this by adding values to the array.