#tungtn1099

1 messages · Page 1 of 1 (latest)

wicked cragBOT
onyx leaf
lethal nacelle
#

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

onyx leaf
#

not sure what you mean, what does your code look like?

lethal nacelle
#
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

onyx leaf
#

_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.

lethal nacelle
#

oh yeah just noticed that