lib/active_merchant/billing/gateway.rb in activemerchant-1.9.0 vs lib/active_merchant/billing/gateway.rb in activemerchant-1.9.1

- old
+ new

@@ -60,11 +60,12 @@ include RequiresParameters include CreditCardFormatting include Utils DEBIT_CARDS = [ :switch, :solo ] - + CURRENCIES_WITHOUT_FRACTIONS = [ 'JPY' ] + cattr_reader :implementations @@implementations = [] def self.inherited(subclass) super @@ -146,9 +147,14 @@ if self.money_format == :cents cents.to_s else sprintf("%.2f", cents.to_f / 100) end + end + + def localized_amount(money, currency) + amount = amount(money) + CURRENCIES_WITHOUT_FRACTIONS.include?(currency.to_s) ? amount.split('.').first : amount end def currency(money) money.respond_to?(:currency) ? money.currency : self.default_currency end