I’m getting the following error when adding square.js in my local machine. Doesn’t square allow testing the payment flow without https?
square.js:3 Uncaught WebSdkEmbedError: Web Payments SDK can only be embedded on sites that use HTTPS and have a secure context
at Object.payments (square.js:3:390031)
at review-checkout:217:57
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.
Square requires HTTPS for all API calls, including the Web Payments SDK. This is because HTTPS provides a secure connection, which is essential for handling sensitive information like payment details. Therefore, you cannot test the payment flow without HTTPS even on your local machine. You should set up a local HTTPS server for testing purposes.
Hello,
Square’s Web Payments SDK requires HTTPS for embedding due to security protocols. To test locally, you can use localhost, which is considered a secure context. Alternatively, set up HTTPS using tools like Let’s Encrypt or a self-signed certificate. This ensures compliance with Square’s requirements and enables proper functionality.