#maverick_reactnative-error

1 messages ¡ Page 1 of 1 (latest)

twin riverBOT
#

👋 Welcome to your new thread!

⏲️ We'll be here soon! Typically we respond in a few minutes, but sometimes we might take a bit longer if the server is busy or if you have a particularly tricky question.

⏱️ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can always start a new thread if you have another question.

🔗 This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1286013155440332843

📝 Have more to share? Add more details, code, screenshots, videos, etc. below.

Below are links to other discussions we've had with you in the past week in case you want to review that information. If your question is related to one of these previous discussions, please provide a comprehensive summary of the current state and what you need help with now. We help many users simultaneously, so a summary allows us to resolve your issue as soon as possible.

graceful timber
small palm
#

Hello! Seems like initializePaymentSheet isn't getting called. Can you add logging to your code to confirm that's the issue, or is it being called?

graceful timber
#

In the last pic of the console I am logging "PaymentSheet initialized" as u can see

#

otherwise if there would be an error there than it would also console the error

#

but seems that its working finr

small palm
#

Can you add a log line inside openPaymentSheet to see when it's being called?

graceful timber
#

like every time I press the button

twin riverBOT
small palm
#

That's the only time that code is running? It's not being called earlier by something else other than the button?

graceful timber
#

like the button call the opening of the payment sheet, but when the screen will render than the useEffect hook will be called to initialize the paymentsheet

small palm
#

I'm honestly not sure what would be causing this... the code and logging you provided doesn't seem like it could result in this error.

#

Can you add a breakpoint and step through the code and find out exactly which line of code triggers the error?

#

Maybe stepping through the code one line at a time will reveal something.

sullen cloud
#

maverick_reactnative-error

#

What part of the code is causing the error? Can you add a lot more logs inside each of your functions to try and pinpoint the issue?
Your useEffect is strange to me, it feels like you are reinitializing the PaymentSheet multiple times. I'd like to understand the order of each methods being called with clear and detailed logs

#

(okay Rubeus mentioned that useEffect is what our docs recommend so my bad, RN is not my forte, but the rest stands)

graceful timber
#

I mean there are two main things happening there. 1. Initalizing the payment sheet and 2. opening the payment sheet. So the only places I can put error checking for the first point is either in my backend or in the "initializePaymentSheet" function. And both of them have error handling and logging and that seems to be working. Now for the second point, there is also a error handling. Now this is the error which will be shown when as in the pics when opening the sheet. Now I dont really know else should i put additional error handling and logging

#

But u cann tell me where u want that and I can add it there

sullen cloud
#

I would like to see a log line in every part of your JS code related to Stripe at the entry and exit of each method. That's how I would debug if I was you. I'd have Entering initializePaymentSheet() ... at the beginning and Leaving initializePaymentSheet() at the end, and I'd do that on each part of my code so that whenever I see that error appear I cna pin point what is the exact last log line I saw that caused it.

Right now you seem to have one unique log line without any real details beyond this.

#

also you seem to log that an error happened in the if(!error) that's wrong right? Like if you go in the if it means no error happened

#

so I think error might be set and you forgot to log it

#

(that's why pictures of code are painful, if you shared real text I could copy-paste the section I am talking about).
Can you log error before that if?

graceful timber
#

ahhhh I got the error

#

I was passing the whole object for the payment Intent as client secret

#

But when I am openeing the payment sheet I am getting the following error

sullen cloud
#

So you were passing the whole object, you likely have a similar bug with passing/setting your API key. So I recommend carefully adding logs and narrowing it down. Clearly the first error would have been debugged in seconds if you had detailed logs