Class: ActiveMerchant::Billing::Integrations::Maksuturva::Helper

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

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.



6
7
8
9
10
11
12
13
# File 'lib/active_merchant/billing/integrations/maksuturva/helper.rb', line 6

def initialize(order, , options = {})
  md5secret options.delete(:credential2)
  super
  add_field("pmt_action", "NEW_PAYMENT_EXTENDED")
  add_field("pmt_version", "0004")
  add_field("pmt_sellerid", )
  add_field("pmt_hashversion", "MD5")
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



19
20
21
# File 'lib/active_merchant/billing/integrations/maksuturva/helper.rb', line 19

def form_fields
  @fields.merge("pmt_hash" => generate_md5string)
end

#generate_md5stringObject



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/active_merchant/billing/integrations/maksuturva/helper.rb', line 23

def generate_md5string
  fields = [@fields["pmt_action"], @fields["pmt_version"]]
  fields += [@fields["pmt_selleriban"]] unless @fields["pmt_selleriban"].nil?
  fields += [@fields["pmt_id"], @fields["pmt_orderid"], @fields["pmt_reference"], @fields["pmt_duedate"],
  @fields["pmt_amount"], @fields["pmt_currency"], @fields["pmt_okreturn"], @fields["pmt_errorreturn"], @fields["pmt_cancelreturn"],
  @fields["pmt_delayedpayreturn"], @fields["pmt_escrow"], @fields["pmt_escrowchangeallowed"]]

  fields += [@fields["pmt_invoicefromseller"]] unless @fields["pmt_invoicefromseller"].nil?
  fields += [@fields["pmt_paymentmethod"]] unless @fields["pmt_paymentmethod"].nil?
  fields += [@fields["pmt_buyeridentificationcode"]] unless @fields["pmt_buyeridentificationcode"].nil?


  fields += [@fields["pmt_buyername"], @fields["pmt_buyeraddress"], @fields["pmt_buyerpostalcode"], @fields["pmt_buyercity"],
  @fields["pmt_buyercountry"], @fields["pmt_deliveryname"], @fields["pmt_deliveryaddress"], @fields["pmt_deliverypostalcode"], @fields["pmt_deliverycity"],
  @fields["pmt_deliverycountry"], @fields["pmt_sellercosts"]]

  (1..@fields["pmt_rows"].to_i).each do |i|
    fields += [@fields["pmt_row_name#{i}"], @fields["pmt_row_desc#{i}"], @fields["pmt_row_quantity#{i}"]]
    fields += [@fields["pmt_row_articlenr#{i}"]] unless @fields["pmt_row_articlenr#{i}"].nil?
    fields += [@fields["pmt_row_unit#{i}"]] unless @fields["pmt_row_unit#{i}"].nil?
    fields += [@fields["pmt_row_deliverydate#{i}"]]
    fields += [@fields["pmt_row_price_gross#{i}"]] unless @fields["pmt_row_price_gross#{i}"].nil?
    fields += [@fields["pmt_row_price_net#{i}"]] unless @fields["pmt_row_price_net#{i}"].nil?
    fields += [@fields["pmt_row_vat#{i}"], @fields["pmt_row_discountpercentage#{i}"], @fields["pmt_row_type#{i}"]]
  end
  fields += [@md5secret]
  fields = fields.join("&") + "&"
  Digest::MD5.hexdigest(fields).upcase
end

#md5secret(value) ⇒ Object



15
16
17
# File 'lib/active_merchant/billing/integrations/maksuturva/helper.rb', line 15

def md5secret(value)
  @md5secret = value
end