# Intermittent. Sandbox Error when submitting payment: Tokenization has failed

**URL:** <https://developer.squareup.com/forums/t/intermittent-sandbox-error-when-submitting-payment-tokenization-has-failed/14029>\
**Category:** Questions\
**Tags:** sandbox, web-payments-sdk\
**Created:** [March 27, 2024, 9:12pm UTC](https://developer.squareup.com/forums/t/intermittent-sandbox-error-when-submitting-payment-tokenization-has-failed/14029 "2024-03-27T21:12:25Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![schedulesplus](https://sea1.discourse-cdn.com/square/forums/user_avatar/developer.squareup.com/schedulesplus/32/4128_2.png) [@schedulesplus](https://developer.squareup.com/forums/u/schedulesplus)\
**Post date:** [March 27, 2024, 9:12pm UTC](https://developer.squareup.com/forums/t/intermittent-sandbox-error-when-submitting-payment-tokenization-has-failed/14029/1 "2024-03-27T21:12:25Z")

</div>

Using WEB PAYMENTS SDK.

The sandbox site has worked for me for over 8 months. Today, now, it is failing intermittently.  
This error occurs in Sandbox testing, sometimes.  
Some test transactions go through fine. Then, several more fail.  
This just starting happening today 3/27/2024.  
I’ve reviewed all of the current forum articles and find no match or anything similar.

Error returned from Square:  
Tokenization has failed  
An unknown error has occurred.

```auto

CONSOLE-Error:
Request URL:
https://pci-connect.squareupsandbox.com/v2/card-nonce?_=1711573176441.828&version=1.54.10
Request Method: POST
Status Code: 400 Bad Request
Remote Address: 162.159.140.28:443
Referrer Policy: strict-origin-when-cross-origin

 > at ed (https://sandbox.web.squarecdn.com/v1/square.js:3:270929)
> at Object.deserialize (https://sandbox.web.squarecdn.com/v1/square.js:3:271215)
> at listener (https://sandbox.web.squarecdn.com/v1/square.js:3:195326)
> at https://sandbox.web.squarecdn.com/v1/square.js:3:194060
> at Array.forEach (<anonymous>)
> at https://sandbox.web.squarecdn.com/v1/square.js:3:194047
> at Map.forEach (<anonymous>)
> at rd.handleMessage (https://sandbox.web.squarecdn.com/v1/square.js:3:194032)
> at https://sandbox.web.squarecdn.com/v1/square.js:3:192044
> at Array.forEach (<anonymous>)
> at Pa.handleMessage (https://sandbox.web.squarecdn.com/v1/square.js:3:192031)
> at Pa.receiveMessage (https://sandbox.web.squarecdn.com/v1/square.js:3:190572)`

```

---

<div class="post-metadata">

**Author:** ![Square-Dev-AI](https://sea1.discourse-cdn.com/square/forums/user_avatar/developer.squareup.com/square-dev-ai/32/2513_2.png) [@Square-Dev-AI](https://developer.squareup.com/forums/u/Square-Dev-AI)\
**Post date:** [March 27, 2024, 9:12pm UTC](https://developer.squareup.com/forums/t/intermittent-sandbox-error-when-submitting-payment-tokenization-has-failed/14029/2 "2024-03-27T21:12:45Z")

</div>

👋 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:

> **[Sandbox Payments](https://developer.squareup.com/docs/devtools/sandbox/payments)**
>
> A quick reference of test credit card numbers and payment tokens you can use to make test payments with the Square Sandbox.

[https://developer.squareup.com/docs/in-app-payments-sdk/troubleshooting](https://developer.squareup.com/docs/in-app-payments-sdk/troubleshooting)

> **Additional Documentation**
>
> [https://developer.squareup.com/docs/build-basics/handling-errors](https://developer.squareup.com/docs/build-basics/handling-errors)  
> [https://developer.squareup.com/docs/build-basics/general-considerations/handling-errors](https://developer.squareup.com/docs/build-basics/general-considerations/handling-errors)  
> [Web Payments SDK Requirements](https://developer.squareup.com/docs/app-marketplace/requirements/web-payments-sdk)

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.

---

<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:** [March 27, 2024, 9:20pm UTC](https://developer.squareup.com/forums/t/intermittent-sandbox-error-when-submitting-payment-tokenization-has-failed/14029/3 "2024-03-27T21:20:32Z")

</div>

Was the card correctly tokenized? This error is the POST to your server to process the payment. 🙂

---

<div class="post-metadata">

**Author:** ![schedulesplus](https://sea1.discourse-cdn.com/square/forums/user_avatar/developer.squareup.com/schedulesplus/32/4128_2.png) [@schedulesplus](https://developer.squareup.com/forums/u/schedulesplus)\
**Post date:** [March 27, 2024, 9:39pm UTC](https://developer.squareup.com/forums/t/intermittent-sandbox-error-when-submitting-payment-tokenization-has-failed/14029/4 "2024-03-27T21:39:13Z")

</div>

We are in code pulled from square developer site: sq-card-pay.js

In this section of sq-card-pay.js…the exception is coming from the card.tokenize() call…see below

The odd thing----this function has run hundreds of times for us in testing in the past.  
Today it is randomly failing.

from sq-card-pay.js…  
try {  
const result = await card.tokenize();  
if (result.status === ‘OK’) {  
// Use global method from sq-payment-flow.js  
window.createPayment(result.token);  
}  
} catch (e) {  
console.table(e);  
if (e.message) {  
window.showError(`ERROR: Your transaction did not process.\n ${e.message}.`);  
} else {  
window.showError(‘ERROR: Your transaction did not process.’);  
}  
}

---

<div class="post-metadata">

**Author:** ![schedulesplus](https://sea1.discourse-cdn.com/square/forums/user_avatar/developer.squareup.com/schedulesplus/32/4128_2.png) [@schedulesplus](https://developer.squareup.com/forums/u/schedulesplus)\
**Post date:** [March 27, 2024, 9:49pm UTC](https://developer.squareup.com/forums/t/intermittent-sandbox-error-when-submitting-payment-tokenization-has-failed/14029/5 "2024-03-27T21:49:51Z")

</div>

Tried again just now and the card.tokenize works.  
Again, this is so intermittent. Fails 4 times, then wait 5 minute, and it works for 1. it is the card.tokenize() call to the sandbox that is failing.

---

<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:** [March 27, 2024, 9:51pm UTC](https://developer.squareup.com/forums/t/intermittent-sandbox-error-when-submitting-payment-tokenization-has-failed/14029/6 "2024-03-27T21:51:31Z")

</div>

Right, if inspect the page network activity is a nonce ever returned or is there a more detailed error message? Also is the page where this is failing hosted so we can inspect the page? 🙂

---

<div class="post-metadata">

**Author:** ![schedulesplus](https://sea1.discourse-cdn.com/square/forums/user_avatar/developer.squareup.com/schedulesplus/32/4128_2.png) [@schedulesplus](https://developer.squareup.com/forums/u/schedulesplus)\
**Post date:** [March 27, 2024, 10:43pm UTC](https://developer.squareup.com/forums/t/intermittent-sandbox-error-when-submitting-payment-tokenization-has-failed/14029/7 "2024-03-27T22:43:24Z")

</div>

In my first entrance in this chain, I included the exact return from INSPECT on the nonce.  
This is all that was provided in the javascript errors returned from the CONSOLE and the NETWORK errors.

The page I am working from is on my localhost test environment. I am working to test changes for my production environment before I post them. Therefore, I work localhost and setup a sandbox environment with SQUARE to test all of the changes. I am logged into the SANDBOX Test account as I am executing my test cases.

Again, this doesn’t fail all of the time. It works. Then, it fails randomly.

In my initial content in this conversation, the following message was the source of the error and copied from the INSPECT NETWORK information:

```auto
> Request URL:
> https://pci-connect.squareupsandbox.com/v2/card-nonce?_=1711573176441.828&version=1.54.10
> Request Method: POST
> Status Code: 400 Bad Request
> Remote Address: 162.159.140.28:443
> Referrer Policy: strict-origin-when-cross-origin

```

This was returned to us from SQUARE sandbox.

1. Is the sandbox functioning at the remote address listed?
2. Is the SQUARE SANDBOX environment experiencing issues today.

---

<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:** [March 27, 2024, 10:47pm UTC](https://developer.squareup.com/forums/t/intermittent-sandbox-error-when-submitting-payment-tokenization-has-failed/14029/8 "2024-03-27T22:47:26Z")

</div>

What’s your application 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:** [March 27, 2024, 11:41pm UTC](https://developer.squareup.com/forums/t/intermittent-sandbox-error-when-submitting-payment-tokenization-has-failed/14029/10 "2024-03-27T23:41:47Z")

</div>

The team found some issues and are looking into resolving them. Thanks for bringing this to our attention. 🙂

---

<div class="post-metadata">

**Author:** ![Wysonge3](https://avatars.discourse-cdn.com/v4/letter/w/96bed5/32.png) [@Wysonge3](https://developer.squareup.com/forums/u/Wysonge3)\
**Post date:** [April 1, 2024, 12:35pm UTC](https://developer.squareup.com/forums/t/intermittent-sandbox-error-when-submitting-payment-tokenization-has-failed/14029/11 "2024-04-01T12:35:36Z")

</div>

thanks for sharing your knowledge.[.](https://kohlscreditcard.xyz).

---

<div class="post-metadata">

**Author:** ![michael\_god](https://avatars.discourse-cdn.com/v4/letter/m/258eb7/32.png) [@michael\_god](https://developer.squareup.com/forums/u/michael_god)\
**Post date:** [April 2, 2025, 2:33pm UTC](https://developer.squareup.com/forums/t/intermittent-sandbox-error-when-submitting-payment-tokenization-has-failed/14029/12 "2025-04-02T14:33:43Z")

</div>

Hi, we are encountering the same issue in our app. This also randomly appears in all environments (production and sandbox).

When it occurs, the request for the card nonce is not sent.

[https://pci-connect.squareupsandbox.com/v2/card-nonce](https://pci-connect.squareupsandbox.com/v2/card-nonce)

 ![Screenshot from 2025-04-02 16-28-39](https://global.discourse-cdn.com/square/original/2X/6/650d04a8ca70063fd6a199de01ee21aa0321f0fc.png)  
 ![Screenshot from 2025-04-02 16-22-52](https://global.discourse-cdn.com/square/original/2X/d/dd7c174cb68b5a2722c00c3cf7df321562c556fc.png)

My application\_id: “sandbox-sq0idb-KPTG4PVwUYDVNfdxNpiABA”

---

<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:** [April 2, 2025, 7:28pm UTC](https://developer.squareup.com/forums/t/intermittent-sandbox-error-when-submitting-payment-tokenization-has-failed/14029/13 "2025-04-02T19:28:23Z")

</div>

From what I see in the logs it looks like the nonce was returned. If you click on `card_nonce` and check the response does it have the nonce in the payload? 🙂

---

<div class="post-metadata">

**Author:** ![michael\_god](https://avatars.discourse-cdn.com/v4/letter/m/258eb7/32.png) [@michael\_god](https://developer.squareup.com/forums/u/michael_god)\
**Post date:** [April 2, 2025, 7:57pm UTC](https://developer.squareup.com/forums/t/intermittent-sandbox-error-when-submitting-payment-tokenization-has-failed/14029/14 "2025-04-02T19:57:46Z")

</div>

Yes I attached 2 screenshoots. First one works correctly, but second one not. If nonce is not returned there is issue. It’s happens randomly sometime it working for a while and then not working for a while.

---

<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:** [April 2, 2025, 8:00pm UTC](https://developer.squareup.com/forums/t/intermittent-sandbox-error-when-submitting-payment-tokenization-has-failed/14029/15 "2025-04-02T20:00:37Z")

</div>

It’s possible that there could be a transient network issue if it’s happening only once in a while? Whats the frequency your seeing this? 🙂

---

<div class="post-metadata">

**Author:** ![michael\_god](https://avatars.discourse-cdn.com/v4/letter/m/258eb7/32.png) [@michael\_god](https://developer.squareup.com/forums/u/michael_god)\
**Post date:** [April 3, 2025, 12:26pm UTC](https://developer.squareup.com/forums/t/intermittent-sandbox-error-when-submitting-payment-tokenization-has-failed/14029/16 "2025-04-03T12:26:01Z")

</div>

It occurs randomly—sometimes it works correctly for a while, then stops working. We tested it on different computers and operating systems simultaneously, but there is no consistency. Sometimes it works on one machine, sometimes on all, and sometimes on none. The issue occurs in both the production and sandbox environments.
