I am running into an issue where, for various reasons, a user may attempt to place an order using the pay_order
orders API endpoint and have this fail. We then void all the payments attached to that payment attempt.
After doing so, if the user attempts to remove line items from their order, we are unable to do so.
I am sending this sparse json object to the update_order
endpoint, and expect line item uid_1 to be removed:
{
"order": {
"line_items": [
{
"quantity": "1",
"uid": "uid_1",
"note": "",
"catalog_object_id": "id_1",
"modifiers": [],
"applied_taxes": [
{
"uid": "applied_tax_1",
"tax_uid": "tax_1"
}
],
"applied_discounts": [
{
"uid": "applied_discount_1",
"discount_uid": "discount_1"
}
]
},
{
"quantity": "1",
"uid": "uid_2",
"note": "",
"catalog_object_id": "id_2",
"modifiers": [],
"applied_taxes": [
{
"uid": "applied_tax_2",
"tax_uid": "tax_2"
}
],
"applied_discounts": [
{
"uid": "applied_discount_2",
"discount_uid": "discount_2"
}
]
}
],
"taxes": [
{
"uid": "tax_1",
"name": "Tax 1",
"type": "ADDITIVE",
"percentage": "5",
"scope": "LINE_ITEM"
},
{
"uid": "tax_2",
"name": "Tax 2",
"type": "ADDITIVE",
"percentage": "4",
"scope": "LINE_ITEM"
}
],
"discounts": [
{
"uid": "discount_1",
"scope": "LINE_ITEM",
"type": "FIXED_AMOUNT",
"name": "Discount",
"amount_money": {
"amount": 50,
"currency": "USD"
}
},
{
"uid": "discount_2",
"scope": "LINE_ITEM",
"type": "FIXED_AMOUNT",
"name": "Discount",
"amount_money": {
"amount": 25,
"currency": "USD"
}
}
],
"fulfillments": [
{
"type": "PICKUP",
"uid": "order_uid",
"pickup_details": {
"recipient": {
"customer_id": "customer_1"
},
"is_square_pickup_order": true,
"pickup_at": "2025-01-01T00:00:00+00:00",
"prep_time_duration": "PT5M"
}
}
],
"version": 17
},
"fields_to_clear": [
"line_items[uid_1]"
],
"idempotency_key": "idempotency_key"
}
However, I get this error response:
{
"code": "INVALID_VALUE",
"detail": "Read-only field is calculated and cannot be set by a client.",
"field": "order.line_items[uid_1].gross_sales_money",
"category": "INVALID_REQUEST_ERROR"
}
I am not touching this calculated field, I am removing the line item it is attached to. Given that the previous payments have been voided, I would expect this to work without issue, but that is not the case.
Please advise. Currently my workaround will be to recreate this order entirely, because I am functionally unable to update it at all once a payment is attempted (and failed).
"fields_to_clear": [
"line_items[uid_1]"
]
This is the correct for removing items from an array in an update request, per your docs - I have seen elsewhere recommendations to use line_items.uid_1
but afaict that is incorrect and will fail because it is an invalid dot notation access.
Note: I am using the Square Ruby SDK