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,
'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
Returns a new instance of Helper.
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
# File 'lib/offsite_payments/integrations/universal.rb', line 49
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
72
73
74
|
# File 'lib/offsite_payments/integrations/universal.rb', line 72
def amount=(amount)
add_field 'x_amount', format_amount(amount, @currency)
end
|
#credential_based_url ⇒ Object
64
65
66
|
# File 'lib/offsite_payments/integrations/universal.rb', line 64
def credential_based_url
@forward_url
end
|
68
69
70
|
# File 'lib/offsite_payments/integrations/universal.rb', line 68
def form_fields
sign_fields
end
|
#generate_signature ⇒ Object
80
81
82
|
# File 'lib/offsite_payments/integrations/universal.rb', line 80
def generate_signature
Universal.sign(@fields, @key)
end
|
#sign_fields ⇒ Object
76
77
78
|
# File 'lib/offsite_payments/integrations/universal.rb', line 76
def sign_fields
@fields.merge!('x_signature' => generate_signature)
end
|