What I would do is make a new directory app/stripe_handlers
and stick that code in a file named customer_created.rb
. Any code in app/
gets automagically loaded by Rails. You could also stick it somewhere in lib/
but it wouldn't get autoloaded.
You would put your handler from your question in app/stripe_handlers/customer_created.rb
, then in config/initializers/stripe_event.rb
you would say something like:
StripeEvent.configure do |events|
events.subscribe 'customer.created', CustomerCreated.new
end
When StripeEvent
gets an event with type customer.created
it will call the call
method on the instance of CustomerCreated
that you made in the initializer.