Class: OffsitePayments::Integrations::Robokassa::Helper

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

Constructor Details

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

Returns a new instance of Helper.



55
56
57
58
# File 'lib/offsite_payments/integrations/robokassa.rb', line 55

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



76
77
78
79
80
81
82
83
84
85
# File 'lib/offsite_payments/integrations/robokassa.rb', line 76

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



60
61
62
# File 'lib/offsite_payments/integrations/robokassa.rb', line 60

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

#main_paramsObject



64
65
66
# File 'lib/offsite_payments/integrations/robokassa.rb', line 64

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

#paramsObject



68
69
70
# File 'lib/offsite_payments/integrations/robokassa.rb', line 68

def params
  @fields
end

#secretObject



72
73
74
# File 'lib/offsite_payments/integrations/robokassa.rb', line 72

def secret
  @md5secret
end