Class: OffsitePayments::Integrations::Universal::Helper
- Inherits:
-
Helper
- Object
- Helper
- OffsitePayments::Integrations::Universal::Helper
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,
'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?
#to_cents
Constructor Details
#initialize(order, account, options = {}) ⇒ Helper
Returns a new instance of Helper.
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
# File 'lib/offsite_payments/integrations/universal.rb', line 48
def initialize(order, account, options = {})
@forward_url = options[:forward_url]
@key = options[:credential2]
@currency = options[:currency]
options[:credential3] = nil if options[:credential3] == @forward_url
super
self.country = options[:country]
self.account_name = 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
71
72
73
|
# File 'lib/offsite_payments/integrations/universal.rb', line 71
def amount=(amount)
add_field 'x_amount', format_amount(amount, @currency)
end
|
#credential_based_url ⇒ Object
63
64
65
|
# File 'lib/offsite_payments/integrations/universal.rb', line 63
def credential_based_url
@forward_url
end
|
67
68
69
|
# File 'lib/offsite_payments/integrations/universal.rb', line 67
def form_fields
sign_fields
end
|
#generate_signature ⇒ Object
79
80
81
82
|
# File 'lib/offsite_payments/integrations/universal.rb', line 79
def generate_signature
fields_to_sign = @fields.select { |key, _| key.start_with?('x_') && key != 'x_signature' }
Universal.sign(fields_to_sign, @key)
end
|
#sign_fields ⇒ Object
75
76
77
|
# File 'lib/offsite_payments/integrations/universal.rb', line 75
def sign_fields
@fields.merge!('x_signature' => generate_signature)
end
|