Module: Rubykassa::SignatureGenerator
- Included in:
- Notification, PaymentInterface
- Defined in:
- lib/rubykassa/signature_generator.rb
Constant Summary collapse
- KIND_ERROR_MESSAGE =
'Available kinds are only :payment, :result or :success'.freeze
Instance Method Summary collapse
Instance Method Details
#custom_params ⇒ Object
25 26 27 28 29 30 |
# File 'lib/rubykassa/signature_generator.rb', line 25 def custom_params @params.sort.inject([]) do |result, element| result << element.join('=') if element[0] =~ /^shp/ result end end |
#generate_signature_for(kind) ⇒ Object
6 7 8 9 10 11 |
# File 'lib/rubykassa/signature_generator.rb', line 6 def generate_signature_for(kind) unless [:success, :payment, :result].include?(kind) raise ArgumentError, KIND_ERROR_MESSAGE end method(Rubykassa.hash_algorithm).call params_string(kind) end |
#params_string(kind) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/rubykassa/signature_generator.rb', line 13 def params_string kind result = case kind when :payment [Rubykassa.login, @total, @invoice_id, @receipt, Rubykassa.first_password, custom_params] when :result [@total, @invoice_id, Rubykassa.second_password, custom_params] when :success [@total, @invoice_id, Rubykassa.first_password, custom_params] end result.flatten.join ':' end |