Module: ActiveMerchant::Billing::Base

Defined in:
lib/active_merchant/billing/base.rb

Constant Summary collapse

GATEWAY_MODE_DEPRECATION_MESSAGE =
'Base#gateway_mode is deprecated in favor of Base#mode and will be removed in a future version'

Class Method Summary collapse

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::Billing::Base.gateway(‘moneris’).new

Raises:

  • (ArgumentError)


30
31
32
33
34
35
36
37
38
39
40
# File 'lib/active_merchant/billing/base.rb', line 30

def self.gateway(name)
  name_str = name.to_s.strip.downcase

  raise(ArgumentError, 'A gateway provider must be specified') if name_str.blank?

  begin
    Billing.const_get("#{name_str}_gateway".camelize)
  rescue
    raise ArgumentError, "The specified gateway is not valid (#{name_str})"
  end
end

.gateway_modeObject



16
17
18
19
# File 'lib/active_merchant/billing/base.rb', line 16

def self.gateway_mode
  ActiveMerchant.deprecated(GATEWAY_MODE_DEPRECATION_MESSAGE)
  @@mode
end

.gateway_mode=(mode) ⇒ Object



11
12
13
14
# File 'lib/active_merchant/billing/base.rb', line 11

def self.gateway_mode=(mode)
  ActiveMerchant.deprecated(GATEWAY_MODE_DEPRECATION_MESSAGE)
  @@mode = mode
end

.test?Boolean

A check to see if we’re in test mode

Returns:

  • (Boolean)


43
44
45
# File 'lib/active_merchant/billing/base.rb', line 43

def self.test?
  mode == :test
end