activemerchant 1.56.0 → 1.66.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (113) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG +331 -0
  3. data/README.md +9 -9
  4. data/lib/active_merchant/billing/check.rb +3 -0
  5. data/lib/active_merchant/billing/credit_card.rb +8 -3
  6. data/lib/active_merchant/billing/credit_card_methods.rb +41 -1
  7. data/lib/active_merchant/billing/gateway.rb +14 -6
  8. data/lib/active_merchant/billing/gateways/adyen.rb +228 -0
  9. data/lib/active_merchant/billing/gateways/authorize_net.rb +157 -44
  10. data/lib/active_merchant/billing/gateways/authorize_net_cim.rb +7 -4
  11. data/lib/active_merchant/billing/gateways/barclaycard_smartpay.rb +283 -0
  12. data/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb +68 -2
  13. data/lib/active_merchant/billing/gateways/blue_pay.rb +2 -2
  14. data/lib/active_merchant/billing/gateways/blue_snap.rb +348 -0
  15. data/lib/active_merchant/billing/gateways/bpoint.rb +1 -1
  16. data/lib/active_merchant/billing/gateways/braintree_blue.rb +58 -20
  17. data/lib/active_merchant/billing/gateways/bridge_pay.rb +37 -8
  18. data/lib/active_merchant/billing/gateways/card_stream.rb +161 -40
  19. data/lib/active_merchant/billing/gateways/cashnet.rb +1 -0
  20. data/lib/active_merchant/billing/gateways/checkout_v2.rb +5 -2
  21. data/lib/active_merchant/billing/gateways/citrus_pay.rb +24 -0
  22. data/lib/active_merchant/billing/gateways/clearhaus.rb +24 -40
  23. data/lib/active_merchant/billing/gateways/conekta.rb +6 -1
  24. data/lib/active_merchant/billing/gateways/creditcall.rb +1 -1
  25. data/lib/active_merchant/billing/gateways/credorax.rb +310 -0
  26. data/lib/active_merchant/billing/gateways/culqi.rb +279 -0
  27. data/lib/active_merchant/billing/gateways/cyber_source.rb +80 -64
  28. data/lib/active_merchant/billing/gateways/data_cash.rb +10 -304
  29. data/lib/active_merchant/billing/gateways/digitzs.rb +292 -0
  30. data/lib/active_merchant/billing/gateways/elavon.rb +40 -26
  31. data/lib/active_merchant/billing/gateways/element.rb +356 -0
  32. data/lib/active_merchant/billing/gateways/fat_zebra.rb +16 -2
  33. data/lib/active_merchant/billing/gateways/firstdata_e4.rb +6 -1
  34. data/lib/active_merchant/billing/gateways/forte.rb +10 -2
  35. data/lib/active_merchant/billing/gateways/global_collect.rb +311 -0
  36. data/lib/active_merchant/billing/gateways/global_transport.rb +1 -0
  37. data/lib/active_merchant/billing/gateways/iats_payments.rb +13 -0
  38. data/lib/active_merchant/billing/gateways/in_context_paypal_express.rb +15 -0
  39. data/lib/active_merchant/billing/gateways/iveri.rb +251 -0
  40. data/lib/active_merchant/billing/gateways/jetpay.rb +33 -19
  41. data/lib/active_merchant/billing/gateways/kushki.rb +217 -0
  42. data/lib/active_merchant/billing/gateways/latitude19.rb +416 -0
  43. data/lib/active_merchant/billing/gateways/linkpoint.rb +2 -0
  44. data/lib/active_merchant/billing/gateways/litle.rb +29 -13
  45. data/lib/active_merchant/billing/gateways/mastercard.rb +268 -0
  46. data/lib/active_merchant/billing/gateways/maxipago.rb +145 -122
  47. data/lib/active_merchant/billing/gateways/merchant_e_solutions.rb +15 -1
  48. data/lib/active_merchant/billing/gateways/merchant_warrior.rb +10 -7
  49. data/lib/active_merchant/billing/gateways/mercury.rb +13 -5
  50. data/lib/active_merchant/billing/gateways/metrics_global.rb +1 -1
  51. data/lib/active_merchant/billing/gateways/migs.rb +23 -1
  52. data/lib/active_merchant/billing/gateways/monei.rb +1 -1
  53. data/lib/active_merchant/billing/gateways/moneris.rb +21 -1
  54. data/lib/active_merchant/billing/gateways/nab_transact.rb +12 -0
  55. data/lib/active_merchant/billing/gateways/ncr_secure_pay.rb +165 -0
  56. data/lib/active_merchant/billing/gateways/netbanx.rb +245 -0
  57. data/lib/active_merchant/billing/gateways/nmi.rb +30 -9
  58. data/lib/active_merchant/billing/gateways/omise.rb +9 -5
  59. data/lib/active_merchant/billing/gateways/openpay.rb +10 -1
  60. data/lib/active_merchant/billing/gateways/opp.rb +362 -0
  61. data/lib/active_merchant/billing/gateways/orbital.rb +28 -7
  62. data/lib/active_merchant/billing/gateways/pagarme.rb +248 -0
  63. data/lib/active_merchant/billing/gateways/pay_junction_v2.rb +190 -0
  64. data/lib/active_merchant/billing/gateways/payeezy.rb +61 -12
  65. data/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb +1 -1
  66. data/lib/active_merchant/billing/gateways/payflow.rb +6 -0
  67. data/lib/active_merchant/billing/gateways/payment_express.rb +1 -1
  68. data/lib/active_merchant/billing/gateways/paymill.rb +29 -11
  69. data/lib/active_merchant/billing/gateways/paypal/paypal_common_api.rb +1 -1
  70. data/lib/active_merchant/billing/gateways/paypal_express.rb +1 -6
  71. data/lib/active_merchant/billing/gateways/payu_in.rb +3 -2
  72. data/lib/active_merchant/billing/gateways/payu_latam.rb +402 -0
  73. data/lib/active_merchant/billing/gateways/pin.rb +6 -3
  74. data/lib/active_merchant/billing/gateways/pro_pay.rb +326 -0
  75. data/lib/active_merchant/billing/gateways/psl_card.rb +3 -3
  76. data/lib/active_merchant/billing/gateways/quickpay/quickpay_common.rb +1 -1
  77. data/lib/active_merchant/billing/gateways/quickpay/quickpay_v10.rb +0 -2
  78. data/lib/active_merchant/billing/gateways/quickpay/quickpay_v4to7.rb +1 -1
  79. data/lib/active_merchant/billing/gateways/quickpay.rb +3 -3
  80. data/lib/active_merchant/billing/gateways/qvalent.rb +44 -1
  81. data/lib/active_merchant/billing/gateways/redsys.rb +3 -0
  82. data/lib/active_merchant/billing/gateways/s5.rb +8 -5
  83. data/lib/active_merchant/billing/gateways/safe_charge.rb +220 -0
  84. data/lib/active_merchant/billing/gateways/sage.rb +397 -128
  85. data/lib/active_merchant/billing/gateways/sage_pay.rb +45 -20
  86. data/lib/active_merchant/billing/gateways/secure_net.rb +0 -5
  87. data/lib/active_merchant/billing/gateways/secure_pay.rb +1 -1
  88. data/lib/active_merchant/billing/gateways/secure_pay_au.rb +12 -0
  89. data/lib/active_merchant/billing/gateways/securion_pay.rb +46 -17
  90. data/lib/active_merchant/billing/gateways/stripe.rb +125 -29
  91. data/lib/active_merchant/billing/gateways/telr.rb +275 -0
  92. data/lib/active_merchant/billing/gateways/tns.rb +13 -222
  93. data/lib/active_merchant/billing/gateways/trans_first.rb +40 -16
  94. data/lib/active_merchant/billing/gateways/trans_first_transaction_express.rb +606 -0
  95. data/lib/active_merchant/billing/gateways/usa_epay_advanced.rb +114 -9
  96. data/lib/active_merchant/billing/gateways/vanco.rb +14 -10
  97. data/lib/active_merchant/billing/gateways/visanet_peru.rb +209 -0
  98. data/lib/active_merchant/billing/gateways/wepay.rb +73 -38
  99. data/lib/active_merchant/billing/gateways/wirecard.rb +1 -0
  100. data/lib/active_merchant/billing/gateways/world_net.rb +344 -0
  101. data/lib/active_merchant/billing/gateways/worldpay.rb +48 -16
  102. data/lib/active_merchant/billing/network_tokenization_credit_card.rb +15 -0
  103. data/lib/active_merchant/country.rb +6 -4
  104. data/lib/active_merchant/posts_data.rb +1 -1
  105. data/lib/active_merchant/version.rb +1 -1
  106. metadata +32 -13
  107. data/lib/active_merchant/billing/gateways/app55.rb +0 -176
  108. data/lib/active_merchant/billing/gateways/barclays_epdq.rb +0 -314
  109. data/lib/active_merchant/billing/gateways/certo_direct.rb +0 -278
  110. data/lib/active_merchant/billing/gateways/sage/sage_bankcard.rb +0 -89
  111. data/lib/active_merchant/billing/gateways/sage/sage_core.rb +0 -115
  112. data/lib/active_merchant/billing/gateways/sage/sage_vault.rb +0 -149
  113. data/lib/active_merchant/billing/gateways/sage/sage_virtual_check.rb +0 -97
