#domhacking

1 messages ยท Page 1 of 1 (latest)

alpine tuskBOT
worthy tide
#

Hi there

#

Sounds like a duplicate request is occurring

#

Can you show me your relevant code?

haughty belfry
#

Hey ๐Ÿ™‚

#

Give me two secs

#

will remove some of the commented out code.

#

@worthy tide โ˜๏ธ

worthy tide
#

Okay give me a moment to take a look

proud yoke
#

๐Ÿ‘‹ have you tried putting a console log in your handleDiscoverReaders to see if it accidentally is getting called twice?

haughty belfry
#

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

proud yoke
#

can you try adding a console log in useStripeTerminal 's callback didUpdateDiscoveredReaders?

haughty belfry
#

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.

proud yoke
#

gotcha, does this only happen with simulated readers? do you have a physical reader you can test with?

haughty belfry
#

unfortunately not at the moment. ๐Ÿ˜ฆ

proud yoke
haughty belfry
#

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

proud yoke
#

Initialize is in the child component right?

haughty belfry
#

Yes it is

#

Made that mistake yesterday ๐Ÿ™‚

proud yoke
#

Gotcha.. thinking

haughty belfry
#

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 ๐Ÿ™‚

proud yoke
#

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?

haughty belfry
#

So leave it running?

proud yoke
#

yup

haughty belfry
#

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?

proud yoke
#

yup

haughty belfry
#

Ok will do that. Give me a minute ๐Ÿ™‚

proud yoke
#

๐Ÿ‘

alpine tuskBOT
haughty belfry
#

It does not time out.

proud yoke
haughty belfry
#

Ok thanks

#

Is it expo or regular react native app?

haughty belfry
#

cool