Class: Gateway

Inherits:
PaymentMethod show all
Defined in:
app/models/gateway.rb

Defined Under Namespace

Classes: AuthorizeNet, AuthorizeNetCim, Beanstream, Bogus, Braintree, Eway, Linkpoint, PayPal, SagePay

Constant Summary

Constants inherited from PaymentMethod

PaymentMethod::DISPLAY

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from PaymentMethod

active?, available, #destroy, find_with_destroyed, #provider_class, providers

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args) ⇒ Object



33
34
35
36
37
38
39
# File 'app/models/gateway.rb', line 33

def method_missing(method, *args)
 	if @provider.nil? || !@provider.respond_to?(method)
		super
	else
     provider.send(method)
	end
end

Class Method Details

.currentObject

instantiates the selected gateway and configures with the options stored in the database



14
15
16
# File 'app/models/gateway.rb', line 14

def self.current
   super
end

Instance Method Details

#method_typeObject



45
46
47
# File 'app/models/gateway.rb', line 45

def method_type
  "gateway"
end

#optionsObject



25
26
27
28
29
30
31
# File 'app/models/gateway.rb', line 25

def options
   options_hash = {}
   self.preferences.each do |key,value|
     options_hash[key.to_sym] = value
   end
   options_hash
end

#payment_profiles_supported?Boolean

Returns:

  • (Boolean)


41
42
43
# File 'app/models/gateway.rb', line 41

def payment_profiles_supported?
 false
end

#payment_source_classObject



9
10
11
# File 'app/models/gateway.rb', line 9

def payment_source_class
  Creditcard
end

#providerObject



18
19
20
21
22
23
# File 'app/models/gateway.rb', line 18

def provider
  gateway_options = options
  gateway_options.delete :login if gateway_options.has_key?(:login) and gateway_options[:login].nil?
  ActiveMerchant::Billing::Base.gateway_mode = gateway_options[:server].to_sym
  @provider ||= provider_class.new(gateway_options)
end