#Antriksh

1 messages ยท Page 1 of 1 (latest)

versed ravineBOT
short obsidian
#

๐Ÿ‘‹ Thanks for reaching out
Please give couple of minutes while analyzing this

tawdry cypress
#

Sure. Thanks

short obsidian
#

Are you doing Step3 without disconnecting/unregistering the reader ?

tawdry cypress
#

Yes I am connecting to the reader and doing multiple payments.

short obsidian
#

yeah, but at step 3 why you want to rediscover an already discovered reader before? you said Now, when doing this process again when I try to discover readers again

#

I'm not seeing why you want to rediscover the reader again, sorry not sure I'm following your senario 100%

tawdry cypress
#

I am doing this again, because when we repeat this process (Doing second payment after first successful one), we need to show updated list of ONLINE readers, which comes on discovery.

#

So, to show live ONLINE readers, we do discover readers before each payment.

short obsidian
#

Ah ok I see now, you don't need to rediscover reader before each payments. You just monitor the function onUnexpectedReaderDisconnect to see if a reader has been disconnected or not, otherwise you keep in your integration the reader AS online

tawdry cypress
#

Ok, but what if I discovered the online readers and then after sometime one specific reader comes online. How will we know that reader has come online and we can use it ?

#

This is the case where we have multiple readers and they can be ONLINE anytime AFTER our web-app has loaded.

short obsidian
#

Sorry for my late reply

#

In order to discover a reader, are you creating a new StripeTerminal ?

tawdry cypress
#

No, using the same StripeTerminal todiscover

short obsidian
tawdry cypress
#

Yes, I am just calling terminal.discoverReaders with same StripeTerminal created initially.

#

Should this call the fetchToken callback everytime ?

#

My flow --

Discover online reader -> Connect reader (only if not connected) -> Collect payment -> Process payment -> Repeat.
On repeat the generate_pos_rpc_session gives that redeem error, but readers still get discovered.

short obsidian
tawdry cypress
#

yes

short obsidian
#

Yeah, that's need by the SDK in order to connect to the reader.

tawdry cypress
#

So, why is it not doing same for discover readers ? And that generate_pos_rpc_session fails for token redemption.

short obsidian
#

I think you need to provide more details about your integration and code, can you prepare a sample project that reproduce this issue so that we can analyze further ?

tawdry cypress
#

See, this is the issue I get on discovery.

#

On your sample app, you can try these steps -

  1. Discover readers
  2. Connect reader
  3. Collect and process payment
  4. Discover readers again.

It should show an error in console.

fading depot
#

๐Ÿ‘‹ taking over for my colleague. Let me catch up.

tawdry cypress
#

Sure.

#

Hey, Do you need a brief ?

fading depot
#

sorry discord is super busy now, will be with you shortly

#

AFAIK you don't have to rediscover readers once you have already established a connection to one

tawdry cypress
#

So, how do we get readers which came online after connecting to one another reader ?

fading depot
#

you should keep track of the ids of the readers that you are connected to at a given point

tawdry cypress
#

My issue is here, If I have 2 readers, I switched ON

#

only 1 readser

#

connected to it and payment done,

#

Now if i switched 2nd reader ONLINE, how to know that it is ONLINE now, without refreshing page ?

#

Don't I need to rediscover for that ?

fading depot
#

yes but the problem you described and the error that you got wasn't from discovery it was from trying to use an already used connection token

tawdry cypress
#

yes, but that request went when I did discoverReader, SDK should call the fetchToken itself ? And this happens only if I collect payment and then try again. If I try reader connect and then do discovery, the fetchToken callback gets called.

minor comet
#

the SDK will call fetchToken when it needs to automatically, such as if doesn't have a token yet or the one it had expired.

tawdry cypress
#

Correct, so if SDK is giving this error , then it need a new token ? Right ? It should have called it ?

minor comet
#

I would imagine so

#

can you share full code, such as the implementation of the fetchConnectionToken function and confirm that you have a backend server set up which you've written code in that function to call to get a new token?

tawdry cypress
#

//Load Stripe terminal SDK and create session.
async setUpTerminal() {
const StripeTerminal = await loadStripeTerminal();
this.terminalSession = StripeTerminal.create({
onFetchConnectionToken: this.fetchConnectionToken,
onUnexpectedReaderDisconnect: this.unexpectedDisconnect,
});
}

//Get stripe secret token for terminal connection.
async fetchConnectionToken(): Promise<string> {
    const headers = new Headers();
    headers.set('Accept', 'application/json, text/plain');
    headers.set('Content-Type', 'application/json;charset=UTF-8');

    let options = {
        method: 'GET',
        headers: headers
    };

    return fetch(`${configStore.get('baseUrl')}/api/Terminal/${configStore.get('dealerId')}/ConnectionToken`, api.addAuthHeader(options))
        .then((response) => {
            return response.json();
        })
        .then((data) => {
            return data.secret;
        });
}
#

This is what I do on my web-app load.

#

call setUpTerminal method.

#

On initial discovery,

#

On discovery after collect payment -

minor comet
#

ack. As my colleagues mentioned I don't think we really expect you to be trying to discover/connect again when you're already connected to a reader, that's not how I built my integration when I did this. Probably it causes an issue.

tawdry cypress
#

Ohk. yeah I can try doing that, disconnecting after each payment and then discovery.
Because I want to show updated ONLINE readers everytime I go for Payment, for which new discovery is necessary.

minor comet
#

yes I know, I just don't think that is a use case we consider in the design of the SDK

#

discovery in the way we design things is something you only do when you don't have an active connection to a reader and need to find one, but you clearly see it differently