Module: Payanyway::Controller

Extended by:
ActiveSupport::Concern
Defined in:
lib/payanyway/controller.rb

Instance Method Summary collapse

Instance Method Details

#checkObject



51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/payanyway/controller.rb', line 51

def check
  request = Payanyway::Request::Check.new(permitted_params)
  if request.pretty_params.present?
    raise request.error_message unless request.success?

    render xml: request.response(check_implementation(request.pretty_params)).to_xml
  else
    # Не выдавать ошибку, если параметры пустые
    # Необходимо для проверки со стороны moneta.ru
    head :ok
  end
end

#failObject



33
34
35
36
37
# File 'lib/payanyway/controller.rb', line 33

def fail
  request = Payanyway::Request::Base.new(permitted_params)

  fail_implementation(request.pretty_params[:transaction_id])
end

#in_progressObject



45
46
47
48
49
# File 'lib/payanyway/controller.rb', line 45

def in_progress
  request = Payanyway::Request::Base.new(permitted_params)

  in_progress_implementation(request.pretty_params[:transaction_id])
end

#payObject



14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/payanyway/controller.rb', line 14

def pay
  request = Payanyway::Request::Pay.new(permitted_params)
  request.success? ?
    pay_implementation(request.pretty_params) :
    Rails.logger.error(request.error_message)

  if Gem::Version.new(Rails.version) < Gem::Version.new('5.1')
    render text: request.response
  else
    render plain: request.response
  end
end

#returnObject



39
40
41
42
43
# File 'lib/payanyway/controller.rb', line 39

def return
  request = Payanyway::Request::Base.new(permitted_params)

  return_implementation(request.pretty_params[:transaction_id])
end

#successObject



27
28
29
30
31
# File 'lib/payanyway/controller.rb', line 27

def success
  request = Payanyway::Request::Base.new(permitted_params)

  success_implementation(request.pretty_params)
end