Assigning Individual Tax Ids to the Line items in the Orders API

Actually when we are setting the individual tax ids to the line items in the ORDERS api:

https://connect.squareupsandbox.com/v2/locations/{location_id}/orders

we are setting the applied_taxes parameters and then setting the uid of the tax. But when we submit the api it is saying us:

stdClass Object
(
[errors] => Array
(
[0] => stdClass Object
(

                [code] => VALUE_EMPTY
                [detail] => Field must not be blank
                [field] => order.line_items[0].applied_taxes[0].tax_uid
                [category] => INVALID_REQUEST_ERROR
            )

    )

)

But in the api documentation it is asking to fill uid not the tax_uid.

Moreover when we fetches the tax data it is coming like this:

stdClass Object
(
[object] => stdClass Object
(
[type] => TAX
[id] => EHXLVURA6ETOI7HH6IZLW6IM
[updated_at] => 2020-10-20T10:55:02.256Z
[version] => 1603191302256
[is_deleted] =>
[present_at_all_locations] => 1
[tax_data] => stdClass Object
(
[name] => First Tax
[calculation_phase] => TAX_SUBTOTAL_PHASE
[inclusion_type] => INCLUSIVE
[percentage] => 1.0
[applies_to_custom_amounts] =>
[enabled] => 1
[tax_type_id] => us_sales_tax
[tax_type_name] => Sales Tax
)

    )

)

Could you please let us know what we need to fill in the applied_taxes object uid or tax_uid and could you please let us know how to get this ids from the tax data?

Thanks

It should be tax_uid (in the tech ref it’s marked as “REQUIRED”). Can you share where in the docs it says to use uid instead? Also, these are just string values, it can be anything as long as it matches the root level and item level. They are not the actual tax object’s ids.

Please check the below screenshot that contains the create orders api documentation that have applied_taxes parameter:

If we add some arbitrary tax_uid then we are getting the following error:

There is no tax on this order with uid us_sales_tax.

stdClass Object
(
[errors] => Array
(
[0] => stdClass Object
(
[code] => BAD_REQUEST
[detail] => There is no tax on this order with uid us_sales_tax.
[field] => order.line_items[0].applied_taxes[0].tax_uid
[category] => INVALID_REQUEST_ERROR
)

    )

)

Please let us know how to get the tax_uid from the tax data.

Thanks

Sorry for the confusion. So, tax_uid needs to match a root level taxes->uid. See below for example:

  "idempotency_key": "{{$guid}}",
  "order": {
    "line_items": [
        {
            "name": "Steak",
            "quantity": "1",
            "variation_name": "Rare Steak",
            "base_price_money": {
                "amount": 1,
                "currency": "USD"
            },
            "applied_taxes": [
                {
                    "tax_uid": "test_tax_uid"
                }
            ]
        }
    ],
    "taxes": [{
        "name": "Test Tax",
        "percentage": "5",
        "scope": "LINE_ITEM",
        "uid": "test_tax_uid"
    }]
  }
}

See test_tax_uid and how it matches. It’s just how you reference it so you can use it.

1 Like