#dvsk

1 messages ยท Page 1 of 1 (latest)

velvet idolBOT
calm canopy
#

The webhook can be created either in Dashboard or via API. Both will work

zealous epoch
#

yes.. so when I do router.post('/webhook', express.raw({ type: '/' }), async (request, response) => {***}) in my express app, does this mean creating a webhook endpoint or just using the already existing endpoint that's in the dashbaord?

calm canopy
#

This should just be consuming the events after registering webhook endpoint in the Dashboard

#

The code shouldn't need to register the webhook endpoint

zealous epoch
#

ok...so registering webhook endpoint in the Dashboard means creating the webhook endpoint correct?

calm canopy
#

Your server should create the Webhook endpoint URL to receive the events first, then register it in the Dashboard

#

If you're referring to creating the webhook endpoint as setting up your defined webhook URL in the Dashboard, then yes - it's the same as registering webhook endpoint

zealous epoch
#

ok...so actually when I do router.post('/webhook', express.raw({ type: '/' }), async (request, response) => {***}) in my express app, I see that without the stripe API key the app works fine but only webhook secret is required for authentication... Is it expected way because here I am just consuming the already created webhook in the dashboard?

calm canopy
#

Yes, this is correct

zealous epoch
#

oh! so I can just write const stripe = require('stripe') in the beginning of file for requiring stripe, instead of const stripe = require('stripe')('stripe api key')?

calm canopy
#

When you verify the signature using sstripe.webhooks.constructEvent(), it requires stripe = require('stripe')('stripe api key') to be initialised

zealous epoch
calm canopy
#

In signature validation, it uses Webhook secret. If you make additional request to Stripe in the same code, then API key will be used such as retrieving more object information

zealous epoch
#

I am little confused here... if its actual creation of webhook or just consuming the already created one in the dashboard... Also, I don't remember if I created one in the dashboard, but I see hosted webhook endpoints in the dashboard

calm canopy
#

I don't remember if I created one in the dashboard, but I see hosted webhook endpoints in the dashboard
Can you share your account ID, so that I can check how your webhook endpoint was created? You can find your account ID by logging in to https://dashboard.stripe.com/settings/account. It'll be in the upper right hand corner and looks like acct_123

zealous epoch
#

ok

calm canopy
zealous epoch
#

ok thanks a lot River...for your help today

calm canopy
#

No problem! Happy to help ๐Ÿ˜„

zealous epoch
calm canopy
#

As mentioned, API key is only used when you attempt to make a request to Stripe. In this case, your webhook only consumes the event from Stripe and no request is made to Stripe, API isn't used and won't be validated

zealous epoch
#

oh! in stripe.webhooks.constructEvent method also is it not required, because stripe is initialised from the api key

calm canopy
#

It is initialised from API key, but it's not used in stripe.webhooks.constructEvent()

#

Only secret key is used to validate the event, not API key

zealous epoch
#

okay thank you ๐Ÿ™‚