Intermittent. Sandbox Error when submitting payment: Tokenization has failed


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.

Request URL:
Request Method: POST
Status Code: 400 Bad Request
Remote Address:
Referrer Policy: strict-origin-when-cross-origin

 > at ed (
>     at Object.deserialize (
>     at listener (
>     at
>     at Array.forEach (<anonymous>)
>     at
>     at Map.forEach (<anonymous>)
>     at rd.handleMessage (
>     at
>     at Array.forEach (<anonymous>)
>     at Pa.handleMessage (
>     at Pa.receiveMessage (`

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

Additional Documentation
Web Payments SDK Requirements

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.

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

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
} catch (e) {
if (e.message) {
window.showError(ERROR: Your transaction did not process.\n ${e.message}.);
} else {
window.showError(‘ERROR: Your transaction did not process.’);

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.

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? :slightly_smiling_face:

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:

> Request URL:
> Request Method: POST
> Status Code: 400 Bad Request
> Remote Address:
> 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.

What’s your application ID? :slightly_smiling_face:

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

thanks for sharing your knowledge...