调至内容部分
创建账户
或
登录
Stripe 文档徽标
/
询问人工智能
创建账户
登录
开始
付款
销售收入
平台和交易市场
资金管理
开发人员工具
概览
版本管理
更改日志
升级您的 API 版本
升级 SDK 版本
开发人员工具
SDK
API
测试
Workbench
事件接收端
工作流程
Stripe CLI
    概览
    开始
    自动完成
    CLI 密钥
    触发事件
    升级
    参考编号
Stripe Shell
开发人员管理平台
代理工具包
使用大语言模型构建Stripe for Visual Studio CodeStripe 健康警报文件上传
安全与隐私
安全
隐私
扩展 Stripe
Stripe 应用程序
Stripe Connector
合作伙伴
合作伙伴生态
合作伙伴认证
首页开发人员工具Stripe CLI

Stripe CLI

Manage your Stripe resources in a sandbox directly from the command line.

复制页面

The Stripe CLI is a developer tool to help you build, test, and manage your integration with Stripe directly from the command line. With the Stripe CLI, it’s easy to perform many common tasks like calling Stripe APIs, testing your webhooks integration, and creating an application.

Start with a guide

Get started with the Stripe CLI

Install the Stripe CLI on macOS, Windows, and Linux and get started with a YouTube video from Developer Advocacy.

Enable autocompletion for the Stripe CLI

Enable autocompletion so that the Stripe CLI automatically completes your commands.

Stripe CLI keys and permissions

Learn about Stripe CLI keys, where they’re stored locally, and where to find their permissions.

Upgrade the Stripe CLI

Take advantage of the latest features of the Stripe CLI.

Reference guides

Use these reference guides to explore the CLI and Stripe APIs.

Log into Stripe to authenticate requests

Log in and authenticate your Stripe user account to generate a set of restricted keys. To learn more, see Stripe CLI keys and permissions.

Command Line
stripe login

Press the Enter key on your keyboard to complete the authentication process in your browser.

Output
Your pairing code is: enjoy-enough-outwit-win This pairing code verifies your authentication with Stripe. Press Enter to open the browser or visit https://dashboard.stripe.com/stripecli/confirm_auth?t=THQdJfL3x12udFkNorJL8OF1iFlN8Az1 (^C to quit)

Specify an API version while running requests

When you call Stripe APIs in the CLI, it uses your default API version in all requests, which you can identify in Workbench. To try out different API versions in the CLI, use the following flags:

FlagDescriptionExample
–stripe-version 2025-05-28.basilUse the --stripe-version flag in any CLI request to specify an API version.stripe products create --name=“My Product” --stripe-version 2025-05-28.basil
--latestUse the --latest flag in any CLI request to specify the latest API version.stripe products create --name="My Product" --latest

You can also view a list of API versions.

Stream request logs

Use the stripe logs tail command to stream API request logs. Keep this window open. If you have an error in your API calls, this terminal returns the API error message and a reason for the error.

Command Line
stripe logs tail

Forward events to your local webhook endpoint

Use the --forward-to flag to send all Stripe events in a sandbox to your local webhook endpoint. To disable HTTPS certificate verification, use the --skip-verify flag.

Command Line
stripe listen --forward-to localhost:4242/webhooks
Output
Ready! Your webhook signing secret is '{{WEBHOOK_SIGNING_SECRET}}' (^C to quit)

To forward specific events in a comma separated list, use the --events flag.

Command Line
stripe listen --events payment_intent.created,customer.created,payment_intent.succeeded,charge.succeeded,checkout.session.completed,charge.failed \ --forward-to localhost:4242/webhook

If you’ve already registered your endpoint in Stripe, you can use the --load-from-webhooks-api and --forward-to flags.

Command Line
stripe listen --load-from-webhooks-api --forward-to localhost:4242

This command forwards events sent to your Stripe-registered public webhook endpoint to your local webhook endpoint. It loads your registered endpoint, parses the path and its registered events, then appends the path to your local webhook endpoint in the --forward-to path. If you’re checking webhook signatures, use the {{WEBHOOK_SIGNING_SECRET}} from the initial output of the listen command.

List all available events

Use the –help flag to list all possible events that can occur for an event category. For example, to list all possible events for the prebuilt checkout page for Stripe Checkout:

Command Line
stripe trigger checkout --help

Create a one-time product and price

  1. Make a single API request to Create a product.
Command Line
stripe products create \ --name="My First Product" \ --description="Created with the Stripe CLI"
  1. Look for the product identifier (in id) in the response object. Save it for the next step.

If everything worked, the command-line displays the following response.

{ "id":
"prod_LTenIrmp8Q67sa"
, "object": "product",
  1. Call Create a price to attach a price of 30 USD. Swap the placeholder in product with your product identifier (for example, prod_LTenIrmp8Q67sa).
Command Line
stripe prices create \ --unit-amount=3000 \ --currency=usd \ --product=
{{PRODUCT_ID}}

If everything worked, the command-line displays the following response.

{ "id":
"price_1KzlAMJJDeE9fu01WMJJr79o"
, "object": "price",

Trigger a webhook event while testing

Trigger the checkout.session.completed event to create the API objects that result from a checkout session successfully completing.

Command Line
stripe trigger checkout.session.completed

Your stripe listen terminal displays the following output:

Command Line
Setting up fixture for: checkout_session Running fixture for: checkout_session Setting up fixture for: payment_page Running fixture for: payment_page Setting up fixture for: payment_method Running fixture for: payment_method Setting up fixture for: payment_page_confirm Running fixture for: payment_page_confirm Trigger succeeded!

To learn more about triggers, read our guide.

此页面的内容有帮助吗?
是否
需要帮助?联系支持。
加入我们的早期使用计划。
查看我们的更改日志。
有问题?联系销售。
LLM? Read llms.txt.
Powered by Markdoc