Class: ActiveMerchant::Billing::Gateway

Inherits:
Object
  • Object
show all
Includes:
PostsData, RequiresParameters
Defined in:
lib/active_merchant/billing/gateway.rb

Overview

The Gateway class is the base class for all ActiveMerchant gateway implementations. The list of gateway functions that concrete gateway classes can and should implement include the following:

Core operations supported by most gateways

  • purchase(money, creditcard, options = {})

  • authorize(money, creditcard, options = {})

  • capture(money, authorization, options = {})

  • void(identification, options = {})

  • credit(money, identification, options = {})

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from RequiresParameters

#requires!

Methods included from PostsData

#included?, #ssl_post

Constructor Details

#initialize(options = {}) ⇒ Gateway

Initialize a new gateway

See the documentation for the gateway you will be using to make sure there are no other required options



53
54
55
# File 'lib/active_merchant/billing/gateway.rb', line 53

def initialize(options = {})    
  @ssl_strict = options[:ssl_strict] || false
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



48
49
50
# File 'lib/active_merchant/billing/gateway.rb', line 48

def options
  @options
end

Class Method Details

.gateway(name) ⇒ Object

Return the matching gateway for the provider

  • bogus: BogusGateway - Does nothing ( for testing)

  • moneris: MonerisGateway

  • authorize_net: AuthorizeNetGateway

  • trust_commerce: TrustCommerceGateway

    ActiveMerchant::Base.gateway(‘moneris’).new



34
35
36
# File 'lib/active_merchant/billing/gateway.rb', line 34

def self.gateway(name)
  ActiveMerchant::Billing.const_get("#{name.to_s.downcase}_gateway".camelize)
end

.supported_cardtypesObject

Get a list of supported credit card types for this gateway



44
45
46
# File 'lib/active_merchant/billing/gateway.rb', line 44

def self.supported_cardtypes
  []
end

.supports?(type) ⇒ Boolean

Does this gateway support credit cards of the passed type?

Returns:

  • (Boolean)


39
40
41
# File 'lib/active_merchant/billing/gateway.rb', line 39

def self.supports?(type)
  supported_cardtypes.include?(type.intern)
end

Instance Method Details

#test?Boolean

Are we running in test mode?

Returns:

  • (Boolean)


58
59
60
# File 'lib/active_merchant/billing/gateway.rb', line 58

def test?
  Base.gateway_mode == :test
end