#domhacking
1 messages ยท Page 1 of 1 (latest)
Hi there
Sounds like a duplicate request is occurring
Can you show me your relevant code?
Hey ๐
Give me two secs
will remove some of the commented out code.
@worthy tide โ๏ธ
Okay give me a moment to take a look
๐ have you tried putting a console log in your handleDiscoverReaders to see if it accidentally is getting called twice?
checking thanks...
So now I am getting a
and this just keeps ticking over in the console.
But I would expect then for this function to return a reader:
const handleConnectBluetoothReader = async (id: string) => {
const { reader, error } = await connectBluetoothReader({
readerId: discoveredReaders[0].id,
// Since the simulated reader is not associated with a real location, we recommend
// specifying its existing mock location.
locationId: discoveredReaders[0].locationId,
});
if (error) {
console.log('connectBluetoothReader error', error);
return;
}
console.log('Reader connected successfully', reader);
};
But the bottom console log is never reached
can you try adding a console log in useStripeTerminal 's callback didUpdateDiscoveredReaders?
yup.
const { discoverReaders, connectBluetoothReader, discoveredReaders } =
useStripeTerminal({
didUpdateDiscoveredReaders: (readers) => {
console.log("didUpdateDiscoveredReaders", readers);
// After the SDK discovers a reader, your app can connect to it.
// Here, we're automatically connecting to the first discovered reader.
handleConnectBluetoothReader(readers[0].id);
},
});
The console log never gets hit.
gotcha, does this only happen with simulated readers? do you have a physical reader you can test with?
unfortunately not at the moment. ๐ฆ
No worries! can you check if you've initialized the SDK correctly?
https://stripe.com/docs/terminal/payments/setup-integration?terminal-sdk-platform=react-native#initialize
You must call the initialize method from a component nested within StripeTerminalProvider and not from the component that contains the StripeTerminalProvider.
Yup I am pretty sure I have
Because I only allow that screen to be shown after a successfull initialisation
And I am getting the 3 simulator devices returned to me.
[Stripe terminal]: didUpdateDiscoveredReaders in this response
Initialize is in the child component right?
Gotcha.. thinking
Thanks
I have removed simulated: true and I still get the same error btw
I am going to try it in a clean project.
Unless you have any other suggestions ๐
the fact that the SDK is printing the correct callback is what's puzzling me
Maybe discoverReader runs for a specific duration before calling didUpdateDiscoveredReaders ? Can you run a quick test to see if it times out in like a minute or so?
So leave it running?
yup
so at the moment every three seconds or so I get didUpdateDiscoveredReaders printed to the console.
And you just want me to leave that running?
yup
Ok will do that. Give me a minute ๐
๐
It does not time out.
ah okay! hmm not sure what else it could be!
We have an example app here that you can test with to see if it shows the same behavior (rather than starting from scratch)
https://github.com/stripe/stripe-terminal-react-native/tree/main/example-app
cool