#tungtn1099
1 messages · Page 1 of 1 (latest)
hi! there's not one "plan", you look at the items. https://stripe.com/docs/api/subscriptions/object#subscription_object-items
i tricked my own eyes
do i need another function to retrieve the items in the subscription object? i cannot go deeper than subscription.items.data
not sure what you mean, what does your code look like?
const _subscription = await StripeClient.getInstance().getSubscription(subscription);
const product = _subscription.items.data.plan;
const customer = _invoice.customer as string;
if(!customer) throw new HttpException(400, HttpMessages._BAD_REQUEST);
await premium.setPremium(customer, product.id, subscription.id);
i want to get the planId to save it
_subscription.items.data is an array
so for example _subscription.items.data[0].plan
but again, a Subscription can have multiple plans(multiple entries in the data array) so you should be aware of that . If you only ever create Subscriptions using one plan, then that's fine and you know that data will only have one element in the array, but just to be aware.
oh yeah just noticed that