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

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

Constant Summary collapse

CHECKSUM_FIELDS =
[ 'txnid', 'amount', 'productinfo', 'firstname', 'email', 'udf1', 'udf2', 'udf3', 'udf4',
'udf5', 'udf6', 'udf7', 'udf8', 'udf9', 'udf10']

Instance Attribute Summary

Attributes inherited from Helper

#fields

Instance Method Summary collapse

Methods inherited from Helper

#add_field, #add_fields, #add_raw_html_field, #billing_address, #form_method, mapping, #raw_html_fields, #shipping_address, #test?

Constructor Details

#initialize(order, account, options = {}) ⇒ Helper

Returns a new instance of Helper.



48
49
50
51
52
# File 'lib/active_merchant/billing/integrations/payu_in/helper.rb', line 48

def initialize(order, , options = {})
  super
  @options = options
  self.pg = 'CC'
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class ActiveMerchant::Billing::Integrations::Helper

Instance Method Details

#form_fieldsObject



54
55
56
57
# File 'lib/active_merchant/billing/integrations/payu_in/helper.rb', line 54

def form_fields
  sanitize_fields
  @fields.merge(mappings[:checksum] => generate_checksum)
end

#generate_checksumObject



59
60
61
62
63
# File 'lib/active_merchant/billing/integrations/payu_in/helper.rb', line 59

def generate_checksum
  checksum_payload_items = CHECKSUM_FIELDS.map { |field| @fields[field] }

  PayuIn.checksum(@fields["key"], @options[:credential2], checksum_payload_items )
end

#sanitize_fieldsObject



65
66
67
68
69
# File 'lib/active_merchant/billing/integrations/payu_in/helper.rb', line 65

def sanitize_fields
  ['address1', 'address2', 'city', 'state', 'country', 'productinfo', 'email', 'phone'].each do |field|
    @fields[field].gsub!(/[^a-zA-Z0-9\-_@\/\s.]/, '') if @fields[field]
  end
end