Class: MerbMerchant::Billing::Integrations::Quickpay::Helper

Inherits:
Helper
  • Object
show all
Defined in:
lib/merb_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, #billing_address, mapping, #shipping_address

Constructor Details

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

Returns a new instance of Helper.



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

def initialize(order, , options = {})
  super
  add_field('protocol', '3')
  add_field('msgtype', 'authorize')
  add_field('language', 'da')
  add_field('autocapture', 0)
  add_field('testmode', 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 MerbMerchant::Billing::Integrations::Helper

Instance Method Details

#form_fieldsObject



21
22
23
# File 'lib/merb_merchant/billing/integrations/quickpay/helper.rb', line 21

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

#format_order_number(number) ⇒ Object

Limited to 20 digits max



34
35
36
# File 'lib/merb_merchant/billing/integrations/quickpay/helper.rb', line 34

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

#generate_md5checkObject



29
30
31
# File 'lib/merb_merchant/billing/integrations/quickpay/helper.rb', line 29

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

#generate_md5stringObject



25
26
27
# File 'lib/merb_merchant/billing/integrations/quickpay/helper.rb', line 25

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

#md5secret(value) ⇒ Object



17
18
19
# File 'lib/merb_merchant/billing/integrations/quickpay/helper.rb', line 17

def md5secret(value)
  @md5secret = value
end