#mangell03_code
1 messages Β· Page 1 of 1 (latest)
Below are links to other discussions we've had with you in the past week in case you want to review that information. If your question is related to one of these previous discussions, please provide a comprehensive summary of the current state and what you need help with now. We help many users simultaneously, so a summary allows us to resolve your issue as soon as possible.
- mangell03_code, 6 days ago, 34 messages
π Welcome to your new thread!
β²οΈ We'll be here soon! Typically we respond in a few minutes, but sometimes we might take a bit longer if the server is busy or if you have a particularly tricky question.
β±οΈ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can always start a new thread if you have another question.
π This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1239666158421020804
π Have more to share? Add more details, code, screenshots, videos, etc. below.
I think fetchConnectionToken is a function that your code needs to define. If you define a function with that name in the same scope, does that clear up the error? https://docs.stripe.com/terminal/payments/setup-integration?terminal-sdk-platform=android#connection-token-client-side
Ok- I am trying to copy over code from the client.js in the terminal demo in to the node server- yes that resolved the issue, but now I am getting
var terminal = StripeTerminal.create({
^
TypeError: StripeTerminal.create is not a function
I think it has something to do with the fact that I can't use import to load terminal-js
Can you show me how you are currently loading terminal.js with the require pattern that you mentioned? And are there any errors when you use that method to import other than nothing terminal related being defined?
`const {loadStripeTerminal} = require ('@stripe/terminal-js');
const StripeTerminal = async function loadStripeTerminalCall() {
return ( await loadStripeTerminal());
}
I will consult my colleagues on this and get backt o you with what I can find. Unfortunately I'm having trouble figuring out how js imports work here
Thank you. It is tricky to integrate terminal-js into a top level node app
Hi π
I'm stepping in as my colleague needs to go
How are you integrating with Stripe Terminal?
What specifically are you building?
terminal-js is used for managing terminal readers in client-side JavaScript. However, because that approach relies on local networking and can be very difficult to troubleshoot, we now recommend server-driven integration as an alternative.
Looking to build a pure node based application that will integrate to a custom POS to a stripe physcial terminal.
terminal js is not a node module though so that's why this approach wont' work
Soecifically wanting to use @stripe/terminal-js in a top level node app. https://www.npmjs.com/package/@stripe/terminal-js
If you read the associated docs you will see this language at the top
For smart readers, such as the BBPOS WisePOS E reader or Stripe Reader S700, we recommend using the server-driven integration instead of the JavaScript SDK. The server-driven integration uses the Stripe API instead of relying on LAN communications to collect payments. The JavaScript SDK and SDI donβt support operating offline. See our platform comparison to help you choose the best platform for your needs.
So the @strip3/terminal-js is not intended for a pure node app? Basically I am trying to take the terminal demo code and take all of the UI portions of the demo, and put them in the server so I can programatically control the flow. Is that not possible without a client (browser) being involved?
Okay, in that case our Server Driven Integration is actually much easier to implement.
And does just what you are looking for.
One nice feature, no additional modules. Just the Stripe Node SDK
So your reader needs to connect to the internet (WisePOS E or S700), and then you make calls to the Stripe API and we communicate to the reader.
You can get a sense for how this works here: https://docs.stripe.com/terminal/payments/collect-card-payment
You could try to load terminal-js in a script tag or using import: https://github.com/stripe/terminal-js?tab=readme-ov-file#usage
But I still strongly recommend using the server-driven integration approach. It will make your application more robust, easier to debug, and have fewer dependencies.
Great advice! My starting point was the simulated reader and the client/server demo which I have working great. That was my first stepping stone, so I tried to figure out how to merge the client with the server using terminal-js. I hope to find this a better approach.
The Server Driven integration is conceptually easier, in my opinion. Also it's easier to debug on our end so you wind up getting better support
Well- The link you sent me is exactly where I started as my next stone. And I run into the import problem.
Okay, yeah. I would just use our Node SDK and API calls like in this doc: https://docs.stripe.com/terminal/payments/collect-card-payment?lang=node
What is the intended scope of terminal-js if it has to be imported?
This is what I kept running into as I looked thru all of the docs. The Collect-card-payments does not mention terminals.
I need to connect to a terminal from npm start
Once I was able to look thru client.js, connecting to a reader flow made sense- but I can't have the chatter between client/server.
Honestly I'm not sure. I've only ever used terminal-js as part of a client-side integration by loading it in a browser (before we had Server Driven Integration).
That's the rub....
I would still not recommend you pursue it any farther
Why?
Just use our Node SDK and server-driven integration
My POS is not browser based.
terminal-js integrations are deprecated because of how often they break for reasons neither we nor the developer have any control over
They are nearly impossible for us to debug
So what you are saying is that Stripe terminals all depend on a browser stack?
No
I am saying you can and should use our server-side integration, which is the recommended path and works entirely on the server
I can discover and use terminals in that approach?
That is what was very unclear reading the docs.
Yes
I must have missed something then...
Take a look at this snippet: https://docs.stripe.com/terminal/payments/connect-reader
You can create terminal records in the API, and list them
You can filter the list by Location ID https://docs.stripe.com/api/terminal/readers/list#list_terminal_reader-location
Yo! I can't believe I haven't seen this one yet. I was stuck in the client/server demo world.
There is a whole section in our API reference doc that is just for Terminal related integrations. It doesn't rely on terminal-js but just uses our Node SDK
You can find and connect to readers, check their status, collect on-screen inputs, display a shopping cart, all the good stuff
I knew I wasn't crazy. If I may offer a suggestion. At the top level of the reader docs, offer a solution path (server based , client/server based).
Yeah, we know that is something we could do better. Redesigning docs is a long process though π
Ok- this is what I needed. I will explore. Do you guys close threads at this point? I would be happy to open a new thread if I have further questions.
Trust me- it SUCKS!
But at least you guys have this forum to mitigate.
Yeah, we also do take pain points, feature requests, and the like and surface them internally. So I'm going to share your suggestion regarding integration paths, even if nothing comes of it for a while. At least the teams will know there is interest in re-working those docs.
Do you guys close threads at this point? I would be happy to open a new thread if I have further questions.
Sorry, just realized you had this Q.
Yes we do close threads after a period of inactivity. You are welcome to come back to the main channel #dev-help and ask a new question.
So I started over from your new docs entry point.
`const express = require("express");
const app = express();
const { resolve } = require("path");
// This is your test secret API key.
const stripe = require("stripe")("sk_test_51O8qkAEPuIFxKCqtwV78O2mjDNip3mlvWq89T2YKSzvllbFiKPbgGlPwk6v2LCfXJKgvyqXVVh61u9WDWppVPnvp00Jza03hN1");
const reader = await stripe.terminal.readers.create({
location: {},
registration_code: 'simulated-wpe',
});`
ERROR: const reader = await stripe.terminal.readers.create({
SyntaxError: await is only valid in async functions and the top level bodies of modules
Yeah, you cannot use await outside the scope of an async function
It's direct from your docs.
When I saw that, I was π€·ββοΈ but tried it anyway.
It's blending client code I think....
The code snippets are not intended to be the complete code. We are just showing you the commands.
Ok- how do I load it without await? I might be asking for JS advice, but the docs at this high level should be copy/paste.
Wrap it in an async function and call that function.
And I understand, there should be a higher level basic integration you can copy/paste and get 1 end-to-end payment processed in Test mode
Yep! Worked. I haven't done JS/node in some while. Now it's complaining I don't have a location which is GREAT news. Time to update the docs π
Great π
Make sure your managers get the news that this was an awesome session!!