Spent my morning working on integrating the webpayment sdk into my check out page using the JS and it works fine except it doesn’t autodetect the locale and I only get the field for US Zip code rather than Canadian postal codes. I tried to force it but it doesn’t seem to work.
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:
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.
The Web Payments SDK should automatically detect the locale based on the device settings or the specified locale in your configuration. However, it seems like the issue you’re experiencing is related to the test credit card numbers you’re using, which are likely defaulting to a US locale.
The test card numbers you mentioned (4111 1111 1111 1111 and 5105 1051 0510 5100) are commonly used for testing and might be associated with US settings, which is why you’re seeing the ZIP code field instead of a Canadian postal code field.
To test with a Canadian postal code, you can try the following:
Ensure that your device or browser is set to a Canadian locale.
Use a test card number that is recognized as Canadian, if available.
If the SDK allows, explicitly set the locale to ‘en-CA’ in your configuration, as you have done, and ensure that this setting is correctly applied.
Unfortunately, if the test card numbers are inherently linked to a US locale, overriding this behavior might not be possible without using a different set of test card numbers that are recognized as Canadian. If you continue to face issues, you might need to check if there are specific test card numbers provided by Square for Canadian testing or consult further resources for locale-specific testing.