Module: ZaakpayRuby
- Defined in:
- lib/zaakpay_ruby.rb,
lib/zaakpay_ruby/request.rb,
lib/zaakpay_ruby/version.rb,
lib/zaakpay_ruby/response.rb,
lib/zaakpay_ruby/transaction.rb,
lib/generators/zaakpay_ruby/install_generator.rb
Defined Under Namespace
Modules: Generators Classes: Configuration, Request, Response, Transaction
Constant Summary collapse
- VERSION =
"0.2.2"
Class Attribute Summary collapse
-
.configuration ⇒ Object
Returns the value of attribute configuration.
Class Method Summary collapse
- .configure {|configuration| ... } ⇒ Object
-
.generate_checksum(params_hash) ⇒ Object
This is where the checksum generation happens arguements: a parameters hash.
-
.sort_params(params_hash) ⇒ Object
This is a helper method for generating ZaakpayRuby checksum It sorts the parameters hash in ascending order of the keys arguments: a parameters hash return value: a hash with sorted in ascending order of keys It is not using now but would keep for the future.
Class Attribute Details
.configuration ⇒ Object
Returns the value of attribute configuration.
19 20 21 |
# File 'lib/zaakpay_ruby.rb', line 19 def configuration @configuration end |
Class Method Details
.configure {|configuration| ... } ⇒ Object
26 27 28 |
# File 'lib/zaakpay_ruby.rb', line 26 def self.configure yield(configuration) if block_given? end |
.generate_checksum(params_hash) ⇒ Object
This is where the checksum generation happens arguements: a parameters hash. return value: HMAC-SHA-256 checksum usign the Key
33 34 35 36 37 38 39 40 |
# File 'lib/zaakpay_ruby.rb', line 33 def self.generate_checksum(params_hash) #sorted_params = self.sort_params(params_hash) paramsstring = "" params_hash.each {|key, value| paramsstring += "'" + value.to_s + "'" } checksum = OpenSSL::HMAC.hexdigest('sha256', ZaakpayRuby.configuration.secret_key, paramsstring) end |
.sort_params(params_hash) ⇒ Object
This is a helper method for generating ZaakpayRuby checksum It sorts the parameters hash in ascending order of the keys arguments: a parameters hash return value: a hash with sorted in ascending order of keys It is not using now but would keep for the future
48 49 50 51 52 53 54 55 |
# File 'lib/zaakpay_ruby.rb', line 48 def self.sort_params(params_hash) sorted_params_hash = {} sorted_keys = params_hash.keys.sort{|x,y| x <=> y} sorted_keys.each do |k| sorted_params_hash[k] = params_hash[k] end sorted_params_hash end |