#RMoura_JS-PaymentIntent-to-SetupIntent
1 messages · Page 1 of 1 (latest)
What do you mean by change the form?
It works with both Setup Intents and Payment Intents, but you'd provide an appropriate client secret and call the appropriate confirm function (payment vs setup)
Im making a page where the user can choose to just add the card or make the payment right way
"setup": {
"type": "setup_intent",
"secret": "seti_1JtZtHIGDBqjniobMiobOyku_secret_KYhH4bpvgos1PzISLhuW3lcNnkZmMcc"
},
"payment": {
"type": "payment_intent",
"secret": "pi_3JtZtIIGDBqjniob0BYiX1Ru_secret_kjqvQwUmHqHOdx5cS5BO5RPx7"
},
but then this happens
You will want to call confirmCardSetup on the setup intent https://stripe.com/docs/js/setup_intents/confirm_card_setup
Complete reference documentation for the Stripe JavaScript SDK.
but then i need to use the card element...
and its not as pretty as the payment element with only the card
Apologies, wrong function, confirmSetup https://stripe.com/docs/js/setup_intents/confirm_setup
Complete reference documentation for the Stripe JavaScript SDK.
but if the user chooses to pay?
im doing that already
but from my understanding this function gets the clientsecret from the elements object
so my question is... How do I change the client secret in the stripe elements...
You would need to re-initialize the Elements with the new client secret, as i understand it
So you'd want to ask your customer to make that decision earlier
Is it possible to set default values (such as cardnumber) on a payment element?
hello again! posting your question here and answering your other questions too
just consolidating in one thread
ok ! thank you!
so my question is... How do I change the client secret in the stripe elements...
in PaymentElement, you re-create the whole instance of PaymentElement when you get a new client_secret
Is it possible to set default values (such as cardnumber) on a payment element?
ah you mean to prefill? that is not supported
you can add placeholders
but not prefill
ok
this was "necessary" to improve the ux for the user ... since im recreating the payment element all the input from the user is lost
but ok
what about this? Any ideia?
hmm what is the scenario where you have to re-set the client_secret? what are you doing to need to do that?
I need the source and not the paymentmethod ID to make a future payment intent
How can I get a source from a payment method (= card )
why?
you should not need a Source ID ever
you should just need PaymentMethods
hmmm
PaymentIntent uses source no?
Stripe::PaymentIntent.create(
amount: prepare_amount(amount),
currency: amount.currency.to_s,
description: description,
customer: options[:customer_id],
** source: payment_method_id,**
payment_method_types: ['card'],
capture_method: 'automatic',
confirm: true,
error_on_requires_action: false
)
this should be payment_method?
PaymentIntent can use source but that is the deprecated approach, you should just pass payment_method: pm_123 instead