activemerchant 1.105.0 → 1.106.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (167) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG +31 -1
  3. data/README.md +1 -1
  4. data/lib/active_merchant/billing/credit_card_methods.rb +12 -3
  5. data/lib/active_merchant/billing/gateway.rb +22 -22
  6. data/lib/active_merchant/billing/gateways/adyen.rb +17 -6
  7. data/lib/active_merchant/billing/gateways/allied_wallet.rb +2 -2
  8. data/lib/active_merchant/billing/gateways/authorize_net.rb +19 -19
  9. data/lib/active_merchant/billing/gateways/authorize_net_arb.rb +11 -11
  10. data/lib/active_merchant/billing/gateways/authorize_net_cim.rb +35 -35
  11. data/lib/active_merchant/billing/gateways/axcessms.rb +3 -3
  12. data/lib/active_merchant/billing/gateways/bambora_apac.rb +1 -1
  13. data/lib/active_merchant/billing/gateways/bank_frick.rb +1 -1
  14. data/lib/active_merchant/billing/gateways/banwire.rb +2 -2
  15. data/lib/active_merchant/billing/gateways/barclaycard_smartpay.rb +5 -5
  16. data/lib/active_merchant/billing/gateways/be2bill.rb +4 -4
  17. data/lib/active_merchant/billing/gateways/beanstream.rb +1 -1
  18. data/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb +27 -27
  19. data/lib/active_merchant/billing/gateways/beanstream_interac.rb +1 -1
  20. data/lib/active_merchant/billing/gateways/blue_pay.rb +8 -8
  21. data/lib/active_merchant/billing/gateways/blue_snap.rb +5 -2
  22. data/lib/active_merchant/billing/gateways/bogus.rb +20 -20
  23. data/lib/active_merchant/billing/gateways/borgun.rb +2 -2
  24. data/lib/active_merchant/billing/gateways/bpoint.rb +1 -1
  25. data/lib/active_merchant/billing/gateways/braintree_blue.rb +74 -74
  26. data/lib/active_merchant/billing/gateways/bridge_pay.rb +3 -3
  27. data/lib/active_merchant/billing/gateways/card_connect.rb +1 -1
  28. data/lib/active_merchant/billing/gateways/card_stream.rb +19 -19
  29. data/lib/active_merchant/billing/gateways/cc5.rb +7 -7
  30. data/lib/active_merchant/billing/gateways/cecabank.rb +3 -3
  31. data/lib/active_merchant/billing/gateways/cenpos.rb +3 -3
  32. data/lib/active_merchant/billing/gateways/checkout_v2.rb +1 -1
  33. data/lib/active_merchant/billing/gateways/clearhaus.rb +1 -1
  34. data/lib/active_merchant/billing/gateways/commercegate.rb +2 -2
  35. data/lib/active_merchant/billing/gateways/conekta.rb +1 -1
  36. data/lib/active_merchant/billing/gateways/creditcall.rb +4 -4
  37. data/lib/active_merchant/billing/gateways/ct_payment.rb +1 -1
  38. data/lib/active_merchant/billing/gateways/culqi.rb +2 -2
  39. data/lib/active_merchant/billing/gateways/cyber_source.rb +86 -72
  40. data/lib/active_merchant/billing/gateways/data_cash.rb +33 -33
  41. data/lib/active_merchant/billing/gateways/decidir.rb +2 -2
  42. data/lib/active_merchant/billing/gateways/ebanx.rb +1 -1
  43. data/lib/active_merchant/billing/gateways/efsnet.rb +23 -23
  44. data/lib/active_merchant/billing/gateways/elavon.rb +13 -13
  45. data/lib/active_merchant/billing/gateways/epay.rb +40 -40
  46. data/lib/active_merchant/billing/gateways/evo_ca.rb +11 -11
  47. data/lib/active_merchant/billing/gateways/eway.rb +3 -3
  48. data/lib/active_merchant/billing/gateways/eway_managed.rb +40 -40
  49. data/lib/active_merchant/billing/gateways/eway_rapid.rb +7 -7
  50. data/lib/active_merchant/billing/gateways/exact.rb +11 -11
  51. data/lib/active_merchant/billing/gateways/fat_zebra.rb +3 -2
  52. data/lib/active_merchant/billing/gateways/federated_canada.rb +5 -5
  53. data/lib/active_merchant/billing/gateways/firstdata_e4.rb +20 -20
  54. data/lib/active_merchant/billing/gateways/firstdata_e4_v27.rb +19 -19
  55. data/lib/active_merchant/billing/gateways/flo2cash.rb +4 -4
  56. data/lib/active_merchant/billing/gateways/forte.rb +1 -1
  57. data/lib/active_merchant/billing/gateways/garanti.rb +8 -8
  58. data/lib/active_merchant/billing/gateways/hdfc.rb +3 -3
  59. data/lib/active_merchant/billing/gateways/hps.rb +1 -1
  60. data/lib/active_merchant/billing/gateways/iats_payments.rb +1 -1
  61. data/lib/active_merchant/billing/gateways/inspire.rb +7 -7
  62. data/lib/active_merchant/billing/gateways/instapay.rb +3 -3
  63. data/lib/active_merchant/billing/gateways/ipp.rb +1 -1
  64. data/lib/active_merchant/billing/gateways/iridium.rb +8 -8
  65. data/lib/active_merchant/billing/gateways/itransact.rb +7 -7
  66. data/lib/active_merchant/billing/gateways/iveri.rb +2 -2
  67. data/lib/active_merchant/billing/gateways/ixopay.rb +21 -0
  68. data/lib/active_merchant/billing/gateways/jetpay.rb +4 -4
  69. data/lib/active_merchant/billing/gateways/jetpay_v2.rb +5 -5
  70. data/lib/active_merchant/billing/gateways/latitude19.rb +2 -2
  71. data/lib/active_merchant/billing/gateways/linkpoint.rb +62 -62
  72. data/lib/active_merchant/billing/gateways/litle.rb +2 -2
  73. data/lib/active_merchant/billing/gateways/mastercard.rb +2 -2
  74. data/lib/active_merchant/billing/gateways/merchant_e_solutions.rb +5 -5
  75. data/lib/active_merchant/billing/gateways/merchant_one.rb +2 -2
  76. data/lib/active_merchant/billing/gateways/merchant_partners.rb +4 -4
  77. data/lib/active_merchant/billing/gateways/merchant_ware.rb +12 -12
  78. data/lib/active_merchant/billing/gateways/merchant_ware_version_four.rb +11 -11
  79. data/lib/active_merchant/billing/gateways/merchant_warrior.rb +12 -2
  80. data/lib/active_merchant/billing/gateways/mercury.rb +9 -9
  81. data/lib/active_merchant/billing/gateways/metrics_global.rb +15 -15
  82. data/lib/active_merchant/billing/gateways/migs.rb +13 -13
  83. data/lib/active_merchant/billing/gateways/modern_payments_cim.rb +7 -7
  84. data/lib/active_merchant/billing/gateways/monei.rb +19 -19
  85. data/lib/active_merchant/billing/gateways/moneris.rb +10 -10
  86. data/lib/active_merchant/billing/gateways/money_movers.rb +5 -5
  87. data/lib/active_merchant/billing/gateways/mundipagg.rb +1 -1
  88. data/lib/active_merchant/billing/gateways/nab_transact.rb +15 -15
  89. data/lib/active_merchant/billing/gateways/ncr_secure_pay.rb +1 -1
  90. data/lib/active_merchant/billing/gateways/net_registry.rb +6 -6
  91. data/lib/active_merchant/billing/gateways/netaxept.rb +4 -4
  92. data/lib/active_merchant/billing/gateways/netbanx.rb +14 -14
  93. data/lib/active_merchant/billing/gateways/netbilling.rb +12 -12
  94. data/lib/active_merchant/billing/gateways/netpay.rb +2 -2
  95. data/lib/active_merchant/billing/gateways/network_merchants.rb +5 -5
  96. data/lib/active_merchant/billing/gateways/ogone.rb +7 -7
  97. data/lib/active_merchant/billing/gateways/openpay.rb +2 -2
  98. data/lib/active_merchant/billing/gateways/opp.rb +1 -1
  99. data/lib/active_merchant/billing/gateways/optimal_payment.rb +9 -9
  100. data/lib/active_merchant/billing/gateways/orbital.rb +10 -10
  101. data/lib/active_merchant/billing/gateways/pac_net_raven.rb +7 -7
  102. data/lib/active_merchant/billing/gateways/pay_conex.rb +2 -2
  103. data/lib/active_merchant/billing/gateways/pay_gate_xml.rb +16 -16
  104. data/lib/active_merchant/billing/gateways/pay_junction.rb +16 -16
  105. data/lib/active_merchant/billing/gateways/pay_junction_v2.rb +18 -2
  106. data/lib/active_merchant/billing/gateways/pay_secure.rb +6 -6
  107. data/lib/active_merchant/billing/gateways/paybox_direct.rb +36 -36
  108. data/lib/active_merchant/billing/gateways/payflow.rb +7 -7
  109. data/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb +12 -12
  110. data/lib/active_merchant/billing/gateways/payflow_express.rb +4 -4
  111. data/lib/active_merchant/billing/gateways/payment_express.rb +7 -7
  112. data/lib/active_merchant/billing/gateways/paymill.rb +3 -3
  113. data/lib/active_merchant/billing/gateways/paypal.rb +1 -1
  114. data/lib/active_merchant/billing/gateways/paypal/paypal_common_api.rb +5 -5
  115. data/lib/active_merchant/billing/gateways/paypal_express_common.rb +1 -1
  116. data/lib/active_merchant/billing/gateways/payscout.rb +5 -5
  117. data/lib/active_merchant/billing/gateways/paystation.rb +2 -2
  118. data/lib/active_merchant/billing/gateways/payu_latam.rb +3 -3
  119. data/lib/active_merchant/billing/gateways/payway.rb +12 -12
  120. data/lib/active_merchant/billing/gateways/pin.rb +16 -16
  121. data/lib/active_merchant/billing/gateways/plugnpay.rb +10 -10
  122. data/lib/active_merchant/billing/gateways/psigate.rb +26 -26
  123. data/lib/active_merchant/billing/gateways/psl_card.rb +4 -4
  124. data/lib/active_merchant/billing/gateways/qbms.rb +23 -23
  125. data/lib/active_merchant/billing/gateways/quantum.rb +4 -4
  126. data/lib/active_merchant/billing/gateways/quickpay/quickpay_common.rb +95 -95
  127. data/lib/active_merchant/billing/gateways/quickpay/quickpay_v10.rb +9 -9
  128. data/lib/active_merchant/billing/gateways/quickpay/quickpay_v4to7.rb +2 -2
  129. data/lib/active_merchant/billing/gateways/qvalent.rb +1 -1
  130. data/lib/active_merchant/billing/gateways/realex.rb +8 -8
  131. data/lib/active_merchant/billing/gateways/redsys.rb +24 -16
  132. data/lib/active_merchant/billing/gateways/safe_charge.rb +1 -1
  133. data/lib/active_merchant/billing/gateways/sage.rb +10 -10
  134. data/lib/active_merchant/billing/gateways/sage_pay.rb +35 -35
  135. data/lib/active_merchant/billing/gateways/sallie_mae.rb +2 -2
  136. data/lib/active_merchant/billing/gateways/secure_net.rb +9 -9
  137. data/lib/active_merchant/billing/gateways/secure_pay.rb +13 -13
  138. data/lib/active_merchant/billing/gateways/secure_pay_au.rb +15 -15
  139. data/lib/active_merchant/billing/gateways/secure_pay_tech.rb +2 -2
  140. data/lib/active_merchant/billing/gateways/skip_jack.rb +8 -8
  141. data/lib/active_merchant/billing/gateways/smart_ps.rb +16 -16
  142. data/lib/active_merchant/billing/gateways/so_easy_pay.rb +6 -6
  143. data/lib/active_merchant/billing/gateways/spreedly_core.rb +4 -4
  144. data/lib/active_merchant/billing/gateways/stripe.rb +8 -8
  145. data/lib/active_merchant/billing/gateways/stripe_payment_intents.rb +10 -3
  146. data/lib/active_merchant/billing/gateways/swipe_checkout.rb +2 -2
  147. data/lib/active_merchant/billing/gateways/trans_first.rb +4 -4
  148. data/lib/active_merchant/billing/gateways/trust_commerce.rb +19 -19
  149. data/lib/active_merchant/billing/gateways/usa_epay_advanced.rb +110 -110
  150. data/lib/active_merchant/billing/gateways/usa_epay_transaction.rb +29 -29
  151. data/lib/active_merchant/billing/gateways/verifi.rb +10 -10
  152. data/lib/active_merchant/billing/gateways/viaklix.rb +6 -6
  153. data/lib/active_merchant/billing/gateways/visanet_peru.rb +6 -6
  154. data/lib/active_merchant/billing/gateways/webpay.rb +2 -2
  155. data/lib/active_merchant/billing/gateways/wirecard.rb +6 -6
  156. data/lib/active_merchant/billing/gateways/worldpay.rb +15 -15
  157. data/lib/active_merchant/billing/gateways/worldpay_online_payments.rb +32 -32
  158. data/lib/active_merchant/billing/gateways/worldpay_us.rb +2 -2
  159. data/lib/active_merchant/connection.rb +1 -1
  160. data/lib/active_merchant/network_connection_retries.rb +3 -3
  161. data/lib/active_merchant/post_data.rb +1 -1
  162. data/lib/active_merchant/version.rb +1 -1
  163. data/lib/certs/cacert.pem +75 -0
  164. data/lib/support/ssl_verify.rb +2 -2
  165. data/lib/support/ssl_version.rb +2 -2
  166. metadata +2 -3
  167. data/lib/active_merchant/billing/gateways/moneris_us.rb +0 -352
