Class: AppdirectIntegration::AppdirectCallbacksController

Inherits:
ApplicationController show all
Defined in:
app/controllers/appdirect_integration/appdirect_callbacks_controller.rb

Instance Method Summary collapse

Instance Method Details

#cancelObject



30
31
32
# File 'app/controllers/appdirect_integration/appdirect_callbacks_controller.rb', line 30

def cancel
  respond_to_event('cancel', 'CANCELLED')
end

#changeObject



26
27
28
# File 'app/controllers/appdirect_integration/appdirect_callbacks_controller.rb', line 26

def change
  respond_to_event('change')
end

#notifyObject



34
35
36
# File 'app/controllers/appdirect_integration/appdirect_callbacks_controller.rb', line 34

def notify
  respond_to_event('notify')
end

#orderObject



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'app/controllers/appdirect_integration/appdirect_callbacks_controller.rb', line 9

def order
  puts "Received order event from AppDirect, requesting info..."

  parsed_result = read_event_data()

  order = AppdirectIntegration.configuration.order_class.new
  order = build_order_object(parsed_result, order)

  order.status = 'ACTIVE' if order.respond_to?('status=')

  if order.save
    render json: success_response('Account creation successful', order.id.to_s)
  else
    render json: fault_response('Error creating account', 'UNKNOWN_ERROR')
  end
end