Class: ActiveMerchant::Billing::Integrations::Robokassa::Helper

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

Instance Attribute Summary

Attributes inherited from Helper

#fields

Instance Method Summary collapse

Methods included from Common

#generate_signature, #generate_signature_string

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.



8
9
10
11
# File 'lib/active_merchant/billing/integrations/robokassa/helper.rb', line 8

def initialize(order, , options = {})
  @md5secret = options.delete(:secret)
  super
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method_id, *args) ⇒ Object



29
30
31
32
33
34
35
36
37
38
# File 'lib/active_merchant/billing/integrations/robokassa/helper.rb', line 29

def method_missing(method_id, *args)
  method_id = method_id.to_s.gsub(/=$/, '')

  # support for robokassa custom parameters
  if method_id =~ /^shp/
    add_field method_id, args.last
  end

  super
end

Instance Method Details

#form_fieldsObject



13
14
15
# File 'lib/active_merchant/billing/integrations/robokassa/helper.rb', line 13

def form_fields
  @fields.merge(ActiveMerchant::Billing::Integrations::Robokassa.signature_parameter_name => generate_signature)
end

#main_paramsObject



17
18
19
# File 'lib/active_merchant/billing/integrations/robokassa/helper.rb', line 17

def main_params
  [:account, :amount, :order].map {|key| @fields[mappings[key]]}
end

#paramsObject



21
22
23
# File 'lib/active_merchant/billing/integrations/robokassa/helper.rb', line 21

def params
  @fields
end

#secretObject



25
26
27
# File 'lib/active_merchant/billing/integrations/robokassa/helper.rb', line 25

def secret
  @md5secret
end