Using stripe CLI to test webhooks in windows dev machine

Viewed 1634

I want to test stripe webhooks in my local windows dev machine, stripe docs mention stripe CLI as the best /easier way to test webhooks endpoints and sending fake events, I followed the docs to down load stripe CLI into my windows machine, I extracted the executable into my desktop but now I don't know how to properly excute commands in my cmd.

stripe.exe in my desktop, I first tried just simply clicking it, command prompt opened and showed message bellow, after a few seconds the command prompt closes.

This is a command line tool.

You need to open cmd.exe and run it from there.

After that I tried opening a CMD window and drag and dropping stripe.exe into the tab, I get the following list of commands:

C:\Users\GABRIEL>C:\Users\GABRIEL\Desktop\stripe.exe
The official command-line tool to interact with Stripe.

Before using the CLI, you'll need to login:

  $ stripe login

If you're working on multiple projects, you can run the login command with the
--project-name flag:

  $ stripe login --project-name rocket-rides

Usage:
  stripe [command]

Webhook commands:
  listen                        Listen for webhook events
  trigger                       Trigger test webhook events

Stripe commands:
  logs                          Interact with Stripe API request logs
  status                        Check the status of the Stripe API

Resource commands:
  get                           Quickly retrieve resources from Stripe
  charges                       Make requests (capture, create, list, etc) on charges
  customers                     Make requests (create, delete, list, etc) on customers
  payment_intents               Make requests (cancel, capture, confirm, etc) on payment intents
  ...                           To see more resource commands, run `stripe resources help`

Other commands:
  completion                    Generate bash and zsh completion scripts
  config                        Manually change the config values for the CLI
  feedback                      Provide us with feedback on the CLI
  fixtures                      Run fixtures to populate your account with data
  help                          Help about any command
  login                         Login to your Stripe account
  logout                        Logout of your Stripe account
  open                          Quickly open Stripe pages
  samples                       Sample integrations built by Stripe
  serve                         Serve static files locally
  version                       Get the version of the Stripe CLI

Flags:
      --api-key string        Your API key to use for the command
      --color string          turn on/off color output (on, off, auto)
      --config string         config file (default is
                              $HOME/.config/stripe/config.toml)
      --device-name string    device name
  -h, --help                  help for stripe
      --log-level string      log level (debug, info, warn, error)
                              (default "info")
  -p, --project-name string   the project name to read from for config
                              (default "default")
  -v, --version               Get the version of the Stripe CLI

Use "stripe [command] --help" for more information about a command.

C:\Users\GABRIEL>

as you see I can't type any command, something like

stripe login

I'm left with no option to do anything with stripe cli in cmd.

4 Answers

You need to cd into the folder where you have stored stripe.exe. In your case that's:

C:\Users\GABRIEL> cd Desktop

Then you simply run stripe commands from there and it'll work. For instance:

C:\Users\GABRIEL\Desktop> stripe --help

OR

C:\Users\GABRIEL\Desktop> stripe login

download the zip file

extract to get the .exe inside it

open cmd

locate the file path

and run "stripe.exe"

C:MyFolder> stripe.exe

Using system variables

I know this is an old question, but i wanted to post this fairly simple answer which is useful also later on while bumping into these kind of problems.

I also do think the other answers are good options when using it once, but when using stripe commands consistently here is my solution:

  1. Create a new folder at a place where you can access it easily for instance in your documents folder. I call my folder custom-commands you can call it however you want.

  2. Create a new notepad file inside the folder and paste the following code in it:

@echo off

set cwd=%cd%
set stripePath=C:\Path\To\Stripe\Location
cd /d %stripePath% && stripe %*
cd /d %cwd%

set cwd=
set stripePath=

Note the stripePath needs to be set to where your stripe.exe is located

This scripts tells your cmd where stripe is located.

  1. In the windows search function search system variables, open the app you will be prompted with a screen that looks like this: System variables prompt

  2. Click system variables and then edit the user path: User path

  3. Add a new path: enter image description here

  1. The path needs to be the path to your newly created folder mine is called: custom-commands.

  2. You might need to restart your computer and then just test it out by typing stripe in a cmd.

That's it! this also has one major benefit, because whenever you need something like this again you only have to create the .bat file and add your own script!

".\stripe login" works not other in windows i faced lots of issues by using stripe login , where that will not work after 100 attempts i tried .\stripe login and it worked finally

Related