#eva_react-native-connect
1 messages · Page 1 of 1 (latest)
👋 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/1458869206073213240
📝 Have more to share? Add more details, code, screenshots, videos, etc. below.
While <StripeProvider> accepts stripeAccountId, doing it dynamically would be problematic as all the payment fetching + payment sheet init/present happens within the same code block, and there's no reliable way to await react re-render or async initStripe that's triggered inside a useEffect
So I went for a combo of initStripe + initPaymentSheet + presentPaymentSheet instead. Each step seems to complete, but presentPaymentSheet fails. After messing around it looks like initPaymentSheet doesn't work correctly here (doesn't throw any error), as presentPaymentSheet doesn't see the newly initialized sheet. That results in either No payment sheet has been initialized or it trying to use the previous, already paid payment intent, which also comes from another stripeAccountId
I'd suspect I need to include stripeAccountId somewhere in the initPaymentSheet but it doesn't seem to accept such params, so I'm not sure what to do now.
hello! sorry for the delay, looks like we had a mistake in our handoff - i'll be looking at your question shortly
if you're still around can you share more about your use case? why are you dynamically switching stripeAccountIds in app? i can experiment with this a bit but i don't know if this is something we explicitly support
eva_react-native-connect
Trying to perform a direct charge on a standard (as opposed to express) account, as we want to allow this option
hmm ok
i think you might need to reinitialize the StripeProvider - have you already experimented with that?
I mentioned why I didn't in the first paragraph
From Provider's code it doesn't look like anything will change - it's just useEffect(() => initStripe(props), [...props]); which is essentially what I'm doing in my case, but at least I can reliably await it
hmm ok, give me a bit to experiment with this
i don't think this is a common use case so i don't have an answer offhand
can you share your code where you're doing all of the initStripe + initPaymentSheet + presentPaymentSheet stuff?
It's a bit over the place so dunno if I can share the entire code
I basically have something like
const params = await getPaymentIntent(...);
if (params.intent.directChargeAccountId) {
await initStripe({ ...defaultAppParams, stripeAccountId: params.intent.directChargeAccountId });
}
await initPaymentSheet(prepareSheetParams(params));
const { error } = await presentPaymentSheet();
if (error) {...} else {...}
I tried initPaymentSheet/presentPaymentSheet from both stripe import and useStripe hook, after checking the code it looks like they're the same anyway so
FWIW on web they just make another instance
any chance you have an example PaymentIntent ID from when you got the error? and the account ID of the account you were trying to use at the moment?
I do but it’s not exactly relevant as presentPaymentSheet errors out with previous payment intent id
I had normal charge happen before this direct charge attempt and it kept spitting out that same old payment intent id instead
silly question but is it possible you're passing in the old paymentIntentClientSecret in this line? await initPaymentSheet(prepareSheetParams(params));
It comes directly from the backend so I’d doubt that (given they got it working on web) but I’d need to check it myself to answer for sure
can you try logging out the results of prepareSheetParams(params) as a sanity check?
Sure I’ll get back on this tomorrow