tax.cartTaxes

This method is used to calculate the Cart taxes.

Version

v2

Arguments

This method has the path /catalog/<version>/tax.cartTaxes and follows the MicroBase API calling conventions.

Argument Required Type Example Description
gateway yes String avalara The taxes gateway to use.
cart yes Object The cart to calculate

cart

Argument Required Type Example Description
cartId yes String default Identifier to be used as a reference.
items yes Object List - The list of entries in the Cart.

Items

Argument Required Type Example Description
id yes String HyR1hMmc Entry id.
productId yes String By2ZWfAPnV The Product Id.
taxCode yes String default The Product tax code
isNetPrice yes Boolean false The Product price type
quantity No Number 1 The quantity of product in the entry.
price yes Object {"amount": 10000, "currency": "EUR", "precision": 2} The total price of this item (Not the single Product price).

Price

Argument Required Type Example Description
amount yes Numeric 10000 The amount. In minimum units (cents for precision 2)
currency yes String EUR The currency code (ISO 4217)
precision yes Numeric 2 Currency dependant precision (USD=2, JPY=0, JOD=3)

Response

Returns a Tax object:

{
    "ok": true,
    "cart": {
        "items": [{
            "id": "HJyElmm9",
            "productId": "By2ZWfAPnV",
            "taxCode": "default",
            "isNetPrice": false,            
            "quantity": 1,
            "price": { "amount": 10000, "currency": "EUR", "precision": 2},
            "taxes": [
              {
                "beforeTax": { "amount": 10000, "currency": "EUR", "precision": 2},
                "tax": { "amount": 700, "currency": "EUR", "precision": 2 },
                "taxDetail": "VAT 7%"
              }
            ]
        }]
    }
}

Errors

Expected errors that this method could return. Some errors return additional data.

Error Data Description
validation_error The data causing the error Some validation error

Example

curl --request POST \
  --url http://localhost:3000/services/catalog/v1/tax.cartTaxes \
  --header 'authorization: Bearer xxxxx...' \
  --header 'accept: application/json' \
  --header 'content-type: application/json' \
  --data '{
      "cart": {
        "cartId": 'H19PRsec', \
          "items": \
           [ { "id": "HJyElmm9", \
               "productId": 'By2ZWfAPnV', \
               "taxCode": "default",
               "isNetPrice": false,             
               "quantity": 1, \
               "price": { "amount": 10000, "currency": "EUR", "precision": 2 } ] \
        } \
      }'