#idhruv-webhook

1 messages · Page 1 of 1 (latest)

digital knoll
#

hi there! can you share more about what you're doing? and the event id?

fierce briar
#

definitely

#

This is the request Id when webhook is created for the first time after subscription schedule is set:

req_SUrrEybwCjbv1D

and this is the eventId of successful webhook response

evt_1LLCEvGdNldKu1zmgCblLqGe

#

both calls were returned with 200 (success)

#

and yet metadata is empty when this response is fetched at endpoint end

digital knoll
#

you shouldn't add the metadata to the webhook endpoint

fierce briar
#

not adding it at endpoint but during creation of webhook

#

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

like this

#

this works totally fine with testing and simulation via stripe cli

digital knoll
#

you would also save the subcription id and metadata to your own DB at this point in time

fierce briar
#

stripe trigger invoice.payment_succeeded --add invoice:metadata.bookingId='1234' okay, then how is running this command via strip CLI is working out? i want to achieve same thing via code

digital knoll
fierce briar
#

okay, is there no way i can get metadata directly after setting it up somewhere like subscription?

digital knoll
#

that CLI command works because it's just generating a one-off invoice

#

not an invoice related to a subscription

fierce briar
#

ohh ok

#

I have a question, if we are anyway using our own DB to retrieve metadata then what is benefit of adding it to subscription object?

#

EDIT: I am not using simple subscriptions, but subscription-schedule

digital knoll
#

you would receive it back in every subscription event e.g. customer.subscription.created, customer.subscription.updated, etc

#

But as a general rule, metadata that is set on an object will not be silently copied over to any associated objects that are created at the same time.

fierce briar
#

ohh..k

digital knoll
#

that's why you won't automatically see the metadata on a subscription on it's corresponding invoice

fierce briar
#

so how about this, I create a metadata on subscription schedule and when webhook calls my endpoint, can i retrieve this data using subscription.updated or similar event

digital knoll
fierce briar
#

this way i dont have to save it in my db

digital knoll
#

so how about this, I create a metadata on subscription schedule and when webhook calls my endpoint, can i retrieve this data using subscription.updated or similar event

yes, you can retrieve the subscription : https://stripe.com/docs/api/subscriptions/retrieve

fierce briar
#

okaay! let me try n see what works n what doesnt. thanks

digital knoll
fierce briar
#

also, what is difference between metadata inside phases and metadata inside subscription object? i mean how it differs from implementation perspective.

digital knoll
#

i'm a bit confused and don't quite understand the question. Could you try rephrasing perhaps?

fierce briar
#

yes

#

what is the difference between putting metadata inside subscription object vs putting it inside phases, which ultimately is an object inside subscription?

digital knoll
#

if you use that parameter to set the metadata, as the description in the doc mentions :

Metadata on a schedule’s phase will update the underlying subscription’s metadata when the phase is entered, adding new keys and replacing existing keys in the subscription’s metadata
fierce briar
#

ok

#

I think i will stick to subscription's metadata coz i dont want to replace anything here

digital knoll
#

but if you want to implement the logic to do it on each subscription that's fine as well

#

hello, how to add metadata to testing clock's customer subscription?

Can you share the request id where you've created the customer subscription with a test clock?