Class: OffsitePayments::Integrations::Maksuturva::Helper

Inherits:
Helper
  • Object
show all
Defined in:
lib/offsite_payments/integrations/maksuturva.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, inherited, mapping, #raw_html_fields, #shipping_address, #test?

Constructor Details

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

Returns a new instance of Helper.



80
81
82
83
84
85
86
87
# File 'lib/offsite_payments/integrations/maksuturva.rb', line 80

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 OffsitePayments::Helper

Instance Method Details

#form_fieldsObject



93
94
95
# File 'lib/offsite_payments/integrations/maksuturva.rb', line 93

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

#generate_md5stringObject



97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
# File 'lib/offsite_payments/integrations/maksuturva.rb', line 97

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



89
90
91
# File 'lib/offsite_payments/integrations/maksuturva.rb', line 89

def md5secret(value)
  @md5secret = value
end