首页 > 解决方案 > 使用 stripe CLI 在 windows 开发机器中测试 webhook

问题描述

我想在我的本地 Windows 开发机器中测试条带 webhook,条带文档提到条带 CLI 作为测试 webhook 端点和发送假事件的最佳/更简单的方法,我按照文档将条带 CLI 下载到我的 Windows 机器中,我提取了可执行到我的桌面,但现在我不知道如何在我的 cmd 中正确执行命令。

stripe.exe 在我的桌面上,我第一次尝试只是简单地单击它,命令提示符打开并显示下面的消息,几秒钟后命令提示符关闭。

This is a command line tool.

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

之后我尝试打开一个 CMD 窗口并将 stripe.exe 拖放到选项卡中,我得到以下命令列表:

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>

如您所见,我无法键入任何命令,例如

stripe login

我没有选择在 cmd 中使用 stripe cli 做任何事情。

标签: javascriptphpwindows

解决方案


您需要cd进入您存储的文件夹stripe.exe。在你的情况下是:

C:\Users\GABRIEL> cd Desktop

然后你只需从那里运行条带命令,它就会工作。例如:

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

或者

C:\Users\GABRIEL\Desktop> stripe login

推荐阅读