Sha256: d00365393b9a2045cf8c14332406c56553803adb153275a9a36c334049c33c3c

Contents?: true

Size: 1.05 KB

Versions: 4

Compression:

Stored size: 1.05 KB

Contents

module Unitpay
  module Controller
    # Skip RequestForgeryProtection
    # skip_before_filter :verify_authenticity_token

    class ServiceNotImplementedError < StandardError; end
    class PayNotImplementedError < StandardError; end
    class ErrorNotImplementedError < StandardError; end

    def notify
      if service.valid_notify_sign?(params[:params])
        send(params[:method])
        success_request
      else
        fail_request
      end
    end

    def success
      warn 'NotImplementedError'
    end

    def fail
      warn 'NotImplementedError'
    end

    private

    def service
      raise ServiceNotImplementedError
    end

    def check
      warn 'NotImplementedError'
    end

    def pay
      raise PayNotImplementedError
    end

    def error
      raise ErrorNotImplementedError
    end

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

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

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
unitpay-0.1 lib/unitpay/controller.rb
unitpay-0.0.4 lib/unitpay/controller.rb
unitpay-0.0.3 lib/unitpay/controller.rb
unitpay-0.0.2 lib/unitpay/controller.rb