activemerchant 1.86.0 → 1.87.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/CHANGELOG +22 -0
- data/lib/active_merchant/billing/avs_result.rb +0 -1
- data/lib/active_merchant/billing/check.rb +1 -1
- data/lib/active_merchant/billing/compatibility.rb +3 -3
- data/lib/active_merchant/billing/credit_card.rb +1 -1
- data/lib/active_merchant/billing/credit_card_formatting.rb +3 -3
- data/lib/active_merchant/billing/credit_card_methods.rb +6 -4
- data/lib/active_merchant/billing/gateway.rb +9 -9
- data/lib/active_merchant/billing/gateways/adyen.rb +48 -7
- data/lib/active_merchant/billing/gateways/allied_wallet.rb +1 -1
- data/lib/active_merchant/billing/gateways/authorize_net.rb +8 -8
- data/lib/active_merchant/billing/gateways/authorize_net_arb.rb +1 -1
- data/lib/active_merchant/billing/gateways/authorize_net_cim.rb +15 -15
- data/lib/active_merchant/billing/gateways/axcessms.rb +2 -2
- data/lib/active_merchant/billing/gateways/balanced.rb +11 -11
- data/lib/active_merchant/billing/gateways/bank_frick.rb +1 -1
- data/lib/active_merchant/billing/gateways/barclaycard_smartpay.rb +5 -5
- data/lib/active_merchant/billing/gateways/beanstream.rb +3 -2
- data/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb +5 -5
- data/lib/active_merchant/billing/gateways/blue_pay.rb +5 -5
- data/lib/active_merchant/billing/gateways/blue_snap.rb +5 -5
- data/lib/active_merchant/billing/gateways/bogus.rb +3 -3
- data/lib/active_merchant/billing/gateways/borgun.rb +5 -6
- data/lib/active_merchant/billing/gateways/braintree_blue.rb +18 -12
- data/lib/active_merchant/billing/gateways/bridge_pay.rb +1 -1
- data/lib/active_merchant/billing/gateways/cams.rb +12 -12
- data/lib/active_merchant/billing/gateways/card_stream.rb +9 -9
- data/lib/active_merchant/billing/gateways/cardknox.rb +4 -4
- data/lib/active_merchant/billing/gateways/cardprocess.rb +1 -1
- data/lib/active_merchant/billing/gateways/cashnet.rb +2 -2
- data/lib/active_merchant/billing/gateways/cc5.rb +2 -2
- data/lib/active_merchant/billing/gateways/cenpos.rb +2 -2
- data/lib/active_merchant/billing/gateways/checkout.rb +1 -1
- data/lib/active_merchant/billing/gateways/clearhaus.rb +12 -12
- data/lib/active_merchant/billing/gateways/commercegate.rb +3 -3
- data/lib/active_merchant/billing/gateways/creditcall.rb +2 -2
- data/lib/active_merchant/billing/gateways/credorax.rb +13 -3
- data/lib/active_merchant/billing/gateways/ct_payment.rb +6 -6
- data/lib/active_merchant/billing/gateways/culqi.rb +1 -1
- data/lib/active_merchant/billing/gateways/cyber_source.rb +8 -8
- data/lib/active_merchant/billing/gateways/data_cash.rb +2 -2
- data/lib/active_merchant/billing/gateways/dibs.rb +2 -2
- data/lib/active_merchant/billing/gateways/digitzs.rb +5 -5
- data/lib/active_merchant/billing/gateways/ebanx.rb +1 -1
- data/lib/active_merchant/billing/gateways/efsnet.rb +4 -4
- data/lib/active_merchant/billing/gateways/elavon.rb +3 -3
- data/lib/active_merchant/billing/gateways/element.rb +4 -4
- data/lib/active_merchant/billing/gateways/epay.rb +1 -1
- data/lib/active_merchant/billing/gateways/eway.rb +2 -2
- data/lib/active_merchant/billing/gateways/eway_managed.rb +5 -5
- data/lib/active_merchant/billing/gateways/eway_rapid.rb +1 -1
- data/lib/active_merchant/billing/gateways/exact.rb +1 -1
- data/lib/active_merchant/billing/gateways/federated_canada.rb +1 -1
- data/lib/active_merchant/billing/gateways/first_giving.rb +1 -1
- data/lib/active_merchant/billing/gateways/firstdata_e4.rb +7 -7
- data/lib/active_merchant/billing/gateways/flo2cash.rb +2 -2
- data/lib/active_merchant/billing/gateways/forte.rb +11 -7
- data/lib/active_merchant/billing/gateways/garanti.rb +5 -5
- data/lib/active_merchant/billing/gateways/global_collect.rb +2 -3
- data/lib/active_merchant/billing/gateways/hdfc.rb +2 -2
- data/lib/active_merchant/billing/gateways/hps.rb +3 -3
- data/lib/active_merchant/billing/gateways/inspire.rb +7 -7
- data/lib/active_merchant/billing/gateways/iridium.rb +14 -14
- data/lib/active_merchant/billing/gateways/itransact.rb +4 -4
- data/lib/active_merchant/billing/gateways/iveri.rb +3 -3
- data/lib/active_merchant/billing/gateways/jetpay.rb +2 -2
- data/lib/active_merchant/billing/gateways/jetpay_v2.rb +2 -2
- data/lib/active_merchant/billing/gateways/latitude19.rb +1 -1
- data/lib/active_merchant/billing/gateways/linkpoint.rb +3 -3
- data/lib/active_merchant/billing/gateways/litle.rb +2 -2
- data/lib/active_merchant/billing/gateways/maxipago.rb +1 -1
- data/lib/active_merchant/billing/gateways/mercado_pago.rb +7 -13
- data/lib/active_merchant/billing/gateways/merchant_e_solutions.rb +3 -3
- data/lib/active_merchant/billing/gateways/merchant_one.rb +4 -4
- data/lib/active_merchant/billing/gateways/merchant_partners.rb +1 -1
- data/lib/active_merchant/billing/gateways/merchant_warrior.rb +3 -3
- data/lib/active_merchant/billing/gateways/mercury.rb +2 -2
- data/lib/active_merchant/billing/gateways/metrics_global.rb +2 -2
- data/lib/active_merchant/billing/gateways/micropayment.rb +1 -1
- data/lib/active_merchant/billing/gateways/migs.rb +4 -6
- data/lib/active_merchant/billing/gateways/modern_payments_cim.rb +2 -2
- data/lib/active_merchant/billing/gateways/moneris.rb +85 -56
- data/lib/active_merchant/billing/gateways/moneris_us.rb +9 -9
- data/lib/active_merchant/billing/gateways/money_movers.rb +1 -1
- data/lib/active_merchant/billing/gateways/mundipagg.rb +1 -1
- data/lib/active_merchant/billing/gateways/nab_transact.rb +1 -1
- data/lib/active_merchant/billing/gateways/net_registry.rb +2 -2
- data/lib/active_merchant/billing/gateways/netaxept.rb +6 -6
- data/lib/active_merchant/billing/gateways/netbanx.rb +36 -36
- data/lib/active_merchant/billing/gateways/netbilling.rb +2 -2
- data/lib/active_merchant/billing/gateways/netpay.rb +1 -1
- data/lib/active_merchant/billing/gateways/nmi.rb +2 -2
- data/lib/active_merchant/billing/gateways/ogone.rb +7 -7
- data/lib/active_merchant/billing/gateways/omise.rb +6 -6
- data/lib/active_merchant/billing/gateways/opp.rb +1 -1
- data/lib/active_merchant/billing/gateways/optimal_payment.rb +5 -0
- data/lib/active_merchant/billing/gateways/orbital.rb +9 -7
- data/lib/active_merchant/billing/gateways/pac_net_raven.rb +6 -6
- data/lib/active_merchant/billing/gateways/pagarme.rb +1 -1
- data/lib/active_merchant/billing/gateways/pay_conex.rb +1 -1
- data/lib/active_merchant/billing/gateways/pay_gate_xml.rb +8 -5
- data/lib/active_merchant/billing/gateways/pay_hub.rb +2 -2
- data/lib/active_merchant/billing/gateways/pay_junction.rb +2 -2
- data/lib/active_merchant/billing/gateways/pay_junction_v2.rb +2 -2
- data/lib/active_merchant/billing/gateways/pay_secure.rb +3 -3
- data/lib/active_merchant/billing/gateways/paybox_direct.rb +8 -8
- data/lib/active_merchant/billing/gateways/payeezy.rb +1 -1
- data/lib/active_merchant/billing/gateways/payex.rb +8 -8
- data/lib/active_merchant/billing/gateways/payflow.rb +13 -13
- data/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb +4 -4
- data/lib/active_merchant/billing/gateways/payflow_express.rb +1 -1
- data/lib/active_merchant/billing/gateways/payment_express.rb +10 -10
- data/lib/active_merchant/billing/gateways/paymentez.rb +3 -0
- data/lib/active_merchant/billing/gateways/paymill.rb +4 -4
- data/lib/active_merchant/billing/gateways/payscout.rb +1 -1
- data/lib/active_merchant/billing/gateways/paystation.rb +1 -1
- data/lib/active_merchant/billing/gateways/payu_in.rb +3 -3
- data/lib/active_merchant/billing/gateways/payu_latam.rb +1 -1
- data/lib/active_merchant/billing/gateways/payway.rb +2 -2
- data/lib/active_merchant/billing/gateways/plugnpay.rb +2 -2
- data/lib/active_merchant/billing/gateways/pro_pay.rb +2 -2
- data/lib/active_merchant/billing/gateways/psigate.rb +1 -1
- data/lib/active_merchant/billing/gateways/psl_card.rb +3 -3
- data/lib/active_merchant/billing/gateways/qbms.rb +1 -1
- data/lib/active_merchant/billing/gateways/quantum.rb +7 -7
- data/lib/active_merchant/billing/gateways/quickbooks.rb +6 -6
- data/lib/active_merchant/billing/gateways/quickpay/quickpay_v10.rb +1 -1
- data/lib/active_merchant/billing/gateways/qvalent.rb +2 -2
- data/lib/active_merchant/billing/gateways/realex.rb +33 -13
- data/lib/active_merchant/billing/gateways/redsys.rb +2 -2
- data/lib/active_merchant/billing/gateways/safe_charge.rb +2 -2
- data/lib/active_merchant/billing/gateways/sage.rb +6 -6
- data/lib/active_merchant/billing/gateways/sage_pay.rb +7 -7
- data/lib/active_merchant/billing/gateways/secure_net.rb +1 -1
- data/lib/active_merchant/billing/gateways/secure_pay.rb +2 -2
- data/lib/active_merchant/billing/gateways/secure_pay_au.rb +1 -1
- data/lib/active_merchant/billing/gateways/secure_pay_tech.rb +1 -1
- data/lib/active_merchant/billing/gateways/skip_jack.rb +5 -6
- data/lib/active_merchant/billing/gateways/smart_ps.rb +7 -7
- data/lib/active_merchant/billing/gateways/so_easy_pay.rb +1 -1
- data/lib/active_merchant/billing/gateways/stripe.rb +5 -5
- data/lib/active_merchant/billing/gateways/swipe_checkout.rb +2 -2
- data/lib/active_merchant/billing/gateways/telr.rb +1 -1
- data/lib/active_merchant/billing/gateways/trans_first_transaction_express.rb +2 -2
- data/lib/active_merchant/billing/gateways/transact_pro.rb +5 -5
- data/lib/active_merchant/billing/gateways/transax.rb +1 -1
- data/lib/active_merchant/billing/gateways/trust_commerce.rb +7 -7
- data/lib/active_merchant/billing/gateways/usa_epay_advanced.rb +17 -16
- data/lib/active_merchant/billing/gateways/usa_epay_transaction.rb +2 -2
- data/lib/active_merchant/billing/gateways/vanco.rb +2 -2
- data/lib/active_merchant/billing/gateways/verifi.rb +1 -1
- data/lib/active_merchant/billing/gateways/viaklix.rb +4 -4
- data/lib/active_merchant/billing/gateways/visanet_peru.rb +4 -4
- data/lib/active_merchant/billing/gateways/wirecard.rb +2 -2
- data/lib/active_merchant/billing/gateways/worldpay.rb +24 -13
- data/lib/active_merchant/billing/gateways/worldpay_online_payments.rb +2 -2
- data/lib/active_merchant/billing/response.rb +7 -7
- data/lib/active_merchant/country.rb +4 -4
- data/lib/active_merchant/network_connection_retries.rb +7 -9
- data/lib/active_merchant/version.rb +1 -1
- data/lib/support/gateway_support.rb +3 -3
- data/lib/support/ssl_verify.rb +1 -1
- metadata +3 -3
@@ -45,12 +45,12 @@ module ActiveMerchant #:nodoc:
|
|
45
45
|
|
46
46
|
MultiResponse.run do |r|
|
47
47
|
identifier = if(payment_method.respond_to?(:number))
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
48
|
+
r.process { store(payment_method, options) }
|
49
|
+
r.authorization
|
50
|
+
else
|
51
|
+
payment_method
|
52
52
|
end
|
53
|
-
r.process{commit('debits', "cards/#{card_identifier_from(identifier)}/debits", post)}
|
53
|
+
r.process { commit('debits', "cards/#{card_identifier_from(identifier)}/debits", post) }
|
54
54
|
end
|
55
55
|
end
|
56
56
|
|
@@ -62,12 +62,12 @@ module ActiveMerchant #:nodoc:
|
|
62
62
|
|
63
63
|
MultiResponse.run do |r|
|
64
64
|
identifier = if(payment_method.respond_to?(:number))
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
65
|
+
r.process { store(payment_method, options) }
|
66
|
+
r.authorization
|
67
|
+
else
|
68
|
+
payment_method
|
69
69
|
end
|
70
|
-
r.process{commit('card_holds', "cards/#{card_identifier_from(identifier)}/card_holds", post)}
|
70
|
+
r.process { commit('card_holds', "cards/#{card_identifier_from(identifier)}/card_holds", post) }
|
71
71
|
end
|
72
72
|
end
|
73
73
|
|
@@ -118,7 +118,7 @@ module ActiveMerchant #:nodoc:
|
|
118
118
|
when %r{\|}
|
119
119
|
uri = identifier.
|
120
120
|
split('|').
|
121
|
-
detect{|part| part.size > 0}
|
121
|
+
detect { |part| part.size > 0 }
|
122
122
|
uri.split('/')[2]
|
123
123
|
when %r{\/}
|
124
124
|
identifier.split('/')[5]
|
@@ -9,7 +9,7 @@ module ActiveMerchant #:nodoc:
|
|
9
9
|
self.test_url = 'https://test.ctpe.io/payment/ctpe'
|
10
10
|
self.live_url = 'https://ctpe.io/payment/ctpe'
|
11
11
|
|
12
|
-
self.supported_countries = ['LI','US']
|
12
|
+
self.supported_countries = ['LI', 'US']
|
13
13
|
self.default_currency = 'EUR'
|
14
14
|
self.supported_cardtypes = [:visa, :master, :american_express, :discover]
|
15
15
|
|
@@ -168,11 +168,11 @@ module ActiveMerchant #:nodoc:
|
|
168
168
|
return Response.new(false, 'Invalid credentials', {}, :test => test?)
|
169
169
|
when '403'
|
170
170
|
return Response.new(false, 'Not allowed', {}, :test => test?)
|
171
|
-
when '422'
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
return Response.new(false,
|
171
|
+
when '422', '500'
|
172
|
+
if e.response.body.split(/\W+/).any? { |word| %w(validation configuration security).include?(word) }
|
173
|
+
error_message = e.response.body[/#{Regexp.escape('message=')}(.*?)#{Regexp.escape('&')}/m, 1].tr('+', ' ')
|
174
|
+
error_code = e.response.body[/#{Regexp.escape('errorCode=')}(.*?)#{Regexp.escape('&')}/m, 1]
|
175
|
+
return Response.new(false, error_code + ': ' + error_message, {}, :test => test?)
|
176
176
|
end
|
177
177
|
end
|
178
178
|
raise
|
@@ -186,8 +186,9 @@ module ActiveMerchant #:nodoc:
|
|
186
186
|
else
|
187
187
|
post[:singleUseToken] = payment_method
|
188
188
|
end
|
189
|
-
options
|
190
|
-
|
189
|
+
options[:vault_id] = vault_id
|
190
|
+
options[:operation] = secure_profile_action(:modify)
|
191
|
+
add_secure_profile_variables(post, options)
|
191
192
|
commit(post, true)
|
192
193
|
end
|
193
194
|
|
@@ -193,11 +193,11 @@ module ActiveMerchant #:nodoc:
|
|
193
193
|
end
|
194
194
|
|
195
195
|
def void_action(original_transaction_type)
|
196
|
-
|
196
|
+
original_transaction_type == TRANSACTIONS[:refund] ? :void_refund : :void_purchase
|
197
197
|
end
|
198
198
|
|
199
199
|
def refund_action(type)
|
200
|
-
|
200
|
+
type == TRANSACTIONS[:check_purchase] ? :check_refund : :refund
|
201
201
|
end
|
202
202
|
|
203
203
|
def secure_profile_action(type)
|
@@ -398,7 +398,7 @@ module ActiveMerchant #:nodoc:
|
|
398
398
|
end
|
399
399
|
|
400
400
|
def commit(params, use_profile_api = false)
|
401
|
-
post(post_data(params,use_profile_api),use_profile_api)
|
401
|
+
post(post_data(params, use_profile_api), use_profile_api)
|
402
402
|
end
|
403
403
|
|
404
404
|
def recurring_commit(params)
|
@@ -412,7 +412,7 @@ module ActiveMerchant #:nodoc:
|
|
412
412
|
:test => test? || response[:authCode] == 'TEST',
|
413
413
|
:authorization => authorization_from(response),
|
414
414
|
:cvv_result => CVD_CODES[response[:cvdId]],
|
415
|
-
:avs_result => { :code =>
|
415
|
+
:avs_result => { :code => AVS_CODES.include?(response[:avsId]) ? AVS_CODES[response[:avsId]] : response[:avsId] }
|
416
416
|
)
|
417
417
|
end
|
418
418
|
|
@@ -463,7 +463,7 @@ module ActiveMerchant #:nodoc:
|
|
463
463
|
params[:vbvEnabled] = '0'
|
464
464
|
params[:scEnabled] = '0'
|
465
465
|
|
466
|
-
params.reject{|k, v| v.blank?}.collect { |key, value| "#{key}=#{CGI.escape(value.to_s)}" }.join('&')
|
466
|
+
params.reject { |k, v| v.blank? }.collect { |key, value| "#{key}=#{CGI.escape(value.to_s)}" }.join('&')
|
467
467
|
end
|
468
468
|
end
|
469
469
|
end
|
@@ -330,7 +330,7 @@ module ActiveMerchant #:nodoc:
|
|
330
330
|
|
331
331
|
def parse_recurring(response_fields, opts={}) # expected status?
|
332
332
|
parsed = {}
|
333
|
-
response_fields.each do |k,v|
|
333
|
+
response_fields.each do |k, v|
|
334
334
|
mapped_key = REBILL_FIELD_MAP.include?(k) ? REBILL_FIELD_MAP[k] : k
|
335
335
|
parsed[mapped_key] = v
|
336
336
|
end
|
@@ -345,14 +345,14 @@ module ActiveMerchant #:nodoc:
|
|
345
345
|
|
346
346
|
def parse(body)
|
347
347
|
# The bp20api has max one value per form field.
|
348
|
-
response_fields = Hash[CGI::parse(body).map{|k,v| [k.upcase,v.first]}]
|
348
|
+
response_fields = Hash[CGI::parse(body).map { |k, v| [k.upcase, v.first] }]
|
349
349
|
|
350
350
|
if response_fields.include? 'REBILL_ID'
|
351
351
|
return parse_recurring(response_fields)
|
352
352
|
end
|
353
353
|
|
354
354
|
parsed = {}
|
355
|
-
response_fields.each do |k,v|
|
355
|
+
response_fields.each do |k, v|
|
356
356
|
mapped_key = FIELD_MAP.include?(k) ? FIELD_MAP[k] : k
|
357
357
|
parsed[mapped_key] = v
|
358
358
|
end
|
@@ -374,7 +374,7 @@ module ActiveMerchant #:nodoc:
|
|
374
374
|
if CARD_CODE_ERRORS.include?(parsed[:card_code])
|
375
375
|
message = CVVResult.messages[parsed[:card_code]]
|
376
376
|
elsif AVS_ERRORS.include?(parsed[:avs_result_code])
|
377
|
-
message = AVSResult.messages[
|
377
|
+
message = AVSResult.messages[parsed[:avs_result_code]]
|
378
378
|
else
|
379
379
|
message = message.chomp('.')
|
380
380
|
end
|
@@ -510,7 +510,7 @@ module ActiveMerchant #:nodoc:
|
|
510
510
|
end
|
511
511
|
|
512
512
|
def handle_response(response)
|
513
|
-
if ignore_http_status || (200...300).
|
513
|
+
if ignore_http_status || (200...300).cover?(response.code.to_i)
|
514
514
|
return response.body
|
515
515
|
end
|
516
516
|
raise ResponseError.new(response)
|
@@ -230,7 +230,7 @@ module ActiveMerchant
|
|
230
230
|
|
231
231
|
def parse_element(parsed, node)
|
232
232
|
if !node.elements.empty?
|
233
|
-
node.elements.each {|e| parse_element(parsed, e) }
|
233
|
+
node.elements.each { |e| parse_element(parsed, e) }
|
234
234
|
else
|
235
235
|
parsed[node.name.downcase] = node.text
|
236
236
|
end
|
@@ -262,7 +262,7 @@ module ActiveMerchant
|
|
262
262
|
|
263
263
|
def url(action = nil)
|
264
264
|
base = test? ? test_url : live_url
|
265
|
-
resource =
|
265
|
+
resource = action == :store ? 'vaulted-shoppers' : 'transactions'
|
266
266
|
"#{base}/#{resource}"
|
267
267
|
end
|
268
268
|
|
@@ -279,7 +279,7 @@ module ActiveMerchant
|
|
279
279
|
end
|
280
280
|
|
281
281
|
def success_from(action, response)
|
282
|
-
(200...300).
|
282
|
+
(200...300).cover?(response.code.to_i)
|
283
283
|
end
|
284
284
|
|
285
285
|
def message_from(succeeded, parsed_response)
|
@@ -288,7 +288,7 @@ module ActiveMerchant
|
|
288
288
|
end
|
289
289
|
|
290
290
|
def authorization_from(action, parsed_response)
|
291
|
-
|
291
|
+
action == :store ? vaulted_shopper_id(parsed_response) : parsed_response['transaction-id']
|
292
292
|
end
|
293
293
|
|
294
294
|
def vaulted_shopper_id(parsed_response)
|
@@ -307,7 +307,7 @@ module ActiveMerchant
|
|
307
307
|
end
|
308
308
|
|
309
309
|
def root_element(action)
|
310
|
-
|
310
|
+
action == :store ? 'vaulted-shopper' : 'card-transaction'
|
311
311
|
end
|
312
312
|
|
313
313
|
def headers
|
@@ -47,7 +47,7 @@ module ActiveMerchant #:nodoc:
|
|
47
47
|
money = amount(money)
|
48
48
|
case normalize(paysource)
|
49
49
|
when /1$/
|
50
|
-
Response.new(true, SUCCESS_MESSAGE, {:paid_amount => money}, :test => true
|
50
|
+
Response.new(true, SUCCESS_MESSAGE, {:paid_amount => money}, :test => true)
|
51
51
|
when /2$/
|
52
52
|
Response.new(false, FAILURE_MESSAGE, {:paid_amount => money, :error => FAILURE_MESSAGE }, :test => true, :error_code => STANDARD_ERROR_CODE[:processing_error])
|
53
53
|
else
|
@@ -106,7 +106,7 @@ module ActiveMerchant #:nodoc:
|
|
106
106
|
when /1$/
|
107
107
|
Response.new(true, SUCCESS_MESSAGE, {}, :test => true)
|
108
108
|
when /2$/
|
109
|
-
Response.new(false, FAILURE_MESSAGE, {:error => FAILURE_MESSAGE }
|
109
|
+
Response.new(false, FAILURE_MESSAGE, {:error => FAILURE_MESSAGE }, :test => true, :error_code => STANDARD_ERROR_CODE[:processing_error])
|
110
110
|
else
|
111
111
|
raise Error, UNSTORE_ERROR_MESSAGE
|
112
112
|
end
|
@@ -130,7 +130,7 @@ module ActiveMerchant #:nodoc:
|
|
130
130
|
money = amount(money)
|
131
131
|
case normalize(paysource)
|
132
132
|
when /1$/, AUTHORIZATION
|
133
|
-
Response.new(true, SUCCESS_MESSAGE, {:authorized_amount => money}, :test => true, :authorization => AUTHORIZATION
|
133
|
+
Response.new(true, SUCCESS_MESSAGE, {:authorized_amount => money}, :test => true, :authorization => AUTHORIZATION)
|
134
134
|
when /2$/
|
135
135
|
Response.new(false, FAILURE_MESSAGE, {:authorized_amount => money, :error => FAILURE_MESSAGE }, :test => true, :error_code => STANDARD_ERROR_CODE[:processing_error])
|
136
136
|
else
|
@@ -76,7 +76,7 @@ module ActiveMerchant #:nodoc:
|
|
76
76
|
|
77
77
|
private
|
78
78
|
|
79
|
-
CURRENCY_CODES = Hash.new{|h,k| raise ArgumentError.new("Unsupported currency for HDFC: #{k}")}
|
79
|
+
CURRENCY_CODES = Hash.new { |h, k| raise ArgumentError.new("Unsupported currency for HDFC: #{k}") }
|
80
80
|
CURRENCY_CODES['ISK'] = '352'
|
81
81
|
CURRENCY_CODES['EUR'] = '978'
|
82
82
|
CURRENCY_CODES['USD'] = '840'
|
@@ -112,7 +112,7 @@ module ActiveMerchant #:nodoc:
|
|
112
112
|
body.children.each do |node|
|
113
113
|
if node.text?
|
114
114
|
next
|
115
|
-
elsif
|
115
|
+
elsif node.elements.size == 0
|
116
116
|
response[node.name.downcase.to_sym] = node.text
|
117
117
|
else
|
118
118
|
node.elements.each do |childnode|
|
@@ -130,7 +130,6 @@ module ActiveMerchant #:nodoc:
|
|
130
130
|
post[:Processor] = @options[:processor]
|
131
131
|
post[:MerchantID] = @options[:merchant_id]
|
132
132
|
|
133
|
-
url = (test? ? test_url : live_url)
|
134
133
|
request = build_request(action, post)
|
135
134
|
raw = ssl_post(url(action), request, headers)
|
136
135
|
pairs = parse(raw)
|
@@ -182,7 +181,7 @@ module ActiveMerchant #:nodoc:
|
|
182
181
|
end
|
183
182
|
|
184
183
|
def build_request(action, post)
|
185
|
-
mode =
|
184
|
+
mode = action == 'void' ? 'cancel' : 'get'
|
186
185
|
xml = Builder::XmlMarkup.new :indent => 18
|
187
186
|
xml.instruct!(:xml, :version => '1.0', :encoding => 'utf-8')
|
188
187
|
xml.tag!("#{mode}Authorization") do
|
@@ -191,7 +190,7 @@ module ActiveMerchant #:nodoc:
|
|
191
190
|
end
|
192
191
|
end
|
193
192
|
inner = CGI.escapeHTML(xml.target!)
|
194
|
-
envelope(mode).sub(/{{ :body }}/,inner)
|
193
|
+
envelope(mode).sub(/{{ :body }}/, inner)
|
195
194
|
end
|
196
195
|
|
197
196
|
def envelope(mode)
|
@@ -214,7 +213,7 @@ module ActiveMerchant #:nodoc:
|
|
214
213
|
end
|
215
214
|
|
216
215
|
def six_random_digits
|
217
|
-
(0...6).map { (48
|
216
|
+
(0...6).map { rand(48..57).chr }.join
|
218
217
|
end
|
219
218
|
end
|
220
219
|
end
|
@@ -39,6 +39,7 @@ module ActiveMerchant #:nodoc:
|
|
39
39
|
#
|
40
40
|
class BraintreeBlueGateway < Gateway
|
41
41
|
include BraintreeCommon
|
42
|
+
include Empty
|
42
43
|
|
43
44
|
self.display_name = 'Braintree (Blue Platform)'
|
44
45
|
|
@@ -53,7 +54,7 @@ module ActiveMerchant #:nodoc:
|
|
53
54
|
super
|
54
55
|
|
55
56
|
if wiredump_device.present?
|
56
|
-
logger = (
|
57
|
+
logger = (Logger === wiredump_device ? wiredump_device : Logger.new(wiredump_device))
|
57
58
|
logger.level = Logger::DEBUG
|
58
59
|
else
|
59
60
|
logger = Braintree::Configuration.logger.clone
|
@@ -69,7 +70,7 @@ module ActiveMerchant #:nodoc:
|
|
69
70
|
:logger => options[:logger] || logger
|
70
71
|
)
|
71
72
|
|
72
|
-
@braintree_gateway = Braintree::Gateway.new(
|
73
|
+
@braintree_gateway = Braintree::Gateway.new(@configuration)
|
73
74
|
end
|
74
75
|
|
75
76
|
def authorize(money, credit_card_or_vault_id, options = {})
|
@@ -123,7 +124,7 @@ module ActiveMerchant #:nodoc:
|
|
123
124
|
if options[:customer].present?
|
124
125
|
MultiResponse.new.tap do |r|
|
125
126
|
customer_exists_response = nil
|
126
|
-
r.process{customer_exists_response = check_customer_exists(options[:customer])}
|
127
|
+
r.process { customer_exists_response = check_customer_exists(options[:customer]) }
|
127
128
|
r.process do
|
128
129
|
if customer_exists_response.params['exists']
|
129
130
|
add_credit_card_to_customer(creditcard, options)
|
@@ -143,7 +144,7 @@ module ActiveMerchant #:nodoc:
|
|
143
144
|
braintree_credit_card = @braintree_gateway.customer.find(vault_id).credit_cards.detect(&:default?)
|
144
145
|
return Response.new(false, 'Braintree::NotFoundError') if braintree_credit_card.nil?
|
145
146
|
|
146
|
-
options
|
147
|
+
options[:update_existing_token] = braintree_credit_card.token
|
147
148
|
credit_card_params = merge_credit_card_options({
|
148
149
|
:credit_card => {
|
149
150
|
:cardholder_name => creditcard.name,
|
@@ -259,7 +260,10 @@ module ActiveMerchant #:nodoc:
|
|
259
260
|
expiration_year: credit_card.year.to_s,
|
260
261
|
device_data: options[:device_data],
|
261
262
|
}
|
262
|
-
|
263
|
+
if options[:billing_address]
|
264
|
+
address = map_address(options[:billing_address])
|
265
|
+
parameters[:credit_card][:billing_address] = address unless address.all? { |_k, v| empty?(v) }
|
266
|
+
end
|
263
267
|
|
264
268
|
result = @braintree_gateway.credit_card.create(parameters)
|
265
269
|
ActiveMerchant::Billing::Response.new(
|
@@ -276,10 +280,10 @@ module ActiveMerchant #:nodoc:
|
|
276
280
|
|
277
281
|
def scrub_email(email)
|
278
282
|
return nil unless email.present?
|
279
|
-
return nil if
|
283
|
+
return nil if
|
280
284
|
email !~ /^.+@[^\.]+(\.[^\.]+)+[a-z]$/i ||
|
281
285
|
email =~ /\.(con|met)$/i
|
282
|
-
|
286
|
+
|
283
287
|
email
|
284
288
|
end
|
285
289
|
|
@@ -303,13 +307,15 @@ module ActiveMerchant #:nodoc:
|
|
303
307
|
end
|
304
308
|
|
305
309
|
parameters[:credit_card] ||= {}
|
306
|
-
parameters[:credit_card]
|
307
|
-
|
310
|
+
parameters[:credit_card][:options] = valid_options
|
311
|
+
if options[:billing_address]
|
312
|
+
address = map_address(options[:billing_address])
|
313
|
+
parameters[:credit_card][:billing_address] = address unless address.all? { |_k, v| empty?(v) }
|
314
|
+
end
|
308
315
|
parameters
|
309
316
|
end
|
310
317
|
|
311
318
|
def map_address(address)
|
312
|
-
return {} if address.nil?
|
313
319
|
mapped = {
|
314
320
|
:street_address => address[:address1],
|
315
321
|
:extended_address => address[:address2],
|
@@ -318,7 +324,7 @@ module ActiveMerchant #:nodoc:
|
|
318
324
|
:region => address[:state],
|
319
325
|
:postal_code => scrub_zip(address[:zip]),
|
320
326
|
}
|
321
|
-
if
|
327
|
+
if address[:country] || address[:country_code_alpha2]
|
322
328
|
mapped[:country_code_alpha2] = (address[:country] || address[:country_code_alpha2])
|
323
329
|
elsif address[:country_name]
|
324
330
|
mapped[:country_name] = address[:country_name]
|
@@ -568,7 +574,7 @@ module ActiveMerchant #:nodoc:
|
|
568
574
|
}
|
569
575
|
|
570
576
|
if options[:skip_advanced_fraud_checking]
|
571
|
-
parameters[:options]
|
577
|
+
parameters[:options][:skip_advanced_fraud_checking] = options[:skip_advanced_fraud_checking]
|
572
578
|
end
|
573
579
|
|
574
580
|
parameters[:custom_fields] = options[:custom_fields]
|
@@ -237,7 +237,7 @@ module ActiveMerchant #:nodoc:
|
|
237
237
|
{
|
238
238
|
:UserName => @options[:user_name],
|
239
239
|
:Password => @options[:password]
|
240
|
-
}.merge(post).collect{|k,v| "#{k}=#{CGI.escape(v.to_s)}"}.join('&')
|
240
|
+
}.merge(post).collect { |k, v| "#{k}=#{CGI.escape(v.to_s)}" }.join('&')
|
241
241
|
end
|
242
242
|
end
|
243
243
|
end
|
@@ -140,18 +140,18 @@ module ActiveMerchant #:nodoc:
|
|
140
140
|
|
141
141
|
def add_address(post, creditcard, options={})
|
142
142
|
post[:firstname] = creditcard.first_name
|
143
|
-
post[:lastname
|
143
|
+
post[:lastname] = creditcard.last_name
|
144
144
|
|
145
145
|
return unless options[:billing_address]
|
146
146
|
|
147
147
|
address = options[:billing_address]
|
148
|
-
post[:address1
|
149
|
-
post[:address2
|
150
|
-
post[:city
|
151
|
-
post[:state
|
152
|
-
post[:zip
|
153
|
-
post[:country
|
154
|
-
post[:phone
|
148
|
+
post[:address1] = address[:address1]
|
149
|
+
post[:address2] = address[:address2]
|
150
|
+
post[:city] = address[:city]
|
151
|
+
post[:state] = address[:state]
|
152
|
+
post[:zip] = address[:zip]
|
153
|
+
post[:country] = address[:country]
|
154
|
+
post[:phone] = address[:phone]
|
155
155
|
end
|
156
156
|
|
157
157
|
def add_reference(post, authorization)
|
@@ -167,15 +167,15 @@ module ActiveMerchant #:nodoc:
|
|
167
167
|
|
168
168
|
def add_payment(post, payment)
|
169
169
|
post[:ccnumber] = payment.number
|
170
|
-
post[:ccexp
|
171
|
-
post[:cvv
|
170
|
+
post[:ccexp] = "#{payment.month.to_s.rjust(2, "0")}#{payment.year.to_s[-2..-1]}"
|
171
|
+
post[:cvv] = payment.verification_value
|
172
172
|
end
|
173
173
|
|
174
174
|
def parse(body)
|
175
175
|
kvs = body.split('&')
|
176
176
|
|
177
177
|
kvs.inject({}) { |h, kv|
|
178
|
-
k,v = kv.split('=')
|
178
|
+
k, v = kv.split('=')
|
179
179
|
h[k] = v
|
180
180
|
h
|
181
181
|
}
|
@@ -219,7 +219,7 @@ module ActiveMerchant #:nodoc:
|
|
219
219
|
parameters[:password] = @options[:password]
|
220
220
|
parameters[:username] = @options[:username]
|
221
221
|
|
222
|
-
parameters.collect{|k,v| "#{k}=#{v}" }.join('&')
|
222
|
+
parameters.collect { |k, v| "#{k}=#{v}" }.join('&')
|
223
223
|
end
|
224
224
|
|
225
225
|
def error_code_from(response)
|