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.
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)`
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:
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/general-considerations/handling-errors
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.
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.’);
}
}
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?
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:
> 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.
- Is the sandbox functioning at the remote address listed?
- Is the SQUARE SANDBOX environment experiencing issues today.
What’s your application ID?
The team found some issues and are looking into resolving them. Thanks for bringing this to our attention.
thanks for sharing your knowledge...