Class: ActiveMerchant::Billing::Integrations::PayflowLink::Helper

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

Instance Attribute Summary

Attributes inherited from Helper

#fields

Instance Method Summary collapse

Methods inherited from Helper

#add_field, #add_fields, #form_fields, mapping, #shipping_address

Constructor Details

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

Returns a new instance of Helper.



7
8
9
10
11
12
13
14
# File 'lib/active_merchant/billing/integrations/payflow_link/helper.rb', line 7

def initialize(order, , options = {})
  super
  add_field('login', )
  add_field('type', 'S')
  add_field('echodata', 'True')
  add_field('user2', ActiveMerchant::Billing::Base.integration_mode == :test || options[:test])
  add_field('invoice', order)
end

Dynamic Method Handling

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

Instance Method Details

#billing_address(params = {}) ⇒ Object



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/active_merchant/billing/integrations/payflow_link/helper.rb', line 37

def billing_address(params = {})
  # Get the country code in the correct format
  # Use what we were given if we can't find anything
  country_code = lookup_country_code(params.delete(:country))
  add_field(mappings[:billing_address][:country], country_code)

  add_field(mappings[:billing_address][:address], [params.delete(:address1), params.delete(:address2)].compact.join(' '))

  province_code = params.delete(:state)
  add_field(mappings[:billing_address][:state], province_code.blank? ? 'N/A' : province_code.upcase)

  # Everything else
  params.each do |k, v|
    field = mappings[:billing_address][k]
    add_field(field, v) unless field.nil?
  end
end

#customer(params = {}) ⇒ Object



33
34
35
# File 'lib/active_merchant/billing/integrations/payflow_link/helper.rb', line 33

def customer(params = {})
  add_field(mappings[:customer][:name], [params.delete(:first_name), params.delete(:last_name)].compact.join(' '))
end