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

Stripe invoice.payment_failed事件触发失败求助

解决Stripe invoice.payment_failed 事件触发失败的问题

1. 清理冗余命令参数

你当前的命令重复添加了3次--add invoice:metadata.userId=7,还重复指定了多个customer参数,这会导致Stripe CLI解析时出现逻辑冲突。先简化命令:

./stripe.exe trigger invoice.payment_failed --override invoice:customer=cus_id123 --add invoice:metadata.userId=7

无需单独覆盖payment_method和invoiceitem的customer值——指定invoice:customer后,关联的支付方式和发票项会自动继承该客户信息。

2. 验证测试卡号的关联逻辑

测试卡号4000000000000341确实用于触发支付失败,但要注意两个关键点:

  • 该卡号仅在首次支付尝试时失败,若目标客户此前有成功支付记录,Stripe的自动重试机制可能延迟或覆盖失败事件;
  • 确保该客户的默认支付方式已绑定此测试卡号,而非其他有效测试卡。用以下命令检查:
./stripe.exe customers retrieve cus_id123

查看输出中default_payment_method对应的支付方式是否使用了4000000000000341卡号。

3. 手动触发支付失败流程

若直接用trigger命令仍无效,可手动走一遍完整流程排查:

  1. 创建关联目标客户的按使用量计费订阅:
./stripe.exe subscriptions create --customer cus_id123 --items price=你的按使用量计费价格ID
  1. 生成待支付发票:
./stripe.exe invoices create --customer cus_id123 --auto_advance=false
  1. 使用测试卡号绑定的支付方式尝试支付:
./stripe.exe invoices pay 生成的发票ID --payment_method 测试卡号对应的支付方式ID

此时应触发invoice.payment_failed事件,用以下命令查看:

./stripe.exe events list --type invoice.payment_failed

4. 升级Stripe CLI到最新版本

旧版本CLI的trigger命令可能存在bug,执行升级:

./stripe.exe update

5. 检查订阅的收款设置

确认订阅的collection_method为charge_automatically——若设置为send_invoice,系统不会自动发起支付,自然不会触发支付失败事件。修改命令:

./stripe.exe subscriptions update 订阅ID --collection_method charge_automatically

内容的提问来源于stack exchange,提问作者Rodrigo Carvalho

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.14 21:37:07