簡體   English   中英

在 windows 開發機器中使用條帶 CLI 測試 webhook

[英]Using stripe CLI to test webhooks in windows dev machine

我想在我的本地 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 window 並將 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 中的條帶 cli 做任何事情。

您需要cd進入存儲stripe.exe的文件夾。 在你的情況下是:

C:\Users\GABRIEL> cd Desktop

然后你只需從那里運行條帶命令,它就會工作。 例如:

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

或者

C:\Users\GABRIEL\Desktop> stripe login

下載 zip 文件

提取以獲取其中的.exe

打開 cmd

定位文件路徑

並運行“stripe.exe”

C:MyFolder>stripe.exe

使用系統變量

我知道這是一個老問題,但我想發布這個相當簡單的答案,這在以后遇到這類問題時也很有用。

我也確實認為其他答案在使用一次時是不錯的選擇,但是當始終使用條帶命令時,這是我的解決方案:

  1. 在您可以輕松訪問的位置創建一個新文件夾,例如在您的文檔文件夾中。 我將我的文件夾稱為自定義命令,您可以隨意調用它。

  2. 在文件夾中創建一個新的記事本文件並將以下代碼粘貼到其中:

@echo off

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

set cwd=
set stripePath=

請注意,stripePath 需要設置為您的 stripe.exe 所在的位置

此腳本告訴您的 cmd 條帶所在的位置。

  1. 在 windows 搜索 function 搜索system variables中,打開應用程序會提示您,屏幕如下所示: 系統變量提示

  2. 單擊system variables ,然后編輯user path 用戶路徑

  3. 添加新路徑: 在此處輸入圖像描述

  1. 該路徑需要是您新創建的文件夾的路徑,我的文件夾名為:custom-commands。

  2. 您可能需要重新啟動計算機,然后通過在 cmd 中鍵入 stripe 來測試它。

就是這樣,這也有一個主要的好處。 因為每當您再次需要這樣的東西時,您只需創建 .bat 文件並添加您自己的腳本!

".\stripe login" 在 windows 中不起作用我使用條帶登錄遇到了很多問題,在我嘗試了 100 次之后,這將無法正常工作。\條帶登錄,它終於工作了

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM