# Square reporting payment not found even though payment exists

**URL:** <https://developer.squareup.com/forums/t/square-reporting-payment-not-found-even-though-payment-exists/7923>\
**Category:** Questions\
**Tags:** payments-api\
**Created:** [December 12, 2022, 11:25pm UTC](https://developer.squareup.com/forums/t/square-reporting-payment-not-found-even-though-payment-exists/7923 "2022-12-12T23:25:17Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![nberces](https://avatars.discourse-cdn.com/v4/letter/n/848f3c/32.png) [@nberces](https://developer.squareup.com/forums/u/nberces)\
**Post date:** [December 12, 2022, 11:25pm UTC](https://developer.squareup.com/forums/t/square-reporting-payment-not-found-even-though-payment-exists/7923/1 "2022-12-12T23:25:17Z")

</div>

Hello all,

I’m a developer working on a PHP-based application that integrates with Square via its API.

About 4 weeks ago, my team started seeing an error being returned from Square for _some_ payments, not all. The offending code is this:

```auto
/**
 * @var \SquareConnect\Api\PaymentsApi $paymentsAPI
 */
$paymentResponse = $paymentsAPI->getPayment("some-payment-id");

```

Which throws an exception (`SquareConnect\ApiException`) with the following message:

```auto
[HTTP/2 404] {"errors": [{"code": "NOT_FOUND","detail": "Could not find payment with id: some-payment-id","category": "INVALID_REQUEST_ERROR"}]}

```

Obviously, “some-payment-id” is an actual payment ID.

Our client - who’s the holder of the Square account with which our application integrates - in all cases can verify that these supposedly “non-existing” payments exist; they can locate the payments on their dashboard using the exact IDs our application is sending.

As stated earlier, this same bit of code only throws the exception for _some_ payments, not all, and we have yet to find a common theme.

Has anyone else experienced this behaviour recently?

---

<div class="post-metadata">

**Author:** ![Bryan-Square](https://sea1.discourse-cdn.com/square/forums/user_avatar/developer.squareup.com/bryan-square/32/38_2.png) [@Bryan-Square](https://developer.squareup.com/forums/u/Bryan-Square)\
**Post date:** [December 12, 2022, 11:56pm UTC](https://developer.squareup.com/forums/t/square-reporting-payment-not-found-even-though-payment-exists/7923/2 "2022-12-12T23:56:06Z")

</div>

Are you calling `GetPayment` right after the payment is being made? Also are you retrying the request when you get this error? There are some asynchronous functions that have to complete in our servers prior before the payment being retrievable with the API. 🙂

---

<div class="post-metadata">

**Author:** ![nberces](https://avatars.discourse-cdn.com/v4/letter/n/848f3c/32.png) [@nberces](https://developer.squareup.com/forums/u/nberces)\
**Post date:** [December 13, 2022, 12:18am UTC](https://developer.squareup.com/forums/t/square-reporting-payment-not-found-even-though-payment-exists/7923/3 "2022-12-13T00:18:52Z")

</div>

No, @Bryan-Square. The call to `getPayment` is part of our workflow when issuing a refund; before we issue a refund, we need to get some info regarding the original payment.

So the payment I’m testing with now, for example, was made mid-August 2022.

---

<div class="post-metadata">

**Author:** ![Bryan-Square](https://sea1.discourse-cdn.com/square/forums/user_avatar/developer.squareup.com/bryan-square/32/38_2.png) [@Bryan-Square](https://developer.squareup.com/forums/u/Bryan-Square)\
**Post date:** [December 13, 2022, 12:22am UTC](https://developer.squareup.com/forums/t/square-reporting-payment-not-found-even-though-payment-exists/7923/4 "2022-12-13T00:22:40Z")

</div>

What’s the `payment_id` and what’s the `merchant_id` of the Square seller you’r trying to get the payment from? Also can you try calling `RetrieveOrder` with the ID? It may be an `order_id` that your trying to call the Payments API with. 🙂

---

<div class="post-metadata">

**Author:** ![nberces](https://avatars.discourse-cdn.com/v4/letter/n/848f3c/32.png) [@nberces](https://developer.squareup.com/forums/u/nberces)\
**Post date:** [December 13, 2022, 12:52am UTC](https://developer.squareup.com/forums/t/square-reporting-payment-not-found-even-though-payment-exists/7923/5 "2022-12-13T00:52:09Z")

</div>

FYI, Bryan, our application is currently using version `2.20200122.2` of the Square Connect client library. I mention this because 1. it may account for the behaviour, and 2. there is no `retrieveOrder` method in this version.

The payment ID is `bKPdBRDf3XhDk1yd4DFYZ1seV` but the merchant ID I’m not sure about - I’ll have to contact our client. All we have on file is the application ID, location ID, and API key.

---

<div class="post-metadata">

**Author:** ![Bryan-Square](https://sea1.discourse-cdn.com/square/forums/user_avatar/developer.squareup.com/bryan-square/32/38_2.png) [@Bryan-Square](https://developer.squareup.com/forums/u/Bryan-Square)\
**Post date:** [December 13, 2022, 12:57am UTC](https://developer.squareup.com/forums/t/square-reporting-payment-not-found-even-though-payment-exists/7923/6 "2022-12-13T00:57:35Z")

</div>

Okay, that’s an `order_id` which makes sense as to why you got payment not found when calling the Payments API with the ID. The `payment_id` for the order is `zTFwM9OqUlRAYN77doH5QrpmuaB`. You can also use [BatchRetrieveOrder](https://developer.squareup.com/reference/square/orders-api/batch-retrieve-orders) to get the order information. That version doesn’t have `RetrieveOrder` cause it wasn’t released yet. 🙂

---

<div class="post-metadata">

**Author:** ![nberces](https://avatars.discourse-cdn.com/v4/letter/n/848f3c/32.png) [@nberces](https://developer.squareup.com/forums/u/nberces)\
**Post date:** [December 13, 2022, 1:18am UTC](https://developer.squareup.com/forums/t/square-reporting-payment-not-found-even-though-payment-exists/7923/7 "2022-12-13T01:18:04Z")

</div>

Really appreciate your help, Bryan, thank you. We recently migrated from the Transactions API to the Payments API and obviously didn’t do a very good job.

So now our DB has a mix of actual payment IDs generated via the Payments API, and “payment IDs” that are actually transaction IDs - now order IDs - generated via Transactions API charges.

Any suggestions to help with our conditional logic? As in, any quick way to differentiate between the two types?

---

<div class="post-metadata">

**Author:** ![Bryan-Square](https://sea1.discourse-cdn.com/square/forums/user_avatar/developer.squareup.com/bryan-square/32/38_2.png) [@Bryan-Square](https://developer.squareup.com/forums/u/Bryan-Square)\
**Post date:** [December 13, 2022, 1:33am UTC](https://developer.squareup.com/forums/t/square-reporting-payment-not-found-even-though-payment-exists/7923/8 "2022-12-13T01:33:32Z")

</div>

Is your DB logging all the ids a `payment_ids`? Also if there’s logic that knows that every ID from this point in time to this point in time is a `transaction_id` call the Orders API and every ID outside of that point in time is a `payment_id` call the Payments API that would help. 🙂

---

<div class="post-metadata">

**Author:** ![nberces](https://avatars.discourse-cdn.com/v4/letter/n/848f3c/32.png) [@nberces](https://developer.squareup.com/forums/u/nberces)\
**Post date:** [December 13, 2022, 1:42am UTC](https://developer.squareup.com/forums/t/square-reporting-payment-not-found-even-though-payment-exists/7923/9 "2022-12-13T01:42:19Z")

</div>

Unfortunately yes, the developer who originally did the work decided to call them all payment IDs (sigh). I’ll try to establish a timeline to help with our conditional logic.

Thanks again, Bryan, your help has been invaluable.

As this is my first time in these forums, do I flag message 5 as the solution?

---

<div class="post-metadata">

**Author:** ![Bryan-Square](https://sea1.discourse-cdn.com/square/forums/user_avatar/developer.squareup.com/bryan-square/32/38_2.png) [@Bryan-Square](https://developer.squareup.com/forums/u/Bryan-Square)\
**Post date:** [December 13, 2022, 1:44am UTC](https://developer.squareup.com/forums/t/square-reporting-payment-not-found-even-though-payment-exists/7923/10 "2022-12-13T01:44:12Z")

</div>

Sounds good! Yes, that would be great if you could flag the solution. 🙂
