#karsh-webhook

1 messages ยท Page 1 of 1 (latest)

warm echo
dire echo
#

I want to test my webhook integration, but can't seem to figure out how to do so... I need to send metadata (an array of product_id's) to my server. So I can query the products and know what they purchased

#

The only way I've been able to do this now is by actually purchasing something. And then using the 'resend' webhook button in the stripe dashboard.

But this particular purchase was with an array of 1 product, I need to test what happens if the metadata contains multiple products

warm echo
#

well ultimately the way to trigger an event is to do the API actions involved, to mimic a real payment and thus trigger the related events.

So you could

  • do a test mode payment with test mode API keys where you change your code involved in passing the metadata to pass what you want to see
  • if you know the event type, stripe-cli has a way to add fields to objects (https://stripe.com/docs/cli/trigger#trigger-add) so that would also work here , like stripe trigger payment_intent.succeeded --add payment_intent:metadata.myfield=myvalue
#

it depends a little on what exactly you've built and what event types/APIs you're using

dire echo
#

Ohh using the CLI sounds really interesting, thanks. I'll try that soon. But I don't know my way around it well yet. So I have one more question

#

With the current integration I have tried to do a test mode payment but I've been getting the following error. Could you tell me more specifically what is going wrong?

Webhook Error: No signatures found matching the expected signature for payload. Are you passing the raw request body you received from Stripe? https://github.com/stripe/stripe-node#webhook-signing

(I'm guessing it's trying to send the webhook to my live server and thus mismatching in the signing secret?)

#

This is the event id: evt_3K7ys5ICsSwpPsxX17K9TFjc

warm echo
dire echo
#

I get that error when doing a test payment on my local server

#

The keys...
Dev:
webhook signing secrets ends on 6mP
publishable key ends on p28
secret key is ending on iHc

With these keys, I do a test transaction using stripe's test card. Which gives me the 400 errors seen here: https://dashboard.stripe.com/test/webhooks/we_1K4OXEKWokmZWsWfJvaZfQed

I'm really at a loss. I would love to simply go through the test checkout to test my webhooks

warm echo
#

ah sorry, ok, I see.

webhook signing secrets ends on 6mP
that's not correct. The one you want ends in gRXMvc (it's on that page you linked most recently)

#

ignore the link to the other endpoint I shared earlier, I was wrong

#

actually I should stop talking

#

you are right, it's the 6mP one

dire echo
#

Haha, no please go ahead

warm echo
#

ok, then are you sure it's the secret?

  • has this endpoint ever worked?
dire echo
#

If you come to a solution at the end I'll be happy ๐Ÿ˜„

warm echo
#

if it never worked then you probably just don't pass the raw request body, as the error message says, since that's a really common issue when using Node

dire echo
#

I don't know how to verify (can I see the raw request that stripe receives?) since I'm using a low code tool that actually sends that request back. However that works flawlessly in other scenario's so I'm assuming that part is fine.

So you're asking if 'this endpoint' has ever worked. It works in live mode... a you can see here https://dashboard.stripe.com/webhooks/we_1K4oijKWokmZWsWfFxPQjhtv
Or am I not answering the question?

warm echo
#

hmm wait

#

so you have the same URL for two different Stripe endpoints

#

so that will never work, since we'll send you events signed with different signing secrets, half the events will fail, which is what you're seeing here.

#

you need to use different logical endpoints(like for test mode, use
https://.......app/webhooks/stripe_testmode/ and for live mode
https://.......app/webhooks/stripe/ ) and configure the code running at those URLs to use the correct secret for each Stripe endpoint.

#

just adding the same URL in test mode just means we'll start sending test mode events signed with the secret of that endpoint we_1K4OXEKWokmZWsWfJvaZfQed to that URl, as well as live events signed with the secret of that endpoint we_1K4oijKWokmZWsWfFxPQjhtv ; but your code on your server behind that URL can only be using one secret at a time and can't know which "Stripe endpoint" it's meant to be, so one of those halves will fail, as you see.

dire echo
#

Thank you for your response, sorry in a meeting. Will reply soon

lime swan
#

Take your time! I'm getting caught up on this thread in the meantime.

dire echo
#

Still in meetings, please keep the thread open! Thank you!!

dire echo
#

Thanks @warm echo I'll pass this through to the developers of the low-code app I'm using. You can close this thread ๐Ÿ˜„

boreal raven
#

OK thanks for letting us know! Good luck ๐Ÿ™‚