#tcurdt-event-livemode
1 messages ยท Page 1 of 1 (latest)
This work for us locally:
stripe listen --forward-to localhost:9000/api/webhooks/stripe
I'm sorry I don't really understand the question
if you use the CLI, it's usually only for local development, nothing else
ah, ok ... so there is no way to trigger an event so it comes from stripe itself?
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.
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
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?
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
let me try again very simple:
I want stripe to send to our server a "checkout.session.completed" event.
is that clear?
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
we are trying to get 2) working
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
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.
Can I ask you to try and provide a lot more specifics? Exact Event id, what your code does, etc.
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.
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
Do we need to switch into "testing" mode?
sorry, that's just not true
and as I said it does work locally
(you have to configure the hapi handler to return raw requests - that's all)
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
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
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?
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
again wrong
alright ... that explains things ... thanks
glad you figured it out!