#hirshy- Terminal Connection Token
1 messages · Page 1 of 1 (latest)
Yes. I have a function running onUnexpectedReaderDisconnect.
What language is your integration written in?
JS
And your instantiation of StripeTerminal looks similar to what is shown here?
https://stripe.com/docs/terminal/payments/connect-reader?terminal-sdk-platform=js&reader-type=internet#handling-disconnects
Yep
And you have defined the fetchConnectionToken function, correct?
If this does generate a request to your back-end to retrieve a connection token, is it possible your back-end is caching the result and returning a stale token?
Yes
I'd have to check that. But shouldn't the library ask for a new one instead of throwing a rejection?
You mean the JS library? No, it's only configured to request a new one is you disconnect unexpectedly AFAIK. I tested this in my own integration by passing a static token value on my back-end and it does through an error
The backend doesn't seem to be caching it.
I'm confused as to when this is getting called. According to my logs there wasn't an unexpected disconnect.
I attempt to discoverReaders. I get this Uncaught (in promise) and then the discoverReaders resolves with a list of results.
I'm not sure who's calling this so that I can catch it. Also, I'm not sure what to do with it once it is caught.
I'm pretty sure this is used internally during the call to terminal.connectReader(), which is why you need to register it when instantiating the StripeTerminal instance.
That's not when it was logged. It shows up when I call discoverReaders. I have a catch on that promise but it's still saying "Uncaught". And the discoverReaders comes back with results.
Okay so discoverReaders comes back with results when you get the Uncaught exception? Are you calling initializeTerminal() as part of that function?
Also, are you calling initializeTerminal more than once? This could also cause problems.
I'm not calling initializeTerminal at all. I've never seen that call in the documentation.
Sorry that was my own code, I meant only initializing the terminal SDK once:
Yes. I'm only calling create() once.
So if terminal.discoverReaders returns results, are you able to connect to a reader? Or does the Uncaught exception block all JS?
That's a separate issue. When I try to connect to the reader I get a Already have an active connection to a reader. Call 'disconnectReader()' first. error which is also Uncaught (in promise).
Hmmm...okay it seems like the StripeTerminal instance is getting into an invalid state at some point.