Update Order created via Payment Link

We are using “Payment Link” to send order information to Square and collect payment from customer. Is there any way to update the order created using the “Payment Link”?

As the update order documentation states that the orders created via Orders API can only be updated.

:wave: I’m Square Dev AI, here to help answer your question!
Based on the information you’ve provided, the following documentation will help answer your question:

https://developer.squareup.com/docs/orders-api/pay-for-orders

Additional Documentation

Orders API Overview
Update Orders
Square Order Checkout

If this documentation helped you find a solution, please check the box indicating that this reply solves the problem.
Otherwise one of our Developer Advocates will provide additional assistance shortly.

Yes, you can update an order associated to a payment link. You’ll use UpdateOrder to update the order created from the Checkout API. :slightly_smiling_face:

Hi @Bryan-Square

I have few question related to Update Order if you can please read below and answer that would be really appreciated:

Update Order requires ‘version’ as when I don’t send it, it returns the following error:

{
  "errors": [
    {
      "code": "BAD_REQUEST",
      "detail": "Missing required parameter.",
      "field": "order.version",
      "category": "INVALID_REQUEST_ERROR"
    }
  ]
}

How to get find the ‘version’ of an order created using Payment Link?

Also, when i randomly put version ‘1’ then I receive the following error back and I get the version number from the error details.

{
  "errors": [
    {
      "code": "VERSION_MISMATCH",
      "detail": "Supplied version 1 does not match the current version 7 of order AzlCrafSsgqjLxOJDfhGiqLOEyPZY.",
      "field": "order.version",
      "category": "INVALID_REQUEST_ERROR"
    }
  ]
}

After using the correct version, I just want to update the order pickup_at time and notes. Sent the following request:

{
    "order": {
      "location_id": "LH891R7KHMSRQ",
      "fulfillments": [
        {
          "pickup_details": {
            "pickup_at": "2024-04-15T21:56:19.378Z",
            "note": "DOORDASH driver will come to pickup."
          }
        }
      ],
      "version": 7
    },
    "idempotency_key": "c101f037-7915-4962-b85b-b3c31b41421a"
  }

Returns the following error:

{
  "errors": [
    {
      "code": "ARRAY_LENGTH_TOO_LONG",
      "detail": "Orders cannot be created with more than one fulfillment.",
      "field": "order.fulfillments",
      "category": "INVALID_REQUEST_ERROR"
    }
  ]
}

Can you please tell me how to update an order with a new pickup_at time?

When a payment link is created an order is also created. That order is in the CreatePaymentLink response. When you need to update an order you’ll want to call RetrieveOrder with the order_id to get the latest version of the order.

As for your second error you’ll need to update the existing fulfillment that’s in the order. For example:

{
    "order": {
        "version": 1,
        "fulfillments": [
            {
                "uid": "{{my_fulfillments_uid}}",
                "state": "CANCELED"
            }
        ]
    }
}

:slightly_smiling_face: