Stripe-dotnet: StripeCustomerService ExpandDefaultSource no longer works?

Created on 8 Jan 2017  ·  5Comments  ·  Source: stripe/stripe-dotnet

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?

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;

All 5 comments

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.

Was this page helpful?
0 / 5 - 0 ratings