@@ -72,8 +72,8 @@ module ActiveMerchant #:nodoc:
72
72
  authorization = response[:unique_id]
73
73
 
74
74
  Response.new(success, message, response,
75
- :authorization => authorization,
76
- :test => (response[:mode] != 'LIVE')
75
+ authorization: authorization,
76
+ test: (response[:mode] != 'LIVE')
77
77
  )
78
78
  end
79
79
 
@@ -103,7 +103,7 @@ module ActiveMerchant #:nodoc:
103
103
  end
104
104
 
105
105
  def build_request(payment_code, money, payment, options)
106
- xml = Builder::XmlMarkup.new :indent => 2
106
+ xml = Builder::XmlMarkup.new indent: 2
107
107
  xml.instruct!
108
108
  xml.tag! 'Request', 'version' => API_VERSION do
109
109
  xml.tag! 'Header' do
@@ -132,7 +132,7 @@ module ActiveMerchant #:nodoc:
132
132
  end
133
133
 
134
134
  def add_credit_card(xml, payment)
135
- xml.CreditCard :Registered => 'False' do
135
+ xml.CreditCard Registered: 'False' do
136
136
  xml.CardNumber payment.number
137
137
  xml.ExpM format(payment.month, :two_digits)
138
138
  xml.ExpY format(payment.year, :four_digits)
