class OffsitePayments::Integrations::TwoCheckout::Helper

Public Class Methods

new(order, account, options = {}) click to toggle source
Calls superclass method
# File lib/offsite_payments/integrations/two_checkout.rb, line 37
def initialize(order, account, options = {})
  super
  if OffsitePayments.mode == :test || options[:test]
    add_field('demo', 'Y')
  end
end

Public Instance Methods

customer(params = {}) click to toggle source
# File lib/offsite_payments/integrations/two_checkout.rb, line 92
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
shipping_address(params = {}) click to toggle source
Calls superclass method
# File lib/offsite_payments/integrations/two_checkout.rb, line 98
def shipping_address(params = {})
  super
  add_field(mappings[:shipping_address][:name], "#{params[:first_name]} #{params[:last_name]}")
end
third_party_cart(params = {}) click to toggle source

Uses Third Party Cart parameter set to pass in lineitem details. You must also specify ‘service.invoice` when using this method.

# File lib/offsite_payments/integrations/two_checkout.rb, line 105
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