I’m trying to implement web payment API with EMV 3D secure to my web store.
I’m not sure the reason, but paymentMethod.tokenize(verificationDetails) returns unknown error on sandbox environment.
The code is almost identical with sample code, like this,
const verificationDetails = {
amount: '10.00',
billingContact: {
givenName: 'John',
familyName: 'Doe',
email: '[email protected] ',
phone: '3214563987',
},
currencyCode: 'JPY',
intent: 'CHARGE',
customerInitiated: true,
sellerKeyedIn: false
};
const tokenResult = await paymentMethod.tokenize(verificationDetails);
if (tokenResult.status === 'OK') {
return tokenResult.token;
} else {
let errorMessage = `Tokenization failed with status: ${tokenResult.status}`;
if (tokenResult.errors) {
errorMessage += ` and errors: ${JSON.stringify(
tokenResult.errors
)}`;
}
throw new Error(errorMessage);
}
It works without 3D secure, means tokenize() works without argument.
Javascript console said,
Tokenization has faild.
An unknown error has occurred.
(Anonymous Funcion) - square.js:5826
...
Any ideas?
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:
An overview of the Square Sandbox, which can be used to simulate orders, invoices, payments, and transactions in a test environment.
Additional Documentation
Test in the Sandbox
Square Developer
Troubleshoot In-App Payments SDK Problems
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.
What test value are you using when you get this error?
I used “SCA testing in the Web Payments SDK” values on the document, but I think this error is not related to the specific test value.
Which one did you use so I can try and replicate the error?
Visa 4800 0000 0000 0004 or Mastercard 5222 2200 0000 0005.
I’ve got same error, I mean it happened at the same line of square.js, line 5826.
just line number, I could not get the exact reason of error.
FYI, same code works at production environment.
more infomation about this error.
following error messages are catched by code like this.
try {
const tokenResult = await paymentMethod.tokenize(verificationDetails);
} catch (e) {
console.error('Tokenization failed - thrown error', e);
throw new Error('Tokenization failed - thrown error');
}
[Javascript Console]
Tokenization failed - thrown error
TokenizationError: Tokenization has failed An unknown error has occurred
Vn — square.js:8323
Ti — square.js:8714
xo — square.js:9216
(anonymous function) — square.js:14257:86
_d — square.js:14003
s — square.js:14020