我正在构建一个小型 Golang 应用程序,需要使用 Stripe Checkout 执行两步付款。
为了了解何时捕获付款,我使用了 Stripe Webhook API。我创建了一个等待事件 payment_intent.succeeded
的小端点。从中我得到的 payment_intent.status
应该位于 “requires_capture”
。
Stripe 提供了一些测试环境来通过其 Stripe CLI 触发 webhook,不幸的是,不支持诸如 stripe trigger payment_intent.requires_capture
之类的东西(我使用的是 Stripe CLI v1.17.0)。
我想知道是否有办法使用 Stripe 工具(但如果有其他方法也可以)触发此类事件,以测试我的系统的捕获工作流程。
我尝试过的
我几乎遵循了 Stripe webhook 测试文档:
$ stripe login
$ stripe listen --forward-to localhost:2121/webhook
在另一个终端盘上,我做了:
stripe trigger payment_intent.requires_capture
The event ‘payment_intent.requires_capture’ is not supported by the Stripe CLI.
因此,当我触发 payment_intent.succeeded
时,我得到的 payment_intent.status
为 successeded
而不是 requires_capture
> 这是我所期望的。
最佳答案
stripe trigger
仅接受 payment_intent.succeeded
有效的事件类型。您可以在https://stripe.com/docs/api/events/types查看事件类型的完整列表。 .
您想要触发 payment_intent.succeeded
类型的自定义固定装置。最简单的方法是:
stripe trigger payment_intent.succeeded --edit
它将打开一个 json 文件。您可以修改它并在其参数中添加 "capture_method": "manual",
,然后保存文件以触发您的自定义事件。
您可以通过创建自己的夹具文件来修改更多其他参数,请参阅https://stackoverflow.com/a/60269842/3631795 .
关于go - 如何模拟 stripe 需要 webhooks 的捕获事件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/76919027/