Class: OffsitePayments::Integrations::HiTrust::Helper

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

Constructor Details

#initialize(order, account, options = {}) ⇒ Helper

Transaction types

  • Auth

  • AuthRe

  • Capture

  • CaptureRe

  • Refund

  • RefundRe

  • Query



28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/offsite_payments/integrations/hi_trust.rb', line 28

def initialize(order, , options = {})
  super
  # Perform an authorization by default
  add_field('Type', 'Auth')

  # Capture the payment right away
  add_field('depositflag', '1')

  # Disable auto query - who knows what it does?
  add_field('queryflag', '1')

  add_field('orderdesc', 'Store purchase')
end

Dynamic Method Handling

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

Instance Method Details

#amount=(money) ⇒ Object

Raises:

  • (ArgumentError)


45
46
47
48
49
50
51
# File 'lib/offsite_payments/integrations/hi_trust.rb', line 45

def amount=(money)
  cents = money.respond_to?(:cents) ? money.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], cents)
end