#thomasnevink

1 messages · Page 1 of 1 (latest)

bold hareBOT
#

Hello thomasnevink, 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.
https://discord.com/channels/841573134531821608/1164087200846204948, 0 days ago, 10 messages
https://discord.com/channels/841573134531821608/1161900761538633789, 6 days ago, 15 messages
https://discord.com/channels/841573134531821608/1161655903515312200, 7 days ago, 5 messages

wild glen
#

👋 how may I help?

vital verge
#

I want to save card for future use. I have implemented Making a payment using payment-element stripe form as one api endpoint and after stripe.confirmPayment() in the frontend is triggered, using the return url parameters it triggers another api endpoint which does post payment processing like storing values in database,etc

wild glen
#

that's really not a good idea

#

you shouldn't rely on your customer hitting the return url

#

you need to implement webhooks if you want to implement logic that happens at certain events

vital verge
#

@stable sluice asked me to follow the above method , you can check #thomas-payment-fulfilment thread

#

I'm able to save values to my database as @stable sluice suggested, so yeah his method works

wild glen
#

He didn't tell you to handle post payment processing with the return url though

vital verge
#

He said to save it in db, that is what I did

wild glen
#

the return url should be used for showing the customer whether their payment has succeeded or not

wild glen
#

so when you create a PaymentIntent, you can save it in your db

#

and once the customer reaches the return url then you can retrieve it

vital verge
#

We have created a payment-element stripe form and a custom checkbox in html which indicates whether the customer wants to save this card for future use

#

We are not able to pass this bool during paymentIntent creation, please help

wild glen
#

would you mind sharing more details please?

vital verge
#

if (save card for future use[bool])
options.SetupFutureUsage = "off_session";
a) Search if customer exists using stripe customer search
b) if customer doesn't exist
create customer and attach payment method
else
Check if the payment method exists based on PaymentMethodId and CustomerId in DB
if the payment method doesn't exist
Attach this payment method to customer
else
options.SetupFutureUsage = "on_session";

#

This is my logic during paymentintent creation

#

I don't want duplicate customers in my stripe dashboard

bold hareBOT
vapid hawk
#

you can pass it on creation, but you also have to also pass confirm=true if so.

vital verge
#

My simple question is doesn't stripe provide a checkbox of sorts where he checks it for saving the card for future use. You need some bool value from the frontend to determine whether to do an on_session or an off_session payment?

vapid hawk
#

I think there's two concepts you're confusing here. There's doing an on session or off session payment. And there's choosing when saving a card if are saving it for the purposes of future on session payments or off seesion payments.

vital verge
#

Which is the code point in the frontend that triggers my api endpoint where paymentIntent creation is happenning, is it before stripe.confirmpayment() is called in the frontend or before that

vapid hawk
#

or you can pass it when creating the PaymentIntent too if you already know, that works too.

vital verge
vapid hawk
#

ah yeah you're right, wrong link

#

I guess it's not possible then and you'd have to set it at the time you create the PaymentIntent.

vital verge
#

is there any way to pass this bool value from the frontend inside stripe.confirmpayment() function

#

Also when does paymentIntent creation happen? Is it when card details have been entered in my payment-element stripe form or when stripe.confirmPayment() has been called?

vapid hawk
#

doesn't seem like it!

vapid hawk
#

so in your case I think I would use the deferred flow and pass the value of your bool along to the backend, and that way you can create the PaymentIntent with the chosen value.

vital verge
#

ok

vapid hawk
#

@vital verge what's up?

vital verge
#

during paymentIntent creation can i create a customer and after the paymentIntent has a status of success , will i be able to update the customer with the paymentmethod used to do the payment?

vapid hawk
#

you can do something like await stripe.paymentIntents.update(pi.id, {customer:customer.id}) after a PaymentIntent succeeds yes. To be clear all that does is make it so the payment appears on their page in the Dashboard/make reporting easier. Not sure if that's what you're looking for.

vital verge
#

We are trying to display the saved cards from the db to the user and when he selects a radiobutton indicating that card, it should populate the stripe form

#

Presently paymentmethodid and customerid are retrieved from db

hardy tapir
#

Hi! I'm taking over from my colleague. Please, give me a moment to catch up.

#

You can't populate Stripe Elements.

#

You can just charge the seleted Payment Method directly.

vapid hawk
vital verge
#

ok

#

@hardy tapir is there a way i can send a bool (a checkbox) indicating whether the customer wants to save the card for future use in my frontend and based on that value I want to set PaymentIntentCreateOptions.SetupFutureUsage to "on_session" or "off_session"?

hardy tapir
#

Yes, you can update the PaymentIntent.

#

You will need to build the checkbox yourself

vital verge
hardy tapir
#

What error?

#

Why do you update the PaymentMethod?

vital verge
#

Yh, no need

hardy tapir
#

What do you mean?

#

Here

#

Do you have any follow up questions?

#

@vital verge