@@ -0,0 +1,416 @@
1
+ module ActiveMerchant #:nodoc:
2
+ module Billing #:nodoc:
3
+ class Latitude19Gateway < Gateway
4
+ self.display_name = "Latitude19 Gateway"
5
+ self.homepage_url = "http://www.l19tech.com"
6
+
7
+ self.live_url = "https://gateway.l19tech.com/payments/"
8
+ self.test_url = "https://gateway-sb.l19tech.com/payments/"
9
+
10
+ self.supported_countries = ["US", "CA"]
11
+ self.default_currency = "USD"
12
+ self.money_format = :cents
13
+ self.supported_cardtypes = [:visa, :master, :american_express, :discover, :diners_club, :jcb]
14
+
15
+ RESPONSE_CODE_MAPPING = {
16
+ '100' => 'Approved',
17
+ '101' => 'Local duplicate detected',
18
+ '102' => 'Accepted local capture with no match',
19
+ '103' => 'Auth succeeded but capture failed',
20
+ '104' => 'Auth succeeded but failed to save info',
21
+ '200' => STANDARD_ERROR_CODE[:card_declined],
22
+ '300' => 'Processor reject',
23
+ '301' => 'Local reject on user/password',
24
+ '302' => 'Local reject',
25
+ '303' => 'Processor unknown response',
26
+ '304' => 'Error parsing processor response',
27
+ '305' => 'Processor auth succeeded but settle failed',
28
+ '306' => 'Processor auth succeeded settle status unknown',
29
+ '307' => 'Processor settle status unknown',
30
+ '308' => 'Processor duplicate',
31
+ '400' => 'Not submitted',
32
+ '401' => 'Terminated before request submitted',
33
+ '402' => 'Local server busy',
34
+ '500' => 'Submitted not returned',
35
+ '501' => 'Terminated before response returned',
36
+ '502' => 'Processor returned timeout status',
37
+ '600' => 'Failed local capture with no match',
38
+ '601' => 'Failed local capture',
39
+ '700' => 'Failed local void (not in capture file)',
40
+ '701' => 'Failed local void',
41
+ '800' => 'Failed local refund (not authorized)',
42
+ '801' => 'Failed local refund'
43
+ }
44
+
45
+ BRAND_MAP = {
46
+ "master" => "MC",
47
+ "visa" => "VI",
48
+ "american_express" => "AX",
49
+ "discover" => "DS",
50
+ "diners_club" => "DC",
51
+ "jcb" => "JC"
52
+ }
53
+
54
+ def initialize(options={})
55
+ requires!(options, :account_number, :configuration_id, :secret)
56
+ super
57
+ end
58
+
59
+ def purchase(amount, payment_method, options={})
60
+ if payment_method.is_a?(String)
61
+ auth_or_sale("sale", payment_method, amount, nil, options)
62
+ else
63
+ MultiResponse.run() do |r|
64
+ r.process { get_session(options) }
65
+ r.process { get_token(r.authorization, payment_method, options) }
66
+ r.process { auth_or_sale("sale", r.authorization, amount, payment_method, options) }
67
+ end
68
+ end
69
+ end
70
+
71
+ def authorize(amount, payment_method, options={})
72
+ if payment_method.is_a?(String)
73
+ auth_or_sale("auth", payment_method, amount, nil, options)
74
+ else
75
+ MultiResponse.run() do |r|
76
+ r.process { get_session(options) }
77
+ r.process { get_token(r.authorization, payment_method, options) }
78
+ r.process { auth_or_sale("auth", r.authorization, amount, payment_method, options) }
79
+ end
80
+ end
81
+ end
82
+
83
+ def capture(amount, authorization, options={})
84
+ post = {}
85
+ post[:method] = "deposit"
86
+ add_request_id(post)
87
+
88
+ params = {}
89
+
90
+ _, params[:pgwTID] = split_authorization(authorization)
91
+
92
+ add_invoice(params, amount, options)
93
+ add_credentials(params, post[:method])
94
+
95
+ post[:params] = [params]
96
+ commit("v1/", post)
97
+ end
98
+
99
+ def void(authorization, options={})
100
+ method, pgwTID = split_authorization(authorization)
101
+ case method
102
+ when "auth"
103
+ reverse_or_void("reversal", pgwTID, options)
104
+ when "deposit", "sale"
105
+ reverse_or_void("void", pgwTID, options)
106
+ else
107
+ message = "Unsupported operation: successful Purchase, Authorize and unsettled Capture transactions can only be voided."
108
+ return Response.new(false, message)
109
+ end
110
+ end
111
+
112
+ def credit(amount, payment_method, options={})
113
+ if payment_method.is_a?(String)
114
+ refundWithCard(payment_method, amount, nil, options)
115
+ else
116
+ MultiResponse.run() do |r|
117
+ r.process { get_session(options) }
118
+ r.process { get_token(r.authorization, payment_method, options) }
119
+ r.process { refundWithCard(r.authorization, amount, payment_method, options) }
120
+ end
121
+ end
122
+ end
123
+
124
+ def verify(payment_method, options={}, action=nil)
125
+ if payment_method.is_a?(String)
126
+ verifyOnly(action, payment_method, nil, options)
127
+ else
128
+ MultiResponse.run() do |r|
129
+ r.process { get_session(options) }
130
+ r.process { get_token(r.authorization, payment_method, options) }
131
+ r.process { verifyOnly(action, r.authorization, payment_method, options) }
132
+ end
133
+ end
134
+ end
135
+
136
+ def store(payment_method, options={})
137
+ verify(payment_method, options, "store")
138
+ end
139
+
140
+ def supports_scrubbing?
141
+ true
142
+ end
143
+
144
+ def scrub(transcript)
145
+ transcript.
146
+ gsub(%r((\"cardNumber\\\":\\\")\d+), '\1[FILTERED]').
147
+ gsub(%r((\"cvv\\\":\\\")\d+), '\1[FILTERED]')
148
+ end
149
+
150
+
151
+ private
152
+
153
+ def add_request_id(post)
154
+ post[:id] = SecureRandom.hex(16)
155
+ end
156
+
157
+ def add_timestamp()
158
+ Time.now.getutc.strftime("%Y%m%d%H%M%S")
159
+ end
160
+
161
+ def add_hmac(params, method)
162
+ if method == "getSession"
163
+ hmac_message = params[:pgwAccountNumber] + "|" + params[:pgwConfigurationId] + "|" + params[:requestTimeStamp] + "|" + method
164
+ else
165
+ hmac_message = params[:pgwAccountNumber] + "|" + params[:pgwConfigurationId] + "|" + (params[:orderNumber] || "") + "|" + method + "|" + (params[:amount] || "") + "|" + (params[:sessionToken] || "") + "|" + (params[:accountToken] || "")
166
+ end
167
+
168
+ OpenSSL::HMAC.hexdigest('sha512', @options[:secret], hmac_message)
169
+ end
170
+
171
+ def add_credentials(params, method)
172
+ params[:pgwAccountNumber] = @options[:account_number]
173
+ params[:pgwConfigurationId] = @options[:configuration_id]
174
+
175
+ params[:requestTimeStamp] = add_timestamp() if method == "getSession"
176
+
177
+ params[:pgwHMAC] = add_hmac(params, method)
178
+ end
179
+
180
+ def add_invoice(params, money, options)
181
+ params[:amount] = amount(money)
182
+ params[:orderNumber] = options[:order_id]
183
+ params[:transactionClass] = options[:transaction_class] || "eCommerce"
184
+ end
185
+
186
+ def add_payment_method(params, credit_card)
187
+ params[:cardExp] = format(credit_card.month, :two_digits).to_s + "/" + format(credit_card.year, :two_digits).to_s
188
+ params[:cardType] = BRAND_MAP[credit_card.brand.to_s]
189
+ params[:cvv] = credit_card.verification_value
190
+ params[:firstName] = credit_card.first_name
191
+ params[:lastName] = credit_card.last_name
192
+ end
193
+
194
+ def add_customer_data(params, options)
195
+ if (billing_address = options[:billing_address] || options[:address])
196
+ params[:address1] = billing_address[:address1]
197
+ params[:address2] = billing_address[:address2]
198
+ params[:city] = billing_address[:city]
199
+ params[:stateProvince] = billing_address[:state]
200
+ params[:zipPostalCode] = billing_address[:zip]
201
+ params[:countryCode] = billing_address[:country]
202
+ end
203
+ end
204
+
205
+ def get_session(options={})
206
+ post = {}
207
+ post[:method] = "getSession"
208
+ add_request_id(post)
209
+
210
+ params = {}
211
+ add_credentials(params, post[:method])
212
+
213
+ post[:params] = [params]
214
+ commit("session", post)
215
+ end
216
+
217
+ def get_token(authorization, payment_method, options={})
218
+ post = {}
219
+ post[:method] = "tokenize"
220
+ add_request_id(post)
221
+
222
+ params = {}
223
+ _, params[:sessionId] = split_authorization(authorization)
224
+ params[:cardNumber] = payment_method.number
225
+
226
+ post[:params] = [params]
227
+ commit("token", post)
228
+ end
229
+
230
+ def auth_or_sale(method, authorization, amount, credit_card, options={})
231
+ post = {}
232
+ post[:method] = method
233
+ add_request_id(post)
234
+
235
+ params = {}
236
+ if credit_card
237
+ _, params[:sessionToken] = split_authorization(authorization)
238
+ add_payment_method(params, credit_card)
239
+ add_customer_data(params, options)
240
+ else
241
+ _, params[:accountToken] = split_authorization(authorization)
242
+ end
243
+ add_invoice(params, amount, options)
244
+ add_credentials(params, post[:method])
245
+
246
+ post[:params] = [params]
247
+ commit("v1/", post)
248
+ end
249
+
250
+ def verifyOnly(action, authorization, credit_card, options={})
251
+ post = {}
252
+ post[:method] = "verifyOnly"
253
+ add_request_id(post)
254
+
255
+ params = {}
256
+ if credit_card
257
+ _, params[:sessionToken] = split_authorization(authorization)
258
+ add_payment_method(params, credit_card)
259
+ add_customer_data(params, options)
260
+ else
261
+ _, params[:accountToken] = split_authorization(authorization)
262
+ end
263
+ params[:requestAccountToken] = "1" if action == "store"
264
+ add_invoice(params, 0, options)
265
+ add_credentials(params, post[:method])
266
+
267
+ post[:params] = [params]
268
+ commit("v1/", post)
269
+ end
270
+
271
+ def refundWithCard(authorization, amount, credit_card, options={})
272
+ post = {}
273
+ post[:method] = "refundWithCard"
274
+ add_request_id(post)
275
+
276
+ params = {}
277
+ if credit_card
278
+ _, params[:sessionToken] = split_authorization(authorization)
279
+ add_payment_method(params, credit_card)
280
+ else
281
+ _, params[:accountToken] = split_authorization(authorization)
282
+ end
283
+ add_invoice(params, amount, options)
284
+ add_credentials(params, post[:method])
285
+
286
+ post[:params] = [params]
287
+ commit("v1/", post)
288
+ end
289
+
290
+ def reverse_or_void(method, pgwTID, options={})
291
+ post = {}
292
+ post[:method] = method
293
+ add_request_id(post)
294
+
295
+ params = {}
296
+ params[:orderNumber] = options[:order_id]
297
+ params[:pgwTID] = pgwTID
298
+ add_credentials(params, post[:method])
299
+
300
+ post[:params] = [params]
301
+ commit("v1/", post)
302
+ end
303
+
304
+ def commit(endpoint, post)
305
+ begin
306
+ raw_response = ssl_post(url() + endpoint, post_data(post), headers)
307
+ response = parse(raw_response)
308
+ rescue ResponseError => e
309
+ raw_response = e.response.body
310
+ response_error(raw_response)
311
+ rescue JSON::ParserError
312
+ unparsable_response(raw_response)
313
+ else
314
+ success = success_from(response)
315
+ Response.new(
316
+ success,
317
+ message_from(response),
318
+ response,
319
+ authorization: success ? authorization_from(response, post[:method]) : nil,
320
+ avs_result: success ? avs_from(response) : nil,
321
+ cvv_result: success ? cvv_from(response) : nil,
322
+ error_code: success ? nil : error_from(response),
323
+ test: test?
324
+ )
325
+ end
326
+ end
327
+
328
+ def headers
329
+ {
330
+ "Content-Type" => "application/json"
331
+ }
332
+ end
333
+
334
+ def post_data(params)
335
+ params.to_json
336
+ end
337
+
338
+ def url
339
+ test? ? test_url : live_url
340
+ end
341
+
342
+ def parse(body)
343
+ JSON.parse(body)
344
+ end
345
+
346
+ def success_from(response)
347
+ return false if response["result"].nil? || response["error"]
348
+
349
+ if response["result"].key?("pgwResponseCode")
350
+ response["error"].nil? && response["result"]["lastActionSucceeded"] == 1 && response["result"]["pgwResponseCode"] == "100"
351
+ else
352
+ response["error"].nil? && response["result"]["lastActionSucceeded"] == 1
353
+ end
354
+ end
355
+
356
+ def message_from(response)
357
+ return response["error"] if response["error"]
358
+ return "Failed" unless response.key?("result")
359
+
360
+ if response["result"].key?("pgwResponseCode")
361
+ RESPONSE_CODE_MAPPING[response["result"]["pgwResponseCode"]] || response["result"]["responseText"]
362
+ else
363
+ response["result"]["lastActionSucceeded"] == 1 ? "Succeeded" : "Failed"
364
+ end
365
+ end
366
+
367
+ def error_from(response)
368
+ return response["error"] if response["error"]
369
+ return "Failed" unless response.key?("result")
370
+ return response["result"]["pgwResponseCode"] || response["result"]["processor"]["responseCode"] || "Failed"
371
+ end
372
+
373
+ def authorization_from(response, method)
374
+ method + "|" + (
375
+ response["result"]["sessionId"] ||
376
+ response["result"]["sessionToken"] ||
377
+ response["result"]["pgwTID"] ||
378
+ response["result"]["accountToken"]
379
+ )
380
+ end
381
+
382
+ def split_authorization(authorization)
383
+ authorization.split("|")
384
+ end
385
+
386
+ def avs_from(response)
387
+ response["result"].key?("avsResponse") ? AVSResult.new(code: response["result"]["avsResponse"]) : nil
388
+ end
389
+
390
+ def cvv_from(response)
391
+ response["result"].key?("cvvResponse") ? CVVResult.new(response["result"]["cvvResponse"]) : nil
392
+ end
393
+
394
+ def response_error(raw_response)
395
+ begin
396
+ response = parse(raw_response)
397
+ rescue JSON::ParserError
398
+ unparsable_response(raw_response)
399
+ else
400
+ return Response.new(
401
+ false,
402
+ message_from(response),
403
+ response,
404
+ :test => test?
405
+ )
406
+ end
407
+ end
408
+
409
+ def unparsable_response(raw_response)
410
+ message = "Invalid JSON response received from Latitude19Gateway. Please contact Latitude19Gateway if you continue to receive this message."
411
+ message += " (The raw response returned by the API was #{raw_response.inspect})"
412
+ return Response.new(false, message)
413
+ end
414
+ end
415
+ end
416
+ end
@@ -144,6 +144,8 @@ module ActiveMerchant #:nodoc:
144
144
  }.update(options)
145
145
 
146
146
  raise ArgumentError, "You need to pass in your pem file using the :pem parameter or set it globally using ActiveMerchant::Billing::LinkpointGateway.pem_file = File.read( File.dirname(__FILE__) + '/../mycert.pem' ) or similar" if @options[:pem].blank?
147
+
148
+ @options[:pem].strip!
147
149
  end
148
150
 
149
151
  # Send a purchase request with periodic options
@@ -34,7 +34,7 @@ module ActiveMerchant #:nodoc:
34
34
  end
35
35
  end
36
36
 
37
- commit(:sale, request)
37
+ commit(:sale, request, money)
38
38
  end
39
39
 
40
40
  def authorize(money, payment_method, options={})
@@ -45,11 +45,11 @@ module ActiveMerchant #:nodoc:
45
45
  end
46
46
  end
47
47
 
48
- commit(:authorization, request)
48
+ commit(:authorization, request, money)
49
49
  end
50
50
 
51
51
  def capture(money, authorization, options={})
52
- transaction_id, _ = split_authorization(authorization)
52
+ transaction_id, _, _ = split_authorization(authorization)
53
53
 
54
54
  request = build_xml_request do |doc|
55
55
  add_authentication(doc)
@@ -60,7 +60,7 @@ module ActiveMerchant #:nodoc:
60
60
  end
61
61
  end
62
62
 
63
- commit(:capture, request)
63
+ commit(:capture, request, money)
64
64
  end
65
65
 
66
66
  def credit(money, authorization, options = {})
@@ -69,7 +69,7 @@ module ActiveMerchant #:nodoc:
69
69
  end
70
70
 
71
71
  def refund(money, authorization, options={})
72
- transaction_id, _ = split_authorization(authorization)
72
+ transaction_id, _, _ = split_authorization(authorization)
73
73
 
74
74
  request = build_xml_request do |doc|
75
75
  add_authentication(doc)
@@ -91,12 +91,13 @@ module ActiveMerchant #:nodoc:
91
91
  end
92
92
 
93
93
  def void(authorization, options={})
94
- transaction_id, kind = split_authorization(authorization)
94
+ transaction_id, kind, money = split_authorization(authorization)
95
95
 
96
96
  request = build_xml_request do |doc|
97
97
  add_authentication(doc)
98
98
  doc.send(void_type(kind), transaction_attributes(options)) do
99
99
  doc.litleTxnId(transaction_id)
100
+ doc.amount(money) if void_type(kind) == :authReversal
100
101
  end
101
102
  end
102
103
 
@@ -120,6 +121,21 @@ module ActiveMerchant #:nodoc:
120
121
  commit(:registerToken, request)
121
122
  end
122
123
 
124
+ def supports_scrubbing?
125
+ true
126
+ end
127
+
128
+ def scrub(transcript)
129
+ transcript.
130
+ gsub(%r((<user>).+(</user>)), '\1[FILTERED]\2').
131
+ gsub(%r((<password>).+(</password>)), '\1[FILTERED]\2').
132
+ gsub(%r((<number>).+(</number>)), '\1[FILTERED]\2').
133
+ gsub(%r((<cardValidationNum>).+(</cardValidationNum>)), '\1[FILTERED]\2').
134
+ gsub(%r((<accountNumber>).+(</accountNumber>)), '\1[FILTERED]\2').
135
+ gsub(%r((<paypageRegistrationId>).+(</paypageRegistrationId>)), '\1[FILTERED]\2').
136
+ gsub(%r((<authenticationValue>).+(</authenticationValue>)), '\1[FILTERED]\2')
137
+ end
138
+
123
139
  private
124
140
  CARD_TYPE = {
125
141
  'visa' => 'VI',
@@ -243,7 +259,7 @@ module ActiveMerchant #:nodoc:
243
259
  def add_order_source(doc, payment_method, options)
244
260
  if options[:order_source]
245
261
  doc.orderSource(options[:order_source])
246
- elsif payment_method.is_a?(NetworkTokenizationCreditCard)
262
+ elsif payment_method.is_a?(NetworkTokenizationCreditCard) && payment_method.source == :apple_pay
247
263
  doc.orderSource('applepay')
248
264
  elsif payment_method.respond_to?(:track_data) && payment_method.track_data.present?
249
265
  doc.orderSource('retail')
@@ -290,11 +306,11 @@ module ActiveMerchant #:nodoc:
290
306
  parsed
291
307
  end
292
308
 
293
- def commit(kind, request)
309
+ def commit(kind, request, money=nil)
294
310
  parsed = parse(kind, ssl_post(url, request, headers))
295
311
 
296
312
  options = {
297
- authorization: authorization_from(kind, parsed),
313
+ authorization: authorization_from(kind, parsed, money),
298
314
  test: test?,
299
315
  :avs_result => { :code => AVS_RESPONSE_CODE[parsed[:fraudResult_avsResult]] },
300
316
  :cvv_result => parsed[:fraudResult_cardValidationResult]
@@ -308,13 +324,13 @@ module ActiveMerchant #:nodoc:
308
324
  %w(000 801 802).include?(parsed[:response])
309
325
  end
310
326
 
311
- def authorization_from(kind, parsed)
312
- (kind == :registerToken) ? parsed[:litleToken] : "#{parsed[:litleTxnId]};#{kind}"
327
+ def authorization_from(kind, parsed, money)
328
+ (kind == :registerToken) ? parsed[:litleToken] : "#{parsed[:litleTxnId]};#{kind};#{money}"
313
329
  end
314
330
 
315
331
  def split_authorization(authorization)
316
- transaction_id, kind = authorization.to_s.split(';')
317
- [transaction_id, kind]
332
+ transaction_id, kind, money = authorization.to_s.split(';')
333
+ [transaction_id, kind, money]
318
334
  end
319
335
 
320
336
  def transaction_attributes(options)