Parent

Included Modules

Class Index [+]

Quicksearch

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 include features for recurring billing

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

DEBIT_CARDS
CURRENCIES_WITHOUT_FRACTIONS
CREDIT_DEPRECATION_MESSAGE

Attributes

options[R]

Public Class Methods

card_brand(source) click to toggle source
     # File lib/active_merchant/billing/gateway.rb, line 108
108:       def self.card_brand(source)
109:         result = source.respond_to?(:brand) ? source.brand : source.type
110:         result.to_s.downcase
111:       end
inherited(subclass) click to toggle source
    # File lib/active_merchant/billing/gateway.rb, line 71
71:       def self.inherited(subclass)
72:         super
73:         @@implementations << subclass
74:       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 121
121:       def initialize(options = {})
122:       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 104
104:       def self.supports?(card_type)
105:         supported_cardtypes.include?(card_type.to_sym)
106:       end

Public Instance Methods

card_brand(source) click to toggle source
     # File lib/active_merchant/billing/gateway.rb, line 113
113:       def card_brand(source)
114:         self.class.card_brand(source)
115:       end
test?() click to toggle source

Are we running in test mode?

     # File lib/active_merchant/billing/gateway.rb, line 125
125:       def test?
126:         Base.gateway_mode == :test
127:       end

Private Instance Methods

amount(money) click to toggle source
     # File lib/active_merchant/billing/gateway.rb, line 135
135:       def amount(money)
136:         return nil if money.nil?
137:         cents = if money.respond_to?(:cents)
138:           deprecated "Support for Money objects is deprecated and will be removed from a future release of ActiveMerchant. Please use an Integer value in cents"
139:           money.cents
140:         else
141:           money
142:         end
143: 
144:         if money.is_a?(String) 
145:           raise ArgumentError, 'money amount must be a positive Integer in cents.' 
146:         end
147: 
148:         if self.money_format == :cents
149:           cents.to_s
150:         else
151:           sprintf("%.2f", cents.to_f / 100)
152:         end
153:       end
currency(money) click to toggle source
     # File lib/active_merchant/billing/gateway.rb, line 160
160:       def currency(money)
161:         money.respond_to?(:currency) ? money.currency : self.default_currency
162:       end
localized_amount(money, currency) click to toggle source
     # File lib/active_merchant/billing/gateway.rb, line 155
155:       def localized_amount(money, currency)
156:         amount = amount(money)
157:         CURRENCIES_WITHOUT_FRACTIONS.include?(currency.to_s) ? amount.split('.').first : amount
158:       end
name() click to toggle source
     # File lib/active_merchant/billing/gateway.rb, line 131
131:       def name 
132:         self.class.name.scan(/\:\:(\w+)Gateway/).flatten.first
133:       end
requires_start_date_or_issue_number?(credit_card) click to toggle source
     # File lib/active_merchant/billing/gateway.rb, line 164
164:       def requires_start_date_or_issue_number?(credit_card)
165:         return false if card_brand(credit_card).blank?
166:         DEBIT_CARDS.include?(card_brand(credit_card).to_sym)
167:       end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.