#Wik

1 messages · Page 1 of 1 (latest)

fresh ospreyBOT
sour marsh
#

Hi there, is your customer's credit card info saved as source or payment_method?

covert hemlock
#

payment_method

sour marsh
#

OK. Although a customer has a default_source , there' s no default_payment_method property in a customer object.

#

Therefore, when you want to create a charge with payment_intents API on a customer, you also need to specify the payment_method ID.

covert hemlock
#

Let me find an example

#

I have a test user https://dashboard.stripe.com/test/customers/cus_My2DVswBz7tdtr. They have two cards. The default one ends in 4242. I want to make the card ending in 0001 default via API. Is it possible? I can easily do it via the dashboard but I need to do it for ~500 customers, so I'd rather write a script for that

sour marsh
#

I see. yes you can do it programmatically. All you need to do is

  1. unset the default_source
  2. set the 0001 card to either default_source or invoice_settings.default_payment_method
covert hemlock
#

How do I unset and set the default source via API?

sour marsh
#

just default_source=null

covert hemlock
#

Ok, cool, thank you!