@@ -166,7 +166,7 @@ module ActiveMerchant #:nodoc:
166
166
  end
167
167
 
168
168
  def build_xml_request(action, data)
169
- xml = Builder::XmlMarkup.new :indent => 2
169
+ xml = Builder::XmlMarkup.new indent: 2
170
170
  xml.Request(version: '1.0') do
171
171
  xml.Header do
172
172
  xml.Security(sender: @options[:sender], type: 'MERCHANT')
@@ -92,8 +92,8 @@ module ActiveMerchant #:nodoc:
92
92
  Response.new(success?(response),
93
93
  response['message'],
94
94
  response,
95
- :test => test?,
96
- :authorization => response['code_auth'])
95
+ test: test?,
96
+ authorization: response['code_auth'])
97
97
  end
98
98
 
99
99
  def success?(response)
@@ -108,7 +108,7 @@ module ActiveMerchant #:nodoc:
108
108
  def store(creditcard, options = {})
109
109
  post = store_request(options)
110
110
  post[:card] = credit_card_hash(creditcard)
111
- post[:recurring] = {:contract => 'RECURRING'}
111
+ post[:recurring] = {contract: 'RECURRING'}
112
112
 
113
113
  commit('store', post)
114
114
  end
@@ -161,20 +161,20 @@ module ActiveMerchant #:nodoc:
161
161
  message_from(response),
162
162
  response,
163
163
  test: test?,
164
- avs_result: AVSResult.new(:code => parse_avs_code(response)),
164
+ avs_result: AVSResult.new(code: parse_avs_code(response)),
165
165
  authorization: response['recurringDetailReference'] || authorization_from(post, response)
166
166
  )
167
167
  rescue ResponseError => e
168
168
  case e.response.code
169
169
  when '401'
170
- return Response.new(false, 'Invalid credentials', {}, :test => test?)
170
+ return Response.new(false, 'Invalid credentials', {}, test: test?)
171
171
  when '403'
172
- return Response.new(false, 'Not allowed', {}, :test => test?)
172
+ return Response.new(false, 'Not allowed', {}, test: test?)
173
173
  when '422', '500'
174
174
  if e.response.body.split(/\W+/).any? { |word| %w(validation configuration security).include?(word) }
