#idhruv-webhooks-metadata

1 messages · Page 1 of 1 (latest)

graceful hull
#

Can you elaborate? Where are you looking for metadata? What are you seeing on your end that seems inconsistent?

oblique topaz
#

sure. i will explain

#

const webhookEndpoint = await stripe.webhookEndpoints.create({ url: ${BASE.URL}/api/payment/create/subscription-paid, enabled_events: [ 'invoice.payment_succeeded', ], metadata: {'bookingId': String(bookingArr[i]?._id)} });

#

i am settin metadata while creating webhooks after my subscription schedule is created

#

now i expect that for every subscription cut every month i send this bookingId to my external api

#

but in my case when payment is cut it sends empty metadata for every cut it takes via subscription

graceful hull
#

Do you have request IDs for both the API call that updated metadata and the event that triggered the webhook with empty metadata?

oblique topaz
#

trying to find the same, just a moment

#

req_5iVWb9kNiCVerU: here we set the webhook with bookingId inside metadata

#

but when internal api gets called it empty data

graceful hull
#

Okay, but that only sets the metadata for invoice.payment_succeeded events, but you said you're looking for the metadata in "subscription schedules"

oblique topaz
#

this is what api caught, empty stuff

oblique topaz
graceful hull
#

Is the view in that screenshot in test-mode?

oblique topaz
#

yes

#

so, the workflow is like this -> subscription cut takes place -> invoice is paid -> webhook calls one of my internal api

graceful hull
#

What is "cut"? I don't know what that means

oblique topaz
#

and i assume it should have that metadata which i loaded it with whle creating webhook

#

cut means when money is fully paid

#

for every monthly cycle from customer's account

graceful hull
#

The endpoint appears to have been configured properly with metadata: https://dashboard.stripe.com/test/logs?object=we_1LL5uqGdNldKu1zmYx0aZ824

So these requests are erroring out and I don't see any successful webhook attempts. I would get that working first, and then attempt to fix the metadata problem. It's possible that no modification to the webhook payload takes place on failed webhooks, though I'm not sure

oblique topaz
#

actually thats what i am struggling with, successful webhook attempt is not occurring coz it cannot find the metadata i send to my internal api which webhook calls

#

and it works if i call via stripe cli but when code is running on the server it returns empty metadata

graceful hull
#

I don't see any successful webhook attempts to your endpoint, so I'm trying to understand. Do you have a conditional in your webhoook handler that relies on metadata in order to send back a 200 success response? Can you confirm that this is actually hitting your server?

oblique topaz
graceful hull
#

Can you send back a 200 saying that you got the webhook and then make sure that the successful delivery of the webhook is not the problem?

#

I would be surprised if it was, but I want to rule that out before attempting to repro, as it will take a considerable amount of time on my end to do so

oblique topaz
#

okay and where should i do it? should i return 200 from webhook endpoint api in my code?

graceful hull
#

Yeah, so you'd just return a 200 in your response at the beginning of your webhook handler, before the metadata conditional executes

oblique topaz
#

yep trying it

#

POST /api/payment/create/subscription-paid 200 3.783 ms - 63

i can see this from my server

#

because as soon as subscription was created few endpoint calls were made

#

but where i can see this in stripe

#

In the logs i can only see req_SUrrEybwCjbv1D and req_ukUK2Dlj3DftaX which just conveys that subscription and webhooks were created with required metadata loaded in webhooks

random ether
#

Hello, two-shoes had to step out but I can help. Catching up on this thread now...

#

Are you setting metadata anywhere other than the webhook endpoint itself?

#

As far as I know, setting metadata on the endpoint will only ever put metadata on the endpoint, it won't populate metadata on all of the events that go to that endpoint.