lib/active_merchant/billing/integrations/ipay88/helper.rb in activemerchant-1.40.0 vs lib/active_merchant/billing/integrations/ipay88/helper.rb in activemerchant-1.41.0
- old
+ new
@@ -44,16 +44,20 @@
@amount_in_cents = options[:amount]
super
add_field mappings[:signature], signature
end
+ def amount_in_dollars
+ sprintf("%.2f", @amount_in_cents.to_f/100)
+ end
+
def amount=(money)
@amount_in_cents = money.respond_to?(:cents) ? money.cents : money
if money.is_a?(String) or @amount_in_cents.to_i < 0
raise ArgumentError, "money amount must be either a Money object or a positive integer in cents."
end
- add_field mappings[:amount], sprintf("%.2f", @amount_in_cents.to_f/100)
+ add_field mappings[:amount], amount_in_dollars
end
def currency(symbol)
raise ArgumentError, "unsupported currency" unless SUPPORTED_CURRENCIES.include?(symbol)
add_field mappings[:currency], symbol
@@ -101,10 +105,10 @@
def sig_components
components = [merchant_key]
components << fields[mappings[:account]]
components << fields[mappings[:order]]
- components << amount_in_cents.to_s.gsub(/[.,]/, '')
+ components << amount_in_dollars.to_s.gsub(/0+$/, '').gsub(/[.,]/, '')
components << fields[mappings[:currency]]
components.join
end
end
end