lib/active_merchant/billing/gateway.rb in activemerchant-1.44.1 vs lib/active_merchant/billing/gateway.rb in activemerchant-1.45.0
- old
+ new
@@ -56,13 +56,44 @@
include PostsData
include CreditCardFormatting
DEBIT_CARDS = [ :switch, :solo ]
CURRENCIES_WITHOUT_FRACTIONS = [ 'BIF', 'BYR', 'CLP', 'CVE', 'DJF', 'GNF', 'HUF', 'ISK', 'JPY', 'KMF', 'KRW', 'PYG', 'RWF', 'TWD', 'UGX', 'VND', 'VUV', 'XAF', 'XOF', 'XPF' ]
+
CREDIT_DEPRECATION_MESSAGE = "Support for using credit to refund existing transactions is deprecated and will be removed from a future release of ActiveMerchant. Please use the refund method instead."
RECURRING_DEPRECATION_MESSAGE = "Recurring functionality in ActiveMerchant is deprecated and will be removed in a future version. Please contact the ActiveMerchant maintainers if you have an interest in taking ownership of a separate gem that continues support for it."
+ # == 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
+
+ STANDARD_ERROR_CODE = {
+ :incorrect_number => 'incorrect_number',
+ :invalid_number => 'invalid_number',
+ :invalid_expiry_date => 'invalid_expiry_date',
+ :invalid_cvc => 'invalid_cvc',
+ :expired_card => 'expired_card',
+ :incorrect_cvc => 'incorrect_cvc',
+ :incorrect_zip => 'incorrect_zip',
+ :incorrect_address => 'incorrect_address',
+ :card_declined => 'card_declined',
+ :processing_error => 'processing_error',
+ :call_issuer => 'call_issuer',
+ :pickup_card => 'pick_up_card'
+ }
+
cattr_reader :implementations
@@implementations = []
def self.inherited(subclass)
super
@@ -110,10 +141,14 @@
def self.card_brand(source)
result = source.respond_to?(:brand) ? source.brand : source.type
result.to_s.downcase
end
+ def self.non_fractional_currency?(currency)
+ CURRENCIES_WITHOUT_FRACTIONS.include?(currency.to_s)
+ end
+
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
@@ -195,21 +230,18 @@
end
def localized_amount(money, currency)
amount = amount(money)
- return amount unless non_fractional_currency?(currency)
+ return amount unless Gateway.non_fractional_currency?(currency)
if self.money_format == :cents
sprintf("%.0f", amount.to_f / 100)
else
amount.split('.').first
end
end
- def non_fractional_currency?(currency)
- CURRENCIES_WITHOUT_FRACTIONS.include?(currency.to_s)
- end
def currency(money)
money.respond_to?(:currency) ? money.currency : self.default_currency
end