Skip to content

[Bug] Stripe Webhook 报错 500,因 API 版本不兼容 (强制要求 2024-11-20) #7

@lpx8898

Description

@lpx8898

问题描述
对于新注册的 Stripe 账号,默认 API 版本已更新为 2026-01-28。但是面板后端代码中引用的 stripe-go 库强制校验 API 版本为 2024-11-20。 这导致 Stripe 发送的回调通知被后端拒绝,报错 500 Internal Server Error,订单无法自动回调到账。

复现步骤
使用一个新的 Stripe 账号(默认 API 版本为 2026-01-28)。

在后台配置 Stripe 支付。

用户发起支付并成功付款。

Stripe 发送 payment_intent.succeeded Webhook 通知。

后端报错 500。
错误日志
后端日志显示如下:

[StripeNotify] error caller=notify/stripeNotifyLogic.go:62 errors=Received event with API version 2026-01-28.clover, but stripe-go 81.1.0 expects API version 2024-11-20.acacia.
...
Otherwise, you can disable this error by using `ConstructEventWithOptions(..., ConstructEventOptions{..., ignoreAPIVersionMismatch: true})`

临时解决方案
我目前通过 Stripe CLI 强制创建了一个旧版本 (2024-11-20) 的 Webhook,并手动修改数据库中的 webhook_secret 才解决此问题。

修复建议
建议开发者:
升级 stripe-go 依赖库以支持最新版 Stripe API。
或者在代码中处理 Webhook 时,使用 IgnoreAPIVersionMismatch: true 选项来忽略版本检查,以兼容新老账号。

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions