Cool. Thanks!
There was one subscription.
One fix on your code:
subs = ::Stripe::Subscription.list(customer: customer.stripe_customer_id, status: 'all')[:data]
There are 100 plans (so probably more than that)-- maybe this is the problem? (I tried with limit: 1000
but that didn’t change anything; I guess that’s a Stripe API limit?)
So maybe if there are >100 plans it fails? Oh, and the users for whom it’s not failing, are on plans that are in the first 100.
discourse(prod)> plan = plans[:data].find { |p| p[:id] == price_id }
discourse(prod)>
=> nil
EDIT:
Yes. If I do this:
# Get the last item's ID
last_price_id = plans.data.last.id
# Get the next 100
next_plans = ::Stripe::Price.list(
expand: ['data.product'],
limit: 100,
starting_after: last_price_id
)
then
discourse(prod)> next_plans[:data].find { |p| p[:id] == price_id }
finds what it’s looking for.
EDIT AGAIN: next_plans.count == 8. I suggested that they delete 10 plans.