Class: OffsitePayments::Integrations::Epay::Helper
- Defined in:
- lib/offsite_payments/integrations/epay.rb
Instance Attribute Summary
Attributes inherited from Helper
Instance Method Summary collapse
- #form_fields ⇒ Object
-
#format_order_number(number) ⇒ Object
Limited to 20 digits max.
- #generate_md5hash ⇒ Object
- #generate_md5string ⇒ Object
-
#initialize(order, merchantnumber, options = {}) ⇒ Helper
constructor
A new instance of Helper.
- #md5secret(value) ⇒ Object
Methods inherited from Helper
#add_field, #add_fields, #add_raw_html_field, #billing_address, #form_method, inherited, mapping, #raw_html_fields, #shipping_address, #test?
Methods included from MoneyCompatibility
Constructor Details
#initialize(order, merchantnumber, options = {}) ⇒ Helper
Returns a new instance of Helper.
16 17 18 19 20 21 22 |
# File 'lib/offsite_payments/integrations/epay.rb', line 16 def initialize(order, merchantnumber, = {}) super add_field('windowstate', 3) add_field('language', '0') add_field('orderid', format_order_number(order)) @fields = Hash[@fields.sort] end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class OffsitePayments::Helper
Instance Method Details
#form_fields ⇒ Object
28 29 30 |
# File 'lib/offsite_payments/integrations/epay.rb', line 28 def form_fields @fields.merge('hash' => generate_md5hash) end |
#format_order_number(number) ⇒ Object
Limited to 20 digits max
41 42 43 |
# File 'lib/offsite_payments/integrations/epay.rb', line 41 def format_order_number(number) number.to_s.gsub(/[^\w_]/, '').rjust(4, "0")[0...20] end |
#generate_md5hash ⇒ Object
36 37 38 |
# File 'lib/offsite_payments/integrations/epay.rb', line 36 def generate_md5hash Digest::MD5.hexdigest(generate_md5string) end |
#generate_md5string ⇒ Object
32 33 34 |
# File 'lib/offsite_payments/integrations/epay.rb', line 32 def generate_md5string @fields.sort.each.map { |key, value| key != 'hash' ? value.to_s : ''} * "" + @md5secret end |
#md5secret(value) ⇒ Object
24 25 26 |
# File 'lib/offsite_payments/integrations/epay.rb', line 24 def md5secret(value) @md5secret = value end |