Class: OgoneRails::StringToHash

Inherits:
Object
  • Object
show all
Defined in:
lib/ogone-rails/string-to-hash.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeStringToHash

Returns a new instance of StringToHash.



6
7
8
9
# File 'lib/ogone-rails/string-to-hash.rb', line 6

def initialize
  @params = {}
  @sha_in_phrase = ""
end

Instance Attribute Details

#sha_in_phraseObject

Returns the value of attribute sha_in_phrase.



4
5
6
# File 'lib/ogone-rails/string-to-hash.rb', line 4

def sha_in_phrase
  @sha_in_phrase
end

Instance Method Details

#add_parameter(key, value) ⇒ Object



11
12
13
# File 'lib/ogone-rails/string-to-hash.rb', line 11

def add_parameter key, value
  @params[key.upcase] = value
end

#generate_sha_inObject



15
16
17
18
19
20
21
# File 'lib/ogone-rails/string-to-hash.rb', line 15

def generate_sha_in
  @params.sort.each do |key, value|
    @sha_in_phrase << "#{key.upcase}=#{value}#{OgoneRails::sha_in}"
  end
  
  Digest::SHA1.hexdigest(@sha_in_phrase).upcase
end

#get_stringObject



23
24
25
26
27
28
# File 'lib/ogone-rails/string-to-hash.rb', line 23

def get_string
  string = ""
  @params.each do |key, value|
    string << "#{key}=#{value}"
  end
end