How to change tax uid for individual tax item from the squareup dashboard?

I have various tax added from the dashboard. Each tax has its unique id. But when i fetches the tax data for different ids from the

https://connect.squareup.com/v2/catalog/object/{tax_id}?include_related_objects=true

api then their uid comes to be same like:

[taxes] => Array
(
[0] => Array
(
[uid] => us_sales_tax
[name] => city
[percentage] => 10.0
[scope] => LINE_ITEM
)

                [1] => Array
                    (
                        [uid] => us_sales_tax
                        [name] => state
                        [percentage] => 5.0
                        [scope] => LINE_ITEM
                    )

            )

and when i apply these tax uid in the catalog items orders api then it is giving me error:

stdClass Object
(
[errors] => Array
(
[0] => stdClass Object
(
[code] => BAD_REQUEST
[detail] => Duplicate entry key us_sales_tax
[field] => order.taxes
[category] => INVALID_REQUEST_ERROR
)

    )

)

So could you please guide how to change the tax uid from squareup dashboard.

Thanks

I’m a bit confused…it looks like you’re talking about several different things. uid in the CreateOrder request can be literally anything…it doesn’t belong to the tax, and it’s just so you can interact with the tax in the order request (like assigning it to a specific item). Do you see this uid in your actual Catalog?

Actually the thing is that when i try to add multiple taxes for a particular item like:

if(isset($tax_id) && count($tax_id) > 0) {

        foreach($tax_id as $kid => $tid) {

            $tx_id = $tid['id'];

            $curl = curl_init();

            curl_setopt_array($curl, array(
            CURLOPT_URL => "https://connect.squareup.com/v2/catalog/object/$tx_id?include_related_objects=true",
            CURLOPT_RETURNTRANSFER => true,
            CURLOPT_ENCODING => "",
            CURLOPT_MAXREDIRS => 10,
            CURLOPT_TIMEOUT => 0,
            CURLOPT_FOLLOWLOCATION => true,
            CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
            CURLOPT_CUSTOMREQUEST => "GET",
            CURLOPT_HTTPHEADER => array(
                "Square-Version: 2020-05-28",
                "Authorization: Bearer $square_access_token",
                "Content-Type: application/json"
            ),
            ));

            $response = curl_exec($curl);

            curl_close($curl);

            $tax_data = json_decode($response);

            $order_params['order']['taxes'][$kid ]['uid'] = $tax_data->object->tax_data->tax_type_id;
            $order_params['order']['taxes'][$kid ]['name'] = $tax_data->object->tax_data->name;
            $order_params['order']['taxes'][$kid ]['percentage'] = $tax_data->object->tax_data->percentage;
            $order_params['order']['taxes'][$kid]['scope'] = "LINE_ITEM";
            
        }

    }

Then it is giving me this error:

stdClass Object
(
[errors] => Array
(
[0] => stdClass Object
(
[code] => BAD_REQUEST
[detail] => Duplicate entry key us_sales_tax
[field] => order.taxes
[category] => INVALID_REQUEST_ERROR
)

    )

)

So i need to change the tax uid that is coming same in these 2 tax ids

Can you share your application id? I’m still not following. The URL suggests you’re trying to get one single tax id, but the error and “order” suggests you’re trying to create an order. There is no “order” in Catalog, so I’m not sure what this is.

Edit: I do not see a “tax_type_id” parameter on a TAX object, so I’m not sure what this is. Again, to reiterate, the “uid” in an order, should be unique and it can be anything you want. It does not need to be equal to some id that the tax object knows about. It can be a random string or whatever, so long as it’s the same everywhere you need to access it in the order. It can be different each time you add it to an order, even.

This is my request body for creating the order:

Array
(
[order] => Array
(
[taxes] => Array
(
[0] => Array
(
[uid] => us_sales_tax
[name] => city
[percentage] => 10.0
[scope] => LINE_ITEM
)

                [1] => Array
                    (
                        [uid] => us_sales_tax
                        [name] => state
                        [percentage] => 5.0
                        [scope] => LINE_ITEM
                    )

            )

        [line_items] => Array
            (
                [0] => Array
                    (
                        [catalog_object_id] => AMADT3BZI7K6AO6GOP4PDYWZ
                        [quantity] => 1
                        [applied_taxes] => Array
                            (
                                [0] => Array
                                    (
                                        [tax_uid] => us_sales_tax
                                    )

                            )

                    )

                [1] => Array
                    (
                        [catalog_object_id] => QDVDYZUNMXYQPJ6SJOKTBDRT
                        [quantity] => 1
                    )

            )

        [fulfillments] => Array
            (
                [0] => Array
                    (
                        [type] => PICKUP
                        [state] => PROPOSED
                        [pickup_details] => Array
                            (
                                [recipient] => Array
                                    (
                                        [display_name] => WTF test 7
                                    )

                                [expires_at] => 2020-12-10T07:00:16.100Z
                                [auto_complete_duration] => P0DT6H0S
                                [schedule_type] => SCHEDULED
                                [pickup_at] => 2020-12-03T07:00:16.115Z
                                [note] => 
                            )

                    )

            )

    )

[idempotency_key] => a6c8d3283c2ceac28453632be824e568

)

Here you can see [uid] => us_sales_tax is same for city tax and state tax.

just want a way where i can change the uid of the tax so that they will not gets duplicated. Please let me know how can i change this.

Thanks

The uid is not set on the Catalog object as I mentioned. The uid is only for the Order. You can literally set it to whatever you want, there is no “changing” it since it’s not saved anywhere. You just need to make each of them unique in the CreateOrder request. Please let me know if I misunderstood, or if you have additional questions.

I am not talking about the uid of Catalog object, i am talking about the uid of the tax items.

(a)
(
[uid] => us_sales_tax
[name] => state
[percentage] => 5.0
[scope] => LINE_ITEM
)

(b)
(
[uid] => us_sales_tax
[name] => city
[percentage] => 10.0
[scope] => LINE_ITEM
)

Here you can see that uid of both the tax items are us_sales_tax that is giving error response from the create order api.

Message: Duplicate entry key us_sales_tax

So i need a way to change the uid of the tax.

Thanks

Right…this “uid” is literally just a string. You’re supplying “us_sales_tax”, but it can be anything. Change the value in the CreateOrder request, and the error will be resolved.

Actually i am not supplying the us_sales_tax uid it is originally coming from the api response.

API:

https://connect.squareup.com/v2/catalog/object/$tx_id?include_related_objects=true

In above api i am passing the tax_id and it is giving me the uid in response.

If i tend to change the uid the api is giving me error: tax uid does not exists.

So what can i do here?

Thanks

You do not need to use the id from the response, as I’ve said above, it can be anything. The uid must match in all places of the order request, or it will say it does not exist. The uid is solely to identify the tax in the order. It has no meaning outside of the order.

Thanks for the help, now i am able to calculate multiple taxes on single product items.

1 Like