#sefinek24

1 messages ยท Page 1 of 1 (latest)

fathom deltaBOT
trim haven
trim haven
#

You're looking at the subscription object

#

you need to look at the invoice associated with it

fathom deltaBOT
trim haven
#

latest_invoice is marked as expandable.

So you'd need to retrieve the Subscription when you receive the event while expanding latest_invoice

trim haven
#

Can you share the subscription IDs in text?

sick sand
#

sub_1O7fSPGl3RNUcXxRVDoByOQY

trim haven
#

and are you making a retrieve subscription API request after you receive the webhook event?

sick sand
#

probably not

trim haven
sick sand
trim haven
#
  'sub_xxxx',{
      expand: ['latest_invoice'],
    }
);```
sick sand
#
case 'customer.subscription.updated': {
    const subscription = await stripe.subscriptions.retrieve(data.object.id, {
        expand: ['latest_invoice'],
    });

    if (subscription.status === 'canceled') {
        await handleCancelledSubscription(verifiedEvent);
    } else {
        await handleChangedProduct(verifiedEvent);
    }

    break;
}
trim haven
#

can you share the whole subscription object you're getting in the retreive request response?

sick sand
trim haven
#

so latest_invoice: 'in_1O7fm3Gl3RNUcXxRaKFNPBDU', clearly exists

#

you're not expanding it correctly

sick sand
trim haven
#
  'sub_xxxx',{
      expand: ['latest_invoice'],
    }
);```

can you print out subscription after you call retreive and before it hits 

```if (subscription.status === 'canceled') {
        await handleCancelledSubscription(verifiedEvent);
    } else {
        await handleChangedProduct(verifiedEvent);
    }```?
sick sand
trim haven
#

I can't write your code for you, I gave you clear instructions above.

sick sand
#

nevermind, i read what you wrote a second time and I understood ^-^

trim haven
#

It isn't related to any payment related code though
It just programming basics

#

ah good ๐Ÿ™‚

trim haven
#

Awesome!

sick sand
#

thanks