projectdx_activemerchant 1.7.1.20100817.1
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +530 -0
- data/CONTRIBUTORS +142 -0
- data/MIT-LICENSE +20 -0
- data/README.rdoc +136 -0
- data/gem-public_cert.pem +20 -0
- data/lib/active_merchant/billing/avs_result.rb +98 -0
- data/lib/active_merchant/billing/base.rb +57 -0
- data/lib/active_merchant/billing/check.rb +68 -0
- data/lib/active_merchant/billing/credit_card.rb +159 -0
- data/lib/active_merchant/billing/credit_card_formatting.rb +21 -0
- data/lib/active_merchant/billing/credit_card_methods.rb +125 -0
- data/lib/active_merchant/billing/cvv_result.rb +38 -0
- data/lib/active_merchant/billing/expiry_date.rb +34 -0
- data/lib/active_merchant/billing/gateway.rb +163 -0
- data/lib/active_merchant/billing/gateways/authorize_net.rb +654 -0
- data/lib/active_merchant/billing/gateways/authorize_net_cim.rb +736 -0
- data/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb +244 -0
- data/lib/active_merchant/billing/gateways/beanstream.rb +102 -0
- data/lib/active_merchant/billing/gateways/beanstream_interac.rb +54 -0
- data/lib/active_merchant/billing/gateways/bogus.rb +102 -0
- data/lib/active_merchant/billing/gateways/braintree/braintree_common.rb +9 -0
- data/lib/active_merchant/billing/gateways/braintree.rb +17 -0
- data/lib/active_merchant/billing/gateways/braintree_blue.rb +210 -0
- data/lib/active_merchant/billing/gateways/braintree_orange.rb +17 -0
- data/lib/active_merchant/billing/gateways/card_stream.rb +230 -0
- data/lib/active_merchant/billing/gateways/convenience_pay.rb +191 -0
- data/lib/active_merchant/billing/gateways/cyber_source.rb +406 -0
- data/lib/active_merchant/billing/gateways/data_cash.rb +593 -0
- data/lib/active_merchant/billing/gateways/efsnet.rb +229 -0
- data/lib/active_merchant/billing/gateways/elavon.rb +134 -0
- data/lib/active_merchant/billing/gateways/eway.rb +277 -0
- data/lib/active_merchant/billing/gateways/exact.rb +222 -0
- data/lib/active_merchant/billing/gateways/first_pay.rb +172 -0
- data/lib/active_merchant/billing/gateways/garanti.rb +222 -0
- data/lib/active_merchant/billing/gateways/instapay.rb +164 -0
- data/lib/active_merchant/billing/gateways/jetpay.rb +270 -0
- data/lib/active_merchant/billing/gateways/linkpoint.rb +449 -0
- data/lib/active_merchant/billing/gateways/merchant_e_solutions.rb +154 -0
- data/lib/active_merchant/billing/gateways/merchant_ware.rb +283 -0
- data/lib/active_merchant/billing/gateways/modern_payments.rb +36 -0
- data/lib/active_merchant/billing/gateways/modern_payments_cim.rb +220 -0
- data/lib/active_merchant/billing/gateways/moneris.rb +205 -0
- data/lib/active_merchant/billing/gateways/net_registry.rb +189 -0
- data/lib/active_merchant/billing/gateways/netbilling.rb +168 -0
- data/lib/active_merchant/billing/gateways/ogone.rb +279 -0
- data/lib/active_merchant/billing/gateways/pay_junction.rb +392 -0
- data/lib/active_merchant/billing/gateways/pay_secure.rb +120 -0
- data/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb +207 -0
- data/lib/active_merchant/billing/gateways/payflow/payflow_express_response.rb +39 -0
- data/lib/active_merchant/billing/gateways/payflow/payflow_response.rb +13 -0
- data/lib/active_merchant/billing/gateways/payflow.rb +236 -0
- data/lib/active_merchant/billing/gateways/payflow_express.rb +138 -0
- data/lib/active_merchant/billing/gateways/payflow_express_uk.rb +15 -0
- data/lib/active_merchant/billing/gateways/payflow_uk.rb +21 -0
- data/lib/active_merchant/billing/gateways/payment_express.rb +230 -0
- data/lib/active_merchant/billing/gateways/paypal/paypal_common_api.rb +326 -0
- data/lib/active_merchant/billing/gateways/paypal/paypal_express_response.rb +38 -0
- data/lib/active_merchant/billing/gateways/paypal.rb +121 -0
- data/lib/active_merchant/billing/gateways/paypal_ca.rb +13 -0
- data/lib/active_merchant/billing/gateways/paypal_express.rb +135 -0
- data/lib/active_merchant/billing/gateways/paypal_express_common.rb +20 -0
- data/lib/active_merchant/billing/gateways/plugnpay.rb +292 -0
- data/lib/active_merchant/billing/gateways/psigate.rb +214 -0
- data/lib/active_merchant/billing/gateways/psl_card.rb +304 -0
- data/lib/active_merchant/billing/gateways/quickpay.rb +213 -0
- data/lib/active_merchant/billing/gateways/realex.rb +200 -0
- data/lib/active_merchant/billing/gateways/sage/sage_bankcard.rb +88 -0
- data/lib/active_merchant/billing/gateways/sage/sage_core.rb +116 -0
- data/lib/active_merchant/billing/gateways/sage/sage_virtual_check.rb +97 -0
- data/lib/active_merchant/billing/gateways/sage.rb +146 -0
- data/lib/active_merchant/billing/gateways/sage_pay.rb +309 -0
- data/lib/active_merchant/billing/gateways/sallie_mae.rb +144 -0
- data/lib/active_merchant/billing/gateways/secure_pay.rb +31 -0
- data/lib/active_merchant/billing/gateways/secure_pay_au.rb +157 -0
- data/lib/active_merchant/billing/gateways/secure_pay_tech.rb +113 -0
- data/lib/active_merchant/billing/gateways/skip_jack.rb +453 -0
- data/lib/active_merchant/billing/gateways/smart_ps.rb +265 -0
- data/lib/active_merchant/billing/gateways/trans_first.rb +127 -0
- data/lib/active_merchant/billing/gateways/transax.rb +25 -0
- data/lib/active_merchant/billing/gateways/trust_commerce.rb +418 -0
- data/lib/active_merchant/billing/gateways/usa_epay.rb +194 -0
- data/lib/active_merchant/billing/gateways/verifi.rb +228 -0
- data/lib/active_merchant/billing/gateways/viaklix.rb +189 -0
- data/lib/active_merchant/billing/gateways/wirecard.rb +318 -0
- data/lib/active_merchant/billing/gateways.rb +18 -0
- data/lib/active_merchant/billing/integrations/action_view_helper.rb +79 -0
- data/lib/active_merchant/billing/integrations/bogus/helper.rb +17 -0
- data/lib/active_merchant/billing/integrations/bogus/notification.rb +11 -0
- data/lib/active_merchant/billing/integrations/bogus/return.rb +10 -0
- data/lib/active_merchant/billing/integrations/bogus.rb +23 -0
- data/lib/active_merchant/billing/integrations/chronopay/helper.rb +120 -0
- data/lib/active_merchant/billing/integrations/chronopay/notification.rb +158 -0
- data/lib/active_merchant/billing/integrations/chronopay/return.rb +10 -0
- data/lib/active_merchant/billing/integrations/chronopay.rb +23 -0
- data/lib/active_merchant/billing/integrations/gestpay/common.rb +42 -0
- data/lib/active_merchant/billing/integrations/gestpay/helper.rb +70 -0
- data/lib/active_merchant/billing/integrations/gestpay/notification.rb +85 -0
- data/lib/active_merchant/billing/integrations/gestpay/return.rb +10 -0
- data/lib/active_merchant/billing/integrations/gestpay.rb +25 -0
- data/lib/active_merchant/billing/integrations/helper.rb +93 -0
- data/lib/active_merchant/billing/integrations/hi_trust/helper.rb +58 -0
- data/lib/active_merchant/billing/integrations/hi_trust/notification.rb +59 -0
- data/lib/active_merchant/billing/integrations/hi_trust/return.rb +67 -0
- data/lib/active_merchant/billing/integrations/hi_trust.rb +27 -0
- data/lib/active_merchant/billing/integrations/nochex/helper.rb +68 -0
- data/lib/active_merchant/billing/integrations/nochex/notification.rb +94 -0
- data/lib/active_merchant/billing/integrations/nochex/return.rb +10 -0
- data/lib/active_merchant/billing/integrations/nochex.rb +88 -0
- data/lib/active_merchant/billing/integrations/notification.rb +62 -0
- data/lib/active_merchant/billing/integrations/paypal/helper.rb +119 -0
- data/lib/active_merchant/billing/integrations/paypal/notification.rb +154 -0
- data/lib/active_merchant/billing/integrations/paypal/return.rb +10 -0
- data/lib/active_merchant/billing/integrations/paypal.rb +39 -0
- data/lib/active_merchant/billing/integrations/quickpay/helper.rb +72 -0
- data/lib/active_merchant/billing/integrations/quickpay/notification.rb +74 -0
- data/lib/active_merchant/billing/integrations/quickpay.rb +17 -0
- data/lib/active_merchant/billing/integrations/return.rb +35 -0
- data/lib/active_merchant/billing/integrations/two_checkout/helper.rb +59 -0
- data/lib/active_merchant/billing/integrations/two_checkout/notification.rb +114 -0
- data/lib/active_merchant/billing/integrations/two_checkout/return.rb +17 -0
- data/lib/active_merchant/billing/integrations/two_checkout.rb +23 -0
- data/lib/active_merchant/billing/integrations.rb +29 -0
- data/lib/active_merchant/billing/response.rb +32 -0
- data/lib/active_merchant/billing.rb +9 -0
- data/lib/active_merchant/common/connection.rb +172 -0
- data/lib/active_merchant/common/country.rb +319 -0
- data/lib/active_merchant/common/error.rb +26 -0
- data/lib/active_merchant/common/post_data.rb +24 -0
- data/lib/active_merchant/common/posts_data.rb +47 -0
- data/lib/active_merchant/common/requires_parameters.rb +16 -0
- data/lib/active_merchant/common/utils.rb +18 -0
- data/lib/active_merchant/common/validateable.rb +76 -0
- data/lib/active_merchant/common.rb +14 -0
- data/lib/active_merchant/version.rb +3 -0
- data/lib/active_merchant.rb +47 -0
- data/lib/activemerchant.rb +1 -0
- data/lib/certs/cacert.pem +7815 -0
- data/lib/support/gateway_support.rb +58 -0
- data/lib/support/outbound_hosts.rb +25 -0
- metadata +254 -0
@@ -0,0 +1,125 @@
|
|
1
|
+
module ActiveMerchant #:nodoc:
|
2
|
+
module Billing #:nodoc:
|
3
|
+
# Convenience methods that can be included into a custom Credit Card object, such as an ActiveRecord based Credit Card object.
|
4
|
+
module CreditCardMethods
|
5
|
+
CARD_COMPANIES = {
|
6
|
+
'visa' => /^4\d{12}(\d{3})?$/,
|
7
|
+
'master' => /^(5[1-5]\d{4}|677189)\d{10}$/,
|
8
|
+
'discover' => /^(6011|65\d{2})\d{12}$/,
|
9
|
+
'american_express' => /^3[47]\d{13}$/,
|
10
|
+
'diners_club' => /^3(0[0-5]|[68]\d)\d{11}$/,
|
11
|
+
'jcb' => /^35(28|29|[3-8]\d)\d{12}$/,
|
12
|
+
'switch' => /^6759\d{12}(\d{2,3})?$/,
|
13
|
+
'solo' => /^6767\d{12}(\d{2,3})?$/,
|
14
|
+
'dankort' => /^5019\d{12}$/,
|
15
|
+
'maestro' => /^(5[06-8]|6\d)\d{10,17}$/,
|
16
|
+
'forbrugsforeningen' => /^600722\d{10}$/,
|
17
|
+
'laser' => /^(6304|6706|6771|6709)\d{8}(\d{4}|\d{6,7})?$/
|
18
|
+
}
|
19
|
+
|
20
|
+
def self.included(base)
|
21
|
+
base.extend(ClassMethods)
|
22
|
+
end
|
23
|
+
|
24
|
+
def valid_month?(month)
|
25
|
+
(1..12).include?(month.to_i)
|
26
|
+
end
|
27
|
+
|
28
|
+
def valid_expiry_year?(year)
|
29
|
+
(Time.now.year..Time.now.year + 20).include?(year.to_i)
|
30
|
+
end
|
31
|
+
|
32
|
+
def valid_start_year?(year)
|
33
|
+
year.to_s =~ /^\d{4}$/ && year.to_i > 1987
|
34
|
+
end
|
35
|
+
|
36
|
+
def valid_issue_number?(number)
|
37
|
+
number.to_s =~ /^\d{1,2}$/
|
38
|
+
end
|
39
|
+
|
40
|
+
module ClassMethods
|
41
|
+
# Returns true if it validates. Optionally, you can pass a card type as an argument and
|
42
|
+
# make sure it is of the correct type.
|
43
|
+
#
|
44
|
+
# References:
|
45
|
+
# - http://perl.about.com/compute/perl/library/nosearch/P073000.htm
|
46
|
+
# - http://www.beachnet.com/~hstiles/cardtype.html
|
47
|
+
def valid_number?(number)
|
48
|
+
valid_test_mode_card_number?(number) ||
|
49
|
+
valid_card_number_length?(number) &&
|
50
|
+
valid_checksum?(number)
|
51
|
+
end
|
52
|
+
|
53
|
+
# Regular expressions for the known card companies.
|
54
|
+
#
|
55
|
+
# References:
|
56
|
+
# - http://en.wikipedia.org/wiki/Credit_card_number
|
57
|
+
# - http://www.barclaycardbusiness.co.uk/information_zone/processing/bin_rules.html
|
58
|
+
def card_companies
|
59
|
+
CARD_COMPANIES
|
60
|
+
end
|
61
|
+
|
62
|
+
# Returns a string containing the type of card from the list of known information below.
|
63
|
+
# Need to check the cards in a particular order, as there is some overlap of the allowable ranges
|
64
|
+
#--
|
65
|
+
# TODO Refactor this method. We basically need to tighten up the Maestro Regexp.
|
66
|
+
#
|
67
|
+
# Right now the Maestro regexp overlaps with the MasterCard regexp (IIRC). If we can tighten
|
68
|
+
# things up, we can boil this whole thing down to something like...
|
69
|
+
#
|
70
|
+
# def type?(number)
|
71
|
+
# return 'visa' if valid_test_mode_card_number?(number)
|
72
|
+
# card_companies.find([nil]) { |type, regexp| number =~ regexp }.first.dup
|
73
|
+
# end
|
74
|
+
#
|
75
|
+
def type?(number)
|
76
|
+
return 'bogus' if valid_test_mode_card_number?(number)
|
77
|
+
|
78
|
+
card_companies.reject { |c,p| c == 'maestro' }.each do |company, pattern|
|
79
|
+
return company.dup if number =~ pattern
|
80
|
+
end
|
81
|
+
|
82
|
+
return 'maestro' if number =~ card_companies['maestro']
|
83
|
+
|
84
|
+
return nil
|
85
|
+
end
|
86
|
+
|
87
|
+
def last_digits(number)
|
88
|
+
number.to_s.length <= 4 ? number : number.to_s.slice(-4..-1)
|
89
|
+
end
|
90
|
+
|
91
|
+
def mask(number)
|
92
|
+
"XXXX-XXXX-XXXX-#{last_digits(number)}"
|
93
|
+
end
|
94
|
+
|
95
|
+
# Checks to see if the calculated type matches the specified type
|
96
|
+
def matching_type?(number, type)
|
97
|
+
type?(number) == type
|
98
|
+
end
|
99
|
+
|
100
|
+
private
|
101
|
+
|
102
|
+
def valid_card_number_length?(number) #:nodoc:
|
103
|
+
number.to_s.length >= 12
|
104
|
+
end
|
105
|
+
|
106
|
+
def valid_test_mode_card_number?(number) #:nodoc:
|
107
|
+
ActiveMerchant::Billing::Base.test? &&
|
108
|
+
%w[1 2 3 success failure error].include?(number.to_s)
|
109
|
+
end
|
110
|
+
|
111
|
+
# Checks the validity of a card number by use of the the Luhn Algorithm.
|
112
|
+
# Please see http://en.wikipedia.org/wiki/Luhn_algorithm for details.
|
113
|
+
def valid_checksum?(number) #:nodoc:
|
114
|
+
sum = 0
|
115
|
+
for i in 0..number.length
|
116
|
+
weight = number[-1 * (i + 2), 1].to_i * (2 - (i % 2))
|
117
|
+
sum += (weight < 10) ? weight : weight - 9
|
118
|
+
end
|
119
|
+
|
120
|
+
(number[-1,1].to_i == (10 - sum % 10) % 10)
|
121
|
+
end
|
122
|
+
end
|
123
|
+
end
|
124
|
+
end
|
125
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
module ActiveMerchant
|
2
|
+
module Billing
|
3
|
+
# Result of the Card Verification Value check
|
4
|
+
# http://www.bbbonline.org/eExport/doc/MerchantGuide_cvv2.pdf
|
5
|
+
# Check additional codes from cybersource website
|
6
|
+
class CVVResult
|
7
|
+
|
8
|
+
MESSAGES = {
|
9
|
+
'D' => 'Suspicious transaction',
|
10
|
+
'I' => 'Failed data validation check',
|
11
|
+
'M' => 'Match',
|
12
|
+
'N' => 'No Match',
|
13
|
+
'P' => 'Not Processed',
|
14
|
+
'S' => 'Should have been present',
|
15
|
+
'U' => 'Issuer unable to process request',
|
16
|
+
'X' => 'Card does not support verification'
|
17
|
+
}
|
18
|
+
|
19
|
+
def self.messages
|
20
|
+
MESSAGES
|
21
|
+
end
|
22
|
+
|
23
|
+
attr_reader :code, :message
|
24
|
+
|
25
|
+
def initialize(code)
|
26
|
+
@code = code.upcase unless code.blank?
|
27
|
+
@message = MESSAGES[@code]
|
28
|
+
end
|
29
|
+
|
30
|
+
def to_hash
|
31
|
+
{
|
32
|
+
'code' => code,
|
33
|
+
'message' => message
|
34
|
+
}
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'date'
|
2
|
+
|
3
|
+
module ActiveMerchant
|
4
|
+
module Billing
|
5
|
+
class CreditCard
|
6
|
+
class ExpiryDate #:nodoc:
|
7
|
+
attr_reader :month, :year
|
8
|
+
def initialize(month, year)
|
9
|
+
@month = month.to_i
|
10
|
+
@year = year.to_i
|
11
|
+
end
|
12
|
+
|
13
|
+
def expired? #:nodoc:
|
14
|
+
Time.now.utc > expiration
|
15
|
+
end
|
16
|
+
|
17
|
+
def expiration #:nodoc:
|
18
|
+
begin
|
19
|
+
Time.utc(year, month, month_days, 23, 59, 59)
|
20
|
+
rescue ArgumentError
|
21
|
+
Time.at(0).utc
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
private
|
26
|
+
def month_days
|
27
|
+
mdays = [nil,31,28,31,30,31,30,31,31,30,31,30,31]
|
28
|
+
mdays[2] = 29 if Date.leap?(year)
|
29
|
+
mdays[month]
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,163 @@
|
|
1
|
+
require 'net/http'
|
2
|
+
require 'net/https'
|
3
|
+
require 'active_merchant/billing/response'
|
4
|
+
|
5
|
+
module ActiveMerchant #:nodoc:
|
6
|
+
module Billing #:nodoc:
|
7
|
+
#
|
8
|
+
# == Description
|
9
|
+
# The Gateway class is the base class for all ActiveMerchant gateway implementations.
|
10
|
+
#
|
11
|
+
# The standard list of gateway functions that most concrete gateway subclasses implement is:
|
12
|
+
#
|
13
|
+
# * <tt>purchase(money, creditcard, options = {})</tt>
|
14
|
+
# * <tt>authorize(money, creditcard, options = {})</tt>
|
15
|
+
# * <tt>capture(money, authorization, options = {})</tt>
|
16
|
+
# * <tt>void(identification, options = {})</tt>
|
17
|
+
# * <tt>credit(money, identification, options = {})</tt>
|
18
|
+
#
|
19
|
+
# Some gateways include features for recurring billing
|
20
|
+
#
|
21
|
+
# * <tt>recurring(money, creditcard, options = {})</tt>
|
22
|
+
#
|
23
|
+
# Some gateways also support features for storing credit cards:
|
24
|
+
#
|
25
|
+
# * <tt>store(creditcard, options = {})</tt>
|
26
|
+
# * <tt>unstore(identification, options = {})</tt>
|
27
|
+
#
|
28
|
+
# === Gateway Options
|
29
|
+
# The options hash consists of the following options:
|
30
|
+
#
|
31
|
+
# * <tt>:order_id</tt> - The order number
|
32
|
+
# * <tt>:ip</tt> - The IP address of the customer making the purchase
|
33
|
+
# * <tt>:customer</tt> - The name, customer number, or other information that identifies the customer
|
34
|
+
# * <tt>:invoice</tt> - The invoice number
|
35
|
+
# * <tt>:merchant</tt> - The name or description of the merchant offering the product
|
36
|
+
# * <tt>:description</tt> - A description of the transaction
|
37
|
+
# * <tt>:email</tt> - The email address of the customer
|
38
|
+
# * <tt>:currency</tt> - 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.
|
39
|
+
# * <tt>:billing_address</tt> - A hash containing the billing address of the customer.
|
40
|
+
# * <tt>:shipping_address</tt> - A hash containing the shipping address of the customer.
|
41
|
+
#
|
42
|
+
# The <tt>:billing_address</tt>, and <tt>:shipping_address</tt> hashes can have the following keys:
|
43
|
+
#
|
44
|
+
# * <tt>:name</tt> - The full name of the customer.
|
45
|
+
# * <tt>:company</tt> - The company name of the customer.
|
46
|
+
# * <tt>:address1</tt> - The primary street address of the customer.
|
47
|
+
# * <tt>:address2</tt> - Additional line of address information.
|
48
|
+
# * <tt>:city</tt> - The city of the customer.
|
49
|
+
# * <tt>:state</tt> - 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.
|
50
|
+
# * <tt>:country</tt> - The [ISO 3166-1-alpha-2 code](http://www.iso.org/iso/country_codes/iso_3166_code_lists/english_country_names_and_code_elements.htm) for the customer.
|
51
|
+
# * <tt>:zip</tt> - The zip or postal code of the customer.
|
52
|
+
# * <tt>:phone</tt> - The phone number of the customer.
|
53
|
+
#
|
54
|
+
# == Implmenting new gateways
|
55
|
+
#
|
56
|
+
# See the {ActiveMerchant Guide to Contributing}[http://code.google.com/p/activemerchant/wiki/Contributing]
|
57
|
+
#
|
58
|
+
class Gateway
|
59
|
+
include PostsData
|
60
|
+
include RequiresParameters
|
61
|
+
include CreditCardFormatting
|
62
|
+
include Utils
|
63
|
+
|
64
|
+
DEBIT_CARDS = [ :switch, :solo ]
|
65
|
+
|
66
|
+
cattr_reader :implementations
|
67
|
+
@@implementations = []
|
68
|
+
|
69
|
+
def self.inherited(subclass)
|
70
|
+
super
|
71
|
+
@@implementations << subclass
|
72
|
+
end
|
73
|
+
|
74
|
+
# The format of the amounts used by the gateway
|
75
|
+
# :dollars => '12.50'
|
76
|
+
# :cents => '1250'
|
77
|
+
class_inheritable_accessor :money_format
|
78
|
+
self.money_format = :dollars
|
79
|
+
|
80
|
+
# The default currency for the transactions if no currency is provided
|
81
|
+
class_inheritable_accessor :default_currency
|
82
|
+
|
83
|
+
# The countries of merchants the gateway supports
|
84
|
+
class_inheritable_accessor :supported_countries
|
85
|
+
self.supported_countries = []
|
86
|
+
|
87
|
+
# The supported card types for the gateway
|
88
|
+
class_inheritable_accessor :supported_cardtypes
|
89
|
+
self.supported_cardtypes = []
|
90
|
+
|
91
|
+
class_inheritable_accessor :homepage_url
|
92
|
+
class_inheritable_accessor :display_name
|
93
|
+
|
94
|
+
# The application making the calls to the gateway
|
95
|
+
# Useful for things like the PayPal build notation (BN) id fields
|
96
|
+
superclass_delegating_accessor :application_id
|
97
|
+
self.application_id = 'ActiveMerchant'
|
98
|
+
|
99
|
+
attr_reader :options
|
100
|
+
|
101
|
+
# Use this method to check if your gateway of interest supports a credit card of some type
|
102
|
+
def self.supports?(card_type)
|
103
|
+
supported_cardtypes.include?(card_type.to_sym)
|
104
|
+
end
|
105
|
+
|
106
|
+
def self.card_brand(source)
|
107
|
+
result = source.respond_to?(:brand) ? source.brand : source.type
|
108
|
+
result.to_s.downcase
|
109
|
+
end
|
110
|
+
|
111
|
+
def card_brand(source)
|
112
|
+
self.class.card_brand(source)
|
113
|
+
end
|
114
|
+
|
115
|
+
# Initialize a new gateway.
|
116
|
+
#
|
117
|
+
# See the documentation for the gateway you will be using to make sure there are no other
|
118
|
+
# required options.
|
119
|
+
def initialize(options = {})
|
120
|
+
end
|
121
|
+
|
122
|
+
# Are we running in test mode?
|
123
|
+
def test?
|
124
|
+
Base.gateway_mode == :test
|
125
|
+
end
|
126
|
+
|
127
|
+
private # :nodoc: all
|
128
|
+
|
129
|
+
def name
|
130
|
+
self.class.name.scan(/\:\:(\w+)Gateway/).flatten.first
|
131
|
+
end
|
132
|
+
|
133
|
+
def amount(money)
|
134
|
+
return nil if money.nil?
|
135
|
+
cents = if money.respond_to?(:cents)
|
136
|
+
warn "Support for Money objects is deprecated and will be removed from a future release of ActiveMerchant. Please use an Integer value in cents"
|
137
|
+
money.cents
|
138
|
+
else
|
139
|
+
money
|
140
|
+
end
|
141
|
+
|
142
|
+
if money.is_a?(String) or cents.to_i < 0
|
143
|
+
raise ArgumentError, 'money amount must be a positive Integer in cents.'
|
144
|
+
end
|
145
|
+
|
146
|
+
if self.money_format == :cents
|
147
|
+
cents.to_s
|
148
|
+
else
|
149
|
+
sprintf("%.2f", cents.to_f / 100)
|
150
|
+
end
|
151
|
+
end
|
152
|
+
|
153
|
+
def currency(money)
|
154
|
+
money.respond_to?(:currency) ? money.currency : self.default_currency
|
155
|
+
end
|
156
|
+
|
157
|
+
def requires_start_date_or_issue_number?(credit_card)
|
158
|
+
return false if card_brand(credit_card).blank?
|
159
|
+
DEBIT_CARDS.include?(card_brand(credit_card).to_sym)
|
160
|
+
end
|
161
|
+
end
|
162
|
+
end
|
163
|
+
end
|