question

mavyasoni avatar image
mavyasoni asked David Marginian Deactivated edited

How to add tax_amount in order pay api using Ecommerce api?

Can't be able to add tax while creating line items

API Url: https://api.clover.com/v3/merchants/XXXXXXXXX/orders/WX27C34S22ZQ8/bulk_line_items


Request : 
{
"items": [
{
"item": {
"id": "ZJHM4KRKVVSNY"
},
"price": 100,
"unitQty": 2,
"taxRates": [
{
"items": [{"id": "ZJHM4KRKVVSNY"}],
"taxType": "INTERNAL_TAX",
"name": "Tax",
"rate": 10,
"isDefault": false,
"taxAmount": 10
}
]
}
]
}


Response:
{
"details": "The requested resource could not be found.",
"message": "Not Found"
}


e-commerce api
10 |2000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
David Marginian avatar image
David Marginian Deactivated answered David Marginian Deactivated edited

It sounds like you are testing, if so, why are you testing in production? You should be using sandbox - https://docs.clover.com/docs/setup-clover-sandbox-account.

There are two problems with your example:

1) You aren't referencing an existing taxRate, hence the error.

2) Even if you were, you are referencing a Clover inventory item, and Clover inventory items will always have the default tax rate applied to them. The taxRate set on the item will not be overridden by taxRates sent in on the lineItem(s) request. So, even if you were referencing an existing taxRate the taxRates you are passing wouldn't do anything.

You have two options if you plan on using the order pay endpoint:

1) Use Clover Inventory - This is what it appears you have chosen to do as you are passing in an item with a Clover Id. If you are referencing a Clover inventory item in your order then the tax rate associated with that inventory item will be used. Any taxRates you pass in the request will be ignored. To set-up tax rates and to set those tax rates on your inventory items you can login to your Clover merchant dashboard.

2) Don't use Clover inventory - If you don't reference an existing Clover inventory then you can pass taxRates. The taxRates you pass must already exist for the merchant.

  "taxRates": [
        {
            "id": "cloverIdOfExistingTaxRate",
            "name": "someTax",
            "taxAmount": 400,
            "rate": 0
        }
    ]

I don't believe that adding taxRates works with the bulk line items endpoint. You will have to individually add the line items or update them after creation if you want to pass taxRates.

10 |2000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Welcome to the
Clover Developer Community