Class: OffsitePayments::Integrations::Universal::Helper

Inherits:
Helper
  • Object
show all
Defined in:
lib/offsite_payments/integrations/universal.rb

Constant Summary collapse

CURRENCY_SPECIAL_MINOR_UNITS =
{
  'BIF' => 0,
  'BYR' => 0,
  'CLF' => 0,
  'CLP' => 0,
  'CVE' => 0,
  'DJF' => 0,
  'GNF' => 0,
  'HUF' => 0,
  'ISK' => 0,
  'JPY' => 0,
  'KMF' => 0,
  'KRW' => 0,
  'PYG' => 0,
  'RWF' => 0,
  'UGX' => 0,
  'UYI' => 0,
  'VND' => 0,
  'VUV' => 0,
  'XAF' => 0,
  'XOF' => 0,
  'XPF' => 0,
  'BHD' => 3,
  'IQD' => 3,
  'JOD' => 3,
  'KWD' => 3,
  'LYD' => 3,
  'OMR' => 3,
  'TND' => 3,
  'COU' => 4
}

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_method, inherited, mapping, #raw_html_fields, #shipping_address, #test?

Constructor Details

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


49
50
51
52
53
54
55
56
57
58
# File 'lib/offsite_payments/integrations/universal.rb', line 49

def initialize(order, , options = {})
  @forward_url = options[:forward_url]
  @key = options[:credential2]
  @currency = options[:currency]
  super
  self.country = options[:country]
  self. = options[:account_name]
  self.transaction_type = options[:transaction_type]
  add_field 'x_test', @test.to_s
end

Dynamic Method Handling

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

Instance Method Details

#amount=(amount) ⇒ Object


68
69
70
# File 'lib/offsite_payments/integrations/universal.rb', line 68

def amount=(amount)
  add_field 'x_amount', format_amount(amount, @currency)
end

#credential_based_urlObject


60
61
62
# File 'lib/offsite_payments/integrations/universal.rb', line 60

def credential_based_url
  @forward_url
end

#form_fieldsObject


64
65
66
# File 'lib/offsite_payments/integrations/universal.rb', line 64

def form_fields
  sign_fields
end

#generate_signatureObject


84
85
86
# File 'lib/offsite_payments/integrations/universal.rb', line 84

def generate_signature
  Universal.sign(@fields, @key)
end

#shipping(amount) ⇒ Object


72
73
74
# File 'lib/offsite_payments/integrations/universal.rb', line 72

def shipping(amount)
  add_field 'x_amount_shipping', format_amount(amount, @currency)
end

#sign_fieldsObject


80
81
82
# File 'lib/offsite_payments/integrations/universal.rb', line 80

def sign_fields
  @fields.merge!('x_signature' => generate_signature)
end

#tax(amount) ⇒ Object


76
77
78
# File 'lib/offsite_payments/integrations/universal.rb', line 76

def tax(amount)
  add_field 'x_amount_tax', format_amount(amount, @currency)
end