|
In April 2008 I started writing a ColdFusion Component allowing CF applications to consume Avalara's AvaTax web services. The CFC exists to simplify the connection to AvaTax to receive tax rates, though for advanced integrations going with a native java CFX is probably best. Download: Click here to download the latest AvaTax Adapter CFC package. Requirements: - A ColdFusion MX, MX 7, or 8 Server - Avalara's Java SDK JAR File Setup & Installation: AvaTax Java Files - Get the AvaTax Java SDK from Avalara - Extract the JAR file and place the JAR in c:\CFusionMX7\lib\ folder - Restart your CF service on the server to load the new JAR in memory
AvaTax Adapter CFC - Download the zip file from the link above - Place the CFC in a common directory or the same directory as your scripts - Use the CreateObject tag to create an instance of the adapter (Note: The adapter is not thread safe, thus should not be in a shared scope like application or server. There's very little time saved in keeping it around as a singleton so don't do it!) Calling AvaTax Adapter: See the sample code to call the AvaTax Adapter component Receiving Rate Results: Results are stored inside the Adapter and the isTaxReady property is set to true. A simple output table here shows how you can call results. <cfoutput> <table border=1 cellspacing=0 cellpadding=2> <tr> <td><b>isTaxReady</b></td> <td>#avaTaxAdapter.isTaxReady#</td> </tr> <tr> <td><b>Document ID</b></td> <td>#avaTaxAdapter.docId#</td> </tr> <tr> <td><b>Result Code</b></td> <td>#avaTaxAdapter.resultCode#</td> </tr> <tr> <td><b>Total Taxable</b></td> <td>#DollarFormat(avaTaxAdapter.TotalTaxable)#</td> </tr> <tr> <td><b>Total Tax</b></td> <td>#DollarFormat(avaTaxAdapter.TotalTax)#</td> </tr> <tr> <td><b>Total Amount</b></td> <td>#DollarFormat(avaTaxAdapter.TotalAmount)#</td> </tr> <tr> <td><b>Tax Rate</b></td> <td>#avaTaxAdapter.taxRate#%</td> </tr> <tr> <td><b>Last Message:</b></td> <td>#avaTaxAdapter.lastMessage# </td> </tr> </table> </cfoutput> |
Important Notes: The connector and related samples developed by JDF Unlimited are now part of the "GPL" or GNU Public License. This means you are free to use them and modify them, though if you do redistribute them please include the GPL license and original code. Consider this my giving back to the hard working folks that make GPL and other open source software that I use. Frequent Questions: Q: I'm getting a class not found "com.avalara.avatax...." type message? A: Make sure you have installed the JAR file and restarted the CF server instance. Q: Will you help me get AvaTax setup on my eCommerce/shopping site? A: Yes, at $95/hr and with appropriate access to your server code. No support is expressed or implied with this connector. It is open source, any improvements are not guaranteed to be compatible with prior versions. Change Log:
v1.2 - 5/19/2008 --------------------------------- - Added "CommitTax" request call that commits a previous tax calculation Use CommitTax on the final step in storing a completed shopping transaction v1.1 - 5/16/2008 --------------------------------- - Removed "CustomerCode" of "G" for Retail, which was breaking on Dev server - Added "PostTax" request call that lets you commit documents
v1.00 --------------------------------- - Initial version release - Adapter and documentation created
Back to top |