Welcome! Today we are going to learn about implementing taxes for your Moltin store. We’ll start broad with the different taxation strategies you can you implement, then narrowing down to the implementation pattern, and finishing by walking through a code example. By the time this has finished, you should have all the knowledge you need to add taxes into your Moltin project today.
Why you need to care about taxes
Not implementing taxation correctly can be an extremely costly mistake. There are a number of things you need to take into account when designing your eCommerce taxation strategy, including:
The location of your own business.
- The location of your shipping warehouses or nexuses.
- The location of your customers.
- The tax category of the different products you sell.
Given this information, in real time, you must be able to calculate the overall tax per product in a customers cart, present them with this information, apply it to the cart (honoring discount strategies), and ensure that it is accurately reflected on the customer’s order. Not only this, but you must consider post order changes, for example, if the customer enters the wrong shipping address. Let’s walk this through in three stages:
1. Collecting and storing the required variables:
No doubt you already know the location of your own business and locations of your warehouses. You can store this information in a Moltin Flow, so you can fetch it any time from the Moltin API. You can also use Flows to extend the Moltin product to store a field called something like `tax category`, and add the correct category for each product you make available. The location of your customer may be a little trickier, as it’s dependant on the address the user enters/chooses at checkout. This should be handled within your website code at the time of checkout.
2. Given the variables, real-time calculation of taxation amounts:
Now everything is available and your user is at a stage where taxes should be presented to them. At this point, we introduce a second service called Taxjar which will help you do the real-time calculations. Specifically, we’ll be using an API of theirs called SmartCalcs, and access starts from $17 per month. You make a single API to their service, providing all of the variables collected above, and they will return the tax to be collected per product.
3. Presenting calculated amounts to the customer and applying them to the cart
We’re ready to apply the tax to the Moltin cart on behalf of the user! Moltin offers tax as sub-items on each cart item. That means that each product in the cart will have its own tax amount. This is helpful when there are products of different tax categories in the cart together. It also means if a customer removes a product from the cart, the tax is automatically removed, too. When you add a tax item to a cart item, you add a number of fields:
- Name: name of the tax item
- Jurisdiction: relevant tax jurisdiction
- Code: tax code
- Rate: percentage of the cart item
One thing to be careful of here, you should make sure that for every cart updated call your application makes, you should recalculate the taxes, and re-add them, to prevent your user from attempting to manipulate the cart just to lower the tax amount.
Once you have added a tax item to a cart item, you can fetch the cart from Moltin, and you will see there is a display price for with tax and without tax, where we have taken the sum of all the tax items in the cart and used them to calculate the correct totals.
Promotions are applied post-tax, so they will discount the entire cart including the tax amounts.
Below, we've compiled some questions Matt didn't have time to go through during his presentation.
Taxes in general
Q: How can I make sure I calculate taxes correctly?
A: By using a paid third party which offers guarantees. At the moment, Moltin provides seamless integration with a third party taxes calculator, TaxJar.
Q: Who calculates taxes for me? Does Moltin calculate taxes?
A: No, the actual calculation is handled outside Moltin by a third party like Taxjar who devote their entire business to doing it well.
Q: Are you going to build your own tax calculator in the future?
A: We tend to take the philosophy that if there is an entire business elsewhere devoted to doing this thing well, we will make it super easy to integrate with them while we focus on what is core to Moltin, so in this case we do not plan to build our own tax calculator.
Q: Is nexus I use validated for me? How can I make sure the nexus I use is correct?
A: TaxJar will do nexus validation for you.
Cost of taxes implementation
Q: How much is this integration going to cost me overall?
A: This depends on the number of transactions you have, and which third party provide you use. We recommend comparing taxjar and avalara.
Q: Is the Moltin part of this functionality free?
A: Yes, this functionality is provided as part of Moltin core features. How much is for your monthly fee, depends on your current plan outlined on our new pricing page
Q: How much does TaxJar cost?
A: Please refer to TaxJar's pricing page.
How taxes work with Moltin
Q: I have my own tax calculator, can I use it with Moltin?
Q: Is there any app example I could use and adapt to my use case?
A: Absolutely, we have built a simple demo site in React that you can find on GitHub.
Q: Are taxes supported for currency other than USD?
A: Yes, taxes will be applied in the same currency as your cart.
Q: Are taxes applied only for default currency?
A: No, it is dependant on the currency used in the Moltin cart they are being applied to.
Q: What if the user changes their shipping address after the sale?
A: Because Moltin doesn't calculate the tax, a new order with an updated shipping address will need to be created by checking the product out again.
Q: Is tax applied to the entire cart or to each individual cart item?
A: Each individual cart item. Additionally, there’s a certain chronology to how you apply these for each cart item. For example, if having a promotion applied to this item, the tax is added after the appropriate discount has been calculated.
Q: All I need is flat tax rate on the cart overall instead of on each item, how would that work with Moltin?
A: In case of a flat rate, you could add a custom cart item with the tax, but please be aware, this will not affect the
without_tax. If you want to have an audit trail, you should distribute the flat rate across the items in the cart by adding a tax item for each product. Take the product price, and calculate the rate that will result in the flat rate you need.
Q: What if I sell a discounted product? Would the tax be applied after or before the promotion is applied to the product?
A: Taxes are calculated after all promotional savings have been applied.
Q: Can I exempt a customer from taxes using Moltin?
A: Yes, you can. If you don’t want to apply a tax to any product, disable the
include_tax flag for that product.
Q: Can I override a particular tax code?
A: When you make the call to the tax provider, you can send whatever tax code you like, even calculating dynamically when you need to
Q: Where can I see what tax and jurisdiction were calculated for my invoice?
A: The tax values will be visible on your Moltin order.
Q: Can I apply taxes from the dashboard?
A: No you cannot.