activemerchant 1.90.0 → 1.91.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (29) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG +38 -0
  3. data/README.md +3 -2
  4. data/lib/active_merchant/billing/credit_card_methods.rb +1 -1
  5. data/lib/active_merchant/billing/gateways/adyen.rb +26 -21
  6. data/lib/active_merchant/billing/gateways/bambora_apac.rb +186 -0
  7. data/lib/active_merchant/billing/gateways/blue_snap.rb +189 -34
  8. data/lib/active_merchant/billing/gateways/braintree_blue.rb +11 -9
  9. data/lib/active_merchant/billing/gateways/card_connect.rb +3 -0
  10. data/lib/active_merchant/billing/gateways/cecabank.rb +13 -2
  11. data/lib/active_merchant/billing/gateways/fat_zebra.rb +20 -7
  12. data/lib/active_merchant/billing/gateways/ipp.rb +1 -0
  13. data/lib/active_merchant/billing/gateways/moneris.rb +3 -4
  14. data/lib/active_merchant/billing/gateways/netbanx.rb +4 -0
  15. data/lib/active_merchant/billing/gateways/nmi.rb +6 -4
  16. data/lib/active_merchant/billing/gateways/openpay.rb +1 -1
  17. data/lib/active_merchant/billing/gateways/orbital.rb +8 -1
  18. data/lib/active_merchant/billing/gateways/payment_express.rb +4 -1
  19. data/lib/active_merchant/billing/gateways/paymentez.rb +4 -9
  20. data/lib/active_merchant/billing/gateways/pin.rb +19 -6
  21. data/lib/active_merchant/billing/gateways/pro_pay.rb +1 -1
  22. data/lib/active_merchant/billing/gateways/qvalent.rb +11 -0
  23. data/lib/active_merchant/billing/gateways/trans_first_transaction_express.rb +3 -3
  24. data/lib/active_merchant/billing/gateways/trust_commerce.rb +1 -0
  25. data/lib/active_merchant/billing/gateways/usa_epay_transaction.rb +11 -3
  26. data/lib/active_merchant/billing/gateways/worldpay.rb +51 -2
  27. data/lib/active_merchant/country.rb +1 -1
  28. data/lib/active_merchant/version.rb +1 -1
  29. metadata +3 -2
@@ -197,14 +197,19 @@ module ActiveMerchant #:nodoc:
197
197
  end
198
198
 
199
199
  def add_invoice(post, options)
200
- post[:invoice] = options[:order_id]
200
+ post[:invoice] = options[:invoice]
201
+ post[:orderid] = options[:order_id]
201
202
  post[:description] = options[:description]
202
203
  end
203
204
 
204
205
  def add_payment(post, payment, options={})
205
206
  if payment.respond_to?(:routing_number)
206
207
  post[:checkformat] = options[:check_format] if options[:check_format]
207
- post[:accounttype] = options[:account_type] if options[:account_type]
208
+ if payment.account_type
209
+ account_type = payment.account_type.to_s.capitalize
210
+ raise ArgumentError, 'account_type must be checking or savings' unless %w(Checking Savings).include?(account_type)
211
+ post[:accounttype] = account_type
212
+ end
208
213
  post[:account] = payment.account_number
209
214
  post[:routing] = payment.routing_number
210
215
  post[:name] = payment.name unless payment.name.blank?
@@ -258,7 +263,10 @@ module ActiveMerchant #:nodoc:
258
263
  # see: https://wiki.usaepay.com/developer/transactionapi#merchant_defined_custom_fields
259
264
  def add_custom_fields(post, options)
260
265
  return unless options[:custom_fields].is_a?(Hash)
266
+
261
267
  options[:custom_fields].each do |index, custom|
268
+ raise ArgumentError.new('Cannot specify custom field with index 0') if index.to_s.to_i.zero?
269
+
262
270
  post["custom#{index}"] = custom
263
271
  end
264
272
  end
@@ -267,7 +275,7 @@ module ActiveMerchant #:nodoc:
267
275
  def add_line_items(post, options)
268
276
  return unless options[:line_items].is_a?(Array)
269
277
  options[:line_items].each_with_index do |line_item, index|
270
- %w(product_ref_num sku name description taxable tax_rate tax_amount commodity_code discount_rate discount_amount).each do |key|
278
+ %w(product_ref_num sku qty name description taxable tax_rate tax_amount commodity_code discount_rate discount_amount).each do |key|
271
279
  post["line#{index}#{key.delete('_')}"] = line_item[key.to_sym] if line_item.has_key?(key.to_sym)
272
280
  end
273
281
 
@@ -23,6 +23,26 @@ module ActiveMerchant #:nodoc:
23
23
  'diners_club' => 'DINERS-SSL',
24
24
  }
25
25
 
26
+ AVS_CODE_MAP = {
27
+ 'A' => 'M', # Match
28
+ 'B' => 'P', # Postcode matches, address not verified
29
+ 'C' => 'Z', # Postcode matches, address does not match
30
+ 'D' => 'B', # Address matched; postcode not checked
31
+ 'E' => 'I', # Address and postal code not checked
32
+ 'F' => 'A', # Address matches, postcode does not match
33
+ 'G' => 'C', # Address does not match, postcode not checked
34
+ 'H' => 'I', # Address and postcode not provided
35
+ 'I' => 'C', # Address not checked postcode does not match
36
+ 'J' => 'C', # Address and postcode does not match
37
+ }
38
+
39
+ CVC_CODE_MAP = {
40
+ 'A' => 'M', # CVV matches
41
+ 'B' => 'P', # Not provided
42
+ 'C' => 'P', # Not checked
43
+ 'D' => 'N', # Does not match
44
+ }
45
+
26
46
  def initialize(options = {})
27
47
  requires!(options, :login, :password)
28
48
  super
@@ -248,12 +268,38 @@ module ActiveMerchant #:nodoc:
248
268
  xml.tag! 'session', 'shopperIPAddress' => options[:ip] if options[:ip]
249
269
  xml.tag! 'session', 'id' => options[:session_id] if options[:session_id]
250
270
  end
251
- add_stored_credential_options(xml, options) if options[:stored_credential_usage]
271
+ add_stored_credential_options(xml, options)
252
272
  end
253
273
  end
254
274
  end
255
275
 
256
276
  def add_stored_credential_options(xml, options={})
277
+ if options[:stored_credential]
278
+ add_stored_credential_using_normalized_fields(xml, options)
279
+ else
280
+ add_stored_credential_using_gateway_specific_fields(xml, options)
281
+ end
282
+ end
283
+
284
+ def add_stored_credential_using_normalized_fields(xml, options)
285
+ if options[:stored_credential][:initial_transaction]
286
+ xml.tag! 'storedCredentials', 'usage' => 'FIRST'
287
+ else
288
+ reason = case options[:stored_credential][:reason_type]
289
+ when 'installment' then 'INSTALMENT'
290
+ when 'recurring' then 'RECURRING'
291
+ when 'unscheduled' then 'UNSCHEDULED'
292
+ end
293
+
294
+ xml.tag! 'storedCredentials', 'usage' => 'USED', 'merchantInitiatedReason' => reason do
295
+ xml.tag! 'schemeTransactionIdentifier', options[:stored_credential][:network_transaction_id] if options[:stored_credential][:network_transaction_id]
296
+ end
297
+ end
298
+ end
299
+
300
+ def add_stored_credential_using_gateway_specific_fields(xml, options)
301
+ return unless options[:stored_credential_usage]
302
+
257
303
  if options[:stored_credential_initiated_reason]
258
304
  xml.tag! 'storedCredentials', 'usage' => options[:stored_credential_usage], 'merchantInitiatedReason' => options[:stored_credential_initiated_reason] do
259
305
  xml.tag! 'schemeTransactionIdentifier', options[:stored_credential_transaction_id] if options[:stored_credential_transaction_id]
@@ -370,7 +416,10 @@ module ActiveMerchant #:nodoc:
370
416
  raw,
371
417
  :authorization => authorization_from(raw),
372
418
  :error_code => error_code_from(success, raw),
373
- :test => test?)
419
+ :test => test?,
420
+ :avs_result => AVSResult.new(code: AVS_CODE_MAP[raw[:avs_result_code_description]]),
421
+ :cvv_result => CVVResult.new(CVC_CODE_MAP[raw[:cvc_result_code_description]])
422
+ )
374
423
  rescue ActiveMerchant::ResponseError => e
375
424
  if e.response.code.to_s == '401'
376
425
  return Response.new(false, 'Invalid credentials', {}, :test => test?)
@@ -245,8 +245,8 @@ module ActiveMerchant #:nodoc:
245
245
  { alpha2: 'PR', name: 'Puerto Rico', alpha3: 'PRI', numeric: '630' },
246
246
  { alpha2: 'QA', name: 'Qatar', alpha3: 'QAT', numeric: '634' },
247
247
  { alpha2: 'RE', name: 'Reunion', alpha3: 'REU', numeric: '638' },
248
- { alpha2: 'RO', name: 'Romania', alpha3: 'ROM', numeric: '642' },
249
248
  { alpha2: 'RO', name: 'Romania', alpha3: 'ROU', numeric: '642' },
249
+ { alpha2: 'RO', name: 'Romania', alpha3: 'ROM', numeric: '642' },
250
250
  { alpha2: 'RU', name: 'Russian Federation', alpha3: 'RUS', numeric: '643' },
251
251
  { alpha2: 'RW', name: 'Rwanda', alpha3: 'RWA', numeric: '646' },
252
252
  { alpha2: 'BL', name: 'Saint Barthélemy', alpha3: 'BLM', numeric: '652' },
@@ -1,3 +1,3 @@
1
1
  module ActiveMerchant
2
- VERSION = '1.90.0'
2
+ VERSION = '1.91.0'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activemerchant
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.90.0
4
+ version: 1.91.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tobias Luetke
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-01-09 00:00:00.000000000 Z
11
+ date: 2019-02-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -162,6 +162,7 @@ files:
162
162
  - lib/active_merchant/billing/gateways/authorize_net_cim.rb
163
163
  - lib/active_merchant/billing/gateways/axcessms.rb
164
164
  - lib/active_merchant/billing/gateways/balanced.rb
165
+ - lib/active_merchant/billing/gateways/bambora_apac.rb
165
166
  - lib/active_merchant/billing/gateways/bank_frick.rb
166
167
  - lib/active_merchant/billing/gateways/banwire.rb
167
168
  - lib/active_merchant/billing/gateways/barclaycard_smartpay.rb