#josephmalam - webhooks

1 messages · Page 1 of 1 (latest)

sullen abyss
#

hey there

jolly ravine
#

Hi @sullen abyss !

sullen abyss
#

reviewing the above - just a min

#

Hmm that's curious -- if you're getting invoice.paid for a subscription, the subscription should already exist

#

Can you share an example failing request ID?

jolly ravine
#

Sure - evt_1Kpr01LmG1DihkghhrPFAFDy
It's especially strange because those two failing events occurred after customer.subscription.created succeeded. And when I manually try retriggering the event it still fails, even though the subscription should exist

sullen abyss
#

I mean the api request you say hits an error when you fetch the subscription, eg

jolly ravine
#

Sorry, I'm not sure what you mean?

sullen abyss
#

You said:

The last two are failing, seemingly because I'm trying to retrieve the subscription. My error logs say:
ReferenceError: Cannot access 'subscription' before initialization

#

What is an example request when that happens?

jolly ravine
#

You can also find request identifiers in the URLs of individual request logs in your Dashboard.
I'm not sure where I'm looking for that, is it different to evt_1Kpr01LmG1DihkghhrPFAFDy?

smoky venture
#

looking (I'm stepping in)

#

I'm guessing you see ReferenceError: Cannot access 'subscription' before initialization in your code at runtime, right?

jolly ravine
#

Yep

smoky venture
#

have you instantiated the stripe() object from stripe-node in that webhook handler?

jolly ravine
#

Do you mean this?

const stripe = require('stripe')('[key]');
#

I have all my hooks in a switch statement:

switch(event.type) {
...

and I printed the invoice.subscription just to confirm it does include it, which it does: sub_1KpqzxLmG1DihkghZKDLt0Ia, and I've checked Dashboard and that subscription does exist

smoky venture
#

can you log out that stripe is instantiated at that point? I know you mentioned it is but just a gut check

jolly ravine
#

Is there something I should look for in particular here?

smoky venture
#

deleted cause of secret key^ (eventhough test mode)

#

no so that looks fine ... thinking

jolly ravine
#

I think I've solved it and if I have it was a silly mistake on my part... now I have a separate issue, give me a few mins to test and I'll let you know