#TheUchi007-elements
1 messages · Page 1 of 1 (latest)
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
Hmmm how would I apply it if I am using stripe.subscriptions.create?
ah, if it's for subscriptions then you can set it via https://stripe.com/docs/api/subscriptions/create#create_subscription-payment_settings-payment_method_types, or set the default payment methods for invoices here : https://dashboard.stripe.com/settings/billing/invoice
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?
gimme a second to test something and get back to you
you need to use https://stripe.com/docs/js/payment_intents/confirm_card_payment to confirm with an existing payment method
Stripe doesn't list out the existing payment methods for you. You'll need to retrieve the list of PaymentMethods attached to the customer and build your own UI to display that list for selection.
You could consider using Link instead - https://stripe.com/docs/payments/link/accept-a-payment?platform=web
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
you don't need to use it with elements
or rather you can't
example flow would be :
- customer selects existing payment method
- 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
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
yep
Awesome, thank you!
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
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!
you need to build the logic