Class: ActiveMerchant::Billing::LitleGateway

Inherits:
Gateway
  • Object
show all
Defined in:
lib/litle.rb

Overview

:nodoc:

Instance Method Summary collapse

Instance Method Details

#add_auth_purchase_params(doc, money, payment_method, options) ⇒ Object



42
43
44
45
46
47
48
49
50
51
52
# File 'lib/litle.rb', line 42

def add_auth_purchase_params(doc, money, payment_method, options)
  doc.orderId(truncate(options[:order_id], 24))
  doc.amount(money)
  add_order_source(doc, payment_method, options)
  add_billing_address(doc, payment_method, options)
  add_shipping_address(doc, payment_method, options)
  # Pass options to add_payment_method
  add_payment_method(doc, payment_method, options)
  add_pos(doc, payment_method)
  add_descriptor(doc, options)
end

#add_payment_method(doc, payment_method, options = {}) ⇒ Object



57
58
59
60
61
62
63
64
65
66
67
# File 'lib/litle.rb', line 57

def add_payment_method(doc, payment_method, options = {})
  if options.has_key?(:paypageRegistrationId)
    doc.paypage do
      doc.paypageRegistrationId(options[:paypage_registration_id])
      doc.expDate(exp_date(payment_method))
      doc.cardValidationNum(payment_method.verification_value)
    end
  else
    old_add_payment_method(doc, payment_method)
  end
end

#old_add_payment_methodObject

Add support for PayPage registration ids



55
# File 'lib/litle.rb', line 55

alias old_add_payment_method add_payment_method

#parse(kind, xml) ⇒ Object

Extract attributes



70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
# File 'lib/litle.rb', line 70

def parse(kind, xml)
  parsed = {}

  doc = Nokogiri::XML(xml).remove_namespaces!
  response_nodes = doc.xpath("//litleOnlineResponse/#{kind}Response")
  return {} unless !response_nodes.nil? && response_nodes.size == 1
  response_node = response_nodes[0]

  # Extract children elements
  response_node.elements.each do |node|
    if (node.elements.empty?)
      parsed[node.name.to_sym] = node.text
    else
      node.elements.each do |childnode|
        name = "#{node.name}_#{childnode.name}"
        parsed[name.to_sym] = childnode.text
      end
    end
  end

  # Extract attributes
  response_node.keys.each do |key|
    parsed[key.to_sym] ||= response_node[key]
  end

  parsed
end

#register_token_request(paypage_registration_id, options = {}) ⇒ Object



30
31
32
33
34
35
36
37
38
39
40
# File 'lib/litle.rb', line 30

def register_token_request(paypage_registration_id, options = {})
  request = build_xml_request do |doc|
    add_authentication(doc)
    doc.registerTokenRequest(transaction_attributes(options)) do
      doc.orderId((options[:order_id] || '')[0..24])
      doc.paypageRegistrationId(paypage_registration_id)
    end
  end

  commit(:registerToken, request)
end