#pedgo-webhooks
1 messages ยท Page 1 of 1 (latest)
Hey @latent fulcrum, there's two commands. The first is stripe listen localhost:3000/webhooks which creates a direct connection between Stripe and your local running server. The second is stripe trigger which will fire all the API calls required to result in a given event.
Don't I need the --forward-to flag?
sorry yeah you need that flag
So I need 2 terminals?
yes
my pleasure ๐
can you help me with one more thing?
I'm using docker to run the stripe CLI. Why won't it accept my --forward-to flag?
docker run --rm -it stripe/stripe-cli listen --forward-to localhost:4000/webhooks/stripe --api-key SECRET_TEST_KEY
Oh, don't worry if that's too complicated. It was a problem about positional argument
ah nice
I managed to open a new cli and now it's working I think
sweet
thank you either way
happy to be a rubber duck ๐ฆ
haha
I'm sorry to bother you hat much but could you help me understanding why my webhooks are being refused even tho I can reach my server with Insomnia?
yeah
so you have stripe listen up and running?
and when you trigger, what is showing in the logs for listen as the response status code?
this
2022-01-15 20:45:12 [ERROR] Failed to POST: Post "http://localhost:4000/webhooks/stripe": dial tcp 127.0.0.1:4000: connect: connection refused```
It says it can't reach http://localhost:4000/webhooks/stripe, but when I do a Post request with Insomnia, I can reach it, it responds a 400 WARNING: Webhook signature verification failed!!! as it should
Okay, I'm a little ignorant about how host names work with docker, but i have a feeling that using localhost is attempting to use the docker container as the host?
Maybe try adding --network="host" to the docker run args?
gonna try
okay i'm seeing the same error you are now and am able to reproduce.
yeah, I tried multiple flags
none worked yet
Only discovered how to connect from outside to docker /:
okay
figured it out. it's weird...
host.docker.internal is the hostname of the host when communicating from the docker image to the host.
Here's my stripe listen command:
docker run --rm -it stripe/stripe-cli listen --forward-to host.docker.internal:4242/webhook --api-key sk_test_xxx
From: https://docs.docker.com/desktop/mac/networking/#use-cases-and-workarounds
We recommend that you connect to the special DNS name host.docker.internal which resolves to the internal IP address used by the host.
ok, you helped me a lot
This was confusing!
I was tying to use this command on the stripe listen command
I'm going to write a little blog post about this, I think.
didn't knew I had to set up directly on the docker command
to me too
awesome, that might help a lot of people
OOC was there a reason you couldn't install the Stripe CLI directly?
and use without docker?
yeah, I use homebrew but stripe homebrew only works on mac according to some github issues I read. So my second option was docker
(And I'm on ubuntu)
gotcha.
I'm gonna try to fix the rest by myself, but just fyi. It ignores the path:
[ERROR] Failed to POST: Post "http://host.docker.internal:4000/webhooks/stripe": dial tcp 192.168.65.2:4000: connect: connection refused