#jacob-subs-deferred
1 messages ยท Page 1 of 1 (latest)
Hello! We'll be with you shortly. 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.
- jacob-coupon-elements, 3 hours ago, 6 messages
Hi, what do you mean by 'have it update the payment element'?
Can you add a bit more details?
Sure! I'm using this tutorial to set things up: https://stripe.com/docs/billing/subscriptions/build-subscriptions?ui=elements
In step 4 of that tutorial, it instructs you to create the subscription on the backend before collecting the payment information through the payment element (which is what I'm doing). My use case/design requires me to collect and apply any promo codes on the same screen as the payment element.
I've got a field set up on the frontend to collect a promo code, which I'm then sending to the backend. On the backend, I'm calling updateSubscription to apply the promo code to the subscription I created in step 4. However, when I continue checking out using the payment element, the promo code is not applied.
What do you mean the promo code is not applied? Are you saying that the amount on the Payment Intent is not being updated? Can you share the request id where you attempted to update the Subscription with the promo code? Here's how you can find a request ID: https://support.stripe.com/questions/finding-the-id-for-an-api-request.
Yeah that's essentially what I'm saying. here's the request ID req_GaQBQuKyg3bQo9
and this is the one I used to create the subscription: req_3Ui1BuvaajKqdb
No problem! Thank you
I also just completed/submitted the checkout with request ID: req_D9yy1vnN6sTqkD if that helps
Thank you, I'm taking to a colleague here
Sounds good! LMK if you need any more info
Sure, thank you
๐ Hopping in here since pgskc has to head out soon - the promotion code is being applied to the subscription, but it'll be applied to the next invoice for that subscription. It won't apply to the Invoice that was already created + finalized when the subscription was created
aaaah gotcha. Is there a way to have it apply to both?
Would I need to update the payment intent as well as the subscription?
You'd have to pass in the promo code when the subscription is created if you want it to apply to that initial invoice. Really the better way to do this is to wait to create the Subscription until the end and use the deferred intents flow (which does not require a client secret up front)
jacob-subs-deferred
Ok gotcha. I'll check out that doc and reply again if I have any more questions. Thanks!
๐
Actually, one more thing. I want to be able to build a toggle on the same page as the payment element. This toggle should let the user switch between the annual plan and the monthly plan. Is it possible to update the amount in the "options" being passed to the payment element? I had trouble updating the clientSecret and wasn't sure if the whole "options" object is immutable or if it's just the clientSecret field
Yup that's one of the nice things about deferred - you can update any of those options! (see the full list here https://stripe.com/docs/js/elements_object/update)