class ActiveMerchant::Billing::Gateway

Description

The Gateway class is the base class for all ActiveMerchant gateway implementations.

The standard list of gateway functions that most concrete gateway subclasses implement is:

Some gateways also support features for storing credit cards:

Gateway Options

The options hash consists of the following options:

The :billing_address, and :shipping_address hashes can have the following keys:

Implmenting new gateways

See the ActiveMerchant Guide to Contributing

Constants

CREDIT_DEPRECATION_MESSAGE
CURRENCIES_WITHOUT_FRACTIONS
DEBIT_CARDS
RECURRING_DEPRECATION_MESSAGE
STANDARD_ERROR_CODE

Standardized Error Codes

:incorrect_number - Card number does not comply with ISO/IEC 7812 numbering standard :invalid_number - Card number was not matched by processor :invalid_expiry_date - Expiry date deos not match correct formatting :invalid_cvc - Security codes does not match correct format (3-4 digits) :expired_card - Card number is expired :incorrect_cvc - Secerity code was not matched by the processor :incorrect_zip - Zip code is not in correct format :incorrect_address - Billing address info was not matched by the processor :card_declined - Card number declined by processor :processing_error - Processor error :call_issuer - Transaction requires voice authentication, call issuer :pickup_card - Issuer requests that you pickup the card from merchant

Attributes

options[R]

Public Class Methods

card_brand(source) click to toggle source
# File lib/active_merchant/billing/gateway.rb, line 141
def self.card_brand(source)
  result = source.respond_to?(:brand) ? source.brand : source.type
  result.to_s.downcase
end
inherited(subclass) click to toggle source
Calls superclass method
# File lib/active_merchant/billing/gateway.rb, line 98
def self.inherited(subclass)
  super
  @@implementations << subclass
end
new(options = {}) click to toggle source

Initialize a new gateway.

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

# File lib/active_merchant/billing/gateway.rb, line 175
def initialize(options = {})
  @options = options
end
non_fractional_currency?(currency) click to toggle source
# File lib/active_merchant/billing/gateway.rb, line 146
def self.non_fractional_currency?(currency)
  CURRENCIES_WITHOUT_FRACTIONS.include?(currency.to_s)
end
supported_countries() click to toggle source
# File lib/active_merchant/billing/gateway.rb, line 159
def self.supported_countries
  @supported_countries ||= []
end
supported_countries=(country_codes) click to toggle source
# File lib/active_merchant/billing/gateway.rb, line 150
def self.supported_countries=(country_codes)
  country_codes.each do |country_code|
    unless ActiveMerchant::Country.find(country_code)
      raise ActiveMerchant::InvalidCountryCodeError, "No country could be found for the country #{country_code}"
    end
  end
  @supported_countries = country_codes.dup
end
supports?(card_type) click to toggle source

Use this method to check if your gateway of interest supports a credit card of some type

# File lib/active_merchant/billing/gateway.rb, line 137
def self.supports?(card_type)
  supported_cardtypes.include?(card_type.to_sym)
end

Public Instance Methods

card_brand(source) click to toggle source
# File lib/active_merchant/billing/gateway.rb, line 167
def card_brand(source)
  self.class.card_brand(source)
end
generate_unique_id() click to toggle source
# File lib/active_merchant/billing/gateway.rb, line 103
def generate_unique_id
  SecureRandom.hex(16)
end
supported_countries() click to toggle source
# File lib/active_merchant/billing/gateway.rb, line 163
def supported_countries
  self.class.supported_countries
end
test?() click to toggle source

Are we running in test mode?

# File lib/active_merchant/billing/gateway.rb, line 180
def test?
  (@options.has_key?(:test) ? @options[:test] : Base.test?)
end