lib/active_merchant/billing/integrations/payu_in/notification.rb in activemerchant-1.42.2 vs lib/active_merchant/billing/integrations/payu_in/notification.rb in activemerchant-1.42.3

- old
+ new

@@ -13,32 +13,24 @@ def complete? status == "Completed" end def status - @status ||= if checksum_ok? - if transaction_id.blank? - 'Invalid' - else - case transaction_status.downcase - when 'success' then 'Completed' - when 'failure' then 'Failed' - when 'pending' then 'Pending' - end - end - else - 'Tampered' + case transaction_status.downcase + when 'success' then 'Completed' + when 'failure' then 'Failed' + when 'pending' then 'Pending' end end def invoice_ok?( order_id ) order_id.to_s == invoice.to_s end # Order amount should be equal to gross - discount def amount_ok?( order_amount, order_discount = BigDecimal.new( '0.0' ) ) - BigDecimal.new( gross ) == order_amount && BigDecimal.new( discount ) == order_discount + BigDecimal.new( gross ) == order_amount && BigDecimal.new( discount.to_s ) == order_discount end # Status of transaction return from the PayU. List of possible values: # <tt>SUCCESS</tt>:: # <tt>PENDING</tt>:: @@ -127,14 +119,11 @@ :city => params['city'], :state => params['state'], :country => params['country'], :zipcode => params['zipcode'] } end def user_defined - return @user_defined if @user_defined - @user_defined = [] - 10.times{ |i| @user_defined.push( params[ "udf#{i+1}" ] ) } - @user_defined + @user_defined ||= 10.times.map { |i| params["udf#{i + 1}"] } end def checksum params['hash'] end @@ -146,12 +135,12 @@ def acknowledge(authcode = nil) checksum_ok? end def checksum_ok? - fields = user_defined.dup.push( customer_email, customer_first_name, product_info, gross, invoice, :reverse => true ) - fields.unshift( transaction_status ) - unless PayuIn.checksum(@merchant_id, @secret_key, *fields ) == checksum + checksum_fields = [transaction_status, *user_defined.reverse, customer_email, customer_first_name, product_info, gross, invoice] + + unless Digest::SHA512.hexdigest([@secret_key, *checksum_fields, @merchant_id].join("|")) == checksum @message = 'Return checksum not matching the data provided' return false end true end