Moving sample app to produciton issue

All,

I used the sample app to create a payment form. I’m trying to migrate it from sandbox to production. I modified env.example to use the square access token. I modified the html to use the production url & I modified card-payment.js to use the produciton appID & locationID. When I call it from localhost it seems to work but all my payments calls are rejected. I’m assuming this is because it’s localhost on dev butnot sure. When I try to access the site from the server I get applicationId and/or locationId is incorrect. Am I missing a step here? How can I call this from a server URL vs. localhost.

Thanks,

Jeff

: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

In-App Payments SDK Quickstart
In-App Payments SDK Quickstart
Move OAuth from the Sandbox to Production

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.

1 Like

Thanks for the reply. These answers are fir in-app purchases. I’m using the web portal payment. Are there any docs for that?

Jeff

To migrate from sandbox to production, you need to ensure that you’re using the production credentials (application ID and access token) and the production base URL (https://connect.squareup.com).

The error message you’re seeing (“applicationId and/or locationId is incorrect”) typically indicates that the application ID or location ID you’re using is not correct. Make sure you’re using the correct production application ID and location ID, which you can find in your Square Developer Dashboard.

Also, ensure that your server is configured to use HTTPS, as Square’s production environment requires secure connections.

Regarding the issue with payments being rejected, it could be due to various reasons such as incorrect card details or issues with the payment processing. Make sure you’re using valid card details for testing in the production environment.

Lastly, ensure that your server is properly set up to handle the Square API responses and that the server is correctly parsing the payment response.

This answer was reviewed by @Bryan-Square.

Bryan,

I have migrated everything over with the production information. In my html I’ve tried both:

<script type="text/javascript" src="https://web.squarecdn.com/v1/square.js"></script>
<script type="text/javascript" src="https://connect.squareup.com/v1/square.js"></script>

Both of these gives me the same result. When I use ‘http://’ I’m getting a 404 error, which I would expect. Now when I use https: I get an error in the browser saying ‘This site can’t provide a secure connection gt.rfidentity.com sent an invalid response ERR_SSL_PROTOCOL_ERROR’. In developer tools I get warning saying crbug/1173575, non-JS module files deprecated.

I call the site using https://gt.rfidentity.com:3000, is that the right way to call the site or should I map a folder or something?

Thanks,

Jeff

For production you’ll use http://web.squarecdn.com/v1/square.js. If your getting an SSL error our security is being triggered by something with your site. With Square’s APIs, HTTPS is required for all API calls to Square endpoints. Unencrypted HTTP API calls do not work.

We strongly recommend finding a way to secure your websites with HTTPS—even if that means changing your hosting provider. :slightly_smiling_face:

Bryan,

That’s the thing. Our site is running under SSL. Is there something I need to do to get node to run under SSL? I’m new to node so I’m not 100% on how to set that up. I was thinking that it would just work as an SSL site.

Jeff

Are you rendering our form in an iframe? If so we don’t recommend doing so. :slightly_smiling_face:

Bryan,

I have plans to but I’m not doing so right now. I’m just pointing to a web page. I’m not sure why the https isn’t working. I’m using the node.js example app & I’m not at all familiar with it. ALso, if I’m not supposed to use an iframe, how do most people use the web api?

Thanks,

Jeff

Our form field is an iframe. We don’t recommend rendering an iframe within a iframe. The form field won’t correctly render if you do this. When your running the server for production are you running npm start? :slightly_smiling_face:

Bryan,

I try but it’s not working, depending on what I’m doing. When I run it from the main folder (the folder with env.sandbox and env.production), I get an error saying it can’t find package.json. I then generate one using ‘npm init – yes’. I then try npm start & I see node come up in the task manager & then it stops. I try npm run & the same thing happened but in the console it says 'echo “Error: no test specified” && exit 1. I’m not sure how to proceed from here.

I’m super new to node.js so this is all new to me,

Thanks,

Jeff

Bryan,

I see in the package.json that it’s outputting the 2 lines:

“test”: “echo "Error: no test specified" && exit 1”,
“start”: “node server.js”

Node does briefly appear in the task manager & then it completes. It feels like I’m missing some steps but can’t get my way out of this. I’ve included the log file below & it just shows that it’s running server.js & that’s it. There’s no errors in the event log & nothing I can see would stop it from working.

I appreciate all the help.

Jeff

0 verbose cli C:\Program Files\nodejs\node.exe C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js
1 info using [email protected]
2 info using [email protected]
3 silly config load:file:C:\Program Files\nodejs\node_modules\npm\npmrc
4 silly config load:file:C:\PLPOA\square.npmrc
5 silly config load:file:C:\Users\jkimm.npmrc
6 silly config load:file:C:\Users\jkimm\AppData\Roaming\npm\etc\npmrc
7 verbose title npm start
8 verbose argv “start”
9 verbose logfile logs-max:10 dir:C:\Users\jkimm\AppData\Local\npm-cache_logs\2024-11-11T23_37_56_080Z-
10 verbose logfile C:\Users\jkimm\AppData\Local\npm-cache_logs\2024-11-11T23_37_56_080Z-debug-0.log
11 silly logfile done cleaning log files
12 verbose cwd C:\PLPOA\square
13 verbose os Windows_NT 10.0.22631
14 verbose node v20.17.0
15 verbose npm v10.8.2
16 verbose exit 0
17 info ok