#sai-rez_code

1 messages ยท Page 1 of 1 (latest)

hushed sirenBOT
#

๐Ÿ‘‹ 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/1266333373262069853

๐Ÿ“ Have more to share? Add more details, code, screenshots, videos, etc. below.

silk kraken
#

hi! well on one page you can either do a) pass a client_secret to initialise Elements or b) initialise Elements without an Intent by passing a mode and other parameters
you can't do both on the same page/instance of Elements at the same time.

median kettle
#

Hmm okay, so would that be the same even after rerendering with the latest value? E.g. intially mode is passed in until the async request for fetching the payment intent is resolved then component is rerendered to pass in client_secret

#

if that makes sense

#

It's basically what I am doing now atm which doesn't work but wanted to know if there are other ways if possible

silk kraken
#

I think you create two separate instances of Elements from the global Stripe object. You can't just change an existing instance to the other mode of operation, it's part of the constructors. Might not be what you want but that's about all I can think of. Note you can't have one PaymentElement instance shared between mutliple Elements instances.

var elements = stripe.elements(..);
var elements2 = stripe.elements({
  clientSecret: 'pi_xxx_secret_yyy',
});
median kettle
#

Ah interesting, okay thanks for clarifying that ๐Ÿ‘

#

So to confirm if I was to use mode 'payment' that should be okay?

silk kraken
#

not sure I can answer that since I don't 100% understand your case

median kettle
#

Haha okay fair enough, essentially we're trying to cover two scenarios in one page where if a user failed authentication and left checkout, they can grab the payment intent from the open invoice and confirm it for the sub to become active or the page also should allow you to update your payment method by creating a setup intent and confirming

silk kraken
#

I see. Well those can be two separate pages, or separate tabs/accordion sections of the same page(using separate instances of the Elements object) ,perhaps.