#hassan

1 messages · Page 1 of 1 (latest)

rain mirageBOT
prisma ore
#

Hi, how about simply initialize another request to your server, and on server call Update PaymentIntent to update the amount?

spring current
#

Mmm so your saying upon the user clicking the upsell item, I can fire a call to update the intent then allow them to click the submit payment button

prisma ore
#

Yep!

spring current
#

How would I do this if I have a subscription attached to the payment intent? Update the subscription, then the paymentIntent would be updated automatically then call fetchUpdates on the client?

prisma ore
#

Um it could be a bit more complicated with PaymentIntent inside Subscription. You would need to update the Subscription price instead, prevent proration to happen, then probably take the new Invoice and discard the old one. I would recommend testing on Test mode first

spring current
#

OK that's where I'm going to get slightly stuck I believe. For one off donations, it's simple. But a subscription you get the paymentIntent from the latestInvoice. Il use your logic to test.

#

Is there another way to deal with subscriptions and payment intent? Or is it recommended to create a subscription and pull out the latest invoice payment intent and send that to the client so the user can authorise and pay?

prisma ore
#

It's recommended to create a Subscription and pull out the latest Invoice PaymentIntent and send to client <- this is the default flow. The issue here is you want to somehow modify the amount after this step

#

A moment

spring current
#

I guess would an alternative be using a SetupIntent. So load Stripe using useStripe and Elements. Then collect the setup intent along with a upsell option. Then when they click Pay Now, upon the setupIntent being set up correctly, create a payment intent and attempt a charge with the payment method?

prisma ore
#

Yep that's one alternative we have been recommending recent years for similar use cases. I was looking at a new Defer flow we released recently that allow you to defer the PaymentIntent/Subscription creation after rendering PaymentElement

#

Here it is

#

So basically you create the Subscription after having the final amount sending from client side, after the PaymentElement was created. But I think the amount specified on client side before mounting also need to be the updated (cross sell) in order to match the server side

#

Please take a look and give it a try!

spring current
#

Yh this is new. I haven't seen this before. It seems like it's perfect for my use case. OK il try this and see how it goes. Thanks.