Class: OffsitePayments::Integrations::WebPay::Helper
- Inherits:
-
Helper
- Object
- Helper
- OffsitePayments::Integrations::WebPay::Helper
show all
- Includes:
- Common
- Defined in:
- lib/offsite_payments/integrations/web_pay.rb
Instance Attribute Summary
Attributes inherited from Helper
#fields
Instance Method Summary
collapse
Methods included from Common
#generate_signature, #notify_signature_string, #request_signature_string
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.
83
84
85
86
87
|
# File 'lib/offsite_payments/integrations/web_pay.rb', line 83
def initialize(order, account, options = {})
@md5secret = options.delete(:secret)
@line_item_count = 0
super
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
in the class OffsitePayments::Helper
Instance Method Details
#add_line_item(options) ⇒ Object
101
102
103
104
105
106
107
|
# File 'lib/offsite_payments/integrations/web_pay.rb', line 101
def add_line_item(options)
options.each do |key, value|
add_field("wsb_invoice_item_#{key}[#{@line_item_count}]", value)
end
@line_item_count += 1
end
|
#calculate_total ⇒ Object
109
110
111
112
113
114
115
116
117
|
# File 'lib/offsite_payments/integrations/web_pay.rb', line 109
def calculate_total
sum = 0
@line_item_count.times do |i|
sum += @fields["wsb_invoice_item_quantity[#{i}]"].to_i * @fields["wsb_invoice_item_price[#{i}]"].to_i
end
sum + @fields[mappings[:tax]].to_i + @fields[mappings[:shipping_price]].to_i - @fields[mappings[:discount_price]].to_i
end
|
89
90
91
|
# File 'lib/offsite_payments/integrations/web_pay.rb', line 89
def form_fields
@fields.merge(OffsitePayments::Integrations::WebPay.signature_parameter_name => generate_signature(:request))
end
|
#params ⇒ Object
93
94
95
|
# File 'lib/offsite_payments/integrations/web_pay.rb', line 93
def params
@fields
end
|
#secret ⇒ Object
97
98
99
|
# File 'lib/offsite_payments/integrations/web_pay.rb', line 97
def secret
@md5secret
end
|