Class: ActiveMerchant::Billing::LitleGateway

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

Defined Under Namespace

Classes: LitleCardToken

Constant Summary collapse

LITLE_SCHEMA_VERSION =
'8.13'

Constants inherited from Gateway

Gateway::CREDIT_DEPRECATION_MESSAGE, Gateway::CURRENCIES_WITHOUT_FRACTIONS, Gateway::DEBIT_CARDS

Instance Attribute Summary

Attributes inherited from Gateway

#options

Instance Method Summary collapse

Methods inherited from Gateway

#card_brand, card_brand, inherited, supports?, #test?

Methods included from CreditCardFormatting

#format

Constructor Details

#initialize(options = {}) ⇒ LitleGateway

Returns a new instance of LitleGateway.



56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# File 'lib/active_merchant/billing/gateways/litle.rb', line 56

def initialize(options = {})
  begin
    require 'LitleOnline'
  rescue LoadError
    raise "Could not load the LitleOnline gem (> 08.15.0).  Use `gem install LitleOnline` to install it."
  end

  if wiredump_device
    LitleOnline::Configuration.logger = ((Logger === wiredump_device) ? wiredump_device : Logger.new(wiredump_device))
    LitleOnline::Configuration.logger.level = Logger::DEBUG
  else
    LitleOnline::Configuration.logger = Logger.new(STDOUT)
    LitleOnline::Configuration.logger.level = Logger::WARN
  end

  @litle = LitleOnline::LitleOnlineRequest.new

  options[:version]  ||= LITLE_SCHEMA_VERSION
  options[:merchant] ||= 'Default Report Group'
  options[:user]     ||= options[:login]

  requires!(options, :merchant_id, :user, :password, :merchant, :version)

  super
end

Instance Method Details

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



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

def authorize(money, creditcard_or_token, options = {})
  to_pass = build_authorize_request(money, creditcard_or_token, options)
  build_response(:authorization, @litle.authorization(to_pass))
end

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



92
93
94
95
96
# File 'lib/active_merchant/billing/gateways/litle.rb', line 92

def capture(money, authorization, options = {})
  transaction_id, kind = split_authorization(authorization)
  to_pass = create_capture_hash(money, transaction_id, options)
  build_response(:capture, @litle.capture(to_pass))
end

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



120
121
122
123
# File 'lib/active_merchant/billing/gateways/litle.rb', line 120

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

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



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

def purchase(money, creditcard_or_token, options = {})
  to_pass = build_purchase_request(money, creditcard_or_token, options)
  build_response(:sale, @litle.sale(to_pass))
end

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



115
116
117
118
# File 'lib/active_merchant/billing/gateways/litle.rb', line 115

def refund(money, authorization, options = {})
  to_pass = build_credit_request(money, authorization, options)
  build_response(:credit, @litle.credit(to_pass))
end

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



125
126
127
128
# File 'lib/active_merchant/billing/gateways/litle.rb', line 125

def store(creditcard_or_paypage_registration_id, options = {})
  to_pass = create_token_hash(creditcard_or_paypage_registration_id, options)
  build_response(:registerToken, @litle.register_token_request(to_pass), %w(000 801 802))
end

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

Note: Litle requires that authorization requests be voided via auth_reversal and other requests via void. To maintain the same interface as the other gateways the transaction_id and the kind of transaction are concatenated together with a ; separator (e.g. 1234;authorization)

A partial auth_reversal can be accomplished by passing :amount as an option



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

def void(identification, options = {})
  transaction_id, kind = split_authorization(identification)
  if(kind == 'authorization')
    to_pass = create_auth_reversal_hash(transaction_id, options[:amount], options)
    build_response(:authReversal, @litle.auth_reversal(to_pass))
  else
    to_pass = create_void_hash(transaction_id, options)
    build_response(:void, @litle.void(to_pass))
  end
end