Class: ActiveMerchant::Billing::Integrations::Nochex::Helper

Inherits:
Helper
  • Object
show all
Defined in:
lib/active_merchant/billing/integrations/nochex/helper.rb

Instance Attribute Summary

Attributes inherited from Helper

#fields

Instance Method Summary collapse

Methods inherited from Helper

#add_field, #add_fields, #add_raw_html_field, #billing_address, #form_fields, #form_method, #initialize, mapping, #raw_html_fields, #shipping_address, #test?

Constructor Details

This class inherits a constructor from ActiveMerchant::Billing::Integrations::Helper

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class ActiveMerchant::Billing::Integrations::Helper

Instance Method Details

#amount=(money) ⇒ Object

Need to format the amount to have 2 decimal places



22
23
24
25
26
27
28
# File 'lib/active_merchant/billing/integrations/nochex/helper.rb', line 22

def amount=(money)
  cents = money.respond_to?(:cents) ? money.cents : money
  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.'
  end
  add_field mappings[:amount], sprintf("%.2f", cents.to_f/100)
end