I keep getting this error in my flutter app: flutter: Failed to charge card: Internal Server Error: Request failed with status code 401

I’m trying to use in app payments pub.dev package to use square in my flutter app for payments. I’m currently in the sandbox environment with appropriate credentials added to my .env file. But I keep getting the “failed to charge card” error. I also have my backend Firebase set up. Any idea why I keep receiving the 401 error?

:wave: 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:

Additional Documentation

Flutter Plugin: In-App Payments SDK
Install the In-App Payments SDK
In-App Payment Solutions

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’s your application ID and are you sure your getting an internal server error? That would be a 5xx instead of a 401 unauthorized. If your getting an unauthorized error are you using our test values? :slightly_smiling_face:

Thank you so much for getting back to me. My application ID is: sandbox-sq0idb-cC_LS-72v_-RnfhiZOscgQ

I think I figured it out. I added “sandbox” to the url in my backend Firebase functions: https://connect.squareupsandbox.com/v2/customers

Fantastic! Yes, if you don’t have the correct base path URL it you’ll get an Unauthorized error. :slightly_smiling_face: