Rails 4,条带集成,Webhook错误

时间:2016-11-02 14:46:36

标签: ruby-on-rails stripe-payments

我有一个与Stripe集成的rails应用程序,我使用stripe_events gem来处理webhooks。

然而,当收到webhook时,我收到以下错误。

NoMethodError - undefined method `[]' for ActiveSupport::Notifications::Fanout::Subscribers::Timed:0x007fde814aaee0

stripe_event (1.5.0) lib/stripe_event.rb:28:in `instrument'
stripe_event (1.5.0) app/controllers/stripe_event/webhook_controller.rb:12:in `event'
actionpack (4.2.5.2) lib/action_controller/metal/implicit_render.rb:4:in `send_action'

有谁知道这是指什么?

这是我的stripe_events.rb文件

StripeEvent.event_retriever = lambda do |params|
  return nil if StripeWebhook.exists?(stripe_id: params[:id])
  StripeWebhook.create!(stripe_id: params[:id])
  Stripe::Event.retrieve(params[:id])
end

StripeEvent.configure do |events|
  events.subscribe 'customer.subscription.created' do |event|   
    puts 'testing 123'
  end
end

1 个答案:

答案 0 :(得分:0)

我设法解决了这个问题...

事实证明我在#config / initializers / stripe.rb

中错过了一些代码
StripeEvent.configure do |events|
  events.subscribe 'charge.failed' do |event|
    # Define subscriber behavior based on the event object
    event.class       #=> Stripe::Event
    event.type        #=> "charge.failed"
    event.data.object #=> #<Stripe::Charge:0x3fcb34c115f8>
  end

  events.all do |event|
    # Handle all event types - logging, etc.
  end
end