Is there a way to limit the orders returned with the “OPEN” filter to only paid orders? I noticed that abandoned carts are included.
Yes, you should be able to. In the SearchOrders
request, there is a query parameter which allows you to filter by state
. So for example, you should be able to call SearchOrders
with a request like this (HTTP request):
{
"location_ids": [
"{{location_id}}"
],
"query": {
"filter": {
"state_filter": {
"states": [
"COMPLETED"
]
}
}
}
}
Edit: Actually, this will return only COMPLETED
orders, which while they are paid, an order doesn’t need to be COMPLETED
to be paid (so this may miss some - like OPEN
, paid orders). In the API today, there is not a way to explicitly search for PAID
orders, so I apologize for the confusion.
That unfortunately returns everything that is shipped. I’m looking for orders that have been paid for, but not yet shipped.
I think if I pull all the “OPEN” orders, then in the client code, I can eleminate the ones that are abandoned carts by looking for the existence of the “tenders” field.
Will that work?
That’s a valid approach! Orders with a Tender are either partially paid or fully paid. Currently only Square Invoices are eligible for partial payments, and they do not include shipping fulfillment. Therefore it’s fair to assume that a complete Tender fully pays an order that has a shipping fulfillment.