Sha256: 0482ae14d020c1d26a2ffa30860ed7349cb6e2867c1a21c3d446e416d0718fb8

Contents?: true

Size: 1.17 KB

Versions: 1

Compression:

Stored size: 1.17 KB

Contents

module Unitpay
  module Controller
    # Skip RequestForgeryProtection
    # skip_before_filter :verify_authenticity_token

    class ServiceNotImplemented < StandardError; end
    class PayMethodNotImplemented < StandardError; end
    class ErrorMethodNotImplemented < StandardError; end
    class RuntimeException < StandardError; end

    def notify
      if service.valid_notify_sign?(params[:params])
        send(params[:method])
        success_request
      else
        fail_request
      end
    rescue RuntimeException => e
      fail_request(e.message)
    end

    def success
      warn 'NotImplementedError'
    end

    def fail
      warn 'NotImplementedError'
    end

    private

    def service
      raise ServiceNotImplemented
    end

    def check
      warn 'NotImplementedError'
    end

    def pay
      raise PayMethodNotImplemented
    end

    def error
      raise ErrorMethodNotImplemented
    end

    def success_request
      render json: { result: { message: 'Запрос успешно обработан' } }
    end

    def fail_request(message = 'Неверная сигнатура')
      render json: { error: { message: message } }
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
unitpay-0.2 lib/unitpay/controller.rb