• Log in
  • Sign up
  • Contact Us

Get in touch  

Concepts • Taxes | Integrations

How taxes work

Last updated: 26 Jun 2019

Moltin allows you to apply tax items to a cart for every product added to that cart.

  • Apply a custom tax item in a scenario in which you have your own tax calculation system configured, or if you want to apply a flat tax rate.
  • Integrate a third party tax calculator in a scenario in which you need a tax calculation system. 

Add tax to items in your cart to apply relevant taxes for checked out products.

This guide explains how taxes work with Moltin and you how to apply a flat rate sales tax to every cart item in a cart. 

Moltin lets you apply any tax rates to a cart. How you calculate the rates is up to you, and so this guide assumes that you already know how to calculate tax rates. Otherwise, you'll need to integrate a third party tax calculator. 

Key points about taxes and how they work

  • Tax calculation logic. The includes_tax field on the product can be set to true or false:
      • true Moltin will perform a backward calculation of taxes meaning the original product price will not be affected during checkout.
      • false Moltin will calculate tax and add it to the original product price.
  • Promotions and Taxes. Taxes are calculated after all promotional savings have been applied.
  • Cart-level promotions. Promotional savings are equally distributed across all items in the cart. If there is a remainder after distributing promotional savings across cart items, the promo saving will be rounded up, so that there is no remainder left.

Get your access token

You will need to get a client_credentials access token to follow along making the API requests outlined below.

curl -X POST https://api.moltin.com/oauth/access_token \
     -d "client_id=XXXX" \
     -d "client_secret=XXXX" \
     -d "grant_type=client_credentials"

Add a product to a cart

Add a product to a cart. If the product has the includes_tax field set to true, and you have created a tax item, the cart will apply the calculated tax rate to the product as soon as you add it to the cart.

curl -X POST https://api.moltin.com/v2/carts/:reference/items \
     -H "Authorization: Bearer XXXX" \
     -H "Content-Type: application/json" \
     -d $'{
        "data": {
          "type": "cart_item",
          "id": "d4fb11d4-2fd6-43a1-a047-7b869d41cf96",
          "quantity": 4

Add a tax item to a cart

To apply a tax item to a cart item, all you have to do is to add a tax item to a cart.

curl -X POST https://api.moltin.com/v2/carts/:cartID/items/:itemID/taxes \     
-H "Authorization: XXXX" \     
-H "Content-Type: application/json" \    
-d $'{
    "data": {
      "type": "tax_item",
      "name": "Tax Name",
      "jurisdiction": "UK",
      "code": "MYTAX01",
      "rate": 10.2

Get taxed item

Relationships between cart items and tax items are created automatically when the product is added to a cart.

Product added to a cart must have the includes_tax field set up to true.

Further reading