Class: ActiveMerchant::Billing::Integrations::TwoCheckout::Helper
- Defined in:
- lib/active_merchant/billing/integrations/two_checkout/helper.rb
Instance Attribute Summary
Attributes inherited from Helper
Instance Method Summary collapse
-
#auto_settle(params = {}) ⇒ Object
Uses Third Party Cart parameter set to pass in lineitem details.
- #customer(params = {}) ⇒ Object
-
#initialize(order, account, options = {}) ⇒ Helper
constructor
A new instance of Helper.
-
#line_item(params = {}) ⇒ Object
Uses Pass Through Product Parameters to pass in lineitems.
Methods inherited from Helper
#add_field, #add_fields, #add_raw_html_field, #billing_address, #form_fields, #form_method, mapping, #raw_html_fields, #shipping_address, #test?
Constructor Details
#initialize(order, account, options = {}) ⇒ Helper
Returns a new instance of Helper.
6 7 8 9 10 11 12 13 |
# File 'lib/active_merchant/billing/integrations/two_checkout/helper.rb', line 6 def initialize(order, account, = {}) super add_field('fixed', 'Y') if ActiveMerchant::Billing::Base.integration_mode == :test || [:test] add_field('demo', 'Y') end end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class ActiveMerchant::Billing::Integrations::Helper
Instance Method Details
#auto_settle(params = {}) ⇒ Object
Uses Third Party Cart parameter set to pass in lineitem details. (sales settle automatically)
75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/active_merchant/billing/integrations/two_checkout/helper.rb', line 75 def auto_settle(params = {}) add_field('id_type', '1') (max_existing_line_item_id = form_fields.keys.map do |key| i = key.to_s[/^c_prod_(\d+)/, 1] (i && i.to_i) end.compact.max || 0) line_item_id = max_existing_line_item_id + 1 params.each do |key, value| add_field("c_#{key}_#{line_item_id}", value) end end |
#customer(params = {}) ⇒ Object
52 53 54 55 56 |
# File 'lib/active_merchant/billing/integrations/two_checkout/helper.rb', line 52 def customer(params = {}) add_field(mappings[:customer][:email], params[:email]) add_field(mappings[:customer][:phone], params[:phone]) add_field('card_holder_name', "#{params[:first_name]} #{params[:last_name]}") end |
#line_item(params = {}) ⇒ Object
Uses Pass Through Product Parameters to pass in lineitems. (must mark tanigble sales as shipped to settle the transaction)
60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/active_merchant/billing/integrations/two_checkout/helper.rb', line 60 def line_item(params = {}) add_field('mode', '2CO') (max_existing_line_item_id = form_fields.keys.map do |key| i = key.to_s[/^li_(\d+)_/, 1] (i && i.to_i) end.compact.max || 0) line_item_id = max_existing_line_item_id + 1 params.each do |key, value| add_field("li_#{line_item_id}_#{key}", value) end end |