#tcurdt-event-livemode

1 messages ยท Page 1 of 1 (latest)

wispy pikeBOT
crimson mesa
#

This work for us locally:
stripe listen --forward-to localhost:9000/api/webhooks/stripe

proper nebula
#

I'm sorry I don't really understand the question

#

if you use the CLI, it's usually only for local development, nothing else

misty summit
#

ah, ok ... so there is no way to trigger an event so it comes from stripe itself?

proper nebula
#

I'm sorry I'm really confused

#

What are you really trying to do?

misty summit
#

when we have a local instance of our server we can use the stripe cli to trigger a webhook. now we have a live server on the internet and we would also like to trigger an event to test the live webhook.

proper nebula
#

Events happen when they are caused by something. customer.created happens when a Customer is created. So you'll get Events in production as your app/website/customers trigger things

#

tcurdt-event-livemode

misty summit
#

right ... so you are saying there is no way to trigger an event for testing that comes from Stripe - either in "test" or "live" mode to the defined webhooks?

proper nebula
#

In Test mode, you can do things to your account to cause Events or you can use stripe trigger with the Stripe CLI

#

I'm sorry I am not trying to be cryptic, but you're not saying really what you want

#

like which exact event are you trying to trigger

misty summit
#

let me try again very simple:

I want stripe to send to our server a "checkout.session.completed" event.

#

is that clear?

proper nebula
#

In Test mode you can either
1/ Create a Checkout Session with your Test API key. Go through Checkout end to end in a browser to cause that Event
2/ Use stripe trigger checkout.session.completed

misty summit
#

we are trying to get 2) working

proper nebula
#

by using #2, it will create a real Checkout Session and complete it, and cause a real Event, and that Event will be sent to all webhook endpoints that listen for that Event. If you have one in Test mode it will receive the Event

misty summit
#

so ... a stripe trigger will send to all the configure webhooks and uses the secret that is configured in the dashboard. good

#

The problem we are seeing is that we are getting a verification error on the live server.

#

It works with the local secret (stripe listen), but with the secret from the dashboard it fails.

proper nebula
#

Can I ask you to try and provide a lot more specifics? Exact Event id, what your code does, etc.

misty summit
#
const Stripe = require('stripe')(Config.stripe.api.secret)

async function handler (request, _h) {
  const payload = request.payload.toString()
  const signature = request.headers['stripe-signature']

  try {
    const event = Stripe.webhooks.constructEvent(
      payload,
      signature,
      Config.stripe.webhook.secret
    )

    ...
  } catch (err) {
    throw Boom.badRequest('signature verification failed')
  }
}

This is the code that works locally that we are trying to get working in a production env.

#

In production the verification fails.

#

It seems like the only reason could be a misconfiguration of the secrets.

proper nebula
#

const payload = request.payload.toString()
this is almost certainly incorrect. We need the exact raw payload for signature verification so I'm surprised this works locally

misty summit
#

Do we need to switch into "testing" mode?

misty summit
#

and as I said it does work locally

#

(you have to configure the hapi handler to return raw requests - that's all)

proper nebula
#

gotcha

#

Then I'm not sure how to help exatly unfortunately. If you use stripe listen --forward-to then the secret used is the CLI one. Otherwise if the Event is sent from Stripe then we use the one for your endpoint.
I'm still really fuzzy about what you are asking unfortunately

misty summit
#

I can see that.

#

Maybe you can explain to me the difference between "test mode" and "live mode" in this context.

#

the little switch on the dashboard

#

I have a feeling that might have something to do with that

proper nebula
misty summit
#

Maybe I have missed it - but I don't see how that answers the question about what "stripe trigger" will do in the two different modes?

wispy pikeBOT
proper nebula
#

Sorry you never said your question was about stripe trigger ๐Ÿ˜…

#

stripe trigger sends an Event in Test mode to your Test mode webhook endpoint(s) configured in Test mode in your Dashboard

misty summit
#

alright ... that explains things ... thanks

proper nebula
#

glad you figured it out!