lib/active_merchant/billing/gateway.rb in activemerchant-1.4.2 vs lib/active_merchant/billing/gateway.rb in activemerchant-1.5.0
- old
+ new
@@ -128,28 +128,29 @@
def name
self.class.name.scan(/\:\:(\w+)Gateway/).flatten.first
end
- # Return a String with the amount in the appropriate format
- #--
- # TODO Refactor this method. It's a tad on the ugly side.
def amount(money)
return nil if money.nil?
- cents = money.respond_to?(:cents) ? money.cents : money
+ cents = if money.respond_to?(:cents)
+ warn "Support for Money objects is deprecated and will be removed from a future release of ActiveMerchant. Please use an Integer value in cents"
+ money.cents
+ else
+ money
+ end
if money.is_a?(String) or cents.to_i < 0
- raise ArgumentError, 'money amount must be either a Money object or a positive integer in cents.'
+ raise ArgumentError, 'money amount must be a positive Integer in cents.'
end
if self.money_format == :cents
cents.to_s
else
sprintf("%.2f", cents.to_f / 100)
end
end
- # Ascertains the currency to be used on the money supplied.
def currency(money)
money.respond_to?(:currency) ? money.currency : self.default_currency
end
def requires_start_date_or_issue_number?(credit_card)