Class: ActiveMerchant::Billing::LitleGateway

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

Constant Summary collapse

SCHEMA_VERSION =
'9.12'

Constants inherited from Gateway

Gateway::CREDIT_DEPRECATION_MESSAGE, Gateway::DEBIT_CARDS, Gateway::RECURRING_DEPRECATION_MESSAGE, Gateway::STANDARD_ERROR_CODE

Instance Attribute Summary

Attributes inherited from Gateway

#options

Instance Method Summary collapse

Methods inherited from Gateway

#card_brand, card_brand, #generate_unique_id, inherited, #supported_countries, supported_countries, supported_countries=, supports?, #supports_network_tokenization?, #test?

Methods included from CreditCardFormatting

#expdate, #format

Methods included from PostsData

included, #raw_ssl_request, #ssl_get, #ssl_post, #ssl_request

Constructor Details

#initialize(options = {}) ⇒ LitleGateway

Returns a new instance of LitleGateway


18
19
20
21
# File 'lib/active_merchant/billing/gateways/litle.rb', line 18

def initialize(options={})
  requires!(options, :login, :password, :merchant_id)
  super
end

Instance Method Details

#authorize(money, payment_method, options = {}) ⇒ Object


34
35
36
37
38
39
40
41
42
43
# File 'lib/active_merchant/billing/gateways/litle.rb', line 34

def authorize(money, payment_method, options={})
  request = build_xml_request do |doc|
    add_authentication(doc)
    doc.authorization(transaction_attributes(options)) do
      add_auth_purchase_params(doc, money, payment_method, options)
    end
  end

  commit(:authorization, request, money)
end

#capture(money, authorization, options = {}) ⇒ Object


45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/active_merchant/billing/gateways/litle.rb', line 45

def capture(money, authorization, options={})
  transaction_id, _, _ = split_authorization(authorization)

  request = build_xml_request do |doc|
    add_authentication(doc)
    add_descriptor(doc, options)
    doc.capture_(transaction_attributes(options)) do
      doc.litleTxnId(transaction_id)
      doc.amount(money) if money
    end
  end

  commit(:capture, request, money)
end

#credit(money, authorization, options = {}) ⇒ Object


60
61
62
63
# File 'lib/active_merchant/billing/gateways/litle.rb', line 60

def credit(money, authorization, options = {})
  ActiveMerchant.deprecated CREDIT_DEPRECATION_MESSAGE
  refund(money, authorization, options)
end

#purchase(money, payment_method, options = {}) ⇒ Object


23
24
25
26
27
28
29
30
31
32
# File 'lib/active_merchant/billing/gateways/litle.rb', line 23

def purchase(money, payment_method, options={})
  request = build_xml_request do |doc|
    add_authentication(doc)
    doc.sale(transaction_attributes(options)) do
      add_auth_purchase_params(doc, money, payment_method, options)
    end
  end

  commit(:sale, request, money)
end

#refund(money, authorization, options = {}) ⇒ Object


65
66
67
68
69
70
71
72
73
74
75
76
77
78
# File 'lib/active_merchant/billing/gateways/litle.rb', line 65

def refund(money, authorization, options={})
  transaction_id, _, _ = split_authorization(authorization)

  request = build_xml_request do |doc|
    add_authentication(doc)
    add_descriptor(doc, options)
    doc.credit(transaction_attributes(options)) do
      doc.litleTxnId(transaction_id)
      doc.amount(money) if money
    end
  end

  commit(:credit, request)
end

#scrub(transcript) ⇒ Object


122
123
124
125
126
127
128
129
130
131
# File 'lib/active_merchant/billing/gateways/litle.rb', line 122

def scrub(transcript)
  transcript.
    gsub(%r((<user>).+(</user>)), '\1[FILTERED]\2').
    gsub(%r((<password>).+(</password>)), '\1[FILTERED]\2').
    gsub(%r((<number>).+(</number>)), '\1[FILTERED]\2').
    gsub(%r((<cardValidationNum>).+(</cardValidationNum>)), '\1[FILTERED]\2').
    gsub(%r((<accountNumber>).+(</accountNumber>)), '\1[FILTERED]\2').
    gsub(%r((<paypageRegistrationId>).+(</paypageRegistrationId>)), '\1[FILTERED]\2').
    gsub(%r((<authenticationValue>).+(</authenticationValue>)), '\1[FILTERED]\2')
end

#store(payment_method, options = {}) ⇒ Object


101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
# File 'lib/active_merchant/billing/gateways/litle.rb', line 101

def store(payment_method, options = {})
  request = build_xml_request do |doc|
    add_authentication(doc)
    doc.registerTokenRequest(transaction_attributes(options)) do
      doc.orderId(truncate(options[:order_id], 24))
      if payment_method.is_a?(String)
        doc.paypageRegistrationId(payment_method)
      else
        doc.accountNumber(payment_method.number)
        doc.cardValidationNum(payment_method.verification_value) if payment_method.verification_value
      end
    end
  end

  commit(:registerToken, request)
end

#supports_scrubbing?Boolean

Returns:

  • (Boolean)

118
119
120
# File 'lib/active_merchant/billing/gateways/litle.rb', line 118

def supports_scrubbing?
  true
end

#verify(creditcard, options = {}) ⇒ Object


80
81
82
83
84
85
# File 'lib/active_merchant/billing/gateways/litle.rb', line 80

def verify(creditcard, options = {})
  MultiResponse.run(:use_first_response) do |r|
    r.process { authorize(0, creditcard, options) }
    r.process(:ignore_result) { void(r.authorization, options) }
  end
end

#void(authorization, options = {}) ⇒ Object


87
88
89
90
91
92
93
94
95
96
97
98
99
# File 'lib/active_merchant/billing/gateways/litle.rb', line 87

def void(authorization, options={})
  transaction_id, kind, money = split_authorization(authorization)

  request = build_xml_request do |doc|
    add_authentication(doc)
    doc.send(void_type(kind), transaction_attributes(options)) do
      doc.litleTxnId(transaction_id)
      doc.amount(money) if void_type(kind) == :authReversal
    end
  end

  commit(void_type(kind), request)
end