stripe-rails icon indicating copy to clipboard operation
stripe-rails copied to clipboard

after_stripe_event! not called after code reload

Open heaven opened this issue 3 years ago • 4 comments

include Stripe::Callbacks

after_stripe_event! do |target, event|
  Billing::Event.create!(stripe_id: event.id, kind: event.type, data: event.to_hash)
end

The code above works well after the app restart. Once I modify the code the app gets reloaded and the callback is never called again.

Can reproduce from rails console

3.1.1 :002 > ::Stripe::Callbacks::critical_callbacks
 => {"stripe.event"=>[#<Proc:0x00000001163479b8 /Users/heaven/Workspace/mdc/app/models/member.rb:30>]}
3.1.1 :003 > reload!
Reloading...
 => true
3.1.1 :004 > ::Stripe::Callbacks::critical_callbacks
 => {}

To reproduce the problem config.eager_load should be true in development.

Rails: 7.0.2 Rails env: development Stripe: 6.5.0 (same with 6.1.0) Stripe Rails: 2.3.4

heaven avatar Jul 04 '22 11:07 heaven

Same issue here. I was going crazy trying to figure out why the callbacks aren't showing up. Probably going to switch back to the basic Stripe gem until this is fixed.

kbrgl avatar Jul 11 '22 11:07 kbrgl

This is a quite serious issue and breaks the development process completely. Can anyone have a look, please? All versions starting from 2.0.0 are affected.

heaven avatar Jul 17 '22 16:07 heaven

Hi folks, I'm currently busy with work right now and won't have time to look at this for at least a few more weeks. If you'd like to take a stab at this, I'll be happy to look at your PR!

Here are some past work on this that might point to why it's broken right now,

  • https://github.com/tansengming/stripe-rails/pull/137
  • https://github.com/tansengming/stripe-rails/pull/159

tansengming avatar Jul 18 '22 00:07 tansengming

+1

XORwell avatar Aug 28 '22 18:08 XORwell