Issue: verifyBuyer()
Failing with 400 Error in Production
Context
I’m using the Web Payments SDK to implement Strong Customer Authentication (SCA). Everything works as expected in Sandbox, including the verifyBuyer()
function, which correctly processes 3D Secure (3DS). However, when switching to Production, the verifyBuyer()
function consistently fails and returns:
POST https://connect.squareup.com/v2/analytics/verifications 400 (Bad Request)
Problem
Regardless of what I send in the verificationDetails
, the response is always a 400 Bad Request error.
- The nonce is generated correctly and passed to the
verifyBuyer()
function. - Payments for cards without 3D Secure work fine.
- The app is authenticated correctly, and there are no issues with other payment flows.
Here’s the relevant code:
// Function to handle 3D Secure verification (SCA)
async function verifyBuyer(nonce) {
// Prepare 3D Secure verification details
const verificationDetails = {
amount: '1.00',
billingContact: {
givenName: 'John',
familyName: 'Doe',
email: '[email protected]',
phone: '3214563987',
addressLines: ['123 Main Street', 'Apartment 1'],
city: 'London',
state: 'LND',
countryCode: 'GB',
},
currencyCode: 'GBP',
intent: 'CHARGE',
};
try {
console.log('Preparing to call verifyBuyer with:', verificationDetails, nonce);
// Initialize Square Payments SDK
const payments = window.Square.payments(appId, locationId);
// Attempt 3D Secure verification
const verificationResult = await payments.verifyBuyer(nonce, verificationDetails);
console.log('verificationResult:', verificationResult);
if (verificationResult.token) {
const verificationToken = verificationResult.token;
document.getElementById('verification').value = verificationToken;
console.log('Card tokenized and 3D Secure verified successfully.', verificationToken);
return verificationToken; // Return verification token if successful
} else {
console.log('3D Secure Verification failed:', verificationResult);
displayError('3D Secure verification failed.');
return null; // Return null if 3D Secure verification fails
}
} catch (error) {
console.error('Error during 3D Secure verification:', error);
// Log more detailed error information if available
if (error.response) {
console.error('Error response data:', error.response.data);
}
// Display an error message (optional)
displayError('3D Secure verification failed.');
return null; // Return null if verification encounters an error
}
}
What I’ve Tried
- I have tried different variations of the
verificationDetails
object, including omitting optional fields (e.g.,addressLines
,state
, etc.). - I verified that the App ID and Location ID are correct for production.
- I reviewed the Square Documentation for verifyBuyer() to ensure compliance.
Questions
- Are there any additional steps or configurations needed to make
verifyBuyer()
work in production? - Could the 400 error be caused by any specific field formatting in the
verificationDetails
object? - Does production require more specific billing information than sandbox?
Any guidance or suggestions would be greatly appreciated. Thank you!