Payment Tokenization failed - in sandbox and production


I run a low volume photography ecommerce website. I’m the photographer and the developer.

I’ve had a working Square integration since December. However, I am no longer able to take payments. I am getting: “Tokenization has failed An unknown error has occurred” on all attempts to tokenize payments, in production or sandbox.

I’m the only programmer - I know no code of ours has been changed in this area. I just checked the git history for the related files to confirm. I haven’t changed anything since I got this all in place 5 months ago.

I’m receiving a 400 BAD REQUEST response.

The error message is: “Tokenization has failed An unknown error has occurred”.

This is the tokenize request body sent by the square js library:

This is the error response received:

These are the response headers:

These are the Square sandbox environment variables I am using:

I’ve seen another developer reported intermittent issues back on 24 March - but mine are 100% failure. No sandbox transactions are going through and I’ve not had a successful eCommerce Integration sourced transaction since the 18th of April - customers are emailing me in frustration.

I’m hoping there’s a simple fix … thanks for any insight!


: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

Move OAuth from the Sandbox to Production
Make your First API Call
Receive Seller Authorization and Manage Seller OAuth Tokens

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.

Is your page publicly hosted? If so what’s the URL so we can take a look. :slightly_smiling_face:

Hi Bryan,

The production site is. (The sandbox site is a local test server, not exposed online). It’s part of a large SPA. I’ve created a test account for you and built a simple cart:

User Name: squaretest
PW: square

When you hit this link, you’ll be prompted to login:

The cart will be displayed. If you click the Payment Link:

The payment dialog will be displayed.

The source for the SPA is all served in one large bundle, but not obfuscated/minified.

There is an object called paymentHandlers which basically defines the tenders (creditcard, googlepay, applepay) and their square methods. I starts at

Line 43270

Here are a couple of functions in that object you may want to break point:

Initialize Square Credit card payment type
Line 43787

Tokenize Payment
Line 43828

Thank your for having a look - I hope you’re able to spot something!


Looks like the issue is that your using an unsupported version of the Web Payments SDK. You’ll need to point to a supported version which is :slightly_smiling_face:

Thanks for pointing that out! Sounds simple enough. :laughing:

Is there a canonical place I can look for the sandbox and production URLs? I feel like I’ve seen them, but I’ve been looking on the site and in the docs and they’re not jumping out at me.

So things are working in sandbox … but still not in production. I’ve not been able to successfully use the production environment on my deployed online server or my in-house development machine. But sandbox is working in-house without issue.

I’m still getting a 400 response from a tokenization request with the following response:


Here is the request data being POSTed:

I’m using:


As the script source.

Is there something else I should be looking at?


Have you searched the entire code base for the old version? :slightly_smiling_face:

Whatever it was, it’s working now. I was just able to complete a purchase on the live site and see the transaction in my Square Dashboard.

Hopefully it continues working! :crossed_fingers:


Glad to here its working as expected. :slightly_smiling_face: