question

shannonf avatar image
shannonf asked shannonf answered

Can't add tax rate to custom line item

I'm unable to add a custom line item to an order with a tax rate via the REST API. (I'm using an updated version of the Python client)

I'm adding the line item on the 'create line item' endpoint:

/v3/merchants/{mId}/orders/{orderId}/line_items

Adding the line item itself with a name and price works, but as soon as I add a taxRate, the line item will not add to the order. No error messages or anything, just no lineitem.

                {
                    "name": "Test",
                    "price": 200,
                    "taxRates": {
                        "id": "631XWCHXCJXMG",
                        "name": "California Sales Tax",
                        "rate": 797500,
                        "isDefault": True
                    }
                }
           

Other things I've tried with no effect:

  • Adding the line item, then updating it with the taxRate
  • Creating the line item with/without the 'defaultTaxRates' flag included, with/without the taxRate
  • Updating the line item with/without the 'defaultTaxRates' flag included, with/without the taxRate

The documentation (https://docs.clover.com/clover-platform/docs/working-with-orders#section-creating-an-order) does not indicate how to add a tax rate to a custom line item at all.

Other answers here on the forum seem to indicate that including the taxRate as I'm doing above is the correct way, but doing so is not creating a line item at all. This is a valid taxRate in our Clover account. What am I missing here?

OrdersREST APILineItemsTaxes
10 |2000

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

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

Can you please clarify where you obtained the "python" client? Per the API docs, taxRates is an array, not an object, perhaps that is your problem? You should try modifying your request so that taxRates is an array and then execute it via curl or Postman, etc. to test it.

10 |2000

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

shannonf avatar image
shannonf answered David Marginian Deactivated edited

Hmm, ok. The python client is an outside library that uses the REST API and works with python: https://github.com/mattlisiv/clover-api-python (We have an updated/forked version of this.)

I'm trying the requests in postman now. I am getting a response from creating the line item now, using a list, this is my request body:

{
    "name": "Test",
    "price": 200,
    "taxRates": [
        {
        "id": "631XWCHXCJXMG",
        "name": "California Sales Tax",
        "rate": 797500,
        "isDefault": true
        }
    ]
}

But the item in the response isn't showing any taxRates on the object. Should it be?

{
    "id": "NQ17K4NN6RY4R",
    "orderRef": {
        "id": "DN16AWR99Y75A"
    },
    "name": "Test",
    "price": 200,
    "printed": false,
    "createdTime": 1588714308000,
    "orderClientCreatedTime": 1588713963000,
    "exchanged": false,
    "refunded": false,
    "isRevenue": true
}


1 comment
10 |2000

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

David Marginian avatar image David Marginian ♦♦ commented ·

No, I wouldn't expect it, taxRates is an expandable field. You can retrieve the lineItems with an expansion on taxRates to make sure it saved as expected (please see the API reference - https://docs.clover.com/clover-platform/reference/orders-1#ordergetorderlineitems-2) and expansion reference - https://docs.clover.com/clover-platform/docs/expanding-fields. Sounds like you need to file a bug with the developer of the Python client.

0 Likes 0 ·
shannonf avatar image
shannonf answered

I do see it under the expanded fields, thank you! That is nicely hidden in the docs :)

Looks like I will be debugging the Python client...appreciate the help!

10 |2000

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