#Damanmokha

1 messages ยท Page 1 of 1 (latest)

strange jewelBOT
lean kindle
#

Is this just the sample quickstart app that you downloaded? Or is this your modified version?

calm spade
#

This is just a sample code that I used in my project. I copied the specific part from the sample and added it to my React application. It worked fine for the first two steps where the payment intent was successfully created. However, when it comes to the payment collection step, I encountered the error mentioned earlier.

lean kindle
#

Ah ok so you merged the code into your existing app

#

Can you share the contents of your attach.js file?

#

Also what line number is it saying the error is occurring on? Screenshot is cut off

calm spade
#

This is my component file, the attach.js file is just react runtime thing, it's asking for authorisation on terminal.collectPaymentMethod, which is on 83 line of my component file which is attached.

lean kindle
#

Oh looks like you leaked your test mode secret key

calm spade
#

opps, sorry. that was not needed in here, added for some hit and trail forgot to remove it ๐Ÿ˜

lean kindle
#

Also apiKey isn't a valid parameter to StripeTerminal.create

calm spade
#

yes, I checked that later in API reference. was trying to provide auth token as it was not populating itself.

#

any idea on that why i am getting auth error?

lean kindle
#

Let me check with a colleague. I'm not as familiar with terminal

maiden cedar
#

Hello ๐Ÿ‘‹

calm spade
#

okay, thanks, will be waiting

#

Hey @maiden cedar

maiden cedar
#

You're using the Javascript SDK correct?

calm spade
#

yes

#

in react

maiden cedar
#

Can you try printing terminal before calling collectPaymentMethod?

calm spade
#

ok let me check and share you the console for it.

maiden cedar
#

Can you expand the object?

#

Do you a reference to the fetchConnectionToken callback function?

calm spade
maiden cedar
#

Oh I think your fetchConnectionToken() is returning a promise instead of a string value

calm spade
#

for only fetchConnectionToken

maiden cedar
#

yup

calm spade
#

let me do it and then check

maiden cedar
#

๐Ÿ‘ I believe the function needs to return a string value for the connectionToken that the client-side SDK then uses to perform operations. Currently, the function is returning a promise instead (returned by fetch)

calm spade
#

Done but its same.

maiden cedar
#

Hmm it seems to be failing a GET request for the PaymentIntent ๐Ÿค”

calm spade
#

i checked it's returning string check the fetchConnectionToken line

#

yes GET request for payment intent is failing and saying to authorise ๐Ÿ˜

maiden cedar
#

Great! Are you calling Stripe API endpoint directly from your client-side code?
what is the value for API_ORDER_PAYMENT_INTENT ?

#

Is it calling your server OR stripe API directly?

calm spade
#

API_ORDER_PAYMENT_INTENT
this is my server BE endpoint for generating Intent.

maiden cedar
#

Gotcha. If you comment out the collectPaymentMethod function, do you see the error OR does it go away?

calm spade
#

Yup, it goes away,

maiden cedar
#

Fascinating.. Hmm, thinking..

calm spade
#

i consoled client_secret just before terminal.collectPaymentMethod, i am getting client_secret, but after that stripe payment intent api fails with authentication.

maiden cedar
#

Can you share the PaymentIntent ID?

calm spade
#

this one is the latest pi_3N6bXfE1QPAb4xC506wh31ls

maiden cedar
#

The reader is registered to the same account correct?

calm spade
#

yes

#

reader is simulator right now.

maiden cedar
#

Only diff is you're running it in a react component

calm spade
#

yup

maiden cedar
#

Can you comment out the useEffect() that you have in the component and try again?

calm spade
#

ok let me check

maiden cedar
#

Huh so weird

calm spade
#

hmm, not sure why it is not getting it, the quick start guide works fine for me also. i have matched the code on various level it seems similar but, not sure why it's not appending auth in payment intent.

strange jewelBOT
maiden cedar
#

You've removed the apiKey parameter from StripeTerminal.create correct?

calm spade
#

Yup!

#

removed.

strange jewelBOT
maiden cedar
#

Thanks, trying to see if I can reproduce this

calm spade
#

Sure thanks. Will be helpful ๐Ÿ™‚

maiden cedar
#

Are you using StrictMode?

#

Also, how exactly are you importing @stripe/terminal-js in your app?

calm spade
#

it's just included in index.html

maiden cedar
#

Gotcha.

#

Okay I tried the same code on my end but couldn't reproduce the behavior ๐Ÿ˜ฆ

#

Can you print API_ORDER_PAYMENT_INTENT before calling .collectPaymentMethod ?

#

The other thing you can try is initializing the SDK in index.js instead of the component and pass the terminal object as props

calm spade
#

it's working on your end?

maiden cedar
#

yup

calm spade
#

strange.

#

you want response from API_ORDER_PAYMENT_INTENT
? before collectPaymentMethod

maiden cedar
#

Just wanted to double check if the URL was correct.
If you look into your network tools and check the failed request headers. what do you see?

#

For my successful request, I see something like this

#

Do you see Authorization key in the headers?

calm spade
#

it's fine, it's responding the payment intent, as have already console.log just before

maiden cedar
#

yup

calm spade
#

no in my request Authorization header is not present.

maiden cedar
#

Ah interesting, that's likely the issue

calm spade
#

yes, but i don't see how to send if its not sent automaticly

#

did you tried the above, in React?

maiden cedar
#

Yup in React
There should be another request to the same path but an OPTIONS request
Can you look at that one and share a screenshot?

#

Is that one failing too?

calm spade
#

let me check.

#

there seems no options request.

maiden cedar
#

I see. Can you try moving the terminal SDK intialization code to index.js file and passing the object down as a prop to your component?

So basically moving StripeTerminal.create. fetchConnectionToken and unexpectedDisconnect to the index file

calm spade
#

yeah sure trying that now.

#

still the same ๐Ÿ˜ฆ

maiden cedar
#

Could you share the complete code in the App component?

#

also try restarting your react server + browser for good luck ๐Ÿ˜…

calm spade
#

my App component has diffrent routes!

maiden cedar
#

Also, curious about authInterceptor function

calm spade
#

should i share that

#

Aahhh Fish

#

that might be the culprit

maiden cedar
#

you should disable it

#

yup

#

IIRC from Angular concepts

#

it messes with Authorization headers

calm spade
#

because in that i was manipulating the Auth for my Server's auth

#

let me try removing it

maiden cedar
#

99% sure that's it ๐Ÿ˜…

#

๐Ÿคž

calm spade
#

Shit

#

100%

#

it was that

maiden cedar
#

Should've asked for your other code way sooner ๐Ÿ˜„
No worries, glad we figured it out

calm spade
#

I was also sending you the one with the component, i should have also checked the parent components ๐Ÿ˜

maiden cedar
#

All good, glad its working now!

calm spade
#

Thank you so much guys!!!

#

You guys were very quick and helpfull ๐Ÿ™‚

maiden cedar
#

Happy to help!

#

I gotta step away now but if you have any follow ups @lethal dirge can help!

calm spade
#

Sure thanks ๐Ÿ™‚