Class: OgoneRails::StringToHash
- Inherits:
-
Object
- Object
- OgoneRails::StringToHash
- Defined in:
- lib/ogone-rails/string-to-hash.rb
Instance Attribute Summary collapse
-
#sha_in_phrase ⇒ Object
Returns the value of attribute sha_in_phrase.
Instance Method Summary collapse
- #add_parameter(key, value) ⇒ Object
- #generate_sha_in ⇒ Object
- #get_string ⇒ Object
-
#initialize ⇒ StringToHash
constructor
A new instance of StringToHash.
Constructor Details
#initialize ⇒ StringToHash
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_phrase ⇒ Object
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_in ⇒ Object
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_string ⇒ Object
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 |