#TheUchi007-elements

1 messages · Page 1 of 1 (latest)

raven breach
#

hello!

how can I make it choose a credit card that was already used before?
how can I control what payment methods to show?

you would define the Payment Methods to use in payment_method_types when creating the PaymentIntent [0] , or via your Dashboard Settings if you're using automatic_payment_methods.enabled=true [1] [2]

[0] https://stripe.com/docs/api/payment_intents/create#create_payment_intent-payment_method_types
[1] https://stripe.com/docs/api/payment_intents/create#create_payment_intent-automatic_payment_methods-enabled
[2] https://dashboard.stripe.com/test/settings/payment_methods

lusty gull
#

Hmmm how would I apply it if I am using stripe.subscriptions.create?

raven breach
lusty gull
#

Perfect, thanks!

#

How about my other question?

#

how can I make it choose a credit card that was already used before?

#

Basically, How can I allow the user to choose a payment method they had already used before?

raven breach
#

gimme a second to test something and get back to you

lusty gull
#

Hmmm so, if I were to use my own UI, how can I work with elements? I did find the API to get the customer's data, including the payment methods they've used, but I am not sure how I can use it with elements

raven breach
#

you don't need to use it with elements

#

or rather you can't

#

example flow would be :

  1. customer selects existing payment method
  2. customer clicks on pay -> you would call confirm_card_payment
#

it's got nothing to do with elements. You only need to initialize stripe, then call stripe .confirmCardPayment

lusty gull
#

Oooh, I see. I just checked the confirmPayment aPI and I see now it says to either get the details from elements, or an ID

raven breach
#

yep

lusty gull
#

Awesome, thank you!

raven breach
#

this confirmCardPayment method is actually meant for use with the Card Element

#

Two flows :

  • if you're collecting payment method details using the Payment Element, you should confirm the payment using confirmPayment
  • if using an existing payment method, then use confirmCardPayment
lusty gull
#

Ah, gotcha

#

Thank you!

#

I guess that, depending on whether the customer has payment methods saved or not, it will display the correct one

#

Thank you for your help!

raven breach
#

you need to build the logic