175
175
  error_message = e.response.body[/#{Regexp.escape('message=')}(.*?)#{Regexp.escape('&')}/m, 1].tr('+', ' ')
176
176
  error_code = e.response.body[/#{Regexp.escape('errorCode=')}(.*?)#{Regexp.escape('&')}/m, 1]
177
- return Response.new(false, error_code + ': ' + error_message, {}, :test => test?)
177
+ return Response.new(false, error_code + ': ' + error_message, {}, test: test?)
178
178
  end
179
179
  end
180
180
  raise
@@ -92,8 +92,8 @@ module ActiveMerchant #:nodoc:
92
92
  successful?(response),
93
93
  message_from(response),
94
94
  response,
95
- :authorization => response['TRANSACTIONID'],
96
- :test => test?
95
+ authorization: response['TRANSACTIONID'],
96
+ test: test?
97
97
  )
98
98
  end
99
99
 
@@ -111,8 +111,8 @@ module ActiveMerchant #:nodoc:
111
111
 
112
112
  def post_data(action, parameters = {})
113
113
  {
114
- :method => action,
115
- :params => parameters.merge(HASH: signature(parameters, action))
114
+ method: action,
115
+ params: parameters.merge(HASH: signature(parameters, action))
116
116
  }.to_query
117
117
  end
118
118
 
@@ -175,7 +175,7 @@ module ActiveMerchant #:nodoc:
175
175
  # can't actually delete a secure profile with the supplicated API. This function sets the status of the profile to closed (C).
176
176
  # Closed profiles will have to removed manually.
177
177
  def delete(vault_id)
178
- update(vault_id, false, {:status => 'C'})
178
+ update(vault_id, false, {status: 'C'})
179
179
  end
180
180
 
181
181
  alias_method :unstore, :delete
@@ -9,20 +9,20 @@ module ActiveMerchant #:nodoc:
9
9
  SP_SERVICE_VERSION = '1.1'
10
10
 
11
11
  TRANSACTIONS = {
12
- :authorization => 'PA',
13
- :purchase => 'P',
14
- :capture => 'PAC',
15
- :refund => 'R',
16
- :void => 'VP',
17
- :check_purchase => 'D',
18
- :check_refund => 'C',
19
- :void_purchase => 'VP',
20
- :void_refund => 'VR'
12
+ authorization: 'PA',
13
+ purchase: 'P',
14
+ capture: 'PAC',
15
+ refund: 'R',
16
+ void: 'VP',
17
+ check_purchase: 'D',
18
+ check_refund: 'C',
19
+ void_purchase: 'VP',
20
+ void_refund: 'VR'
21
21
  }
22
22
 
23
23
  PROFILE_OPERATIONS = {
24
- :new => 'N',
25
- :modify => 'M'
24
+ new: 'N',
25
+ modify: 'M'
26
26
  }
27
27
 
28
28
  CVD_CODES = {
@@ -41,24 +41,24 @@ module ActiveMerchant #:nodoc:
41
41
  }
42
42
 
43
43
  PERIODS = {
44
- :days => 'D',
45
- :weeks => 'W',
46
- :months => 'M',
47
- :years => 'Y'
44
+ days: 'D',
45
+ weeks: 'W',
46
+ months: 'M',
47
+ years: 'Y'
48
48
  }
49
49
 
50
50
  PERIODICITIES = {
51
- :daily => [:days, 1],
52
- :weekly => [:weeks, 1],
53
- :biweekly => [:weeks, 2],
54
- :monthly => [:months, 1],
55
- :bimonthly => [:months, 2],
56
- :yearly => [:years, 1]
51
+ daily: [:days, 1],
52
+ weekly: [:weeks, 1],
53
+ biweekly: [:weeks, 2],
54
+ monthly: [:months, 1],
55
+ bimonthly: [:months, 2],
56
+ yearly: [:years, 1]
57
57
  }
58
58
 
59
59
  RECURRING_OPERATION = {
60
- :update => 'M',
61
- :cancel => 'C'
60
+ update: 'M',
61
+ cancel: 'C'
62
62
  }
63
63
 
64
64
  STATES = {
@@ -414,10 +414,10 @@ module ActiveMerchant #:nodoc:
414
414
  response = parse(ssl_post((use_profile_api ? SECURE_PROFILE_URL : self.live_url), data))
415
415
  response[:customer_vault_id] = response[:customerCode] if response[:customerCode]
416
416
  build_response(success?(response), message_from(response), response,
417
- :test => test? || response[:authCode] == 'TEST',
418
- :authorization => authorization_from(response),
419
- :cvv_result => CVD_CODES[response[:cvdId]],
420
- :avs_result => { :code => AVS_CODES.include?(response[:avsId]) ? AVS_CODES[response[:avsId]] : response[:avsId] }
417
+ test: test? || response[:authCode] == 'TEST',
418
+ authorization: authorization_from(response),
419
+ cvv_result: CVD_CODES[response[:cvdId]],
420
+ avs_result: { code: AVS_CODES.include?(response[:avsId]) ? AVS_CODES[response[:avsId]] : response[:avsId] }
421
421
  )
422
422
  end
423
423
 
@@ -18,7 +18,7 @@ module ActiveMerchant #:nodoc:
18
18
  # post back is for until the response of the confirmation is
19
19
  # received, which contains the order number.
20
20
  def self.confirm(transaction)
21
- gateway = new(:login => '')
21
+ gateway = new(login: '')
22
22
  gateway.confirm(transaction)
23
23
  end
24
24
 
@@ -18,7 +18,7 @@ module ActiveMerchant #:nodoc:
18
18
  'TRANS_ID' => :transaction_id,
19
19
  'STATUS' => :response_code,
20
20
  'AVS' => :avs_result_code,
21
- 'CVV2'=> :card_code,
21
+ 'CVV2' => :card_code,
22
22
  'AUTH_CODE' => :authorization,
23
23
  'MESSAGE' => :message,
24
24
  'REBID' => :rebid,
@@ -29,7 +29,7 @@ module ActiveMerchant #:nodoc:
29
29
 
30
30
  REBILL_FIELD_MAP = {
31
31
  'REBILL_ID' => :rebill_id,
32
- 'ACCOUNT_ID'=> :account_id,
32
+ 'ACCOUNT_ID' => :account_id,
33
33
  'USER_ID' => :user_id,
34
34
  'TEMPLATE_ID' => :template_id,
35
35
  'STATUS' => :status,
@@ -343,8 +343,8 @@ module ActiveMerchant #:nodoc:
343
343
  message = parsed[:status]
344
344
 
345
345
  Response.new(success, message, parsed,
346
- :test => test?,
347
- :authorization => parsed[:rebill_id])
346
+ test: test?,
347
+ authorization: parsed[:rebill_id])
348
348
  end
349
349
 
350
350
  def parse(body)
@@ -363,10 +363,10 @@ module ActiveMerchant #:nodoc:
363
363
  message = message_from(parsed)
364
364
  success = parsed[:response_code] == '1'
365
365
  Response.new(success, message, parsed,
366
- :test => test?,
367
- :authorization => (parsed[:rebid] && parsed[:rebid] != '' ? parsed[:rebid] : parsed[:transaction_id]),
368
- :avs_result => { :code => parsed[:avs_result_code] },
369
- :cvv_result => parsed[:card_code]
366
+ test: test?,
367
+ authorization: (parsed[:rebid] && parsed[:rebid] != '' ? parsed[:rebid] : parsed[:transaction_id]),
368
+ avs_result: { code: parsed[:avs_result_code] },
369
+ cvv_result: parsed[:card_code]
370
370
  )
371
371
  end
372
372
 
@@ -9,6 +9,8 @@ module ActiveMerchant
9
9
 
10
10
  self.default_currency = 'USD'
11
11
  self.supported_cardtypes = [:visa, :master, :american_express, :discover, :jcb, :diners_club, :maestro, :naranja, :cabal]
12
+ self.currencies_without_fractions = %w(BYR CLP ILS JPY KRW VND XOF)
13
+ self.currencies_with_three_decimal_places = %w(BHD JOD KWD OMR TND)
12
14
 
13
15
  self.homepage_url = 'https://home.bluesnap.com/'
14
16
  self.display_name = 'BlueSnap'
@@ -188,8 +190,9 @@ module ActiveMerchant
188
190
  end
189
191
 
190
192
  def add_amount(doc, money, options)
191
- doc.amount(amount(money))
192
- doc.currency(options[:currency] || currency(money))
193
+ currency = options[:currency] || currency(money)
194
+ doc.amount(localized_amount(money, currency))
195
+ doc.currency(currency)
193
196
  end
194
197
 
195
198
  def add_personal_info(doc, payment_method, options)
@@ -47,9 +47,9 @@ 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
- Response.new(false, FAILURE_MESSAGE, {:paid_amount => money, :error => FAILURE_MESSAGE }, :test => true, :error_code => STANDARD_ERROR_CODE[:processing_error])
52
+ Response.new(false, FAILURE_MESSAGE, {paid_amount: money, error: FAILURE_MESSAGE }, test: true, error_code: STANDARD_ERROR_CODE[:processing_error])
53
53
  else
54
54
  raise Error, error_message(paysource)
55
55
  end
@@ -61,9 +61,9 @@ module ActiveMerchant #:nodoc:
61
61
  when /1$/
62
62
  raise Error, REFUND_ERROR_MESSAGE
63
63
  when /2$/
64
- Response.new(false, FAILURE_MESSAGE, {:paid_amount => money, :error => FAILURE_MESSAGE }, :test => true, :error_code => STANDARD_ERROR_CODE[:processing_error])
64
+ Response.new(false, FAILURE_MESSAGE, {paid_amount: money, error: FAILURE_MESSAGE }, test: true, error_code: STANDARD_ERROR_CODE[:processing_error])
65
65
  else
66
- Response.new(true, SUCCESS_MESSAGE, {:paid_amount => money}, :test => true)
66
+ Response.new(true, SUCCESS_MESSAGE, {paid_amount: money}, test: true)
67
67
  end
68
68
  end
69
69
 
@@ -73,9 +73,9 @@ module ActiveMerchant #:nodoc:
73
73
  when /1$/
74
74
  raise Error, CAPTURE_ERROR_MESSAGE
75
75
  when /2$/
76
- Response.new(false, FAILURE_MESSAGE, {:paid_amount => money, :error => FAILURE_MESSAGE }, :test => true, :error_code => STANDARD_ERROR_CODE[:processing_error])
76
+ Response.new(false, FAILURE_MESSAGE, {paid_amount: money, error: FAILURE_MESSAGE }, test: true, error_code: STANDARD_ERROR_CODE[:processing_error])
77
77
  else
78
- Response.new(true, SUCCESS_MESSAGE, {:paid_amount => money}, :test => true)
78
+ Response.new(true, SUCCESS_MESSAGE, {paid_amount: money}, test: true)
79
79
  end
80
80
  end
81
81
 
@@ -84,18 +84,18 @@ module ActiveMerchant #:nodoc:
84
84
  when /1$/
85
85
  raise Error, VOID_ERROR_MESSAGE
86
86
  when /2$/
87
- Response.new(false, FAILURE_MESSAGE, {:authorization => reference, :error => FAILURE_MESSAGE }, :test => true, :error_code => STANDARD_ERROR_CODE[:processing_error])
87
+ Response.new(false, FAILURE_MESSAGE, {authorization: reference, error: FAILURE_MESSAGE }, test: true, error_code: STANDARD_ERROR_CODE[:processing_error])
88
88
  else
89
- Response.new(true, SUCCESS_MESSAGE, {:authorization => reference}, :test => true)
89
+ Response.new(true, SUCCESS_MESSAGE, {authorization: reference}, test: true)
90
90
  end
91
91
  end
92
92
 
93
93
  def store(paysource, options = {})
94
94
  case normalize(paysource)
95
95
  when /1$/
96
- Response.new(true, SUCCESS_MESSAGE, {:billingid => '1'}, :test => true, :authorization => AUTHORIZATION)
96
+ Response.new(true, SUCCESS_MESSAGE, {billingid: '1'}, test: true, authorization: AUTHORIZATION)
97
97
  when /2$/
98
- Response.new(false, FAILURE_MESSAGE, {:billingid => nil, :error => FAILURE_MESSAGE }, :test => true, :error_code => STANDARD_ERROR_CODE[:processing_error])
98
+ Response.new(false, FAILURE_MESSAGE, {billingid: nil, error: FAILURE_MESSAGE }, test: true, error_code: STANDARD_ERROR_CODE[:processing_error])
99
99
  else
100
100
  raise Error, error_message(paysource)
101
101
  end
@@ -104,9 +104,9 @@ module ActiveMerchant #:nodoc:
104
104
  def unstore(reference, options = {})
105
105
  case reference
106
106
  when /1$/
107
- Response.new(true, SUCCESS_MESSAGE, {}, :test => true)
107
+ Response.new(true, SUCCESS_MESSAGE, {}, test: true)
108
108
  when /2$/
109
- Response.new(false, FAILURE_MESSAGE, {:error => FAILURE_MESSAGE }, :test => true, :error_code => STANDARD_ERROR_CODE[:processing_error])
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
@@ -118,9 +118,9 @@ module ActiveMerchant #:nodoc:
118
118
  money = amount(money)
119
119
  case money
120
120
  when /00$/
121
- Response.new(true, SUCCESS_MESSAGE, {:authorized_amount => money}, :test => true, :authorization => AUTHORIZATION, :emv_authorization => AUTHORIZATION_EMV_SUCCESS)
121
+ Response.new(true, SUCCESS_MESSAGE, {authorized_amount: money}, test: true, authorization: AUTHORIZATION, emv_authorization: AUTHORIZATION_EMV_SUCCESS)
122
122
  when /05$/
123
- Response.new(false, FAILURE_MESSAGE, {:authorized_amount => money, :error => FAILURE_MESSAGE }, :test => true, :error_code => STANDARD_ERROR_CODE[:processing_error], :emv_authorization => AUTHORIZATION_EMV_DECLINE)
123
+ Response.new(false, FAILURE_MESSAGE, {authorized_amount: money, error: FAILURE_MESSAGE }, test: true, error_code: STANDARD_ERROR_CODE[:processing_error], emv_authorization: AUTHORIZATION_EMV_DECLINE)
124
124
  else
125
125
  raise Error, error_message(paysource)
126
126
  end
@@ -130,9 +130,9 @@ 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
- Response.new(false, FAILURE_MESSAGE, {:authorized_amount => money, :error => FAILURE_MESSAGE }, :test => true, :error_code => STANDARD_ERROR_CODE[:processing_error])
135
+ Response.new(false, FAILURE_MESSAGE, {authorized_amount: money, error: FAILURE_MESSAGE }, test: true, error_code: STANDARD_ERROR_CODE[:processing_error])
136
136
  else
137
137
  raise Error, error_message(paysource)
138
138
  end
@@ -142,9 +142,9 @@ module ActiveMerchant #:nodoc:
142
142
  money = amount(money)
143
143
  case money
144
144
  when /00$/
145
- Response.new(true, SUCCESS_MESSAGE, {:paid_amount => money}, :test => true, :authorization => AUTHORIZATION, :emv_authorization => AUTHORIZATION_EMV_SUCCESS)
145
+ Response.new(true, SUCCESS_MESSAGE, {paid_amount: money}, test: true, authorization: AUTHORIZATION, emv_authorization: AUTHORIZATION_EMV_SUCCESS)
146
146
  when /05$/
147
- Response.new(false, FAILURE_MESSAGE, {:paid_amount => money, :error => FAILURE_MESSAGE }, :test => true, :error_code => STANDARD_ERROR_CODE[:processing_error], :emv_authorization => AUTHORIZATION_EMV_DECLINE)
147
+ Response.new(false, FAILURE_MESSAGE, {paid_amount: money, error: FAILURE_MESSAGE }, test: true, error_code: STANDARD_ERROR_CODE[:processing_error], emv_authorization: AUTHORIZATION_EMV_DECLINE)
148
148
  else
149
149
  raise Error, error_message(paysource)
150
150
  end
@@ -154,9 +154,9 @@ module ActiveMerchant #:nodoc:
154
154
  money = amount(money)
155
155
  case normalize(paysource)
156
156
  when /1$/, AUTHORIZATION
157
- Response.new(true, SUCCESS_MESSAGE, {:paid_amount => money}, :test => true, :authorization => AUTHORIZATION)
157
+ Response.new(true, SUCCESS_MESSAGE, {paid_amount: money}, test: true, authorization: AUTHORIZATION)
158
158
  when /2$/
159
- Response.new(false, FAILURE_MESSAGE, {:paid_amount => money, :error => FAILURE_MESSAGE }, :test => true, :error_code => STANDARD_ERROR_CODE[:processing_error])
159
+ Response.new(false, FAILURE_MESSAGE, {paid_amount: money, error: FAILURE_MESSAGE }, test: true, error_code: STANDARD_ERROR_CODE[:processing_error])
160
160
  else
161
161
  raise Error, error_message(paysource)
162
162
  end
@@ -182,8 +182,8 @@ module ActiveMerchant #:nodoc:
182
182
 
183
183
  def build_request(action, post)
184
184
  mode = action == 'void' ? 'cancel' : 'get'
185
- xml = Builder::XmlMarkup.new :indent => 18
186
- xml.instruct!(:xml, :version => '1.0', :encoding => 'utf-8')
185
+ xml = Builder::XmlMarkup.new indent: 18
186
+ xml.instruct!(:xml, version: '1.0', encoding: 'utf-8')
187
187
  xml.tag!("#{mode}Authorization") do
188
188
  post.each do |field, value|
189
189
  xml.tag!(field, value)
@@ -91,7 +91,7 @@ module ActiveMerchant #:nodoc:
91
91
  private
92
92
 
93
93
  def soap_request
94
- Nokogiri::XML::Builder.new(:encoding => 'utf-8') do |xml|
94
+ Nokogiri::XML::Builder.new(encoding: 'utf-8') do |xml|
95
95
  xml.send('soap12:Envelope', soap_envelope_attributes) {
96
96
  xml.send('soap12:Body') {
97
97
  yield(xml) if block_given?
@@ -60,12 +60,12 @@ module ActiveMerchant #:nodoc:
60
60
  end
61
61
 
62
62
  @configuration = Braintree::Configuration.new(
63
- :merchant_id => options[:merchant_id],
64
- :public_key => options[:public_key],
65
- :private_key => options[:private_key],
66
- :environment => (options[:environment] || (test? ? :sandbox : :production)).to_sym,
67
- :custom_user_agent => "ActiveMerchant #{ActiveMerchant::VERSION}",
68
- :logger => options[:logger] || logger
63
+ merchant_id: options[:merchant_id],
64
+ public_key: options[:public_key],
65
+ private_key: options[:private_key],
66
+ environment: (options[:environment] || (test? ? :sandbox : :production)).to_sym,
67
+ custom_user_agent: "ActiveMerchant #{ActiveMerchant::VERSION}",
68
+ logger: options[:logger] || logger
69
69
  )
70
70
 
71
71
  @braintree_gateway = Braintree::Gateway.new(@configuration)
@@ -83,7 +83,7 @@ module ActiveMerchant #:nodoc:
83
83
  end
84
84
 
85
85
  def purchase(money, credit_card_or_vault_id, options = {})
86
- authorize(money, credit_card_or_vault_id, options.merge(:submit_for_settlement => true))
86
+ authorize(money, credit_card_or_vault_id, options.merge(submit_for_settlement: true))
87
87
  end
88
88
 
89
89
  def credit(money, credit_card_or_vault_id, options = {})
@@ -144,26 +144,26 @@ module ActiveMerchant #:nodoc:
144
144
 
145
145
  options[:update_existing_token] = braintree_credit_card.token
146
146
  credit_card_params = merge_credit_card_options({
147
- :credit_card => {
148
- :cardholder_name => creditcard.name,
149
- :number => creditcard.number,
150
- :cvv => creditcard.verification_value,
151
- :expiration_month => creditcard.month.to_s.rjust(2, '0'),
152
- :expiration_year => creditcard.year.to_s
147
+ credit_card: {
148
+ cardholder_name: creditcard.name,
149
+ number: creditcard.number,
150
+ cvv: creditcard.verification_value,
151
+ expiration_month: creditcard.month.to_s.rjust(2, '0'),
152
+ expiration_year: creditcard.year.to_s
153
153
  }
154
154
  }, options)[:credit_card]
155
155
 
156
156
  result = @braintree_gateway.customer.update(vault_id,
157
- :first_name => creditcard.first_name,
158
- :last_name => creditcard.last_name,
159
- :email => scrub_email(options[:email]),
160
- :phone => options[:phone] || (options[:billing_address][:phone] if options[:billing_address] &&
157
+ first_name: creditcard.first_name,
158
+ last_name: creditcard.last_name,
159
+ email: scrub_email(options[:email]),
160
+ phone: options[:phone] || (options[:billing_address][:phone] if options[:billing_address] &&
161
161
  options[:billing_address][:phone]),
162
- :credit_card => credit_card_params
162
+ credit_card: credit_card_params
163
163
  )
164
164
  Response.new(result.success?, message_from_result(result),
165
- :braintree_customer => (customer_hash(@braintree_gateway.customer.find(vault_id), :include_credit_cards) if result.success?),
166
- :customer_vault_id => (result.customer.id if result.success?)
165
+ braintree_customer: (customer_hash(@braintree_gateway.customer.find(vault_id), :include_credit_cards) if result.success?),
166
+ customer_vault_id: (result.customer.id if result.success?)
167
167
  )
168
168
  end
169
169
  end
@@ -215,33 +215,33 @@ module ActiveMerchant #:nodoc:
215
215
  credit_card_params = { payment_method_nonce: options[:payment_method_nonce] }
216
216
  else
217
217
  credit_card_params = {
218
- :credit_card => {
219
- :cardholder_name => creditcard.name,
220
- :number => creditcard.number,
221
- :cvv => creditcard.verification_value,
222
- :expiration_month => creditcard.month.to_s.rjust(2, '0'),
223
- :expiration_year => creditcard.year.to_s,
224
- :token => options[:credit_card_token]
218
+ credit_card: {
219
+ cardholder_name: creditcard.name,
220
+ number: creditcard.number,
221
+ cvv: creditcard.verification_value,
222
+ expiration_month: creditcard.month.to_s.rjust(2, '0'),
223
+ expiration_year: creditcard.year.to_s,
224
+ token: options[:credit_card_token]
225
225
  }
226
226
  }
227
227
  end
228
228
  parameters = {
229
- :first_name => creditcard.first_name,
230
- :last_name => creditcard.last_name,
231
- :email => scrub_email(options[:email]),
232
- :phone => options[:phone] || (options[:billing_address][:phone] if options[:billing_address] &&
229
+ first_name: creditcard.first_name,
230
+ last_name: creditcard.last_name,
231
+ email: scrub_email(options[:email]),
232
+ phone: options[:phone] || (options[:billing_address][:phone] if options[:billing_address] &&
233
233
  options[:billing_address][:phone]),
234
- :id => options[:customer],
235
- :device_data => options[:device_data],
234
+ id: options[:customer],
235
+ device_data: options[:device_data],
236
236
  }.merge credit_card_params
237
237
  result = @braintree_gateway.customer.create(merge_credit_card_options(parameters, options))
238
238
  Response.new(result.success?, message_from_result(result),
239
239
  {
240
- :braintree_customer => (customer_hash(result.customer, :include_credit_cards) if result.success?),
241
- :customer_vault_id => (result.customer.id if result.success?),
242
- :credit_card_token => (result.customer.credit_cards[0].token if result.success?)
240
+ braintree_customer: (customer_hash(result.customer, :include_credit_cards) if result.success?),
241
+ customer_vault_id: (result.customer.id if result.success?),
242
+ credit_card_token: (result.customer.credit_cards[0].token if result.success?)
243
243
  },
244
- :authorization => (result.customer.id if result.success?)
244
+ authorization: (result.customer.id if result.success?)
245
245
  )
246
246
  end
247
247
  end
@@ -313,12 +313,12 @@ module ActiveMerchant #:nodoc:
313
313
 
314
314
  def map_address(address)
315
315
  mapped = {
316
- :street_address => address[:address1],
317
- :extended_address => address[:address2],
318
- :company => address[:company],
319
- :locality => address[:city],
320
- :region => address[:state],
321
- :postal_code => scrub_zip(address[:zip]),
316
+ street_address: address[:address1],
317
+ extended_address: address[:address2],
318
+ company: address[:company],
319
+ locality: address[:city],
320
+ region: address[:state],
321
+ postal_code: scrub_zip(address[:zip]),
322
322
  }
323
323
 
324
324
  mapped[:country_code_alpha2] = (address[:country] || address[:country_code_alpha2]) if address[:country] || address[:country_code_alpha2]
@@ -565,18 +565,18 @@ module ActiveMerchant #:nodoc:
565
565
 
566
566
  def create_transaction_parameters(money, credit_card_or_vault_id, options)
567
567
  parameters = {
568
- :amount => localized_amount(money, options[:currency] || default_currency).to_s,
569
- :order_id => options[:order_id],
570
- :customer => {
571
- :id => options[:store] == true ? '' : options[:store],
572
- :email => scrub_email(options[:email]),
573
- :phone => options[:phone] || (options[:billing_address][:phone] if options[:billing_address] &&
568
+ amount: localized_amount(money, options[:currency] || default_currency).to_s,
569
+ order_id: options[:order_id],
570
+ customer: {
571
+ id: options[:store] == true ? '' : options[:store],
572
+ email: scrub_email(options[:email]),
573
+ phone: options[:phone] || (options[:billing_address][:phone] if options[:billing_address] &&
574
574
  options[:billing_address][:phone])
575
575
  },
576
- :options => {
577
- :store_in_vault => options[:store] ? true : false,
578
- :submit_for_settlement => options[:submit_for_settlement],
579
- :hold_in_escrow => options[:hold_in_escrow],
576
+ options: {
577
+ store_in_vault: options[:store] ? true : false,
578
+ submit_for_settlement: options[:submit_for_settlement],
579
+ hold_in_escrow: options[:hold_in_escrow],
580
580
  }
581
581
  }
582
582
 
@@ -692,38 +692,38 @@ module ActiveMerchant #:nodoc:
692
692
  end
693
693
  else
694
694
  parameters[:customer].merge!(
695
- :first_name => credit_card_or_vault_id.first_name,
696
- :last_name => credit_card_or_vault_id.last_name
695
+ first_name: credit_card_or_vault_id.first_name,
696
+ last_name: credit_card_or_vault_id.last_name
697
697
  )
698
698
  if credit_card_or_vault_id.is_a?(NetworkTokenizationCreditCard)
699
699
  if credit_card_or_vault_id.source == :apple_pay
700
700
  parameters[:apple_pay_card] = {
701
- :number => credit_card_or_vault_id.number,
702
- :expiration_month => credit_card_or_vault_id.month.to_s.rjust(2, '0'),
703
- :expiration_year => credit_card_or_vault_id.year.to_s,
704
- :cardholder_name => credit_card_or_vault_id.name,
705
- :cryptogram => credit_card_or_vault_id.payment_cryptogram,
706
- :eci_indicator => credit_card_or_vault_id.eci
701
+ number: credit_card_or_vault_id.number,
702
+ expiration_month: credit_card_or_vault_id.month.to_s.rjust(2, '0'),
703
+ expiration_year: credit_card_or_vault_id.year.to_s,
704
+ cardholder_name: credit_card_or_vault_id.name,
705
+ cryptogram: credit_card_or_vault_id.payment_cryptogram,
706
+ eci_indicator: credit_card_or_vault_id.eci
707
707
  }
708
708
  elsif credit_card_or_vault_id.source == :android_pay || credit_card_or_vault_id.source == :google_pay
709
709
  parameters[:android_pay_card] = {
710
- :number => credit_card_or_vault_id.number,
711
- :cryptogram => credit_card_or_vault_id.payment_cryptogram,
712
- :expiration_month => credit_card_or_vault_id.month.to_s.rjust(2, '0'),
713
- :expiration_year => credit_card_or_vault_id.year.to_s,
714
- :google_transaction_id => credit_card_or_vault_id.transaction_id,
715
- :source_card_type => credit_card_or_vault_id.brand,
716
- :source_card_last_four => credit_card_or_vault_id.last_digits,
717
- :eci_indicator => credit_card_or_vault_id.eci
710
+ number: credit_card_or_vault_id.number,
711
+ cryptogram: credit_card_or_vault_id.payment_cryptogram,
712
+ expiration_month: credit_card_or_vault_id.month.to_s.rjust(2, '0'),
713
+ expiration_year: credit_card_or_vault_id.year.to_s,
714
+ google_transaction_id: credit_card_or_vault_id.transaction_id,
715
+ source_card_type: credit_card_or_vault_id.brand,
716
+ source_card_last_four: credit_card_or_vault_id.last_digits,
717
+ eci_indicator: credit_card_or_vault_id.eci
718
718
  }
719
719
  end
720
720
  else
721
721
  parameters[:credit_card] = {
722
- :number => credit_card_or_vault_id.number,
723
- :cvv => credit_card_or_vault_id.verification_value,
724
- :expiration_month => credit_card_or_vault_id.month.to_s.rjust(2, '0'),
725
- :expiration_year => credit_card_or_vault_id.year.to_s,
726
- :cardholder_name => credit_card_or_vault_id.name
722
+ number: credit_card_or_vault_id.number,
723
+ cvv: credit_card_or_vault_id.verification_value,
724
+ expiration_month: credit_card_or_vault_id.month.to_s.rjust(2, '0'),
725
+ expiration_year: credit_card_or_vault_id.year.to_s,
726
+ cardholder_name: credit_card_or_vault_id.name
727
727
  }
728
728
  end
729
729
  end