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
-
#add_level_three_data(doc, payment_method, options = {}) ⇒ Object
-
#add_level_three_information_tags_master(doc, payment_method, level_3_data) ⇒ Object
-
#add_level_three_information_tags_visa(doc, payment_method, level_3_data) ⇒ Object
-
#add_level_two_data(doc, payment_method, options = {}) ⇒ Object
-
#add_line_item_information_for_level_three_visa(doc, payment_method, level_3_data) ⇒ Object
-
#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.
22
23
24
25
|
# File 'lib/active_merchant/billing/gateways/litle.rb', line 22
def initialize(options = {})
requires!(options, :login, :password, :merchant_id)
super
end
|
Instance Method Details
#add_level_three_data(doc, payment_method, options = {}) ⇒ Object
63
64
65
66
67
68
69
70
71
72
73
74
75
|
# File 'lib/active_merchant/billing/gateways/litle.rb', line 63
def add_level_three_data(doc, payment_method, options = {})
level_3_data = options[:level_3_data]
if level_3_data
doc.enhancedData do
case payment_method.brand
when 'visa'
add_level_three_information_tags_visa(doc, payment_method, level_3_data)
when 'master'
add_level_three_information_tags_master(doc, payment_method, level_3_data)
end
end
end
end
|
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
|
# File 'lib/active_merchant/billing/gateways/litle.rb', line 91
def add_level_three_information_tags_master(doc, payment_method, level_3_data)
doc.customerReference :customerReference, level_3_data[:customer_code] if level_3_data[:customer_code]
doc.salesTax(level_3_data[:total_tax_amount]) if level_3_data[:total_tax_amount]
doc.detailTax do
doc.taxIncludedInTotal(level_3_data[:tax_included_in_total]) if level_3_data[:tax_included_in_total]
doc.taxAmount(level_3_data[:tax_amount]) if level_3_data[:tax_amount]
doc.cardAcceptorTaxId :cardAcceptorTaxId, level_3_data[:card_acceptor_tax_id] if level_3_data[:card_acceptor_tax_id]
end
doc.lineItemData do
level_3_data[:line_items].each do |line_item|
doc.itemDescription(line_item[:item_description]) if line_item[:item_description]
doc.productCode(line_item[:product_code]) if line_item[:product_code]
doc.quantity(line_item[:quantity]) if line_item[:quantity]
doc.unitOfMeasure(line_item[:unit_of_measure]) if line_item[:unit_of_measure]
doc.lineItemTotal(line_item[:line_item_total]) if line_item[:line_item_total]
end
end
end
|
77
78
79
80
81
82
83
84
85
86
87
88
89
|
# File 'lib/active_merchant/billing/gateways/litle.rb', line 77
def add_level_three_information_tags_visa(doc, payment_method, level_3_data)
doc.discountAmount(level_3_data[:discount_amount]) if level_3_data[:discount_amount]
doc.shippingAmount(level_3_data[:shipping_amount]) if level_3_data[:shipping_amount]
doc.dutyAmount(level_3_data[:duty_amount]) if level_3_data[:duty_amount]
doc.detailTax do
doc.taxIncludedInTotal(level_3_data[:tax_included_in_total]) if level_3_data[:tax_included_in_total]
doc.taxAmount(level_3_data[:tax_amount]) if level_3_data[:tax_amount]
doc.taxRate(level_3_data[:tax_rate]) if level_3_data[:tax_rate]
doc.taxTypeIdentifier(level_3_data[:tax_type_identifier]) if level_3_data[:tax_type_identifier]
doc.cardAcceptorTaxId(level_3_data[:card_acceptor_tax_id]) if level_3_data[:card_acceptor_tax_id]
end
add_line_item_information_for_level_three_visa(doc, payment_method, level_3_data)
end
|
#add_level_two_data(doc, payment_method, options = {}) ⇒ Object
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
# File 'lib/active_merchant/billing/gateways/litle.rb', line 43
def add_level_two_data(doc, payment_method, options = {})
level_2_data = options[:level_2_data]
if level_2_data
doc.enhancedData do
case payment_method.brand
when 'visa'
doc.salesTax(level_2_data[:sales_tax]) if level_2_data[:sales_tax]
when 'master'
doc.customerReference(level_2_data[:customer_code]) if level_2_data[:customer_code]
doc.salesTax(level_2_data[:total_tax_amount]) if level_2_data[:total_tax_amount]
doc.detailTax do
doc.taxIncludedInTotal(level_2_data[:tax_included_in_total]) if level_2_data[:tax_included_in_total]
doc.taxAmount(level_2_data[:tax_amount]) if level_2_data[:tax_amount]
doc.cardAcceptorTaxId(level_2_data[:card_acceptor_tax_id]) if level_2_data[:card_acceptor_tax_id]
end
end
end
end
end
|
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
|
# File 'lib/active_merchant/billing/gateways/litle.rb', line 110
def add_line_item_information_for_level_three_visa(doc, payment_method, level_3_data)
doc.lineItemData do
level_3_data[:line_items].each do |line_item|
doc.itemSequenceNumber(line_item[:item_sequence_number]) if line_item[:item_sequence_number]
doc.commodityCode(line_item[:commodity_code]) if line_item[:commodity_code]
doc.itemDescription(line_item[:item_description]) if line_item[:item_description]
doc.productCode(line_item[:product_code]) if line_item[:product_code]
doc.quantity(line_item[:quantity]) if line_item[:quantity]
doc.unitOfMeasure(line_item[:unit_of_measure]) if line_item[:unit_of_measure]
doc.taxAmount(line_item[:tax_amount]) if line_item[:tax_amount]
doc.itemDiscountAmount(line_item[:discount_per_line_item]) unless line_item[:discount_per_line_item] < 0
doc.unitCost(line_item[:unit_cost]) unless line_item[:unit_cost] < 0
doc.detailTax do
doc.taxIncludedInTotal(line_item[:tax_included_in_total]) if line_item[:tax_included_in_total]
doc.taxAmount(line_item[:tax_amount]) if line_item[:tax_amount]
doc.taxRate(line_item[:tax_rate]) if line_item[:tax_rate]
doc.taxTypeIdentifier(line_item[:tax_type_identifier]) if line_item[:tax_type_identifier]
doc.cardAcceptorTaxId(line_item[:card_acceptor_tax_id]) if line_item[:card_acceptor_tax_id]
end
end
end
end
|
#authorize(money, payment_method, options = {}) ⇒ Object
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
|
# File 'lib/active_merchant/billing/gateways/litle.rb', line 133
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
149
150
151
152
153
154
155
156
157
158
159
160
161
162
|
# File 'lib/active_merchant/billing/gateways/litle.rb', line 149
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
# File 'lib/active_merchant/billing/gateways/litle.rb', line 27
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
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
|
# File 'lib/active_merchant/billing/gateways/litle.rb', line 169
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_credit_params(doc, money, payment, options)
end
end
end
commit(refund_type(payment), request)
end
|
#scrub(transcript) ⇒ Object
236
237
238
239
240
241
242
243
244
245
246
247
|
# File 'lib/active_merchant/billing/gateways/litle.rb', line 236
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
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
|
# File 'lib/active_merchant/billing/gateways/litle.rb', line 210
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
232
233
234
|
# File 'lib/active_merchant/billing/gateways/litle.rb', line 232
def supports_scrubbing?
true
end
|
#verify(creditcard, options = {}) ⇒ Object
189
190
191
192
193
194
|
# File 'lib/active_merchant/billing/gateways/litle.rb', line 189
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
196
197
198
199
200
201
202
203
204
205
206
207
208
|
# File 'lib/active_merchant/billing/gateways/litle.rb', line 196
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
|