Errors retrieving Orders after Payment.Created webhook

I am having trouble retrieving Orders using the given orderId from Payment.Created web hook event. I am using square-node-sdk v17.1.0. The problem presents in two ways.

  1. I receive the event, grab the orderId and then ordersApi.retrieveOrder(‘orderId’), but receive a NOT_FOUND error. I return an error to the web hook. Event comes again, make same request, order returned successfully.

1a. Why does the first request fail? The event has an orderId, wouldn’t this indicate the order already exists? This honestly happens on 99% of payment.created events.

  1. Basically same as #1, however the order is NEVER able to be retrieved, over 24 hour period of requesting. The orders are available in Square Dashboard, but cannot be retrieved via the ordersApi.

2a. Is the returned orderId incorrect? Why does this process ~work for the other payments but not these few?

:wave: Due to some asynchronous functions that happen within Square may cause a delay of the order being retrieved from the API even though its ID was retuned in the webhook or response. We recommend putting in a retry method for when this happens.

For the orders that weren’t available for 24 hours what’s the orders_ids?

The order I’m referring to for today/yesterday is ZzRwzzmTY1ULfqBKcAf93MreV

It was an in store purchase for $27.90 at 5:52pm Feb 8 2022. It does appear in the Seller Dashboard under Transactions.

That order is a voided order. Voided and declined orders aren’t returned with the Orders API. Also I tried looking for it in the Transactions section of the seller Dashboard and it’s not showing which is expected for voided orders. Are you sure your able to see it in the seller Dashboard?

Can you explain more about how an order is ‘voided’?

Also if the order is voided what is the value in receiving the Payment.Created event with that given orderId? Does that mean the Payment still exists but the order doesn’t? What causes ‘voided’?

The order_id for that payment is nIkYINtCWcSrfL4T6fsemtieV not ZzRwzzmTY1ULfqBKcAf93MreV.

This is the body of the Payment.Created event that I received.

I associated this event with that transaction via the timestamp, credit card information, and square receipt that the patron included in their email.

  "data": {
    "id": "lSq75r4j7aQxlZGr8og1oXOxuaB",
    "object": {
      "payment": {
        "order_id": "ZzRwzzmTY1ULfqBKcAf93MreV",
        "version": 1,
        "updated_at": "2022-02-08T22:52:00.076Z",
        "approved_money": {
          "currency": "USD",
          "amount": 2545
        "location_id": "...",
        "source_type": "CARD",
        "receipt_number": "lSq7",
        "created_at": "2022-02-08T22:51:59.483Z",
        "total_money": {
          "currency": "USD",
          "amount": 2545
        "device_details": {
        "status": "APPROVED",
        "id": "lSq75r4j7aQxlZGr8og1oXOxuaB",
        "application_details": {
          "square_product": "SQUARE_POS"
        "amount_money": {
          "currency": "USD",
          "amount": 2545
        "card_details": {}
    "type": "payment"
  "type": "payment.created",
  "merchant_id": "...",
  "created_at": "2022-02-08T22:52:00.081Z",
  "event_id": "98487d4f-9ae2-4345-8f3f-a5b30ff35957"

Right, the status is APPROVED which means it can still be voided since it’s not COMPLETE. Did you get a payment.updated event later that showed it was voided?

I unfortunately do not have a log for payment.updated.

What would cause an order to be voided?
Would the payment.updated contained a new orderId?

It seems I miss understood how I need to handle some of these interactions.

There could be a lot of reasons for a voided payment. For example you can cancel a payment if asked for a tip. You would get a payment.created event as well as a payment.updated event if it was voided. :slightly_smiling_face:

Ok, thank you for that information. I have also found a record using the orderId you gave me earlier and I see I can find that orderId by exporting the transactions to csv from the seller dashboard.

Perfect! Please feel free to reach out if you have any additional questions. We’re always happy to help. :slightly_smiling_face: