activemerchant 1.86.0 → 1.87.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (164) hide show
  1. checksums.yaml +5 -5
  2. data/CHANGELOG +22 -0
  3. data/lib/active_merchant/billing/avs_result.rb +0 -1
  4. data/lib/active_merchant/billing/check.rb +1 -1
  5. data/lib/active_merchant/billing/compatibility.rb +3 -3
  6. data/lib/active_merchant/billing/credit_card.rb +1 -1
  7. data/lib/active_merchant/billing/credit_card_formatting.rb +3 -3
  8. data/lib/active_merchant/billing/credit_card_methods.rb +6 -4
  9. data/lib/active_merchant/billing/gateway.rb +9 -9
  10. data/lib/active_merchant/billing/gateways/adyen.rb +48 -7
  11. data/lib/active_merchant/billing/gateways/allied_wallet.rb +1 -1
  12. data/lib/active_merchant/billing/gateways/authorize_net.rb +8 -8
  13. data/lib/active_merchant/billing/gateways/authorize_net_arb.rb +1 -1
  14. data/lib/active_merchant/billing/gateways/authorize_net_cim.rb +15 -15
  15. data/lib/active_merchant/billing/gateways/axcessms.rb +2 -2
  16. data/lib/active_merchant/billing/gateways/balanced.rb +11 -11
  17. data/lib/active_merchant/billing/gateways/bank_frick.rb +1 -1
  18. data/lib/active_merchant/billing/gateways/barclaycard_smartpay.rb +5 -5
  19. data/lib/active_merchant/billing/gateways/beanstream.rb +3 -2
  20. data/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb +5 -5
  21. data/lib/active_merchant/billing/gateways/blue_pay.rb +5 -5
  22. data/lib/active_merchant/billing/gateways/blue_snap.rb +5 -5
  23. data/lib/active_merchant/billing/gateways/bogus.rb +3 -3
  24. data/lib/active_merchant/billing/gateways/borgun.rb +5 -6
  25. data/lib/active_merchant/billing/gateways/braintree_blue.rb +18 -12
  26. data/lib/active_merchant/billing/gateways/bridge_pay.rb +1 -1
  27. data/lib/active_merchant/billing/gateways/cams.rb +12 -12
  28. data/lib/active_merchant/billing/gateways/card_stream.rb +9 -9
  29. data/lib/active_merchant/billing/gateways/cardknox.rb +4 -4
  30. data/lib/active_merchant/billing/gateways/cardprocess.rb +1 -1
  31. data/lib/active_merchant/billing/gateways/cashnet.rb +2 -2
  32. data/lib/active_merchant/billing/gateways/cc5.rb +2 -2
  33. data/lib/active_merchant/billing/gateways/cenpos.rb +2 -2
  34. data/lib/active_merchant/billing/gateways/checkout.rb +1 -1
  35. data/lib/active_merchant/billing/gateways/clearhaus.rb +12 -12
  36. data/lib/active_merchant/billing/gateways/commercegate.rb +3 -3
  37. data/lib/active_merchant/billing/gateways/creditcall.rb +2 -2
  38. data/lib/active_merchant/billing/gateways/credorax.rb +13 -3
  39. data/lib/active_merchant/billing/gateways/ct_payment.rb +6 -6
  40. data/lib/active_merchant/billing/gateways/culqi.rb +1 -1
  41. data/lib/active_merchant/billing/gateways/cyber_source.rb +8 -8
  42. data/lib/active_merchant/billing/gateways/data_cash.rb +2 -2
  43. data/lib/active_merchant/billing/gateways/dibs.rb +2 -2
  44. data/lib/active_merchant/billing/gateways/digitzs.rb +5 -5
  45. data/lib/active_merchant/billing/gateways/ebanx.rb +1 -1
  46. data/lib/active_merchant/billing/gateways/efsnet.rb +4 -4
  47. data/lib/active_merchant/billing/gateways/elavon.rb +3 -3
  48. data/lib/active_merchant/billing/gateways/element.rb +4 -4
  49. data/lib/active_merchant/billing/gateways/epay.rb +1 -1
  50. data/lib/active_merchant/billing/gateways/eway.rb +2 -2
  51. data/lib/active_merchant/billing/gateways/eway_managed.rb +5 -5
  52. data/lib/active_merchant/billing/gateways/eway_rapid.rb +1 -1
  53. data/lib/active_merchant/billing/gateways/exact.rb +1 -1
  54. data/lib/active_merchant/billing/gateways/federated_canada.rb +1 -1
  55. data/lib/active_merchant/billing/gateways/first_giving.rb +1 -1
  56. data/lib/active_merchant/billing/gateways/firstdata_e4.rb +7 -7
  57. data/lib/active_merchant/billing/gateways/flo2cash.rb +2 -2
  58. data/lib/active_merchant/billing/gateways/forte.rb +11 -7
  59. data/lib/active_merchant/billing/gateways/garanti.rb +5 -5
  60. data/lib/active_merchant/billing/gateways/global_collect.rb +2 -3
  61. data/lib/active_merchant/billing/gateways/hdfc.rb +2 -2
  62. data/lib/active_merchant/billing/gateways/hps.rb +3 -3
  63. data/lib/active_merchant/billing/gateways/inspire.rb +7 -7
  64. data/lib/active_merchant/billing/gateways/iridium.rb +14 -14
  65. data/lib/active_merchant/billing/gateways/itransact.rb +4 -4
  66. data/lib/active_merchant/billing/gateways/iveri.rb +3 -3
  67. data/lib/active_merchant/billing/gateways/jetpay.rb +2 -2
  68. data/lib/active_merchant/billing/gateways/jetpay_v2.rb +2 -2
  69. data/lib/active_merchant/billing/gateways/latitude19.rb +1 -1
  70. data/lib/active_merchant/billing/gateways/linkpoint.rb +3 -3
  71. data/lib/active_merchant/billing/gateways/litle.rb +2 -2
  72. data/lib/active_merchant/billing/gateways/maxipago.rb +1 -1
  73. data/lib/active_merchant/billing/gateways/mercado_pago.rb +7 -13
  74. data/lib/active_merchant/billing/gateways/merchant_e_solutions.rb +3 -3
  75. data/lib/active_merchant/billing/gateways/merchant_one.rb +4 -4
  76. data/lib/active_merchant/billing/gateways/merchant_partners.rb +1 -1
  77. data/lib/active_merchant/billing/gateways/merchant_warrior.rb +3 -3
  78. data/lib/active_merchant/billing/gateways/mercury.rb +2 -2
  79. data/lib/active_merchant/billing/gateways/metrics_global.rb +2 -2
  80. data/lib/active_merchant/billing/gateways/micropayment.rb +1 -1
  81. data/lib/active_merchant/billing/gateways/migs.rb +4 -6
  82. data/lib/active_merchant/billing/gateways/modern_payments_cim.rb +2 -2
  83. data/lib/active_merchant/billing/gateways/moneris.rb +85 -56
  84. data/lib/active_merchant/billing/gateways/moneris_us.rb +9 -9
  85. data/lib/active_merchant/billing/gateways/money_movers.rb +1 -1
  86. data/lib/active_merchant/billing/gateways/mundipagg.rb +1 -1
  87. data/lib/active_merchant/billing/gateways/nab_transact.rb +1 -1
  88. data/lib/active_merchant/billing/gateways/net_registry.rb +2 -2
  89. data/lib/active_merchant/billing/gateways/netaxept.rb +6 -6
  90. data/lib/active_merchant/billing/gateways/netbanx.rb +36 -36
  91. data/lib/active_merchant/billing/gateways/netbilling.rb +2 -2
  92. data/lib/active_merchant/billing/gateways/netpay.rb +1 -1
  93. data/lib/active_merchant/billing/gateways/nmi.rb +2 -2
  94. data/lib/active_merchant/billing/gateways/ogone.rb +7 -7
  95. data/lib/active_merchant/billing/gateways/omise.rb +6 -6
  96. data/lib/active_merchant/billing/gateways/opp.rb +1 -1
  97. data/lib/active_merchant/billing/gateways/optimal_payment.rb +5 -0
  98. data/lib/active_merchant/billing/gateways/orbital.rb +9 -7
  99. data/lib/active_merchant/billing/gateways/pac_net_raven.rb +6 -6
  100. data/lib/active_merchant/billing/gateways/pagarme.rb +1 -1
  101. data/lib/active_merchant/billing/gateways/pay_conex.rb +1 -1
  102. data/lib/active_merchant/billing/gateways/pay_gate_xml.rb +8 -5
  103. data/lib/active_merchant/billing/gateways/pay_hub.rb +2 -2
  104. data/lib/active_merchant/billing/gateways/pay_junction.rb +2 -2
  105. data/lib/active_merchant/billing/gateways/pay_junction_v2.rb +2 -2
  106. data/lib/active_merchant/billing/gateways/pay_secure.rb +3 -3
  107. data/lib/active_merchant/billing/gateways/paybox_direct.rb +8 -8
  108. data/lib/active_merchant/billing/gateways/payeezy.rb +1 -1
  109. data/lib/active_merchant/billing/gateways/payex.rb +8 -8
  110. data/lib/active_merchant/billing/gateways/payflow.rb +13 -13
  111. data/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb +4 -4
  112. data/lib/active_merchant/billing/gateways/payflow_express.rb +1 -1
  113. data/lib/active_merchant/billing/gateways/payment_express.rb +10 -10
  114. data/lib/active_merchant/billing/gateways/paymentez.rb +3 -0
  115. data/lib/active_merchant/billing/gateways/paymill.rb +4 -4
  116. data/lib/active_merchant/billing/gateways/payscout.rb +1 -1
  117. data/lib/active_merchant/billing/gateways/paystation.rb +1 -1
  118. data/lib/active_merchant/billing/gateways/payu_in.rb +3 -3
  119. data/lib/active_merchant/billing/gateways/payu_latam.rb +1 -1
  120. data/lib/active_merchant/billing/gateways/payway.rb +2 -2
  121. data/lib/active_merchant/billing/gateways/plugnpay.rb +2 -2
  122. data/lib/active_merchant/billing/gateways/pro_pay.rb +2 -2
  123. data/lib/active_merchant/billing/gateways/psigate.rb +1 -1
  124. data/lib/active_merchant/billing/gateways/psl_card.rb +3 -3
  125. data/lib/active_merchant/billing/gateways/qbms.rb +1 -1
  126. data/lib/active_merchant/billing/gateways/quantum.rb +7 -7
  127. data/lib/active_merchant/billing/gateways/quickbooks.rb +6 -6
  128. data/lib/active_merchant/billing/gateways/quickpay/quickpay_v10.rb +1 -1
  129. data/lib/active_merchant/billing/gateways/qvalent.rb +2 -2
  130. data/lib/active_merchant/billing/gateways/realex.rb +33 -13
  131. data/lib/active_merchant/billing/gateways/redsys.rb +2 -2
  132. data/lib/active_merchant/billing/gateways/safe_charge.rb +2 -2
  133. data/lib/active_merchant/billing/gateways/sage.rb +6 -6
  134. data/lib/active_merchant/billing/gateways/sage_pay.rb +7 -7
  135. data/lib/active_merchant/billing/gateways/secure_net.rb +1 -1
  136. data/lib/active_merchant/billing/gateways/secure_pay.rb +2 -2
  137. data/lib/active_merchant/billing/gateways/secure_pay_au.rb +1 -1
  138. data/lib/active_merchant/billing/gateways/secure_pay_tech.rb +1 -1
  139. data/lib/active_merchant/billing/gateways/skip_jack.rb +5 -6
  140. data/lib/active_merchant/billing/gateways/smart_ps.rb +7 -7
  141. data/lib/active_merchant/billing/gateways/so_easy_pay.rb +1 -1
  142. data/lib/active_merchant/billing/gateways/stripe.rb +5 -5
  143. data/lib/active_merchant/billing/gateways/swipe_checkout.rb +2 -2
  144. data/lib/active_merchant/billing/gateways/telr.rb +1 -1
  145. data/lib/active_merchant/billing/gateways/trans_first_transaction_express.rb +2 -2
  146. data/lib/active_merchant/billing/gateways/transact_pro.rb +5 -5
  147. data/lib/active_merchant/billing/gateways/transax.rb +1 -1
  148. data/lib/active_merchant/billing/gateways/trust_commerce.rb +7 -7
  149. data/lib/active_merchant/billing/gateways/usa_epay_advanced.rb +17 -16
  150. data/lib/active_merchant/billing/gateways/usa_epay_transaction.rb +2 -2
  151. data/lib/active_merchant/billing/gateways/vanco.rb +2 -2
  152. data/lib/active_merchant/billing/gateways/verifi.rb +1 -1
  153. data/lib/active_merchant/billing/gateways/viaklix.rb +4 -4
  154. data/lib/active_merchant/billing/gateways/visanet_peru.rb +4 -4
  155. data/lib/active_merchant/billing/gateways/wirecard.rb +2 -2
  156. data/lib/active_merchant/billing/gateways/worldpay.rb +24 -13
  157. data/lib/active_merchant/billing/gateways/worldpay_online_payments.rb +2 -2
  158. data/lib/active_merchant/billing/response.rb +7 -7
  159. data/lib/active_merchant/country.rb +4 -4
  160. data/lib/active_merchant/network_connection_retries.rb +7 -9
  161. data/lib/active_merchant/version.rb +1 -1
  162. data/lib/support/gateway_support.rb +3 -3
  163. data/lib/support/ssl_verify.rb +1 -1
  164. metadata +3 -3
@@ -186,7 +186,7 @@ module ActiveMerchant #:nodoc:
186
186
  def parse(body)
187
187
  results = {}
188
188
  body.split(/&/).each do |pair|
189
- key,val = pair.split(/\=/)
189
+ key, val = pair.split(/\=/)
190
190
  results[key.to_sym] = CGI.unescape(val)
191
191
  end
192
192
  results
@@ -224,7 +224,7 @@ module ActiveMerchant #:nodoc:
224
224
  parameters[:pay_type] = 'C'
225
225
  parameters[:tran_type] = TRANSACTIONS[action]
226
226
 
227
- parameters.reject{|k,v| v.blank?}.collect { |key, value| "#{key}=#{CGI.escape(value.to_s)}" }.join('&')
227
+ parameters.reject { |k, v| v.blank? }.collect { |key, value| "#{key}=#{CGI.escape(value.to_s)}" }.join('&')
228
228
  end
229
229
 
230
230
  end
@@ -190,7 +190,7 @@ module ActiveMerchant #:nodoc:
190
190
  add_login_data(parameters)
191
191
  add_action(parameters, action, options)
192
192
 
193
- post = parameters.collect{|key, value| "#{key}=#{CGI.escape(value.to_s)}" }.join('&')
193
+ post = parameters.collect { |key, value| "#{key}=#{CGI.escape(value.to_s)}" }.join('&')
194
194
  parse(ssl_post(url, post), parameters)
195
195
  end
196
196
 
@@ -246,7 +246,7 @@ module ActiveMerchant #:nodoc:
246
246
  end
247
247
 
248
248
  def post_data(action, params)
249
- params.map {|k, v| "#{k}=#{CGI.escape(v.to_s)}"}.join('&')
249
+ params.map { |k, v| "#{k}=#{CGI.escape(v.to_s)}" }.join('&')
250
250
  end
251
251
 
252
252
  def url
@@ -254,7 +254,7 @@ module ActiveMerchant #:nodoc:
254
254
  end
255
255
 
256
256
  def parse(body)
257
- Hash[CGI::parse(body).map { |k,v| [k.intern, v.first] }]
257
+ Hash[CGI::parse(body).map { |k, v| [k.intern, v.first] }]
258
258
  end
259
259
 
260
260
  def success_from(response)
@@ -149,7 +149,7 @@ module ActiveMerchant #:nodoc:
149
149
  # Verify and reserve the specified amount on the account, without actually doing the transaction.
150
150
  def authorize(money, payment_source, options = {})
151
151
  post = {}
152
- action = (payment_source.brand == 'mastercard') ? 'PAU' : 'RES'
152
+ action = payment_source.brand == 'mastercard' ? 'PAU' : 'RES'
153
153
  add_invoice(post, options)
154
154
  add_payment_source(post, payment_source, options)
155
155
  add_address(post, payment_source, options)
@@ -213,7 +213,7 @@ module ActiveMerchant #:nodoc:
213
213
 
214
214
  # Store a credit card by creating an Ogone Alias
215
215
  def store(payment_source, options = {})
216
- options.merge!(:alias_operation => 'BYPSP') unless(options.has_key?(:billing_id) || options.has_key?(:store))
216
+ options[:alias_operation] = 'BYPSP' unless(options.has_key?(:billing_id) || options.has_key?(:store))
217
217
  response = authorize(@options[:store_amount] || 1, payment_source, options)
218
218
  void(response.authorization) if response.success?
219
219
  response
@@ -301,8 +301,8 @@ module ActiveMerchant #:nodoc:
301
301
  add_pair post, 'ECI', eci.to_s
302
302
  end
303
303
 
304
- def add_alias(post, _alias, alias_operation = nil)
305
- add_pair post, 'ALIAS', _alias
304
+ def add_alias(post, alias_name, alias_operation = nil)
305
+ add_pair post, 'ALIAS', alias_name
306
306
  add_pair post, 'ALIASOPERATION', alias_operation unless alias_operation.nil?
307
307
  end
308
308
 
@@ -429,9 +429,9 @@ module ActiveMerchant #:nodoc:
429
429
  raise "Unknown signature algorithm #{algorithm}"
430
430
  end
431
431
 
432
- filtered_params = signed_parameters.select{|k,v| !v.blank?}
432
+ filtered_params = signed_parameters.select { |k, v| !v.blank? }
433
433
  sha_encryptor.hexdigest(
434
- filtered_params.sort_by{|k,v| k.upcase}.map{|k, v| "#{k.upcase}=#{v}#{secret}"}.join('')
434
+ filtered_params.sort_by { |k, v| k.upcase }.map { |k, v| "#{k.upcase}=#{v}#{secret}" }.join('')
435
435
  ).upcase
436
436
  end
437
437
 
@@ -446,7 +446,7 @@ module ActiveMerchant #:nodoc:
446
446
  PSPID
447
447
  Operation
448
448
  ALIAS
449
- ).map{|key| parameters[key]} +
449
+ ).map { |key| parameters[key] } +
450
450
  [secret]
451
451
  ).join('')
452
452
  ).upcase
@@ -164,7 +164,7 @@ module ActiveMerchant #:nodoc:
164
164
  transcript.
165
165
  gsub(/(Authorization: Basic )\w+/i, '\1[FILTERED]').
166
166
  gsub(/(\\"number\\":)\\"\d+\\"/, '\1[FILTERED]').
167
- gsub(/(\\"security_code\\":)\\"\d+\\"/,'\1[FILTERED]')
167
+ gsub(/(\\"security_code\\":)\\"\d+\\"/, '\1[FILTERED]')
168
168
  end
169
169
 
170
170
  private
@@ -246,15 +246,15 @@ module ActiveMerchant #:nodoc:
246
246
  def message_to_standard_error_code_from(response)
247
247
  message = response['message'] if response['code'] == 'invalid_card'
248
248
  case message
249
- when /brand not supported/
249
+ when /brand not supported/
250
250
  STANDARD_ERROR_CODE[:invalid_number]
251
- when /number is invalid/
251
+ when /number is invalid/
252
252
  STANDARD_ERROR_CODE[:incorrect_number]
253
- when /expiration date cannot be in the past/
253
+ when /expiration date cannot be in the past/
254
254
  STANDARD_ERROR_CODE[:expired_card]
255
- when /expiration \w+ is invalid/
255
+ when /expiration \w+ is invalid/
256
256
  STANDARD_ERROR_CODE[:invalid_expiry_date]
257
- else
257
+ else
258
258
  STANDARD_ERROR_CODE[:processing_error]
259
259
  end
260
260
  end
@@ -272,7 +272,7 @@ module ActiveMerchant #:nodoc:
272
272
  def add_options(post, options)
273
273
  post[:createRegistration] = options[:create_registration] if options[:create_registration] && !options[:registrationId]
274
274
  post[:testMode] = options[:test_mode] if test? && options[:test_mode]
275
- options.each {|key, value| post[key] = value if key.to_s.match('customParameters\[[a-zA-Z0-9\._]{3,64}\]') }
275
+ options.each { |key, value| post[key] = value if key.to_s.match('customParameters\[[a-zA-Z0-9\._]{3,64}\]') }
276
276
  post['customParameters[SHOPPER_pluginId]'] = 'activemerchant'
277
277
  post['customParameters[custom_disable3DSecure]'] = options[:disable_3d_secure] if options[:disable_3d_secure]
278
278
  end
@@ -60,6 +60,11 @@ module ActiveMerchant #:nodoc:
60
60
  commit('ccSettlement', money, options)
61
61
  end
62
62
 
63
+ def verify(credit_card, options = {})
64
+ parse_card_or_auth(credit_card, options)
65
+ commit('ccVerification', 0, options)
66
+ end
67
+
63
68
  def supports_scrubbing?
64
69
  true
65
70
  end
@@ -273,13 +273,13 @@ module ActiveMerchant #:nodoc:
273
273
  # 'MS' - Manual Suspend
274
274
 
275
275
  def add_customer_profile(creditcard, options = {})
276
- options.merge!(:customer_profile_action => CREATE)
276
+ options[:customer_profile_action] = CREATE
277
277
  order = build_customer_request_xml(creditcard, options)
278
278
  commit(order, :add_customer_profile)
279
279
  end
280
280
 
281
281
  def update_customer_profile(creditcard, options = {})
282
- options.merge!(:customer_profile_action => UPDATE)
282
+ options[:customer_profile_action] = UPDATE
283
283
  order = build_customer_request_xml(creditcard, options)
284
284
  commit(order, :update_customer_profile)
285
285
  end
@@ -516,12 +516,12 @@ module ActiveMerchant #:nodoc:
516
516
  end
517
517
  end
518
518
 
519
- response.delete_if { |k,_| SENSITIVE_FIELDS.include?(k) }
519
+ response.delete_if { |k, _| SENSITIVE_FIELDS.include?(k) }
520
520
  end
521
521
 
522
522
  def recurring_parse_element(response, node)
523
523
  if node.has_elements?
524
- node.elements.each{|e| recurring_parse_element(response, e) }
524
+ node.elements.each { |e| recurring_parse_element(response, e) }
525
525
  else
526
526
  response[node.name.underscore.to_sym] = node.text
527
527
  end
@@ -529,9 +529,11 @@ module ActiveMerchant #:nodoc:
529
529
 
530
530
  def commit(order, message_type, trace_number=nil)
531
531
  headers = POST_HEADERS.merge('Content-length' => order.size.to_s)
532
- headers.merge!( 'Trace-number' => trace_number.to_s,
533
- 'Merchant-Id' => @options[:merchant_id] ) if @options[:retry_logic] && trace_number
534
- request = lambda{|url| parse(ssl_post(url, order, headers))}
532
+ if @options[:retry_logic] && trace_number
533
+ headers['Trace-number'] = trace_number.to_s
534
+ headers['Merchant-Id'] = @options[:merchant_id]
535
+ end
536
+ request = ->(url) { parse(ssl_post(url, order, headers)) }
535
537
 
536
538
  # Failover URL will be attempted in the event of a connection error
537
539
  response = begin
@@ -107,7 +107,7 @@ module ActiveMerchant #:nodoc:
107
107
  end
108
108
 
109
109
  def parse(body)
110
- Hash[body.split('&').map{|x| x.split('=').map{|y| CGI.unescape(y)}}]
110
+ Hash[body.split('&').map { |x| x.split('=').map { |y| CGI.unescape(y) } }]
111
111
  end
112
112
 
113
113
  def commit(action, money, parameters)
@@ -193,11 +193,11 @@ module ActiveMerchant #:nodoc:
193
193
 
194
194
  def signature(action, post, parameters = {})
195
195
  string = if %w(cc_settle cc_debit cc_preauth cc_refund).include?(action)
196
- post['UserName'] + post['Timestamp'] + post['RequestID'] + post['PymtType'] + parameters['Amount'].to_s + parameters['Currency']
197
- elsif action == 'void'
198
- post['UserName'] + post['Timestamp'] + post['RequestID'] + parameters['TrackingNumber']
199
- else
200
- post['UserName']
196
+ post['UserName'] + post['Timestamp'] + post['RequestID'] + post['PymtType'] + parameters['Amount'].to_s + parameters['Currency']
197
+ elsif action == 'void'
198
+ post['UserName'] + post['Timestamp'] + post['RequestID'] + parameters['TrackingNumber']
199
+ else
200
+ post['UserName']
201
201
  end
202
202
  OpenSSL::HMAC.hexdigest(OpenSSL::Digest::SHA1.new(@options[:secret]), @options[:secret], string)
203
203
  end
@@ -230,7 +230,7 @@ module ActiveMerchant #:nodoc:
230
230
  end
231
231
  end
232
232
 
233
- def test?()
233
+ def test?
234
234
  @api_key.start_with?('ak_test')
235
235
  end
236
236
 
@@ -231,7 +231,7 @@ module ActiveMerchant #:nodoc:
231
231
 
232
232
  def post_data(action, params)
233
233
  params[:transaction_type] = action
234
- params.map {|k, v| "#{k}=#{CGI.escape(v.to_s)}"}.join('&')
234
+ params.map { |k, v| "#{k}=#{CGI.escape(v.to_s)}" }.join('&')
235
235
  end
236
236
 
237
237
  def unparsable_response(raw_response)
@@ -162,29 +162,32 @@ module ActiveMerchant #:nodoc:
162
162
 
163
163
  def purchase(money, creditcard, options = {})
164
164
  MultiResponse.run do |r|
165
- r.process{authorize(money, creditcard, options)}
166
- r.process{capture(money, r.authorization, options)}
165
+ r.process { authorize(money, creditcard, options) }
166
+ r.process { capture(money, r.authorization, options) }
167
167
  end
168
168
  end
169
169
 
170
170
  def authorize(money, creditcard, options = {})
171
171
  action = 'authtx'
172
172
 
173
- options.merge!(:money => money, :creditcard => creditcard)
173
+ options[:money] = money
174
+ options[:creditcard] = creditcard
174
175
  commit(action, build_request(action, options))
175
176
  end
176
177
 
177
178
  def capture(money, authorization, options = {})
178
179
  action = 'settletx'
179
180
 
180
- options.merge!(:money => money, :authorization => authorization)
181
+ options[:money] = money
182
+ options[:authorization] = authorization
181
183
  commit(action, build_request(action, options), authorization)
182
184
  end
183
185
 
184
186
  def refund(money, authorization, options={})
185
187
  action = 'refundtx'
186
188
 
187
- options.merge!(:money => money, :authorization => authorization)
189
+ options[:money] = money
190
+ options[:authorization] = authorization
188
191
  commit(action, build_request(action, options))
189
192
  end
190
193
 
@@ -171,7 +171,7 @@ module ActiveMerchant #:nodoc:
171
171
  success = false
172
172
 
173
173
  begin
174
- raw_response = ssl_post(live_url, post.to_json, {'Content-Type' => 'application/json'} )
174
+ raw_response = ssl_post(live_url, post.to_json, {'Content-Type' => 'application/json'})
175
175
  response = parse(raw_response)
176
176
  success = (response['RESPONSE_CODE'] == '00')
177
177
  rescue ResponseError => e
@@ -200,7 +200,7 @@ module ActiveMerchant #:nodoc:
200
200
 
201
201
  def json_error(raw_response)
202
202
  {
203
- error_message: 'Invalid response received from the Payhub API. Please contact wecare@payhub.com if you continue to receive this message.' +
203
+ error_message: 'Invalid response received from the Payhub API. Please contact wecare@payhub.com if you continue to receive this message.' \
204
204
  " (The raw response returned by the API was #{raw_response.inspect})"
205
205
  }
206
206
  end
@@ -334,7 +334,7 @@ module ActiveMerchant #:nodoc:
334
334
  def commit(action, parameters)
335
335
  url = test? ? self.test_url : self.live_url
336
336
 
337
- response = parse( ssl_post(url, post_data(action, parameters)) )
337
+ response = parse(ssl_post(url, post_data(action, parameters)))
338
338
 
339
339
  Response.new(successful?(response), message_from(response), response,
340
340
  :test => test?,
@@ -366,7 +366,7 @@ module ActiveMerchant #:nodoc:
366
366
  params[:version] = API_VERSION
367
367
  params[:transaction_type] = action
368
368
 
369
- params.reject{|k,v| v.blank?}.collect{ |k, v| "dc_#{k.to_s}=#{CGI.escape(v.to_s)}" }.join('&')
369
+ params.reject { |k, v| v.blank? }.collect { |k, v| "dc_#{k}=#{CGI.escape(v.to_s)}" }.join('&')
370
370
  end
371
371
 
372
372
  def parse(body)
@@ -146,7 +146,7 @@ module ActiveMerchant #:nodoc:
146
146
  end
147
147
 
148
148
  def post_data(params)
149
- params.map {|k, v| "#{k}=#{CGI.escape(v.to_s)}"}.join('&')
149
+ params.map { |k, v| "#{k}=#{CGI.escape(v.to_s)}" }.join('&')
150
150
  end
151
151
 
152
152
  def url(params={})
@@ -173,7 +173,7 @@ module ActiveMerchant #:nodoc:
173
173
  def message_from(response)
174
174
  return response['response']['message'] if response['response']
175
175
 
176
- response['errors']&.inject(''){ |message,error| error['message'] + '|' + message }
176
+ response['errors']&.inject('') { |message, error| error['message'] + '|' + message }
177
177
  end
178
178
 
179
179
  def authorization_from(response)
@@ -52,7 +52,7 @@ module ActiveMerchant #:nodoc:
52
52
  end
53
53
 
54
54
  def add_invoice(post, options)
55
- post[:merchant_transid] = options[:order_id].to_s.slice(0,21)
55
+ post[:merchant_transid] = options[:order_id].to_s.slice(0, 21)
56
56
  post[:memnum] = options[:invoice]
57
57
  post[:custnum] = options[:customer]
58
58
  post[:clientdata] = options[:description]
@@ -66,7 +66,7 @@ module ActiveMerchant #:nodoc:
66
66
  end
67
67
 
68
68
  def commit(action, money, parameters)
69
- response = parse( ssl_post(self.live_url, post_data(action, parameters)) )
69
+ response = parse(ssl_post(self.live_url, post_data(action, parameters)))
70
70
 
71
71
  Response.new(successful?(response), message_from(response), response,
72
72
  :test => test_response?(response),
@@ -104,7 +104,7 @@ module ActiveMerchant #:nodoc:
104
104
  parameters[:merchant_id] = @options[:login]
105
105
  parameters[:password] = @options[:password]
106
106
 
107
- parameters.reject{|k,v| v.blank?}.collect { |key, value| "#{key.to_s.upcase}=#{CGI.escape(value.to_s)}" }.join('&')
107
+ parameters.reject { |k, v| v.blank? }.collect { |key, value| "#{key.to_s.upcase}=#{CGI.escape(value.to_s)}" }.join('&')
108
108
  end
109
109
  end
110
110
  end
@@ -86,8 +86,8 @@ module ActiveMerchant #:nodoc:
86
86
  post = {}
87
87
  add_invoice(post, options)
88
88
  add_amount(post, money, options)
89
- post[:numappel] = authorization[0,10]
90
- post[:numtrans] = authorization[10,10]
89
+ post[:numappel] = authorization[0, 10]
90
+ post[:numtrans] = authorization[10, 10]
91
91
 
92
92
  commit('capture', money, post)
93
93
  end
@@ -130,8 +130,8 @@ module ActiveMerchant #:nodoc:
130
130
  end
131
131
 
132
132
  def add_reference(post, identification)
133
- post[:numappel] = identification[0,10]
134
- post[:numtrans] = identification[10,10]
133
+ post[:numappel] = identification[0, 10]
134
+ post[:numtrans] = identification[10, 10]
135
135
  end
136
136
 
137
137
  def add_amount(post, money, options)
@@ -142,14 +142,14 @@ module ActiveMerchant #:nodoc:
142
142
  def parse(body)
143
143
  results = {}
144
144
  body.split(/&/).each do |pair|
145
- key,val = pair.split(/\=/)
145
+ key, val = pair.split(/\=/)
146
146
  results[key.downcase.to_sym] = CGI.unescape(val) if val
147
147
  end
148
148
  results
149
149
  end
150
150
 
151
151
  def commit(action, money = nil, parameters = nil)
152
- request_data = post_data(action,parameters)
152
+ request_data = post_data(action, parameters)
153
153
  response = parse(ssl_post(test? ? self.test_url : self.live_url, request_data))
154
154
  response = parse(ssl_post(self.live_url_backup, request_data)) if service_unavailable?(response) && !test?
155
155
  Response.new(success?(response), message_from(response), response.merge(
@@ -157,7 +157,7 @@ module ActiveMerchant #:nodoc:
157
157
  :test => test?,
158
158
  :authorization => response[:numappel].to_s + response[:numtrans].to_s,
159
159
  :fraud_review => false,
160
- :sent_params => parameters.delete_if{|key,value| ['porteur','dateval','cvv'].include?(key.to_s)}
160
+ :sent_params => parameters.delete_if { |key, value| ['porteur', 'dateval', 'cvv'].include?(key.to_s) }
161
161
  )
162
162
  end
163
163
 
@@ -179,7 +179,7 @@ module ActiveMerchant #:nodoc:
179
179
  :type => TRANSACTIONS[action.to_sym],
180
180
  :dateq => Time.now.strftime('%d%m%Y%H%M%S'),
181
181
  :numquestion => unique_id(parameters[:order_id]),
182
- :site => @options[:login].to_s[0,7],
182
+ :site => @options[:login].to_s[0, 7],
183
183
  :rang => @options[:rang] || @options[:login].to_s[7..-1],
184
184
  :cle => @options[:password],
185
185
  :pays => '',
@@ -135,7 +135,7 @@ module ActiveMerchant
135
135
 
136
136
  def add_authorization_info(params, authorization, options = {})
137
137
  transaction_id, transaction_tag, method, _ = authorization.split('|')
138
- params[:method] = (method == 'token') ? 'credit_card' : method
138
+ params[:method] = method == 'token' ? 'credit_card' : method
139
139
 
140
140
  if options[:reversal_id]
141
141
  params[:reversal_id] = options[:reversal_id]
@@ -63,8 +63,8 @@ module ActiveMerchant #:nodoc:
63
63
  if payment_method.respond_to?(:number)
64
64
  # credit card authorization
65
65
  MultiResponse.new.tap do |r|
66
- r.process {send_initialize(amount, true, options)}
67
- r.process {send_purchasecc(payment_method, r.params['orderref'])}
66
+ r.process { send_initialize(amount, true, options) }
67
+ r.process { send_purchasecc(payment_method, r.params['orderref']) }
68
68
  end
69
69
  else
70
70
  # stored authorization
@@ -91,8 +91,8 @@ module ActiveMerchant #:nodoc:
91
91
  if payment_method.respond_to?(:number)
92
92
  # credit card purchase
93
93
  MultiResponse.new.tap do |r|
94
- r.process {send_initialize(amount, false, options)}
95
- r.process {send_purchasecc(payment_method, r.params['orderref'])}
94
+ r.process { send_initialize(amount, false, options) }
95
+ r.process { send_purchasecc(payment_method, r.params['orderref']) }
96
96
  end
97
97
  else
98
98
  # stored purchase
@@ -154,10 +154,10 @@ module ActiveMerchant #:nodoc:
154
154
  requires!(options, :order_id)
155
155
  amount = amount(1) # 1 cent for authorization
156
156
  MultiResponse.run(:first) do |r|
157
- r.process {send_create_agreement(options)}
158
- r.process {send_initialize(amount, true, options.merge({agreement_ref: r.authorization}))}
157
+ r.process { send_create_agreement(options) }
158
+ r.process { send_initialize(amount, true, options.merge({agreement_ref: r.authorization})) }
159
159
  order_ref = r.params['orderref']
160
- r.process {send_purchasecc(creditcard, order_ref)}
160
+ r.process { send_purchasecc(creditcard, order_ref) }
161
161
  end
162
162
  end
163
163
 
@@ -364,7 +364,7 @@ module ActiveMerchant #:nodoc:
364
364
  doc = Nokogiri::XML(body)
365
365
 
366
366
  doc.root&.xpath('*')&.each do |node|
367
- if (node.elements.size == 0)
367
+ if node.elements.size == 0
368
368
  response[node.name.downcase.to_sym] = node.text
369
369
  else
370
370
  node.elements.each do |childnode|