Class: ActiveMerchant::Billing::LitleGateway

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

Constant Summary collapse

SCHEMA_VERSION =
'8.18'

Constants inherited from Gateway

Gateway::CREDIT_DEPRECATION_MESSAGE, Gateway::CURRENCIES_WITHOUT_FRACTIONS, 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, non_fractional_currency?, #scrub, supported_countries, #supported_countries, supported_countries=, supports?, #supports_scrubbing?, #test?

Methods included from CreditCardFormatting

#expdate, #format

Constructor Details

#initialize(options = {}) ⇒ LitleGateway

Public: Create a new Litle gateway.

options - A hash of options:

:login         - The user.
:password      - The password.
:merchant_id   - The merchant id.

24
25
26
27
# File 'lib/active_merchant/billing/gateways/litle.rb', line 24

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

Instance Method Details

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


40
41
42
43
44
45
46
47
48
49
# File 'lib/active_merchant/billing/gateways/litle.rb', line 40

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)
end

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


51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/active_merchant/billing/gateways/litle.rb', line 51

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)
end

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


66
67
68
69
# File 'lib/active_merchant/billing/gateways/litle.rb', line 66

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

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


29
30
31
32
33
34
35
36
37
38
# File 'lib/active_merchant/billing/gateways/litle.rb', line 29

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)
end

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


71
72
73
74
75
76
77
78
79
80
81
82
83
84
# File 'lib/active_merchant/billing/gateways/litle.rb', line 71

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

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


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

def store(creditcard, options = {})
  request = build_xml_request do |doc|
    add_authentication(doc)
    doc.registerTokenRequest(transaction_attributes(options)) do
      doc.orderId(truncated(options[:order_id]))
      doc.accountNumber(creditcard.number)
    end
  end

  commit(:registerToken, request)
end

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


86
87
88
89
90
91
# File 'lib/active_merchant/billing/gateways/litle.rb', line 86

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


93
94
95
96
97
98
99
100
101
102
103
104
# File 'lib/active_merchant/billing/gateways/litle.rb', line 93

def void(authorization, options={})
  transaction_id, kind = 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)
    end
  end

  commit(void_type(kind), request)
end