#lenna_code
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/1229509659086557194
๐ Have more to share? Add more details, code, screenshots, videos, etc. below.
Good question. I don't see a client secret in our elements.update method but I thought this was possible. Can you tell me a bit more about the context of why you are replacing the client secret here?
if clientSecret is a prop to <Elements> and it changes, i would assume <Element> would be re-rendered, but it isn't
there was additional context in the referenced thread, but briefly:
we want to have a single page where the user can choose their plan interval (monthly v annual; left hand side) and pay (right hand side). when the user chooses a new interval, we have to create a new payment intent.
that paymentintent is tied to a subscription
Ah, so you are creating a new subscription each time they switch their selection?
eys
*yes
is there a different way of going about this?
we have not been able to update the price on the payment intent, i assume(?) because it's tied to the subscription
i feel like there has to be a better solution than trying to destroy <Elements>
There are flows where the subscription doesn't have to be created until after the user submits their payment method info. If you are open to switching to that, that may be easier to handle in this case, you would just need to make an elements.update call each time the user switches their plan and then create the subscription at the price they were on when they submitted.
https://docs.stripe.com/payments/accept-a-payment-deferred?platform=web&type=subscription
https://docs.stripe.com/js/elements_object/update#elements_update-options-amount
If you are doing the flow where the subscription needs to be created beforehand that is more tricky. It isn't possible to update the payment intent for that. You could modify the subscription but that would still create a new intnet. I am trying to think of what may help in that case.
we did try to create the subscription on submit instead
but ran into issues
@alpine juniper maybe you can fill in some of the details here?
๐
is there an example repo/code for that flow you're describing?
wehre the subscription is created on submit?
This doc shows an example of how to do this with subscriptions https://docs.stripe.com/payments/accept-a-payment-deferred?platform=web&type=subscription
I definitely think this would be much easier for you to work with in this scenario. Just let me know what issues you were running in to and I'm happy to consult.
when the other dev comes back should we open up a new thread? i know these get closed after some interval.
Yeah we typically keep these open ~20 mins without activity. If the thread is closed it is best to ask again in the main channel and whoever is around can pick it up and investigate
got it, tysm
Hey team. So we have a payment form that is wrapped around stripe's Elements. I tried to not create a subscription and render the payment form, and then on submit, create subscription and complete it back to back, but since the PaymentForm was wrapped in stripes Elements, it needed a client_secret which we could only get by creating a payment intent. Is there a work around for that?
Yes, the guide that I send shows how you can initiate Stripe Elements without a payment intent. Basically when you call elements.create you specify what the payment will look like, but you don't pass a client secret
https://docs.stripe.com/payments/accept-a-payment-deferred?platform=web&type=subscription#set-up-stripe.js
https://docs.stripe.com/js/elements_object/create_without_intent
And then when the user changes their plan, you can make an elements.update call to update the amount in Stripe.js
https://docs.stripe.com/js/elements_object/update#elements_update-options-amount
I'd reccommend trying out the flow from that first link that I sent in test mode, it will make it clearer how that all works