Object
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:
purchase(money, creditcard, options = {})
authorize(money, creditcard, options = {})
capture(money, authorization, options = {})
void(identification, options = {})
credit(money, identification, options = {})
Some gateways include features for recurring billing
recurring(money, creditcard, options = {})
Some gateways also support features for storing credit cards:
store(creditcard, options = {})
unstore(identification, options = {})
The options hash consists of the following options:
:order_id - The order number
:ip - The IP address of the customer making the purchase
:customer - The name, customer number, or other information that identifies the customer
:invoice - The invoice number
:merchant - The name or description of the merchant offering the product
:description - A description of the transaction
:email - The email address of the customer
:currency - The currency of the transaction. Only important when you are using a currency that is not the default with a gateway that supports multiple currencies.
:billing_address - A hash containing the billing address of the customer.
:shipping_address - A hash containing the shipping address of the customer.
The :billing_address, and :shipping_address hashes can have the following keys:
:name - The full name of the customer.
:company - The company name of the customer.
:address1 - The primary street address of the customer.
:address2 - Additional line of address information.
:city - The city of the customer.
:state - The state of the customer. The 2 digit code for US and Canadian addresses. The full name of the state or province for foreign addresses.
:country - The [ISO 3166-1-alpha-2 code](www.iso.org/iso/country_codes/iso_3166_code_lists/english_country_names_and_code_elements.htm) for the customer.
:zip - The zip or postal code of the customer.
:phone - The phone number of the customer.
# 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
# File lib/active_merchant/billing/gateway.rb, line 71 71: def self.inherited(subclass) 72: super 73: @@implementations << subclass 74: end
# 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
# 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
# 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
# File lib/active_merchant/billing/gateway.rb, line 131 131: def name 132: self.class.name.scan(/\:\:(\w+)Gateway/).flatten.first 133: end
# 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.
Generated with the Darkfish Rdoc Generator 1.1.6.