# Random errors on create payment API endpoint

**URL:** <https://developer.squareup.com/forums/t/random-errors-on-create-payment-api-endpoint/7809>\
**Category:** Questions\
**Tags:** payments-api\
**Created:** [December 2, 2022, 9:37pm UTC](https://developer.squareup.com/forums/t/random-errors-on-create-payment-api-endpoint/7809 "2022-12-02T21:37:18Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![MikeP117](https://avatars.discourse-cdn.com/v4/letter/m/6a8cbe/32.png) [@MikeP117](https://developer.squareup.com/forums/u/MikeP117)\
**Post date:** [December 2, 2022, 9:37pm UTC](https://developer.squareup.com/forums/t/random-errors-on-create-payment-api-endpoint/7809/1 "2022-12-02T21:37:18Z")

</div>

I am using the create payment endpoint to process payments.

It works fine 90% of the time, and returns the payment JSON.

10% of the time it returns the error {“errors”: [{“code”: “NOT\_FOUND”,“detail”: “Card nonce not found”,“category”: “INVALID\_REQUEST\_ERROR”}]}.

I am certain that I am sending the correct payment token, (source\_id, card nonce)  
returned by Square. i searched my log to make sure I am not re-using an old payment token.

I’ve tried resubmitting the post on failure to try again. I know it’s not the device because I can run 10 transactions on a device and have one fail.

Below is the request info from the API log. The first one failed the second one succeeded.

Thanks in advance for any help.

```auto
{
  "source_id": "[redacted]",
  "idempotency_key": "51991464",
  "amount_money": {
    "amount": 11500,
    "currency": "USD"
  },
  "autocomplete": true,
  "customer_id": "97773",
  "accept_partial_authorization": false
}

```

```auto
{
  "source_id": "[redacted]",
  "idempotency_key": "82876609",
  "amount_money": {
    "amount": 5500,
    "currency": "USD"
  },
  "autocomplete": true,
  "customer_id": "97773",
  "accept_partial_authorization": false
}

```

---

<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 2, 2022, 10:13pm UTC](https://developer.squareup.com/forums/t/random-errors-on-create-payment-api-endpoint/7809/2 "2022-12-02T22:13:43Z")

</div>

Is the `CreatePayment` request getting sent prior to the token being generated and sent to the backend? If you validate that the `source_id` is included before any request is sent does it solve the issue? 🙂

---

<div class="post-metadata">

**Author:** ![MikeP117](https://avatars.discourse-cdn.com/v4/letter/m/6a8cbe/32.png) [@MikeP117](https://developer.squareup.com/forums/u/MikeP117)\
**Post date:** [December 3, 2022, 5:14am UTC](https://developer.squareup.com/forums/t/random-errors-on-create-payment-api-endpoint/7809/3 "2022-12-03T05:14:34Z")

</div>

Thanks for responding Bryan. When the source\_id is sent I record what was sent. There hasn’t been a case when the source\_id was empty. I’m certain that I’m sending the source\_id that I got from Square. I’m also sure that I’m not trying to re-use an old source\_id. And I don’t have any kind of logic that would randomly create an incorrect source\_ID.

---

<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 5, 2022, 5:12pm UTC](https://developer.squareup.com/forums/t/random-errors-on-create-payment-api-endpoint/7809/4 "2022-12-05T17:12:09Z")

</div>

Okay, if that’s the case if you retry the request does the payment succeed or do you get the same error? 🙂

---

<div class="post-metadata">

**Author:** ![MikeP117](https://avatars.discourse-cdn.com/v4/letter/m/6a8cbe/32.png) [@MikeP117](https://developer.squareup.com/forums/u/MikeP117)\
**Post date:** [December 5, 2022, 5:28pm UTC](https://developer.squareup.com/forums/t/random-errors-on-create-payment-api-endpoint/7809/5 "2022-12-05T17:28:53Z")

</div>

Same error. If I knew what source\_ID it was expecting it might help. If I’m using the wrong ID I don’t know where it would come from besides Square.

---

<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 5, 2022, 5:50pm UTC](https://developer.squareup.com/forums/t/random-errors-on-create-payment-api-endpoint/7809/6 "2022-12-05T17:50:55Z")

</div>

The `source_id` is expecting is alway the token that’s returned from the `tokenize` request from the Web Payments SDK. It looks like: `cnon:CBASEH0FOa3a4tqMMfYfD9i_8t4` 🙂

---

<div class="post-metadata">

**Author:** ![MikeP117](https://avatars.discourse-cdn.com/v4/letter/m/6a8cbe/32.png) [@MikeP117](https://developer.squareup.com/forums/u/MikeP117)\
**Post date:** [December 5, 2022, 6:49pm UTC](https://developer.squareup.com/forums/t/random-errors-on-create-payment-api-endpoint/7809/7 "2022-12-05T18:49:57Z")

</div>

Yes, I am getting the source\_id from the tokenize request. It is successfully completing the transactions 90% of the time.

The question is why, 10% of the time, is it returning an error saying source\_id not found. Where did I get a bad source\_id? I don’t have any logic that creates source\_ids. I’m not reusing an old source\_id, if I re-use one it says it has been used already. I’m getting the error that it can’t find the source\_id when I submit the payment. Is there any way to see the source\_ids in the API log. Source\_ids are redacted in the API log. I don’t know why they are redacted since they are disabled after use.

---

<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 5, 2022, 7:00pm UTC](https://developer.squareup.com/forums/t/random-errors-on-create-payment-api-endpoint/7809/8 "2022-12-05T19:00:17Z")

</div>

What’s the application ID and do you have a recent example of this happening? If so could you provide the request? 🙂

---

<div class="post-metadata">

**Author:** ![MikeP117](https://avatars.discourse-cdn.com/v4/letter/m/6a8cbe/32.png) [@MikeP117](https://developer.squareup.com/forums/u/MikeP117)\
**Post date:** [December 5, 2022, 8:52pm UTC](https://developer.squareup.com/forums/t/random-errors-on-create-payment-api-endpoint/7809/9 "2022-12-05T20:52:05Z")

</div>

Here is my application ID: sq0idp-bVuaxYqK9c94A9rl91eMVA

Here is my API log from today

 ![Screen Shot 2022-12-05 at 12.35.43 PM.png](https://global.discourse-cdn.com/square/original/2X/d/d21e81110e90b2570067afcbf478691b0a311525.png)

Request

```auto
content-length: 259
content-type: application/json
square-version: 2022-10-19
accept-encoding: deflate, gzip
accept: */*
user-agent: FileMaker/17.0

    {
  "source_id": "[redacted]",
  "idempotency_key": "96305309",
  "amount_money": {
    "amount": 10000,
    "currency": "USD"
  },
  "autocomplete": true,
  "customer_id": "97773",
  "accept_partial_authorization": false
}

```

```auto

```

```auto

```

```auto
Response

```

```auto
date: Mon, 05 Dec 2022 12:38:53 GMT

```

```auto
content-length: 105
content-type: application/json
square-version: 2022-10-19
strict-transport-security: max-age=31536000
x-frame-options: DENY

    {
  "errors": [
    {
      "category": "INVALID_REQUEST_ERROR",
      "code": "NOT_FOUND",
      "detail": "Card nonce not found"
    }
  ]
}

```

```auto

```

```auto

```
