#mangell03_code

1 messages Β· Page 1 of 1 (latest)

wheat gyroBOT
prisma spireBOT
#

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.

wheat gyroBOT
#

πŸ‘‹ 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.

foggy shuttle
sterile raptor
#

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

foggy shuttle
#

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?

sterile raptor
#

`const {loadStripeTerminal} = require ('@stripe/terminal-js');

const StripeTerminal = async function loadStripeTerminalCall() {
return ( await loadStripeTerminal());

}

foggy shuttle
#

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

sterile raptor
#

Thank you. It is tricky to integrate terminal-js into a top level node app

wheat gyroBOT
brisk echo
#

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.

sterile raptor
#

Looking to build a pure node based application that will integrate to a custom POS to a stripe physcial terminal.

brisk echo
#

terminal js is not a node module though so that's why this approach wont' work

sterile raptor
#

Soecifically wanting to use @stripe/terminal-js in a top level node app. https://www.npmjs.com/package/@stripe/terminal-js

brisk echo
#

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.

sterile raptor
#

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?

brisk echo
#

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.

brisk echo
sterile raptor
#

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.

brisk echo
#

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

sterile raptor
#

Well- The link you sent me is exactly where I started as my next stone. And I run into the import problem.

brisk echo
sterile raptor
#

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.

brisk echo
#

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).

sterile raptor
#

That's the rub....

brisk echo
#

I would still not recommend you pursue it any farther

sterile raptor
#

Why?

brisk echo
#

Just use our Node SDK and server-driven integration

sterile raptor
#

My POS is not browser based.

brisk echo
#

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

sterile raptor
#

So what you are saying is that Stripe terminals all depend on a browser stack?

brisk echo
#

No

#

I am saying you can and should use our server-side integration, which is the recommended path and works entirely on the server

sterile raptor
#

I can discover and use terminals in that approach?

#

That is what was very unclear reading the docs.

brisk echo
#

Yes

sterile raptor
#

I must have missed something then...

brisk echo
#

You can create terminal records in the API, and list them

sterile raptor
#

Yo! I can't believe I haven't seen this one yet. I was stuck in the client/server demo world.

brisk echo
#

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

sterile raptor
#

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).

brisk echo
#

Yeah, we know that is something we could do better. Redesigning docs is a long process though πŸ˜…

sterile raptor
#

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.

sterile raptor
#

But at least you guys have this forum to mitigate.

brisk echo
#

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.

brisk echo
#

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.

sterile raptor
#

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

brisk echo
#

Yeah, you cannot use await outside the scope of an async function

sterile raptor
#

It's direct from your docs.

#

When I saw that, I was πŸ€·β€β™‚οΈ but tried it anyway.

#

It's blending client code I think....

brisk echo
#

The code snippets are not intended to be the complete code. We are just showing you the commands.

sterile raptor
#

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.

brisk echo
#

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

wheat gyroBOT
sterile raptor
#

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 πŸ˜‰

brisk echo
#

Great πŸŽ‰

sterile raptor
#

Make sure your managers get the news that this was an awesome session!!