lib/payanyway/helpers/signature_generator.rb in payanyway-1.2.2 vs lib/payanyway/helpers/signature_generator.rb in payanyway-1.2.3
- old
+ new
@@ -2,10 +2,11 @@
module Payanyway
module Helpers
class SignatureGenerate
BASE_KEYS = %w(
+ moneta_id
MNT_TRANSACTION_ID
MNT_OPERATION_ID
MNT_AMOUNT
MNT_CURRENCY_CODE
MNT_SUBSCRIBER_ID
@@ -29,14 +30,20 @@
private
def generate_by(params, keys)
values = keys.map { |key| get_value(params, key) }.join
- md5(Payanyway::Gateway.config['moneta_id'].to_s + values + Payanyway::Gateway.config['token'])
+ md5(values + Payanyway::Gateway.config['token'])
end
def get_value(params, key)
- (key == 'MNT_AMOUNT' && params[key].present?) ? '%.2f' % params[key] : params[key]
+ if key == 'MNT_AMOUNT' && params[key].present?
+ '%.2f' % params[key]
+ elsif key == 'moneta_id'
+ Payanyway::Gateway.config['moneta_id'].to_s
+ else
+ params[key]
+ end
end
def md5(str)
Digest::MD5.hexdigest(str).downcase
end
\ No newline at end of file