#Duplicated
1 messages ยท Page 1 of 1 (latest)
If the event is a live-mode event, it'll be livemode = true
can you share the sample live mode event that doesn't have livemode = true?
I've blocked out some potentially identifiable information here, but I can DM you the actual event ID.
@fickle jewel evt_3Ll4iQJjv9PMR4aC0Hr8S7NA
Thanks! In this event I see livemode: false. This is not what you were expecting?
Oh, your question if why you are getting test mode events to your live mode webhook endpoint?
If so, this is explained in our documentation here: https://stripe.com/docs/connect/webhooks#:~:text=For Connect webhooks,should be taken.
I understand this paragraph, but I'm not sure what I'm experiencing is the same thing here. Are you suggesting that the payload I've shown you in the screenshot above actually came from test mode?
The event you shared, evt_3Ll4iQJjv9PMR4aC0Hr8S7NA, is test mode yes. This is the API request that generated that event: https://dashboard.stripe.com/test/logs/req_K7LPpDICo4QxCb and it was made with a test API key.
That lines up with what the documentation says then.
In that case, if I would like the test payload to only go into the webhook endpoint inside test mode, what do I need to do?
Also, I'm not sure if this matters or not, but whoever set up Stripe webhook endpoints for this particular account reused the same endpoint for both live and test mode.
From the previous ticket:
I also have the same webhook endpoint for my backend registered on Stripe in both modes under the same Stripe parent account, so it looks something like this:
live mode: <domain_A><route_A><query_parameter_A>
test mode: <domain_A><route_A><query_parameter_A>&<query_parameter_B>
In that case, if I would like the test payload to only go into the webhook endpoint inside test mode, what do I need to do?
That makes sense, unfortunately that's not possible when using Connect. So you'll need to write some code to ignore test events in your livemode webhook by checking thelivemodeproperty of the event.
Also, I'm not sure if this matters or not, but whoever set up Stripe webhook endpoints for this particular account reused the same endpoint for both live and test mode.
Interesting. Well that means that both live mode and test mode event will definitely go to the same URL then.
Well that means that both live mode and test mode event will definitely go to the same URL then.
Is that anti-pattern in terms of how we're supposed to consume Stripe webhooks here?
That's completely up to you. You could use a single URL as long as your code process livemode and test mode events differently.
Hey, taking over here. Let me know if there's any follow-up Qs I can answer!
You could use a single URL as long as your code process livemode and test mode events differently.
That's what I did earlier, but the fact that it haslivemode: falsewhen inside both live and test mode webhook endpoints means I cannot differentiate one payload from the other.
Basically, what I was trying to do is to process only one of these webhooks. In this case, since they're essentially the same event, with the exact same payload, either one is fine, but because I have no way of remembering whether I have already processed this particular event id yet or not (without extensively modifying my business logic), they both pop up within the backend service.
Again if you are using connect webhook, as mentioned above and according to the doc that my colleague shared with you, you can differentiate events on the field livemode: true?false? if the same endpoint is processing both live and test events
https://stripe.com/docs/connect/webhooks#:~:text=For Connect webhooks,should be taken.
Like I said at the beginning of this conversation, I cannot differentiate using the field livemode since it's a payload created in test mode, which goes into both live and test mode webhook endpoints (exactly as explained in the doc you and your colleague have shared with me), where both live and test mode webhook endpoints happen to be the same one.
Anyhow, I've already updated the business logic to check for my custom flag instead, which is independent of Stripe, so hopefully that should be the last of this issue (for now). Thank you all ๐
Glad to hear, that you've managed to find a solution. Don't hesitate to come back if you have any follow-up Questions ๐
Hey, taking over here. Let me know if there's any follow-up Qs I can answer!