#Sairony - confirmPayment

1 messages · Page 1 of 1 (latest)

finite inlet
#

Hi there!

#

Depending on the PaymentMethod used, the user might be redirected to a different page to authenticate. That's why it's mandatory to set a return_url, so that users are able to return to your website after the payment.

#

What do you mean by "especially if you want to pass a long data"?

craggy cedar
#

Ah, so for those payment methods actually the whole tab is redirected to the payment vendors site?

#

I guess that makes sense

finite inlet
#

Exactly.

craggy cedar
#

For example, I create a setup intent, pop the payment elements for it. The user can also enter promo codes. So when the payment details are collected I want to create a subscription from that setup intent & optionally apply the coupon if present. If it could just be a callback in the promise that would be really easy to just create a POST to the server side API. But now instead I need to bake in the setup ID & the promo code in the return_url & make sure that the landing site completes the last step

finite inlet
#

For this type for things we recommend to use webhook events. For example listen to setup_intent.succeeded to run your code.
Otherwise, if the use close their browser before the redirect happens, you may loose information.

craggy cedar
#

Ok, I'll check that route

#

Also, do I need to clean up setup intents?

#

Since they need to be created before I can use payment elements there's always the risk that the user doesn't go through & completes it, there doesn't seem to be a nice natural point of action to clean them up unless we want to run cron jobs to list & destroy them when they're old enough

finite inlet
#

From Stripe point of view there is no downsides to having many SetupIntent in incomplete status. And note that SetupIntent don't expire.
But if you want to, you can cancel a SetupIntent with https://stripe.com/docs/api/setup_intents/cancel but you don't have to.

craggy cedar
#

Sweet, then we'll let them build up for now

finite inlet
#

Makes sense 🙂

wide dome
#

Hey, taking over here. Let me know if there's any follow-up Qs I can answer!