Class: ActiveMerchant::Billing::Integrations::Dwolla::Helper

Inherits:
Helper
  • Object
show all
Defined in:
lib/active_merchant/billing/integrations/dwolla/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_fields, #form_method, mapping, #raw_html_fields, #shipping_address, #test?

Constructor Details

- (Helper) initialize(order, account, options = {})

Returns a new instance of Helper



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/active_merchant/billing/integrations/dwolla/helper.rb', line 8

def initialize(order, , options = {})
  super
  add_field('name', 'Store Purchase')

  timestamp = Time.now.to_i.to_s

  if ActiveMerchant::Billing::Base.integration_mode == :test || options[:test]
    add_field('test', 'true')
    # timestamp used for test signature generation:
    timestamp = "1370726016"
  end

  add_field('timestamp', timestamp)
  add_field('allowFundingSources', 'true')

  key = options[:credential2].to_s
  secret = options[:credential3].to_s
  orderid = order.to_s
  signature = OpenSSL::HMAC.hexdigest(OpenSSL::Digest::SHA1.new, secret, "#{key}&#{timestamp}&#{orderid}")
  add_field('signature', signature)
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class ActiveMerchant::Billing::Integrations::Helper