#luanvdw-paymentmethod
1 messages · Page 1 of 1 (latest)
hi! in general the default_source field is legacy, and it's not compatible with the current API object for cards(which is PaymentMethods pm_xxx) (hence the error). It's best not to use it at all.
Thank you for your response. What will be the best way to set the default payment method for a customer then?
I am adding payment methods with setup intents and confirming the setup Intent with stripeJs + Elements stripe.confirmSetup
Since I cannot pass in options to do this with the stripe.confirmSetup method, what would be the best way to set this newly added payment method as the default for a customer?
depends on the context!
-for one time payments, there's no such thing — we don't have a default, you tell us what card to charge by passing it to the payment_method field when creating a PaymentIntent.
-for subscriptions, can use either https://stripe.com/docs/api/subscriptions/create#create_subscription-default_payment_method or set https://stripe.com/docs/api/customers/update#update_customer-invoice_settings-default_payment_method
what would be the best way to set this newly added payment method as the default for a customer?
if it's for subscriptions, setting one of those fields mentioned above, during the webhook handler, like you described/are doing. We talk about it here (it's for Checkout, but same applies when using Elements+confirmSetup directly)
https://stripe.com/docs/payments/checkout/subscriptions/update-payment-details#set-default-payment-method
It would be for subscriptions, and the cards are added before a subscription is created.
So ideally the default payment method would be set before a user subscribed to anything
I think your second route of updating invoice_settings on a customer is what I am looking for. I will quickly try that and see
Thank you for your response, I will confirm in the next few minutes
et voila!
Worked like a charm,
invoice_settings: {
default_payment_method: 'pm_123'
}
Thank you for your response, I will make a note that we do not use default_source on a customer
thanks!