Class: StripeRails::CallbacksController

Inherits:
ApplicationController show all
Defined in:
app/controllers/stripe_rails/callbacks_controller.rb

Instance Method Summary collapse

Instance Method Details

#postObject



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'app/controllers/stripe_rails/callbacks_controller.rb', line 5

def post
  data = JSON.parse(request.body.read)
  callback_class = (data['type'].gsub(/\./,'_') + '_callback').camelize

  # Render not implemented (501) if the callback does not exist.

  return head :not_implemented unless Object.autoload_const_defined?(callback_class) && callback_class.constantize.superclass == StripeRails::Callback

  callback = callback_class.constantize.new(data)

  callback.actions

  render json: callback.response

end