#thomasnevink
1 messages · Page 1 of 1 (latest)
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
👋 how may I help?
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
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
@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
He didn't tell you to handle post payment processing with the return url though
He said to save it in db, that is what I did
the return url should be used for showing the customer whether their payment has succeeded or not
he meant before not after
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
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
would you mind sharing more details please?
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
it's a confirm-time param
you can pass it on creation, but you also have to also pass confirm=true if so.
the only time you'd do that is if it's an off-session payment. Otherwise you just create the PaymentIntent normally and confirm on-session on the frontend, via e.g. https://stripe.com/docs/js/payment_intents/confirm_card_payment#stripe_confirm_card_payment-existing
is this from the frontend ?
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?
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.
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
for the latter, that's based on what you pass to setup_future_usage
you can pass a bool to https://stripe.com/docs/js/payment_intents/confirm_card_payment#stripe_confirm_card_payment-data-setup_future_usage based on a checkbox in your UI.
or you can pass it when creating the PaymentIntent too if you already know, that works too.
could you provide the one for payment-element and not card-element
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.
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?
doesn't seem like it!
depends how you integrate, there's two options. It can be before you render the PaymentElement(https://stripe.com/docs/payments/accept-a-payment?platform=web&ui=elements), or after the details are entered and the button is pressed(https://stripe.com/docs/payments/accept-a-payment-deferred).
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.
ok
@vital verge what's up?
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?
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.
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
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.
and you can use https://stripe.com/docs/js/payment_intents/confirm_card_payment#stripe_confirm_card_payment-existing to do an on-session payment on a known saved card(since the docs above don't explicitly mention that). The idea being that you can call that function from UI in your page where the user selected a card in your radiobuttons.
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"?
When I updated the PaymentMethod it threw an error
Yh, no need