stripe / stripe-go

Go library for the Stripe API.
https://stripe.com
MIT License
2.11k stars 457 forks source link

Cannot make default for customer card with ID pm_XXXXXXXX #889

Closed layby42 closed 5 years ago

layby42 commented 5 years ago

looks like a bug, but I'm not sure:

Customer has a number of cards returned by PaymentMethods. One has ID card_XXXX (created using old-way Stripe Token), another has ID pm_XXXX (created via Setup Intent -> Payment Method Confirmation -> Payment Method attached to customer).

I have no problem change customer's default card to "old" card_XXXX (using DefaultSource=card_XXXX), but attempt to change it to "new" pm_XXXX (using DefaultSource=pm_XXXX) results in No such source: pm_XXXX error.

Should it be possible to make Payment Method default for customer? How?

layby42 commented 5 years ago

UPDATE: I've looked at Source (CustomerParams), but it does not look like it supports Payment Method

remi-stripe commented 5 years ago

@layby42 objects with the id pm_123 are PaymentMethod objects: https://stripe.com/docs/api/payment_methods/object

This is a new abstraction that is entirely separate from the Card or the Source objects.

When you have a PaymentMethod, you can pass its id in invoice_settings[default_payment_method] instead.

layby42 commented 5 years ago

@remi-stripe thanks. so even if payment method type is "card" it cannot be default card for customer unless its ID starts with card_. hm... OK. I'll try invoice_settings[default_payment_method]

remi-stripe commented 5 years ago

Correct, because there's the Card object, the Source object of type card and the PaymentMethod object of type card. They are all entirely separate objects.

If you are now using PaymentMethods you should ignore the default_source field moving forward.