Class: OgoneRails::CheckAuth
- Inherits:
-
Object
- Object
- OgoneRails::CheckAuth
- Defined in:
- lib/ogone-rails/check-auth.rb
Instance Method Summary collapse
- #get_params ⇒ Object
-
#initialize(request) ⇒ CheckAuth
constructor
A new instance of CheckAuth.
- #valid? ⇒ Boolean
Constructor Details
#initialize(request) ⇒ CheckAuth
Returns a new instance of CheckAuth.
6 7 8 9 10 11 12 13 |
# File 'lib/ogone-rails/check-auth.rb', line 6 def initialize request @request = request.GET # clear empty keys @request.delete_if { |k,v| v.empty? } @params = {} get_params end |
Instance Method Details
#get_params ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/ogone-rails/check-auth.rb', line 43 def get_params # return values in readable format @params = { :order_id => (@request['orderID']), :amount => (@request['amount']).to_f, :currency => @request['currency'], :payment_method => @request['PM'], :acceptance => @request['ACCEPTANCE'], :status => STATUS_CODES[@request['STATUS'].to_i], :card_number => @request['CARDNO'], :pay_id => @request['PAYID'], :error => @request['NC ERROR'], :brand => @request['BRAND'], :sha_sign => @request['SHASIGN'] } end |
#valid? ⇒ Boolean
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/ogone-rails/check-auth.rb', line 16 def valid? # Check authentication # sha_sign == sha_out_phrase sha_sign, sha_out_phrase, ogone_return = @request['SHASIGN'], "", {} # Upcase and sort paramaters to params @request.each do |key, value| ogone_return[key.upcase] = value unless key == 'SHASIGN' # exclude SHASIGN end # Generate sha_out_hash ogone_return.sort.each do |key, value| sha_out_phrase << "#{key.upcase}=#{value}#{OgoneRails::sha_out}" end # Digest sha_out_phrase sha_check = Digest::SHA1.hexdigest(sha_out_phrase).upcase # Compare sha_sign with digested phrase if sha_check == sha_sign return true else return false end end |