Class: OffsitePayments::Integrations::Nochex::Helper

Inherits:
Helper
  • Object
show all
Defined in:
lib/offsite_payments/integrations/nochex.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, inherited, #initialize, mapping, #raw_html_fields, #shipping_address, #test?

Methods included from MoneyCompatibility

#to_cents

Constructor Details

This class inherits a constructor from OffsitePayments::Helper

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class OffsitePayments::Helper

Instance Method Details

#amount=(money) ⇒ Object

Need to format the amount to have 2 decimal places

Raises:

  • (ArgumentError)


96
97
98
99
100
101
102
# File 'lib/offsite_payments/integrations/nochex.rb', line 96

def amount=(money)
  cents = to_cents(money)
  raise ArgumentError, "amount must be a Money object or an integer" if money.is_a?(String)
  raise ActionViewHelperError, "amount must be greater than $0.00" if cents.to_i <= 0

  add_field mappings[:amount], sprintf("%.2f", cents.to_f/100)
end