#RMoura_JS-PaymentIntent-to-SetupIntent

1 messages · Page 1 of 1 (latest)

burnt orchid
thick lily
#

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)

ashen pendant
#

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

burnt orchid
ashen pendant
#

but then i need to use the card element...

#

and its not as pretty as the payment element with only the card

burnt orchid
ashen pendant
#

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...

thick lily
#

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

ashen pendant
#

How can I get a source from a payment method (= card )

#

from a setupconfirmintent

carmine jolt
#

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

ashen pendant
#

ok ! thank you!

carmine jolt
#

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

ashen pendant
#

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

ashen pendant
carmine jolt
#

hmm what is the scenario where you have to re-set the client_secret? what are you doing to need to do that?

ashen pendant
#

I need the source and not the paymentmethod ID to make a future payment intent

carmine jolt
#

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

ashen pendant
#

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?

carmine jolt
#

PaymentIntent can use source but that is the deprecated approach, you should just pass payment_method: pm_123 instead