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
- #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.
- #shipping_address(params = {}) ⇒ Object
-
#third_party_cart(params = {}) ⇒ Object
Uses Third Party Cart parameter set to pass in lineitem details.
Methods inherited from Helper
#add_field, #add_fields, #add_raw_html_field, #billing_address, #form_fields, #form_method, inherited, mapping, #raw_html_fields, #test?
Constructor Details
#initialize(order, account, options = {}) ⇒ Helper
Returns a new instance of Helper.
6 7 8 9 10 11 |
# File 'lib/active_merchant/billing/integrations/two_checkout/helper.rb', line 6 def initialize(order, account, = {}) super 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
#customer(params = {}) ⇒ Object
64 65 66 67 68 |
# File 'lib/active_merchant/billing/integrations/two_checkout/helper.rb', line 64 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.
76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/active_merchant/billing/integrations/two_checkout/helper.rb', line 76 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 |
#shipping_address(params = {}) ⇒ Object
70 71 72 73 |
# File 'lib/active_merchant/billing/integrations/two_checkout/helper.rb', line 70 def shipping_address(params = {}) super add_field(mappings[:shipping_address][:name], "#{params[:first_name]} #{params[:last_name]}") end |
#third_party_cart(params = {}) ⇒ Object
Uses Third Party Cart parameter set to pass in lineitem details. You must also specify ‘service.invoice` when using this method.
91 92 93 94 95 96 97 98 99 100 101 102 |
# File 'lib/active_merchant/billing/integrations/two_checkout/helper.rb', line 91 def third_party_cart(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 |