stripe / stripe-cli Goto Github PK
View Code? Open in Web Editor NEWA command-line tool for Stripe
Home Page: https://stripe.com/docs/stripe-cli
License: Apache License 2.0
A command-line tool for Stripe
Home Page: https://stripe.com/docs/stripe-cli
License: Apache License 2.0
stripe login --api-key pk_test_****
it then shows
Your pairing code is: some-codes
This pairing code verifies your authentication with Stripe.
Press Enter to open the browser (^C to quit)
⣯ Waiting for confirmation...
Then it sticks in it and after some mins it shows
exceeded max attempts and quits
Probably opens a browser. Not sure.
Ubuntu 19 Linux
I am trying to run stripe listen
non-interactively in one docker container to proxy events to a different docker container, so that I can validate my webhooks in an automated test.
I run:
stripe listen --device-name my-test --api-key sk_test_XXXX
The output is:
your device name has not been configured. Use `stripe configure` to set your device name
but if I then run:
stripe configure
it outputs:
unknown command "configure" for "stripe"
So, the issue is:
stripe listen --help
I should be able to set this with --device-name
. The first command should succeed as is.If I populate ~/.config/stripe/config.toml
directly instead of using command-line flags, stripe listen
works great. (While undocumented, this might be a better idea regardless, because then I don't need to worry about my API key being in an error message if the command fails.)
Ubuntu 18.04 running under Docker, Stripe CLI 0.2.3 installed via https://github.com/stripe/stripe-cli/releases/download/v0.2.3/stripe_0.2.3_linux_amd64.deb.
stripe listen
is great. I've been wanting something like this for a long time.
The more information we have the easier it is for us to help. Feel free to remove any sections that might not apply
When I try to do two actions on stripe (Cancel subscription and Reactivate it) - it feels like it only listens to ONE event?
I expect the second action to also generate a console line indicating it has recieved an event?
Start up the cli stripe listen --forward-to https://localhost/stripe/webhook
Go to your stripe dashboard -
Create a subscription Product and create it for a dummy customer if there isnt one to play around with
Go to that customer and try to cancel the subscription.
You will see one output:
2019-10-06 09:26:29 Received:
But now when you try to reactivate it. You will not see any output.
Also note that quitting* and restarting and then if you reactivate you see an acknowledge message like above but if you do a second action it again doesnt acknowledge it
*which in itself is broken - i try to do control +C, it doesnt seem to work, so i end up doing ctrl +c, x, z and command +c,z,x etc
I am also not sure if when it fwds the request it uses a GET or a POST? as even the one event it acknowledges my App doesnt seem to be responding?
macOS
When trying to use stripe-cli together with a server behind puma-dev I get errors as the Go HTTP Client doesn't resolve .test
domains to http://127.0.0.1:80
.
Have a flag to set a custom Host
Header on requests.
$ stripe listen --forward-to http://127.0.0.1:80 --forward-to-host foo.test
payment_intent.canceled
event is not supported at the moment
Support of payment_intent.canceled
.
Running stripe trigger payment_intent.canceled
leads to event payment_intent.canceled is not supported.
Pull request #229
Starting up listen locally works and I can see the webhooks getting sent:
stripe listen --load-from-webhooks-api --forward-to localhost:3000/_billing_events --forward-connect-to localhost:3000/_billing_event
However, Stripe posts to /
of my Rails app no matter what.
Receive a POST at /_billing_events on port 3000
Described in the above
[Sun, 08 Sep 2019 21:11:12 PDT] INFO Received Connect event: evt_1FGeDcLlccjANAyCK4MbPG7P [type: invoice.payment_succeeded]
[Sun, 08 Sep 2019 21:11:12 PDT] INFO Received Connect event: evt_1FGeDcLlccjANAyCvYeiN11P [type: customer.subscription.created]
[Sun, 08 Sep 2019 21:11:12 PDT] INFO Got response from local endpoint, status=404
[Sun, 08 Sep 2019 21:11:12 PDT] INFO Got response from local endpoint, status=404
macOS
When listening to webhooks, there's occasional error messages
Expect to only see messages related to webhook events
$ stripe listen
ERROR read error: websocket: unexpected reserved bits 0x40
macOS 10.14.6
I am using Laravel Homestead, an Ubuntu-based development VM — which I would assume many people would want to use with stripe-cli, given the popularity of Laravel Cashier.
But trying to install stripe-cli by following the installation instructions for Debian and Ubuntu-based distributions fails at step 1 when run inside a firewalled VM.
The docs instruct to run the following command to add Bintray's GPG key to the apt sources keyring:
sudo apt-key adv --keyserver hkp://pool.sks-keyservers.net --recv-keys 379CE192D401AB61
However, when running the commands from within a firewalled virtual machine, this may result in the following vague error:
Executing: /tmp/apt-key-gpghome.mA57CDqXT9/gpg.1.sh --keyserver hkp://pool.sks-keyservers.net --recv-keys 379CE192D401AB61
gpg: keyserver receive failed: Server indicated a failure
Specifying that port 80 should be used for the keyserver URL seemed to allow the command to run successfully for me:
sudo apt-key adv --keyserver hkp://pool.sks-keyservers.net:80 --recv-keys 379CE192D401AB61
It may be worth updating the installation docs to account for this.
When trying to use stripe-cli together with a server behind puma-dev I get errors as the Go HTTP Client doesn't resolve .test
domains to http://127.0.0.1:80
.
Have a flag to set a custom Host
Header on requests.
$ stripe listen --forward-to http://127.0.0.1:80 --forward-to-host foo.test
I am using stripe listen --forward-to
(amazing feature 🙇) on my mac. It is running in the foreground in one terminal tab.
When I leave my computer for some time (goes to sleep) and I come back, the command is still running but no new webhooks are received and forwarded
I would expect the CLI to either quit when not connected, or (better) reconnect automatically
Run stripe listen --forward-to
, but the computer to sleep for a while, come back, trigger a webhook and see it delivered
macOS, installed using brew
Apologies if this is a me issue, and not a bug, but I am having the following problem:
I am testing a rails endpoint set up to accept the payment_intent.succeeded
webhook, and when triggering the event I am seeing 3 subsequent POST requests to my local server.
My webook is set up from the dashboard to only notify on payment_intent success/failure.
I expect there to be 1 POST request (for the payment intent success) rather than 3.
stripe listen --forward-to <local server>
.payment_intent.succeeded
, I invariably see 3 separate POST requests to my server.From cli trigger window:
> stripe trigger payment_intent.succeeded
Trigger succeeded! Check dashboard for event details.
From stripe listen
window:
stripe listen --forward-to localhost:3000/services/stripe/payment_intents
> Ready! Your webhook signing secret is <SECRET> (^C to quit)
2019-10-01 13:37:26 Received: payment_intent.created [evt_1FOs6EEeqVASFOA53jddw7Q8]
2019-10-01 13:37:26 Received: charge.succeeded [evt_1FOs6EEeqVASFOA56kApBNZN]
2019-10-01 13:37:26 Received: payment_intent.succeeded [evt_1FOs6FEeqVASFOA5veXZwo3O]
2019-10-01 13:37:26 [200] POST http://localhost:3000/services/stripe/payment_intents
2019-10-01 13:37:26 [200] POST http://localhost:3000/services/stripe/payment_intents
2019-10-01 13:37:26 [200] POST http://localhost:3000/services/stripe/payment_intents
From my local server window:
Started POST "/services/stripe/payment_intents" for ::1 at 2019-10-01 13:37:26 -0700
Processing by....
X 3
It seems like the trigger is not recognizing the webhook settings in the UI and sending all downstream events anyway?
macOS
Hi,
This is great! I literally requested this in a Stripe engineering session and here it is. Thank you! I literally paid for ngrok today, and then this. Magic!!
I installed the cli via homebrew as instructed on macOS (Mojave)
Running stripe login
works great ... browser opens and I get an authenticated message.
$ stripe login
Your pairing code is: nifty-reform-solid-excite
Press Enter to open up the browser (^C to quit)
> Done! The Stripe CLI is configured for Tito with account id user_...
but when I run stripe listen
, I just get a 500 every time:
$ stripe listen --forward-to https://checkout.dev.tito.io/incoming_webhooks
⣽ Getting ready... [Tue, 16 Jul 2019 23:22:58 IST] FATAL Error while authenticating with Stripe: Authorization failed, status=500, body={
"error": {
"message": "An unknown error occurred",
"type": "api_error"
}
}
Not much more I can do from here!
I am receiving events but also receive errors when trying to reach the local app. Setup is Laravel 5.7 with Homebrew and Valet.
Ready! Your webhook signing secret is whsec...
[Sun, 21 Jul 2019 13:52:21 CEST] INFO Received event: evt_1EydaSJFP015mQcJpyAozhkF [type: payment_intent.created]
[Sun, 21 Jul 2019 13:52:21 CEST] ERROR Failed to POST event to local endpoint, error = Post https://myappname.test/hooks/stripe/paymentintent: dial tcp: lookup friendships.test on MYIP:53: no such host
$ docker run --rm -it stripe/stripe-cli version
Unable to find image 'stripe/stripe-cli:latest' locally
docker: Error response from daemon: Get https://registry-1.docker.io/v2/stripe/stripe-cli/manifests/latest: unauthorized: incorrect username or password.
See 'docker run --help'.
Why do I need a password to fetch the Stripe CLI image? What kind of password do I need? Can you add some instructions around this to the readme? Thanks.
Reported by @homemadePopcorn in #37:
stripe.exe was labelled as a suspicious file by my anti-virus software. I can add an exception to that file on my firewall but just thought I would write the issue down.
Is there something we can do to make Windows happier with that behavior? We didn't have issues with this when we were doing Windows testing locally, wonder if there's something specific it's flagging.
Stripe open throws exception.
stripe open
stripe open
panic: runtime error: index out of range
goroutine 1 [running]:
github.com/stripe/stripe-cli/pkg/cmd.(*openCmd).runOpenCmd(0xc0000940d0, 0xc0001b2780, 0x19e9fd8, 0x0, 0x0, 0x0, 0x0)
/home/travis/gopath/src/github.com/stripe/stripe-cli/pkg/cmd/open.go:121 +0x4be
github.com/spf13/cobra.(*Command).execute(0xc0001b2780, 0x19e9fd8, 0x0, 0x0, 0xc0001b2780, 0x19e9fd8)
/home/travis/gopath/pkg/mod/github.com/spf13/[email protected]/command.go:826 +0x465
github.com/spf13/cobra.(*Command).ExecuteC(0x19c4da0, 0x6bd, 0xc0000c5f68, 0x147e2f8)
/home/travis/gopath/pkg/mod/github.com/spf13/[email protected]/command.go:914 +0x2fc
github.com/spf13/cobra.(*Command).Execute(...)
/home/travis/gopath/pkg/mod/github.com/spf13/[email protected]/command.go:864
github.com/stripe/stripe-cli/pkg/cmd.Execute()
/home/travis/gopath/src/github.com/stripe/stripe-cli/pkg/cmd/root.go:59 +0x9e
main.main()
/home/travis/gopath/src/github.com/stripe/stripe-cli/cmd/stripe/main.go:6 +0x20
No error and list of available open commands.
I'd like to use stripe-cli
to help me with end to end testing of issuing
webhooks.
I'd like to be able to trigger issuing events:
issuing_authorization.request
issuing_authorization.created
issuing_authorization.updated
I'd like to be able to trigger hooks on a connected account so I can test different use cases like:
I'm not sure if this is the right way to approach it, any help is appreciated.
I was thinking of creating a new authorization but the API doesn't have an endpoint to do so
https://stripe.com/docs/api/issuing/authorizations
I guess a simple test case would be:
issuing_authorization.request
event gets triggeredstripe-cli
to a local instanceThanks!
➜ stripe trigger issuing_authorization.updated
event issuing_authorization.updated is not supported.
Just an example to show cli is setup correctly
➜ stripe get /issuing/cardholders --stripe-account acct_***
{
"object": "list",
"data": [
],
"has_more": false,
"url": "/v1/issuing/cardholders"
}
➜ stripe trigger payment_intent.created
Trigger succeeded! Check dashboard for event details.
-d 'expand[]=foo'
works to expand fields in API responses but --expand foo
(as per documentation) gives the following error:
{
"error": {
"message": "Invalid array",
"param": "expand",
"type": "invalid_request_error"
}
}
Tried with:
> stripe get subscriptions/sub_FSBap8m2DfyHl8 --expand latest_invoice
> stripe get subscriptions/sub_FSBap8m2DfyHl8 -d 'expand[]=latest_invoice'
macOS 10.14.5, stripe CLI installed via homebrew
> stripe --version
stripe version 0.2.2
Trying to test charge.refunded
webhooks with the CLI but it is not supported as of now.
Support for charge.refunded
events in the CLI. Providing a way to specify the charge_id you want it to attach to, and a refund amount to test it with would be amazing.
The more information we have the easier it is for us to help. Feel free to remove any sections that might not apply
While testing my application, I use stripe CLI to forwardd webhook events to my local dev server. Everything seems to be working well except I get the following warning for every webhook event that arrives.
WARN Received malformed message: Unexpected message type: error
I expected to not receive warnings or maybe a more descriptive warning message.
Starting with a dev server running locally at port 8000, Issue the following command
./stripe listen --forward-to localhost:8000/stripe/webhook/
> Ready! Your webhook signing secret is whsec_***** (^C to quit)
2019-10-03 14:15:34 Received: customer.created [evt_1FPYpuC4YIU961kJvzVQYypN]
2019-10-03 14:15:34 [200] POST http://localhost:8000/stripe/webhook/
[Thu, 03 Oct 2019 14:15:34 EDT] WARN Received malformed message: Unexpected message type: error
2019-10-03 14:15:50 Received: customer.updated [evt_1FPYqAC4YIU961kJpBIi9Pd3]
2019-10-03 14:15:50 Received: payment_method.attached [evt_1FPYqAC4YIU961kJD1w1xprf]
2019-10-03 14:15:50 Received: customer.source.created [evt_1FPYqAC4YIU961kJv9rEpjFY]
2019-10-03 14:15:50 [200] POST http://localhost:8000/stripe/webhook/
2019-10-03 14:15:51 [200] POST http://localhost:8000/stripe/webhook/
[Thu, 03 Oct 2019 14:15:52 EDT] WARN Received malformed message: Unexpected message type: error
[Thu, 03 Oct 2019 14:15:52 EDT] WARN Received malformed message: Unexpected message type: error
2019-10-03 14:15:52 Received: charge.succeeded [evt_1FPYqCC4YIU961kJjgpQMtEn]
2019-10-03 14:15:53 Received: payment_intent.created [evt_1FPYqCC4YIU961kJxZP6jR0R]
2019-10-03 14:15:53 Received: payment_intent.succeeded [evt_1FPYqCC4YIU961kJXJFaJ1LJ]
2019-10-03 14:15:53 [200] POST http://localhost:8000/stripe/webhook/
2019-10-03 14:15:53 Received: customer.updated [evt_1FPYqDC4YIU961kJ0gauIXjj]
[Thu, 03 Oct 2019 14:15:53 EDT] WARN Received malformed message: Unexpected message type: error
2019-10-03 14:15:53 [200] POST http://localhost:8000/stripe/webhook/
2019-10-03 14:15:53 Received: invoice.created [evt_1FPYqDC4YIU961kJhJDPfa6N]
[Thu, 03 Oct 2019 14:15:53 EDT] WARN Received malformed message: Unexpected message type: error
2019-10-03 14:15:53 Received: invoice.finalized [evt_1FPYqDC4YIU961kJxl6e3gqF]
2019-10-03 14:15:53 [200] POST http://localhost:8000/stripe/webhook/
2019-10-03 14:15:53 [200] POST http://localhost:8000/stripe/webhook/
2019-10-03 14:15:53 Received: invoice.payment_succeeded [evt_1FPYqDC4YIU961kJW6NPf0p3]
[Thu, 03 Oct 2019 14:15:53 EDT] WARN Received malformed message: Unexpected message type: error
[Thu, 03 Oct 2019 14:15:53 EDT] WARN Received malformed message: Unexpected message type: error
2019-10-03 14:15:53 Received: customer.subscription.created [evt_1FPYqDC4YIU961kJJZNWZVue]
2019-10-03 14:15:54 [200] POST http://localhost:8000/stripe/webhook/
[Thu, 03 Oct 2019 14:15:54 EDT] WARN Received malformed message: Unexpected message type: error
2019-10-03 14:15:54 [200] POST http://localhost:8000/stripe/webhook/
[Thu, 03 Oct 2019 14:15:54 EDT] WARN Received malformed message: Unexpected message type: error
2019-10-03 14:15:55 [200] POST http://localhost:8000/stripe/webhook/
2019-10-03 14:15:55 [200] POST http://localhost:8000/stripe/webhook/
2019-10-03 14:15:55 [200] POST http://localhost:8000/stripe/webhook/
[Thu, 03 Oct 2019 14:15:55 EDT] WARN Received malformed message: Unexpected message type: error
[Thu, 03 Oct 2019 14:15:55 EDT] WARN Received malformed message: Unexpected message type: error
[Thu, 03 Oct 2019 14:15:55 EDT] WARN Received malformed message: Unexpected message type: error
Linux (Fedora 30)
Just set this up to use instead of https://ngrok.io for webhook testing.
It seems that, at least for me, the webhooks functionality is not entirely reliable.
[Wed, 17 Jul 2019 12:46:59 EEST] INFO Received event: evt_1Ex9iwFSbr6xR4YALCCcvkG6 [type: charge.failed]
[Wed, 17 Jul 2019 12:46:59 EEST] INFO Received event: evt_1Ex9iwFSbr6xR4YAzXlJL5BA [type: source.chargeable]
[Wed, 17 Jul 2019 12:46:59 EEST] INFO Received event: evt_1Ex9iwFSbr6xR4YALCCcvkG6 [type: charge.failed]
[Wed, 17 Jul 2019 12:46:59 EEST] INFO Received event: evt_1Ex9iwFSbr6xR4YALCCcvkG6 [type: charge.failed]
[Wed, 17 Jul 2019 12:47:00 EEST] INFO Got response from local endpoint, status=400
[Wed, 17 Jul 2019 12:47:01 EEST] INFO Got response from local endpoint, status=400
[Wed, 17 Jul 2019 12:47:01 EEST] INFO Got response from local endpoint, status=400
[Wed, 17 Jul 2019 12:47:01 EEST] INFO Got response from local endpoint, status=400
[Wed, 17 Jul 2019 12:47:01 EEST] INFO Got response from local endpoint, status=400
[Wed, 17 Jul 2019 12:47:01 EEST] INFO Got response from local endpoint, status=400
[Wed, 17 Jul 2019 12:47:02 EEST] ERROR read error: websocket: close 1009 (message too big): WebSocket frame length too large
[Wed, 17 Jul 2019 12:47:02 EEST] ERROR read error: websocket: close 1009 (message too big): WebSocket frame length too large
[Wed, 17 Jul 2019 12:47:03 EEST] ERROR read error: websocket: close 1009 (message too big): WebSocket frame length too large
[Wed, 17 Jul 2019 12:52:51 EEST] INFO Received event: evt_1Ex9ocFSbr6xR4YAMbMYmUW5 [type: source.chargeable]
[Wed, 17 Jul 2019 12:52:51 EEST] INFO Received event: evt_1Ex9ocFSbr6xR4YAMbMYmUW5 [type: source.chargeable]
[Wed, 17 Jul 2019 12:52:51 EEST] INFO Received event: evt_1Ex9ocFSbr6xR4YAMbMYmUW5 [type: source.chargeable]
[Wed, 17 Jul 2019 12:52:52 EEST] INFO Got response from local endpoint, status=400
[Wed, 17 Jul 2019 12:52:52 EEST] INFO Got response from local endpoint, status=400
[Wed, 17 Jul 2019 12:52:52 EEST] INFO Got response from local endpoint, status=400
[Wed, 17 Jul 2019 12:52:53 EEST] ERROR read error: websocket: close 1009 (message too big): WebSocket frame length too large
[Wed, 17 Jul 2019 12:52:53 EEST] ERROR read error: websocket: close 1009 (message too big): WebSocket frame length too large
[Wed, 17 Jul 2019 12:52:54 EEST] ERROR read error: read tcp 192.168.1.6:52461->54.187.159.182:443: i/o timeout
[Wed, 17 Jul 2019 12:55:51 EEST] INFO Received event: evt_1Ex9rXFSbr6xR4YAehMY6wdv [type: source.chargeable]
[Wed, 17 Jul 2019 12:55:51 EEST] INFO Received event: evt_1Ex9rXFSbr6xR4YAehMY6wdv [type: source.chargeable]
[Wed, 17 Jul 2019 12:55:51 EEST] INFO Received event: evt_1Ex9rXFSbr6xR4YAehMY6wdv [type: source.chargeable]
[Wed, 17 Jul 2019 12:55:52 EEST] INFO Got response from local endpoint, status=400
[Wed, 17 Jul 2019 12:55:52 EEST] INFO Got response from local endpoint, status=400
[Wed, 17 Jul 2019 12:55:52 EEST] INFO Got response from local endpoint, status=400
[Wed, 17 Jul 2019 12:55:53 EEST] ERROR read error: websocket: close 1009 (message too big): WebSocket frame length too large
[Wed, 17 Jul 2019 12:55:53 EEST] ERROR read error: websocket: close 1009 (message too big): WebSocket frame length too large
[Wed, 17 Jul 2019 12:57:04 EEST] ERROR read error: read tcp 192.168.1.6:52729->54.187.119.242:443: i/o timeout
Is there a debug mode or something I could enable to provide more information than this? The webhooks in question are triggered using Charge API with card number 4000000000003063
to trigger 3DS 1.0 flow.
It would be nice if there was a way to fetch error logs from production, using filters that aren't available via the dashboard https://dashboard.stripe.com/logs
e.g. I'd like to see a list of the latest HTTP 400 invalid_request_error
logs, with HTTP 402 card_error
logs filtered out in a format that I can pipe through jq to extract more info.
Ideally these filters would be available in the dashboard too, but I can't see a way to do that.
I'm a developer that's authenticated as a particular user/org in the CLI, and I want to quickly be able to open the Stripe Dashboard without changing user and using the org-switcher
Add new stripe dashboard
command that would open the default browser, navigating to Stripe Dashboard authenticated as that particular user/org.
This feature could be generalized to other areas with a generic stripe open <x>
command.
Areas of interest:
stripe open dashboard
stripe open dashboard/<area>
stripe open dashboard/terminal
stripe open docs
stripe open docs/search/<keyword>
stripe version 0.6.5 (beta)
Ran stripe login
and received error message
Post https://dashboard.stripe.com/stripecli/auth: http2: server sent GOAWAY and closed the connection; LastStreamID=1, ErrCode=ENHANCE_YOUR_CALM, debug=""
According to the readme: "You'll be redirected to the Stripe dashboard to confirm that you want to give access to your account to the CLI. After confirming, a new API key will be created and returned to the CLI."
brew install stripe/stripe-cli/stripe
stripe login
Post https://dashboard.stripe.com/stripecli/auth: http2: server sent GOAWAY and closed the connection; LastStreamID=1, ErrCode=ENHANCE_YOUR_CALM, debug=""
macOS
thx
We use a self signed SSL certificate for our API when developing locally. When trying to forward requests to an endpoint on that API we get an error because the SSL certificate is not valid.
It would be useful to have a flag that allows ignoring the certificate check. I suspect a lot of other developers use a similar setup.
ERROR Failed to POST event to local endpoint, error = Post https://api.local/stripe: x509: certificate signed by unknown authority
The more information we have the easier it is for us to help. Feel free to remove any sections that might not apply
Describe what happened and what you were trying to do
Tell us what you expected to happen
What are the steps we can take to reproduce this and verify it's fixed?
Share any debug output that was given by the CLI
Select one of: macOS, Linux, Windows, Other
stripe listen --api-version 2019-09-09
results in:
unknown flag: --api-version
The same goes for stripe trigger checkout.session.completed --api-version 2019-09-09
Second issue:
It looks like Stripe CLI is defaulting to the 2019-03-14 API version, not to my currently used API version.
I have:
stripe version 0.6.12 (beta)
I think it'd be awesome to see a shortcut to run stripe -v
and have the same behavior as stripe --version
.
$ docker run --rm -it stripe/stripe-cli login
Your pairing code is: virtue-vivid-jovial-rosy
Press Enter to open up the browser (^C to quit)
⣾ Waiting for confirmation... exec: "xdg-open": executable file not found in $PATH
$ echo $XDG_CONFIG_HOME
$ which xdg-open
/usr/bin/xdg-open
Is it trying to run xdg-open inside the container? Can it maybe print the URL I'm supposed to open?
It'd be nice to be able to listen for certain events only. Currently It sends listens for all events. Something like this:
stripe listen --events checkout.session.completed customer.created
After quitting stripe CLI using ^C
, it still remains in the process list, listening and polluting output on receiving webhook. (This also explains the duplicate lines in the output of #38)
~: stripe listen --forward-to http://<REDACTED>
[1] 14685
~: > Ready! Your webhook signing secret is whsec_<REDACTED> (^C to quit)
[^C]
~: ps
PID TTY TIME CMD
<REDACTED>
14685 ttys001 0:00.15 stripe listen --forward-to <REDACTED>
~:
What are you trying to do?
I'm trying to test a webhook endpoint's event handlers. The plugin I'm updating to the latest API has only a few of them, but just one is supported in the current CLI:
What would help you accomplish your original task
I was wondering if you are planning to add any of these soon?
Or is there any way for the "Send Test Webhook" tool in the dashboard, to use actual objects from previous tests or made-up ones, that the handler could then retrieve or update?
Thanks for all your work! :)
Hey! Fantastic work on the cli, makes testing webhooks so much easier 😄.
When dealing with multiple webhook calls from Stripe in a short period of time, the cli output can be a bit confusing, see screenshot below:
Understanding which webhook failed and which succeeded can be hard when new Received
message are inserted between response status. Would it be possible to log which event id the request are related to? For example:
2019-10-03 14:29:43 Received: invoice.created [evt_1FPZ3bKhzQLuvV5m9skPC8Hs]
2019-10-03 14:29:43 Received: customer.subscription.created [evt_1FPZ3bKhzQLuvV5mxfEgQ0B3]
2019-10-03 14:29:43 Received: invoice.finalized [evt_1FPZ3bKhzQLuvV5mYJi4b0qz]
2019-10-03 14:29:44 [200] POST http://stripe.lvh.me:3001/api/stripe_event [evt_1FPZ3bKhzQLuvV5m9skPC8Hs]
2019-10-03 14:29:44 [200] POST http://stripe.lvh.me:3001/api/stripe_event [evt_1FPZ3bKhzQLuvV5mxfEgQ0B3]
2019-10-03 14:29:44 [500] POST http://stripe.lvh.me:3001/api/stripe_event [evt_1FPZ3bKhzQLuvV5mYJi4b0qz]
I'm using version 0.6.12 (beta)
on MacOS 10.13.6
In our staging and production setup, as well as current use with ngrok
, we have two separate URLs set up - one for account hooks on our platform account and one for connect events for all connected accounts. However, the CLI only supports a single forward-to
.
Add a separate URL / forward-to-connect
argument to split the two types of events.
The command only works when there's a [default] project. Using --project-name
to choose a project produces this:
API key is too short, must be at least 12 characters long
Trying to set up and run https://github.com/stripe/stripe-payments-demo but the start script fails at the step that runs stripe listen
. It seems that stripe
thinks the API keys are not set, but AFAICT they are.
Edit: the stripe
command appears to work if I specify --api-key rk_test_####
from the default section of the config file. So it seems that stripe
is not propagating the default api key for a non-default project (or device?) name. /edit
To verify, I manually ran the stripe listen
command:
$ stripe listen --project-name=stripe-payments-demo --forward-to http://localhost:8000/webhook
you have not configured API keys yet. To do so, run `stripe login` which will configure your API keys from Stripe
So I ran stripe login
:
$ stripe login
Your pairing code is: ####-####-####-####
This pairing code verifies your authentication with Stripe.
Press Enter to open the browser (^C to quit)
Done! The Stripe CLI is configured for your account with account id ####
But after running stripe login
and clicking the button to verify in the web browser that opens, stripe listen
makes the same error.
According to stripe --help
, the default config file is $HOME/.config/stripe/config.toml
. This file contains:
[default]
device_name = "####"
live_mode_publishable_key = "pk_live_####"
test_mode_api_key = "rk_test_####"
test_mode_publishable_key = "pk_test_####"
[stripe-payments-demo]
device_name = "stripe-payments-demo"
secret_key = "sk_test_####"
Linux Mint 19.1
stripe version 0.6.11 (beta)
When I forgot to restart the command to forward webhooks I would like to say "fetch the webhooks of the last x minutes"
A --backfill=time option where I can say --backfill=2m or --backfill=2h
I think the two items above covers it.
Testing checkout webhook
checkout.session.completed
I cant even find docs what will object checkout.session.completed look like in webhook and cant test with cli and testing on real domains or tunnels is a pain
trigger checkout.session.completed
I'm not sure why stripe listen
isn't working - maybe the endpoint is down or I've made a mistake (it was working earlier with no changes on my end).
Regardless, it's super confusing that the CLI says "Ready! Your webhook signing secret..." when in fact the CLI is silently dialing the websocket endpoint and repeatedly failing.
I expected the stripe listen
to log its connection failures / retries (without having to run the command with --log-level=debug
).
Run stripe listen
in such a way that it authenticates properly but can't create a websocket connection to stripe-cli.stripe.com.
stripe listen --forward-to localhost:4000/webhooks/stripeaccountupdated --print-json --log-level debug
⣾ Getting ready... [Tue, 10 Sep 2019 20:42:17 EDT] DEBUG stripeauth.client.Authorize: Authenticating with Stripe...
⡿ Getting ready... [Tue, 10 Sep 2019 20:42:27 EDT] DEBUG stripeauth.Client.Authorize: Got successful response from Stripe display_connect_filter_warning=false reconnect_delay=36 websocket_authorized_feature=webhook-payloads websocket_id={ws-id}websocket_url=wss://stripe-cli.stripe.com/subscribe/{account}
[Tue, 10 Sep 2019 20:42:27 EDT] DEBUG websocket.client.Run: Attempting to connect to Stripe
> Ready! Your webhook signing secret is {secret} (^C to quit)
[Tue, 10 Sep 2019 20:42:27 EDT] DEBUG websocket.Client.connect: Dialing websocket url=wss://stripe-cli.stripe.com/subscribe/{account}?websocket_feature=webhook-payloads
[Tue, 10 Sep 2019 20:42:37 EDT] DEBUG websocket.Client.connect: Websocket connection error error=dial tcp: i/o timeout
[Tue, 10 Sep 2019 20:42:37 EDT] DEBUG websocket.client.Run: Failed to connect to Stripe. Retrying...
[Tue, 10 Sep 2019 20:42:47 EDT] DEBUG websocket.Client.connect: Dialing websocket url=wss://stripe-cli.stripe.com/subscribe/{account}?websocket_feature=webhook-payloads
[Tue, 10 Sep 2019 20:42:57 EDT] DEBUG websocket.Client.connect: Websocket connection error error=dial tcp: i/o timeout
[Tue, 10 Sep 2019 20:42:57 EDT] DEBUG websocket.client.Run: Failed to connect to Stripe. Retrying...
^C[Tue, 10 Sep 2019 20:43:00 EDT] DEBUG proxy.Proxy.Run: Ctrl+C received, cleaning up...
[Tue, 10 Sep 2019 20:43:00 EDT] DEBUG proxy.Proxy.Run: Bye!
macOS
When I use stripe listen locally, it works fine.
But when I use it on our test server, the webhooks seem to call GET, rather than POST and my webhook is not set up to serve GET requests:-
[Fri, 16 Aug 2019 16:49:56 BST] INFO Received event: evt_1F87geDLZTy5tB2lWSjs3aI0 [type: checkout.session.completed]
[Fri, 16 Aug 2019 16:49:56 BST] INFO Got response from local endpoint, status=405
and in my internal logs:-
[pid: 1091|app: 0|req: 3/9] 192.168.100.52 () {44 vars in 875 bytes} [Fri Aug 16 16:49:56 2019] GET /prices/payment_received/ => generated 0 bytes in 4 msecs (HTTP/1.1 405) 5 headers in 159 bytes (2 switches on core 0)
Is this expected behaviour and I should handle the GET requests? Or is something else going on?
The command line listener is receiving no events, instead events are being sent to the dashboard.
(The CLI is also telling me to upgrade to 0.7.3 despite being on 0.7.3)
The command line listener to receive events, and to not receive them in the dashboard.
stripe login --interactive
(Then follow the steps, enter the secret key from the test API Keys)stripe listen
stripe listen checkout.session.completed
$ stripe listen
A newer version of the Stripe CLI is available, please update to: v0.7.3
> Ready! Your webhook signing secret is {...} (^C to quit)
$ stripe trigger checkout.session.completed
A newer version of the Stripe CLI is available, please update to: v0.7.3
Trigger succeeded! Check dashboard for event details.
macOS
cli version 0.7.3
If I understood docs correctly, when using listen
command, I can specify --load-from-webhooks-api
which will take all existing webhooks endpoints from existing Stripe test account (visible in dashboard) and will forward only those events that are used by those webhooks.
I have configured webhook in dashboard (pointing to our staging server).
When I use command: stripe listen --load-from-webhooks-api --forward-to localhost:3000/webhook/stripe
I get error:
You have not defined any webhook endpoints on your account. Go to the Stripe Dashboard to add some: https://dashboard.stripe.com/test/webhooks
It's not clear to me if it's a bug or I am doing something wrong. Do you have any insights on this topic?
stripe -v
stripe version 0.2.7 (beta)
When running stripe listen -p segment --livemode --forward-to https://localhost:3000/stripe_webhook
I got the following error
you have not configured API keys yet. To do so, run `stripe login` which will configure your API keys from Stripe
I then generated a restricted key from the Stripe dashboard with the write rights for CLI, and added the missing live_mode_api_key
in ~/.config/stripe/config.toml
for the "segment" project.
When running again the same command, I get the following error:
FATAL Error while authenticating with Stripe: Authorization failed, status=400, body={
"error": {
"message": "Cannot create StripeCLI session with a live API key. Try again with a test API key.",
"type": "invalid_request_error"
}
}
My initial need was to use stripe trigger
to replay production events locally and debug our webhook.
If I use the stripe listen
command without the flag --livemode
and use stripe trigger --event production_event_id
, then the listen command doesn't seem to catch the Stripe event. That is why I thought of using the --livemode.
I expected the listen command to run and be able to listen for production events I would trigger using stripe trigger -p segment --event production_event_id
.
stripe listen -p segment --livemode
without the entry live_mode_api_key
in ~/.config/stripe/config.toml
.~/.config/stripe/config.toml
.stripe listen -p segment --livemode
⣾ Getting ready... [Mon, 14 Oct 2019 14:21:42 CEST] DEBUG stripeauth.client.Authorize: Authenticating with Stripe...
⣽ Getting ready... [Mon, 14 Oct 2019 14:21:44 CEST] DEBUG stripeauth.client.Authorize: Authenticating with Stripe...
⣻ Getting ready... [Mon, 14 Oct 2019 14:21:46 CEST] DEBUG stripeauth.client.Authorize: Authenticating with Stripe...
⣽ Getting ready... [Mon, 14 Oct 2019 14:21:48 CEST] DEBUG stripeauth.client.Authorize: Authenticating with Stripe...
⡿ Getting ready... [Mon, 14 Oct 2019 14:21:49 CEST] DEBUG stripeauth.client.Authorize: Authenticating with Stripe...
⣟ Getting ready... [Mon, 14 Oct 2019 14:21:51 CEST] DEBUG stripeauth.client.Authorize: Authenticating with Stripe...
[Mon, 14 Oct 2019 14:21:53 CEST] FATAL Error while authenticating with Stripe: Authorization failed, status=400, body={
"error": {
"message": "Cannot create StripeCLI session with a live API key. Try again with a test API key.",
"type": "invalid_request_error"
}
}
macOS
Showing more attributes on error requests would be great when tailing logs:
https://stripe.com/docs/api/errors#errors-type
The string attributes would be handy:
But leaving out hash attributes (payment_intent, payment_method, setup_intent, source) probably makes sense.
The more information we have the easier it is for us to help. Feel free to remove any sections that might not apply
Describe what happened and what you were trying to do
Tell us what you expected to happen
What are the steps we can take to reproduce this and verify it's fixed?
Share any debug output that was given by the CLI
Select one of: macOS, Linux, Windows, Other
Using listen --project-name
without a device_name in the [default] profile (even if a device_name) exists in the named project profile results in this error response:
[Thu, 08 Aug 2019 09:18:17 BST] FATAL Error while authenticating with Stripe: Authorization failed, status=400, body={
"error": {
"code": "parameter_invalid_empty",
"doc_url": "https://stripe.com/docs/error-codes/parameter-invalid-empty",
"message": "You passed an empty string for 'device_name'. We assume empty values are an attempt to unset a parameter; however 'device_name' cannot be unset. You should remove 'device_name' from your request or supply a non-empty value.",
"param": "device_name",
"type": "invalid_request_error"
}
}
The code expects:
stripe logs tail --format json
But the help text suggests
stripe logs tail --format JSON
Only the lowercase version works.
Describe what happened and what you were trying to do
I ran the stripe executable from the command line and while the connections seem to establish correctly, invalid characters are output to the console window which is both "ugly", but also tricky (i.e. to copy the webhook signing secret).
Tell us what you expected to happen
I expect the intention is to include these values in quotes, or to mark them up, however apparently the control characters aren't being recognized.
What are the steps we can take to reproduce this and verify it's fixed?
Windows 10 Home
Version 10.0.18362 Build 18362
I followed the very basic steps to download and execute the stripe.exe - nothing fancy. You can see the entire output of the commands I've run in the screenshot above.
Command line codepage is 437 with font Consolas if it matters (grabbed from command properties).
Select one of: macOS, Linux, Windows, Other
Windows - see above for more details.
While I understand the appeal of ONLY sending the "leaf element" object id of the event, as a "best practice" principle, any "element" included the event type path should have its corresponding ID included in the object sent. So in this event case, the event object would ideally include a cus_id AND a src_id included. Currently, only a src_id is being sent.
Our service doesn't hold or track src_id's in our database (no reason to), only a cus_id. The lack of a cus_id in the object prevents me from being able to determine WHICH of our customers has a source expiring, so I'm unable to send them an alert, so this event serves no purpose as I’m unable to determine without going through each customer I have to see which customers source is expiring.
Please add the ID of each enclosed object element. Thanks
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.