Class: ActiveMerchant::Billing::LitleGateway
- Inherits:
-
Gateway
- Object
- Gateway
- ActiveMerchant::Billing::LitleGateway
show all
- Defined in:
- lib/active_merchant/billing/gateways/litle.rb
Constant Summary
collapse
- SCHEMA_VERSION =
'9.14'
Constants inherited
from Gateway
Gateway::CREDIT_DEPRECATION_MESSAGE, Gateway::RECURRING_DEPRECATION_MESSAGE, Gateway::STANDARD_ERROR_CODE
Instance Attribute Summary
Attributes inherited from Gateway
#options
Instance Method Summary
collapse
-
#authorize(money, payment_method, options = {}) ⇒ Object
-
#capture(money, authorization, options = {}) ⇒ Object
-
#credit(money, authorization, options = {}) ⇒ Object
-
#initialize(options = {}) ⇒ LitleGateway
constructor
A new instance of LitleGateway.
-
#purchase(money, payment_method, options = {}) ⇒ Object
-
#refund(money, payment, options = {}) ⇒ Object
-
#scrub(transcript) ⇒ Object
-
#store(payment_method, options = {}) ⇒ Object
-
#supports_scrubbing? ⇒ Boolean
-
#verify(creditcard, options = {}) ⇒ Object
-
#void(authorization, options = {}) ⇒ Object
Methods inherited from Gateway
#add_field_to_post_if_present, #add_fields_to_post_if_present, #card_brand, card_brand, #generate_unique_id, inherited, #supported_countries, supported_countries, supported_countries=, supports?, #supports_network_tokenization?, #test?
#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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
# File 'lib/active_merchant/billing/gateways/litle.rb', line 39
def authorize(money, payment_method, options={})
request = build_xml_request do |doc|
add_authentication(doc)
if check?(payment_method)
doc.echeckVerification(transaction_attributes(options)) do
add_echeck_purchase_params(doc, money, payment_method, options)
end
else
doc.authorization(transaction_attributes(options)) do
add_auth_purchase_params(doc, money, payment_method, options)
end
end
end
check?(payment_method) ? commit(:echeckVerification, request, money) : commit(:authorization, request, money)
end
|
#capture(money, authorization, options = {}) ⇒ Object
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
# File 'lib/active_merchant/billing/gateways/litle.rb', line 55
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
#purchase(money, payment_method, options = {}) ⇒ Object
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
# 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)
if check?(payment_method)
doc.echeckSale(transaction_attributes(options)) do
add_echeck_purchase_params(doc, money, payment_method, options)
end
else
doc.sale(transaction_attributes(options)) do
add_auth_purchase_params(doc, money, payment_method, options)
end
end
end
check?(payment_method) ? commit(:echeckSales, request, money) : commit(:sale, request, money)
end
|
#refund(money, payment, options = {}) ⇒ Object
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
|
# File 'lib/active_merchant/billing/gateways/litle.rb', line 75
def refund(money, payment, options={})
request = build_xml_request do |doc|
add_authentication(doc)
add_descriptor(doc, options)
doc.send(refund_type(payment), transaction_attributes(options)) do
if payment.is_a?(String)
transaction_id, _, _ = split_authorization(payment)
doc.litleTxnId(transaction_id)
doc.amount(money) if money
elsif check?(payment)
add_echeck_purchase_params(doc, money, payment, options)
else
add_auth_purchase_params(doc, money, payment, options)
end
end
end
commit(refund_type(payment), request)
end
|
#scrub(transcript) ⇒ Object
142
143
144
145
146
147
148
149
150
151
152
153
|
# File 'lib/active_merchant/billing/gateways/litle.rb', line 142
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((<accNum>).+(</accNum>)), '\1[FILTERED]\2').
gsub(%r((<routingNum>).+(</routingNum>)), '\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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
|
# File 'lib/active_merchant/billing/gateways/litle.rb', line 116
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.(payment_method)
elsif check?(payment_method)
doc.echeckForToken do
doc.accNum(payment_method.account_number)
doc.routingNum(payment_method.routing_number)
end
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
138
139
140
|
# File 'lib/active_merchant/billing/gateways/litle.rb', line 138
def supports_scrubbing?
true
end
|
#verify(creditcard, options = {}) ⇒ Object
95
96
97
98
99
100
|
# File 'lib/active_merchant/billing/gateways/litle.rb', line 95
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
102
103
104
105
106
107
108
109
110
111
112
113
114
|
# File 'lib/active_merchant/billing/gateways/litle.rb', line 102
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
|