Closed mvincent7891 closed 2 years ago
Hey @mvincent7891 thanks for reaching out. If you look at the dev-app
in our repo we have that set up to switch merchants on the fly for our own internal testing. While there are a number of patterns in that app you'd never want to deploy to production it does outline how to go about it. I think the key piece you're missing is a call to clearCachedCredentials
when switching to a new merchant. You can see our call and surrounding logic here. Let me know how that works out for you!
That's perfect, will try that and report back. Thanks @jdivock-stripe!
Works great!
Hey @jdivock-stripe, sorry for commenting on such an old issue.
In the code example above, why is it calling clearCachedCredentials()
right after initialize()
?
The usage is pretty different from steps is described in the docs https://docs.stripe.com/terminal/references/api/js-sdk#clear-cached-credentials
It is sometimes necessary in development as well as in production to switch the location of a device connected to a Stripe Terminal. This is mostly useful in development, but could be relevant in our production app as well for instance when training staff across locations.
When this happens within the context of the app, I would like to re-initialize Stripe with the new
tokenProvider
, which requests a connection token for the new location. So far, I'm unable to figure out a way to handle the location change without completely restarting the app.A great solution would just be a
reinitialize()
callback returned fromuseStripeTerminal()
, or at least an automatic reinitialization if a change is detected fortokenProvider
.An alternative would just be to refetch the connection token if
tokenProvider
changes.