我的 ruby-on-rails 应用程序使用 stripe 进行卡支付。 Stripe 提供了 webhooks,通过它可以联系回我的应用程序并提供有关每个交易的详细信息 - 成功或失败。
为此,我在我的 Controller 中有这样的东西:
class StripeController < ApplicationController
def webhook
data_json = JSON.parse request.body.read
p data_json['data']['object']['customer']
end
我的问题是如何验证此 webhook 的真实性?据我所知和理解,可以很容易地模仿这一点(中间人攻击)。
最佳答案
来自 Stripe 的 webhooks documentation :
If security is a concern, or if it's important to confirm that Stripe sent the webhook, you should only use the ID sent in your webhook and should request the remaining details from the Stripe API directly.
关于ruby-on-rails - Stripe webhook 身份验证 - Ruby,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21824307/