You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何用Stripe CLI转发本地事件至预发布环境Webhook并使用自定义签名密钥?

关于Stripe CLI自定义Webhook签名密钥转发事件的问题

问题背景

我已在应用中集成Stripe争议功能并部署了Webhook,现希望通过本地CLI将dispute.created事件转发至预发布环境的Webhook,执行命令如下:

➜ ./stripe listen --forward-to https://myapp.stage.app/stripe/webhook/event

执行后控制台生成新的Webhook签名密钥:

A newer version of the Stripe CLI is available, please update to: v1.19.4
> Ready! You are using Stripe API Version [2020-03-02]. 
Your webhook signing secret is whsec_local_secret (^C to quit)

请问是否可以使用自定义Webhook签名密钥进行事件转发?由于测试面板无法将付款标记为争议,我暂无其他测试争议集成的方法。

解答

  • 自定义签名密钥转发的实现方式:Stripe CLI支持使用自定义签名密钥进行事件转发,只需在执行监听命令时添加--signing-secret参数,指定你的自定义密钥即可。示例命令如下:

    ./stripe listen --forward-to https://myapp.stage.app/stripe/webhook/event --signing-secret whsec_your_custom_secret
    

    执行该命令后,CLI转发事件时会用你指定的自定义密钥生成签名,预发布环境的Webhook验证逻辑可直接沿用已配置的密钥完成签名校验。

  • 测试争议事件的替代方案:如果测试面板无法标记付款为争议,你可以直接用Stripe CLI触发测试版的dispute.created事件,命令如下:

    ./stripe trigger dispute.created
    

    该命令会自动模拟生成一条测试争议事件,并通过当前监听的转发地址发送到预发布环境。若需要自定义争议的关联付款、争议类型等细节,可添加--params参数指定:

    ./stripe trigger dispute.created --params "payment_intent=pi_test_your_payment_id"
    

内容的提问来源于stack exchange,提问作者Shubham A.

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.25 21:03:14