Class: OffsitePayments::Integrations::RealexOffsite::Helper
- Inherits:
-
Helper
- Object
- Helper
- OffsitePayments::Integrations::RealexOffsite::Helper
show all
- Includes:
- Common
- Defined in:
- lib/offsite_payments/integrations/realex_offsite.rb
Constant Summary
Constants included
from Common
Common::CURRENCY_SPECIAL_MINOR_UNITS
Instance Attribute Summary
Attributes inherited from Helper
#fields
Instance Method Summary
collapse
Methods included from Common
#create_signature, #extract_avs_code, #extract_digits, #format_amount, #format_amount_as_float
Methods inherited from Helper
#add_field, #add_fields, #add_raw_html_field, #form_method, inherited, mapping, #raw_html_fields, #test?
Constructor Details
#initialize(order, account, options = {}) ⇒ Helper
Returns a new instance of Helper.
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
|
# File 'lib/offsite_payments/integrations/realex_offsite.rb', line 103
def initialize(order, account, options = {})
@timestamp = Time.now.strftime('%Y%m%d%H%M%S')
@currency = options[:currency]
@merchant_id = account
@sub_account = options[:credential2]
@secret = options[:credential3]
super
add_field 'MERCHANT_ID', @merchant_id
add_field 'ACCOUNT', @sub_account
add_field 'AUTO_SETTLE_FLAG', '1'
add_field 'RETURN_TSS', '1'
add_field 'TIMESTAMP', @timestamp
add_field 'X-CURRENCY', @currency
add_field 'X-TEST', @test.to_s
add_field 'ORDER_ID', "#{order}#{@timestamp.to_i}"
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
128
129
130
|
# File 'lib/offsite_payments/integrations/realex_offsite.rb', line 128
def amount=(amount)
add_field 'AMOUNT', format_amount(amount, @currency)
end
|
#billing_address(params = {}) ⇒ Object
132
133
134
135
|
# File 'lib/offsite_payments/integrations/realex_offsite.rb', line 132
def billing_address(params={})
add_field(mappings[:billing_address][:zip], (params))
add_field(mappings[:billing_address][:country], lookup_country_code(params[:country]))
end
|
124
125
126
|
# File 'lib/offsite_payments/integrations/realex_offsite.rb', line 124
def form_fields
sign_fields
end
|
#generate_signature ⇒ Object
146
147
148
149
150
151
152
153
|
# File 'lib/offsite_payments/integrations/realex_offsite.rb', line 146
def generate_signature
fields_to_sign = []
['TIMESTAMP', 'MERCHANT_ID', 'ORDER_ID', 'AMOUNT', 'CURRENCY'].each do |field|
fields_to_sign << @fields[field]
end
create_signature(fields_to_sign, @secret)
end
|
#shipping_address(params = {}) ⇒ Object
137
138
139
140
|
# File 'lib/offsite_payments/integrations/realex_offsite.rb', line 137
def shipping_address(params={})
add_field(mappings[:shipping_address][:zip], (params))
add_field(mappings[:shipping_address][:country], lookup_country_code(params[:country]))
end
|
#sign_fields ⇒ Object
142
143
144
|
# File 'lib/offsite_payments/integrations/realex_offsite.rb', line 142
def sign_fields
@fields.merge!('SHA1HASH' => generate_signature)
end
|