#juraj-subscription-expansion
1 messages · Page 1 of 1 (latest)
juraj-subscription-expansion
@grizzled oasis which language are you using? The $ tells me PHP but the way you use Subscription::retrieve() could be ruby.
its php
Okay so the way you're using stripe-php has been deprecated for a few years
https://github.com/stripe/stripe-php/wiki/Migration-to-StripeClient-and-services-in-7.33.0 this is the guide to migrate. If you don't, you end up having to be a werid call for retrieve that would look like this: $subscription = Subscription::retrieve([ 'id' => $sub->getSubscriptionId(), 'expand' => $sub->getTrial() ? ['pending_setup_intent'] : ['latest_invoice.payment_intent'] ]);
Also: you can expand both you don't need that ternary operator, we'll just expand the relevant one (and ignore the other one) so you can do this: $subscription = Subscription::retrieve([ 'id' => $sub->getSubscriptionId(), 'expand' => ['pending_setup_intent', 'latest_invoice.payment_intent'], ]); which is a bit easier to read