#Austin_Rowe - loadStripe dynamically

1 messages · Page 1 of 1 (latest)

lost heath
#

Good question. Not sure what our official recommendation is for initializing stripe.js for different accounts dynamically like that. I am checking in to how this is typically done and will let you know what I find

kindred hemlock
#

Amazing, thanks Pompey!

lost heath
#

I will also check in to GigStartr's suggestion though if I remember correctly that is typically for the server side client libraries. I don't know if stripe.js supports it
#dev-help message

kindred hemlock
#

I think GigStartr's suggestion won't necessarily be the solution here. We use the connected account_id when creating the payment intent on the server side, but when I was initializing stripe with just our publisable_key I would get an error saying the account didn't have a payment intent related to the client secret that was returned from creating the intent. After hardcoding the connected account into the stripe initialization it no longer showed the error and the PaymentElement loaded in properly.

vapid vale
#

Hi there, stepping in for Pompey as the server is quite busy.

#

So yes useEffect is a good way to handle this and you can initialize multiple times if needed. When you do so, you will need to create a new PaymentIntent on your server using the corresponding account ID for the account that you are initializing client-side for.

#

The only other thing to consider is that this will re-render your Payment Element component.

#

So you want to handle this before the customer would enter details into Payment Element

kindred hemlock
#

Understood! Thanks bismarck