upgraded from 6.12 to 7.0.1, the card property on Default source appears to be null even with ExpandDefaultSource set to true?
var customerService = new StripeCustomerService() { ExpandDefaultSource = true };
stripeCustomer = customerService.Get(user.StripeCustomerId);
stripeCustomer.defaultsource.type is "Card"
stripeCustomer.defaultsource.id is "card_19TGZQ2bDB7vVeQ0DKPVCBqM"
but stripeCustomer.defaultsource.card is null?
Encounter same issue.
What's that Card object is still expanded, but in the Sources list only.
So, as workaround:
stripeCustomer.DefaultSource.Card = stripeCustomer.Sources.Data.First().Card;
ended up using
stripeCustomer.DefaultSource.Card = stripeCustomer.Sources.Data.FirstOrDefault(i => i.Type == SourceType.Card)?.Card;
stripeCustomer.DefaultSource.BankAccount = stripeCustomer.Sources.Data.FirstOrDefault(i => i.Type == SourceType.BankAccount)?.BankAccount;
This is as designed. The list is an IEnumerable - so it doesn't all have to be loaded in the case of many sources. What you did was right. 👍
Not obvious, especially compared to previous versions. I expect more people heading to this issue. However, some note about it in the docs might help.
It's definitely confusing. If ExpandDefaultSource = true
then DefaultSource.Card
shouldn't be null. It should have the default source, as the name suggests.
Most helpful comment
Encounter same issue.
What's that Card object is still expanded, but in the Sources list only.
So, as workaround:
stripeCustomer.DefaultSource.Card = stripeCustomer.Sources.Data.First().Card;