【发布时间】:2017-10-21 03:37:08
【问题描述】:
我在使用 Ruby 2.1.5 的 Rails 4.0.6 应用程序中使用 stripe gem 和 stripe_event gem。在我尝试了 stripe_event gem 自述文件 (https://github.com/integrallis/stripe_event#authenticating-webhooks) 的“保护您的 webhook 端点”或“验证 webhook”部分之前,它一直运行良好。似乎这两个问题都有相似的行为,所以我将在这里只描述第二个问题。
当我尝试使用以下代码验证我的 webhook(在尝试此之前运行良好)时,我收到一个未初始化的常量错误。
#config/initializers/stripe.rb
Rails.configuration.stripe = {
:publishable_key => ENV['STRIPE_PUBLISHABLE_KEY'],
:secret_key => ENV['STRIPE_SECRET_KEY']
}
Stripe.api_key = Rails.configuration.stripe[:secret_key]
#this is the line that supposedly tells stripe_event to verify the stripe signature
StripeEvent.signing_secret = ENV['STRIPE_SIGNING_SECRET']
StripeEvent.configure do |events|
events.all do |event|
if event.type == 'invoice.payment_failed'
#handled this event...removed code for clarity since works fine
end
end
end
这是错误:
NameError stripe_event/webhook#event
uninitialized constant Stripe::SignatureVerificationError
我从我的 stripe 仪表板获得了 stripe 签名的秘密,如 Stripe 文档中所述:https://stripe.com/docs/webhooks#signatures
我一直在测试触发事件,如条纹文档中所述:https://stripe.com/docs/recipes/sending-emails-for-failed-payments#testing
对此的任何帮助将不胜感激。
【问题讨论】:
标签: ruby-on-rails ruby