Updating the State of an order

Hello, Please I am trying to update the state of an order in square but here is the error an getting…

Please I need a link to a documentation where I can get a guide to update an order state

What’s the order_id? Is the order paid for and what state are you trying to change it too? :slightly_smiling_face:

The order state is open… I want to change it to completed because the order has been paid for manual by the customer so I want to update it to completed…

Orders cannot be completed before payments have been processed for the order. Was the payment taken by Square? :slightly_smiling_face:

The payment was not taken by square, the payment was made manually through bank transfer to our account so we want to be able to mark the order as completed instead of the initial state of open

$client = new SquareClient([
‘accessToken’ => env(‘SQUARE_ACCESS_TOKEN2’),
‘environment’ => $this->ENVIRONMENT,
]);

$body = new UpdateOrderRequest();
$body->setState(‘COMPLETED’);
$ordersApi = $client->getOrdersApi();
$apiResponse = $ordersApi->updateOrder($orderId, $body);

You can create an EXTERNAL payment with the order_id and it will complete the order. No money will move, the payment will be accounted for in Square and the order will be paid for. :slightly_smiling_face:

What if in a case where I want to use 100% discount to cover for the payment, how to I go about it in order to ensure that the order is completed… Thanks for your kind responses

Is the order going to be completed in the US? If so you can now create a $0 payment with the Payments API. If your processing in other regions you can use PayOrder to pay for a $0 order. :slightly_smiling_face:

Please can you share the api documentation on how to create a $0 dollar payment using the PaymentApi

Hi ;

I am trying the following request for the update order state but giving the following error.
Could you support me for this ?

Regards.

curl https://connect.squareupsandbox.com/v2/orders/Vg2aBPcaxnpQdtSkD1fzYFBhj7TZY
-X PUT
-H ‘Square-Version: 2024-01-18’
-H ‘Authorization: Bearer ******’
-H ‘Content-Type: application/json’
-d ‘{
“order”: {
“location_id”: “LPNNF5GSK68RD”,
“version”: 15,
“fulfillments”: [
{
“state”: “COMPLETED”,
“uid”: “9d521c70-ea5d-24e7-8562-1496e0a165ed”
}
],
“state”: “COMPLETED”
}
}’

Error

{
  "errors": [
    {
      "code": "INVALID_VALUE",
      "detail": "All fulfillments must have a state of COMPLETED, CANCELED, or FAILED for an order to be able to have a state of COMPLETED.",
      "field": "order.fulfillments[0]",
      "category": "INVALID_REQUEST_ERROR"
    }
  ]
}

Hi @onderboydak, it looks like you may be specifying the wrong uid for the fulfillment you’re attempting to complete. The uid of the fulfillment on that order is s3TJ8yiRgXArwUtKUqnhoB.

Hi

Thank you for reply.

This order is two lines. I think each line will be post.

Regards.