Class: ActiveMerchant::Billing::Integrations::PayuIn::Helper

Inherits:
Helper
  • Object
show all
Defined in:
lib/active_merchant/payu_in/helper.rb

Instance Method Summary collapse

Instance Method Details

#add_checksum(options = {}) ⇒ Object

Computes the checksum for the form data and add it to the field



47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/active_merchant/payu_in/helper.rb', line 47

def add_checksum(  options = {} )
  checksum_fields = [ :order, :amount, :credential2, { :customer => [ :first_name, :email ] },
    { :user_defined => [ :var1, :var2, :var3, :var4, :var5, :var6, :var7, :var8, :var9, :var10 ] } ]
  checksum_payload_items = checksum_fields.inject( [] ) do | items, field |
    if Hash === field then
      key = field.keys.first
      field[key].inject( items ){ |s,x| items.push( form_fields[ mappings[key][x] ] ) }
      # items.push( form_fields[ field.values.each{ |x| mappings[ key ][ x ] } ] )
    else
      items.push( form_fields[ mappings[field] ] )
    end
  end
  checksum_payload_items.push( options )
  checksum = PayuIn.checksum( *checksum_payload_items )
  add_field( mappings[:checksum], checksum )
  return checksum_payload_items
end