Class: OffsitePayments::Integrations::Paydollar::Helper

Inherits:
Helper
  • Object
show all
Defined in:
lib/offsite_payments/integrations/paydollar.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?

Methods included from MoneyCompatibility

#to_cents

Constructor Details

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

Returns a new instance of Helper.



81
82
83
84
85
# File 'lib/offsite_payments/integrations/paydollar.rb', line 81

def initialize(order, , options = {})
  super
  add_field('payType', 'N') # normal sale and not just auth
  @secret = options[:credential2]
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class OffsitePayments::Helper

Instance Method Details

#currency=(currency_code) ⇒ Object



100
101
102
# File 'lib/offsite_payments/integrations/paydollar.rb', line 100

def currency=(currency_code)
  add_field(mappings[:currency], CURRENCY_MAP[currency_code])
end

#form_fieldsObject



87
88
89
# File 'lib/offsite_payments/integrations/paydollar.rb', line 87

def form_fields
  @fields.merge('secureHash' => generate_secure_hash)
end

#generate_secure_hashObject



91
92
93
94
95
96
97
98
# File 'lib/offsite_payments/integrations/paydollar.rb', line 91

def generate_secure_hash
  fields = [@fields[mappings[:account]],
            @fields[mappings[:order]],
            @fields[mappings[:currency]],
            @fields[mappings[:amount]],
            @fields['payType']]
  Paydollar.sign(fields, @secret)
end