Fix order complete: update fulfillment state alongside order state

Square requires all fulfillments to be COMPLETED before the order can be
marked COMPLETED — include fulfillment state in the same updateOrder call.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
chris 2026-06-05 20:08:54 -04:00
parent ef38c42e17
commit ca8773d3c3

View File

@ -24,9 +24,13 @@ export async function POST(
await client.ordersApi.updateOrder(orderId, { await client.ordersApi.updateOrder(orderId, {
order: { order: {
locationId: order.locationId!, locationId: order.locationId!,
state: 'COMPLETED', state: 'COMPLETED',
version: order.version, version: order.version,
fulfillments: (order.fulfillments ?? []).map((f) => ({
uid: f.uid,
state: 'COMPLETED',
})),
}, },
idempotencyKey: `complete-${orderId}`, idempotencyKey: `complete-${orderId}`,
}) })