Stripe CLI不支持触发reporting.report_run.failed事件,求替代方案
使用Stripe CLI配置监听器后,尝试通过stripe trigger reporting.report_run.failed命令触发对应Webhook事件时,收到错误提示:
The event 'reporting.report_run.failed' is not supported by the Stripe CLI.
目前stripe trigger reporting.report_run.succeeded可正常执行,仅reporting.report_run.failed事件不被Stripe CLI支持,寻求其他强制触发该事件的方法。
手动构造并发送模拟事件
先通过stripe trigger reporting.report_run.succeeded获取成功事件的payload,修改其中的type字段为reporting.report_run.failed,将data.object.status改为failed,按需补充错误相关字段。之后用curl把构造好的payload发送到你的Webhook接收地址:curl -X POST http://localhost:3000/webhook \ -H "Content-Type: application/json" \ -H "Stripe-Signature: t=1234567890,v1=abcdef123456..." \ -d '{ "id": "evt_123456", "object": "event", "api_version": "2024-06-20", "created": 1234567890, "data": { "object": { "id": "frr_123456", "object": "reporting.report_run", "status": "failed", "error": { "message": "Simulated report run failure" } // 复制成功事件中的其他必要字段 } }, "type": "reporting.report_run.failed" }'注意:本地测试时可暂时跳过签名验证,正式环境需使用正确的签名。
通过Stripe API主动生成失败报告任务
调用Stripe API创建报告运行时传入无效参数,强制触发失败:curl -X POST https://api.stripe.com/v1/reporting/report_runs \ -u sk_test_your_secret_key: \ -d report_type=invalid_report_type \ -d parameters[interval_start]=1609459200无效的
report_type会导致报告运行失败,Stripe会自动向已配置的Webhook端点发送reporting.report_run.failed事件。利用Stripe Dashboard重新发送事件
先通过上面的API方法生成一个真实的reporting.report_run.failed事件,然后在Stripe Dashboard的「事件」列表中找到该事件,点击「重新发送」按钮,将事件发送到你的测试Webhook端点。
内容的提问来源于stack exchange,提问作者Zabs

