Class: ActiveMerchant::Billing::Integrations::Quickpay::Helper

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

Constant Summary collapse

MD5_CHECK_FIELDS =
[
  :protocol, :msgtype, :merchant, :language, :ordernumber, 
  :amount, :currency, :continueurl, :cancelurl, :callbackurl,
  :autocapture, :cardtypelock, :description, :ipaddress, :testmode
]

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.



7
8
9
10
11
12
13
14
15
16
# File 'lib/active_merchant/billing/integrations/quickpay/helper.rb', line 7

def initialize(order, , options = {})
  md5secret options.delete(:credential2)
  super
  add_field('protocol', '3')
  add_field('msgtype', 'authorize')
  add_field('language', 'da')
  add_field('autocapture', 0)
  add_field('testmode', test? ? 1 : 0)
  add_field('ordernumber', format_order_number(order))
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



22
23
24
# File 'lib/active_merchant/billing/integrations/quickpay/helper.rb', line 22

def form_fields
  @fields.merge('md5check' => generate_md5check)
end

#format_order_number(number) ⇒ Object

Limited to 20 digits max



35
36
37
# File 'lib/active_merchant/billing/integrations/quickpay/helper.rb', line 35

def format_order_number(number)
  number.to_s.gsub(/[^\w_]/, '').rjust(4, "0")[0...20]
end

#generate_md5checkObject



30
31
32
# File 'lib/active_merchant/billing/integrations/quickpay/helper.rb', line 30

def generate_md5check
  Digest::MD5.hexdigest(generate_md5string)
end

#generate_md5stringObject



26
27
28
# File 'lib/active_merchant/billing/integrations/quickpay/helper.rb', line 26

def generate_md5string
  MD5_CHECK_FIELDS.map {|key| @fields[key.to_s]} * "" + @md5secret
end

#md5secret(value) ⇒ Object



18
19
20
# File 'lib/active_merchant/billing/integrations/quickpay/helper.rb', line 18

def md5secret(value)
  @md5secret = value
end