activemerchant 1.86.0 → 1.87.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 (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
@@ -92,7 +92,7 @@ module ActiveMerchant #:nodoc:
92
92
  def recurring_inquiry(profile_id, options = {})
93
93
  ActiveMerchant.deprecated RECURRING_DEPRECATION_MESSAGE
94
94
 
95
- request = build_recurring_request(:inquiry, nil, options.update( :profile_id => profile_id ))
95
+ request = build_recurring_request(:inquiry, nil, options.update(:profile_id => profile_id))
96
96
  commit(request, options.merge(:request_type => :recurring))
97
97
  end
98
98
 
@@ -143,7 +143,7 @@ module ActiveMerchant #:nodoc:
143
143
 
144
144
  billing_address = options[:billing_address] || options[:address]
145
145
  add_address(xml, 'BillTo', billing_address, options) if billing_address
146
- add_address(xml, 'ShipTo', options[:shipping_address],options) if options[:shipping_address]
146
+ add_address(xml, 'ShipTo', options[:shipping_address], options) if options[:shipping_address]
147
147
 
148
148
  xml.tag! 'TotalAmt', amount(money), 'Currency' => options[:currency] || currency(money)
149
149
  end
@@ -289,7 +289,7 @@ module ActiveMerchant #:nodoc:
289
289
  end
290
290
 
291
291
  if action == :add
292
- xml.tag! 'Start', format_rp_date(options[:starting_at] || Date.today + 1 )
292
+ xml.tag! 'Start', format_rp_date(options[:starting_at] || Date.today + 1)
293
293
  else
294
294
  xml.tag! 'Start', format_rp_date(options[:starting_at]) unless options[:starting_at].nil?
295
295
  end
@@ -308,7 +308,7 @@ module ActiveMerchant #:nodoc:
308
308
  xml.tag! 'ProfileID', options[:profile_id]
309
309
  end
310
310
  if action == :inquiry
311
- xml.tag! 'PaymentHistory', ( options[:history] ? 'Y' : 'N' )
311
+ xml.tag! 'PaymentHistory', (options[:history] ? 'Y' : 'N')
312
312
  end
313
313
  end
314
314
  end
@@ -318,20 +318,20 @@ module ActiveMerchant #:nodoc:
318
318
  def get_pay_period(options)
319
319
  requires!(options, [:periodicity, :bimonthly, :monthly, :biweekly, :weekly, :yearly, :daily, :semimonthly, :quadweekly, :quarterly, :semiyearly])
320
320
  case options[:periodicity]
321
- when :weekly then 'Weekly'
322
- when :biweekly then 'Bi-weekly'
323
- when :semimonthly then 'Semi-monthly'
324
- when :quadweekly then 'Every four weeks'
325
- when :monthly then 'Monthly'
326
- when :quarterly then 'Quarterly'
327
- when :semiyearly then 'Semi-yearly'
328
- when :yearly then 'Yearly'
321
+ when :weekly then 'Weekly'
322
+ when :biweekly then 'Bi-weekly'
323
+ when :semimonthly then 'Semi-monthly'
324
+ when :quadweekly then 'Every four weeks'
325
+ when :monthly then 'Monthly'
326
+ when :quarterly then 'Quarterly'
327
+ when :semiyearly then 'Semi-yearly'
328
+ when :yearly then 'Yearly'
329
329
  end
330
330
  end
331
331
 
332
332
  def format_rp_date(time)
333
333
  case time
334
- when Time, Date then time.strftime('%m%d%Y')
334
+ when Time, Date then time.strftime('%m%d%Y')
335
335
  else
336
336
  time.to_s
337
337
  end
@@ -178,10 +178,10 @@ module ActiveMerchant #:nodoc:
178
178
  # down as we do everywhere else. RPPaymentResult elements are not contained
179
179
  # in an RPPaymentResults element so we'll come here multiple times
180
180
  response[node_name] ||= []
181
- response[node_name] << ( payment_result_response = {} )
182
- node.xpath('.//*').each{ |e| parse_element(payment_result_response, e) }
181
+ response[node_name] << (payment_result_response = {})
182
+ node.xpath('.//*').each { |e| parse_element(payment_result_response, e) }
183
183
  when node.xpath('.//*').to_a.any?
184
- node.xpath('.//*').each{|e| parse_element(response, e) }
184
+ node.xpath('.//*').each { |e| parse_element(response, e) }
185
185
  when node_name.to_s =~ /amt$/
186
186
  # *Amt elements don't put the value in the #text - instead they use a Currency attribute
187
187
  response[node_name] = node.attributes['Currency'].to_s
@@ -202,7 +202,7 @@ module ActiveMerchant #:nodoc:
202
202
  'X-VPS-Request-ID' => SecureRandom.hex(16)
203
203
  }
204
204
 
205
- headers.merge!('PAYPAL-NVP' => 'Y') if self.use_paypal_nvp
205
+ headers['PAYPAL-NVP'] = 'Y' if self.use_paypal_nvp
206
206
  headers
207
207
  end
208
208
 
@@ -198,7 +198,7 @@ module ActiveMerchant #:nodoc:
198
198
  xml.tag! 'Token', options[:token] unless options[:token].blank?
199
199
  xml.tag! 'NoShipping', options[:no_shipping] ? '1' : '0'
200
200
  xml.tag! 'AddressOverride', options[:address_override] ? '1' : '0'
201
- xml.tag! 'ButtonSource', application_id.to_s.slice(0,32) unless application_id.blank?
201
+ xml.tag! 'ButtonSource', application_id.to_s.slice(0, 32) unless application_id.blank?
202
202
 
203
203
  # Customization of the payment page
204
204
  xml.tag! 'PageStyle', options[:page_style] unless options[:page_style].blank?
@@ -274,9 +274,9 @@ module ActiveMerchant #:nodoc:
274
274
  xml.add_element('ClientType').text = client_type
275
275
  end
276
276
 
277
- xml.add_element('TxnData1').text = options[:txn_data1].to_s.slice(0,255) unless options[:txn_data1].blank?
278
- xml.add_element('TxnData2').text = options[:txn_data2].to_s.slice(0,255) unless options[:txn_data2].blank?
279
- xml.add_element('TxnData3').text = options[:txn_data3].to_s.slice(0,255) unless options[:txn_data3].blank?
277
+ xml.add_element('TxnData1').text = options[:txn_data1].to_s.slice(0, 255) unless options[:txn_data1].blank?
278
+ xml.add_element('TxnData2').text = options[:txn_data2].to_s.slice(0, 255) unless options[:txn_data2].blank?
279
+ xml.add_element('TxnData3').text = options[:txn_data3].to_s.slice(0, 255) unless options[:txn_data3].blank?
280
280
  end
281
281
 
282
282
  def new_transaction
@@ -340,13 +340,13 @@ module ActiveMerchant #:nodoc:
340
340
 
341
341
  def normalized_client_type(client_type_from_options)
342
342
  case client_type_from_options.to_s.downcase
343
- when 'web' then 'Web'
344
- when 'ivr' then 'IVR'
345
- when 'moto' then 'MOTO'
346
- when 'unattended' then 'Unattended'
347
- when 'internet' then 'Internet'
348
- when 'recurring' then 'Recurring'
349
- else nil
343
+ when 'web' then 'Web'
344
+ when 'ivr' then 'IVR'
345
+ when 'moto' then 'MOTO'
346
+ when 'unattended' then 'Unattended'
347
+ when 'internet' then 'Internet'
348
+ when 'recurring' then 'Recurring'
349
+ else nil
350
350
  end
351
351
  end
352
352
  end
@@ -134,6 +134,9 @@ module ActiveMerchant #:nodoc:
134
134
  post[:user][:email] = options[:email]
135
135
  post[:user][:ip_address] = options[:ip] if options[:ip]
136
136
  post[:user][:fiscal_number] = options[:fiscal_number] if options[:fiscal_number]
137
+ if phone = options[:phone] || options.dig(:billing_address, :phone)
138
+ post[:user][:phone] = phone
139
+ end
137
140
  end
138
141
 
139
142
  def add_invoice(post, money, options)
@@ -82,7 +82,7 @@ module ActiveMerchant #:nodoc:
82
82
  post['account.verification'] = credit_card.verification_value
83
83
  post['account.email'] = (options[:email] || nil)
84
84
  post['presentation.amount3D'] = (options[:money] || nil)
85
- post['presentation.currency3D'] = (options[:currency] || currency( options[:money]))
85
+ post['presentation.currency3D'] = (options[:currency] || currency(options[:money]))
86
86
  end
87
87
 
88
88
  def headers
@@ -128,9 +128,9 @@ module ActiveMerchant #:nodoc:
128
128
  def action_with_token(action, money, payment_method, options)
129
129
  options[:money] = money
130
130
  case payment_method
131
- when String
131
+ when String
132
132
  self.send("#{action}_with_token", money, payment_method, options)
133
- else
133
+ else
134
134
  MultiResponse.run do |r|
135
135
  r.process { save_card(payment_method, options) }
136
136
  r.process { self.send("#{action}_with_token", money, r.authorization, options) }
@@ -314,7 +314,7 @@ module ActiveMerchant #:nodoc:
314
314
 
315
315
  def response_message(parsed_response)
316
316
  return parsed_response['error'] if parsed_response['error']
317
- return 'Transaction approved.' if (parsed_response['data'] == [])
317
+ return 'Transaction approved.' if parsed_response['data'] == []
318
318
 
319
319
  code = parsed_response['data']['response_code'].to_i
320
320
  RESPONSE_CODES[code] || code.to_s
@@ -102,7 +102,7 @@ module ActiveMerchant #:nodoc:
102
102
  end
103
103
 
104
104
  def parse(body)
105
- Hash[body.split('&').map{|x| x.split('=')}]
105
+ Hash[body.split('&').map { |x| x.split('=') }]
106
106
  end
107
107
 
108
108
  def commit(action, money, parameters)
@@ -179,7 +179,7 @@ module ActiveMerchant #:nodoc:
179
179
  message = message_from(response)
180
180
 
181
181
  PaystationResponse.new(success?(response), message, response,
182
- :test => (response[:tm] && response[:tm].downcase == 't'),
182
+ :test => (response[:tm]&.casecmp('t')&.zero?),
183
183
  :authorization => response[:paystation_transaction_id]
184
184
  )
185
185
  end
@@ -32,11 +32,11 @@ module ActiveMerchant #:nodoc:
32
32
  add_auth(post)
33
33
 
34
34
  MultiResponse.run do |r|
35
- r.process{commit(url('purchase'), post)}
35
+ r.process { commit(url('purchase'), post) }
36
36
  if(r.params['enrolled'].to_s == '0')
37
- r.process{commit(r.params['post_uri'], r.params['form_post_vars'])}
37
+ r.process { commit(r.params['post_uri'], r.params['form_post_vars']) }
38
38
  else
39
- r.process{handle_3dsecure(r)}
39
+ r.process { handle_3dsecure(r) }
40
40
  end
41
41
  end
42
42
  end
@@ -167,7 +167,7 @@ module ActiveMerchant #:nodoc:
167
167
  address = options[:billing_address]
168
168
  payer = {}
169
169
  payer[:fullName] = payment_method.name.strip
170
- payer[:contactPhone] = address[:phone] if (address && address[:phone])
170
+ payer[:contactPhone] = address[:phone] if address && address[:phone]
171
171
  payer[:dniNumber] = options[:dni_number] if options[:dni_number]
172
172
  payer[:dniType] = options[:dni_type] if options[:dni_type]
173
173
  payer[:emailAddress] = options[:email] if options[:email]
@@ -150,7 +150,7 @@ module ActiveMerchant
150
150
  post['card.cardHolderName'] = "#{payment_method.first_name} #{payment_method.last_name}"
151
151
  post['card.PAN'] = payment_method.number
152
152
  post['card.CVN'] = payment_method.verification_value
153
- post['card.expiryYear'] = payment_method.year.to_s[-2,2]
153
+ post['card.expiryYear'] = payment_method.year.to_s[-2, 2]
154
154
  post['card.expiryMonth'] = sprintf('%02d', payment_method.month)
155
155
  else
156
156
  post['customer.customerReferenceNumber'] = payment_method
@@ -177,7 +177,7 @@ module ActiveMerchant
177
177
  # Creates the request and returns the summarized result
178
178
  def commit(action, post)
179
179
  add_auth(post)
180
- post.merge!('order.type' => TRANSACTIONS[action])
180
+ post['order.type'] = TRANSACTIONS[action]
181
181
 
182
182
  request = post.map { |k, v| "#{k}=#{CGI.escape(v.to_s)}" }.join('&')
183
183
  response = ssl_post(self.live_url, request)
@@ -174,7 +174,7 @@ module ActiveMerchant
174
174
  private
175
175
 
176
176
  def commit(action, post)
177
- response = parse( ssl_post(self.live_url, post_data(action, post)) )
177
+ response = parse(ssl_post(self.live_url, post_data(action, post)))
178
178
  success = SUCCESS_CODES.include?(response[:finalstatus])
179
179
  message = success ? 'Success' : message_from(response)
180
180
 
@@ -189,7 +189,7 @@ module ActiveMerchant
189
189
  def parse(body)
190
190
  body = CGI.unescape(body)
191
191
  results = {}
192
- body.split('&').collect { |e| e.split('=') }.each do |key,value|
192
+ body.split('&').collect { |e| e.split('=') }.each do |key, value|
193
193
  results[key.downcase.to_sym] = normalize(value.to_s.strip)
194
194
  end
195
195
 
@@ -317,8 +317,8 @@ module ActiveMerchant #:nodoc:
317
317
 
318
318
  def underscore(camel_cased_word)
319
319
  camel_cased_word.to_s.gsub(/::/, '/').
320
- gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').
321
- gsub(/([a-z\d])([A-Z])/,'\1_\2').
320
+ gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2').
321
+ gsub(/([a-z\d])([A-Z])/, '\1_\2').
322
322
  tr('-', '_').
323
323
  downcase
324
324
  end
@@ -168,7 +168,7 @@ module ActiveMerchant #:nodoc:
168
168
 
169
169
  if creditcard
170
170
  exp_month = sprintf('%.2i', creditcard.month) unless creditcard.month.blank?
171
- exp_year = creditcard.year.to_s[2,2] unless creditcard.year.blank?
171
+ exp_year = creditcard.year.to_s[2, 2] unless creditcard.year.blank?
172
172
  card_id_code = (creditcard.verification_value.blank? ? nil : '1')
173
173
 
174
174
  params.update(
@@ -183,7 +183,7 @@ module ActiveMerchant
183
183
  address = options[:billing_address] || options[:address]
184
184
  return if address.nil?
185
185
 
186
- post[:QAAddress] = [:address1, :address2, :city, :state].collect{|a| address[a]}.reject(&:blank?).join(' ')
186
+ post[:QAAddress] = [:address1, :address2, :city, :state].collect { |a| address[a] }.reject(&:blank?).join(' ')
187
187
  post[:QAPostcode] = address[:zip]
188
188
  end
189
189
 
@@ -242,7 +242,7 @@ module ActiveMerchant
242
242
  def parse(body)
243
243
  fields = {}
244
244
  for line in body.split('&')
245
- key, value = *line.scan( %r{^(\w+)\=(.*)$} ).flatten
245
+ key, value = *line.scan(%r{^(\w+)\=(.*)$}).flatten
246
246
  fields[key] = CGI.unescape(value)
247
247
  end
248
248
  fields.symbolize_keys
@@ -257,7 +257,7 @@ module ActiveMerchant
257
257
  # - ActiveMerchant::Billing::Response object
258
258
  #
259
259
  def commit(request)
260
- response = parse( ssl_post(self.live_url, post_data(request)) )
260
+ response = parse(ssl_post(self.live_url, post_data(request)))
261
261
 
262
262
  Response.new(response[:ResponseCode] == APPROVED, response[:Message], response,
263
263
  :test => test?,
@@ -101,7 +101,7 @@ module ActiveMerchant #:nodoc:
101
101
  #
102
102
  def credit(money, identification, options = {})
103
103
  ActiveMerchant.deprecated CREDIT_DEPRECATION_MESSAGE
104
- refund(money, identification, options = {})
104
+ refund(money, identification, {})
105
105
  end
106
106
 
107
107
  def refund(money, identification, options = {})
@@ -44,7 +44,7 @@ module ActiveMerchant #:nodoc:
44
44
  #
45
45
  def authorize(money, creditcard, options = {})
46
46
  setup_address_hash(options)
47
- commit(build_auth_request(money, creditcard, options), options )
47
+ commit(build_auth_request(money, creditcard, options), options)
48
48
  end
49
49
 
50
50
  # Capture an authorization that has previously been requested
@@ -81,7 +81,7 @@ module ActiveMerchant #:nodoc:
81
81
 
82
82
  def build_auth_request(money, creditcard, options)
83
83
  xml = Builder::XmlMarkup.new
84
- add_common_credit_card_info(xml,'AUTH_ONLY')
84
+ add_common_credit_card_info(xml, 'AUTH_ONLY')
85
85
  add_purchase_data(xml, money)
86
86
  add_creditcard(xml, creditcard)
87
87
  add_address(xml, creditcard, options[:billing_address], options)
@@ -94,7 +94,7 @@ module ActiveMerchant #:nodoc:
94
94
 
95
95
  def build_capture_request(money, authorization, options)
96
96
  xml = Builder::XmlMarkup.new
97
- add_common_credit_card_info(xml,'PREVIOUS_SALE')
97
+ add_common_credit_card_info(xml, 'PREVIOUS_SALE')
98
98
  transaction_id, _ = authorization_parts_from(authorization)
99
99
  add_transaction_id(xml, transaction_id)
100
100
  xml.target!
@@ -115,7 +115,7 @@ module ActiveMerchant #:nodoc:
115
115
 
116
116
  def build_void_request(authorization, options)
117
117
  xml = Builder::XmlMarkup.new
118
- add_common_credit_card_info(xml,'VOID')
118
+ add_common_credit_card_info(xml, 'VOID')
119
119
  transaction_id, _ = authorization_parts_from(authorization)
120
120
  add_transaction_id(xml, transaction_id)
121
121
  xml.target!
@@ -123,7 +123,7 @@ module ActiveMerchant #:nodoc:
123
123
 
124
124
  def build_credit_request(money, authorization, options)
125
125
  xml = Builder::XmlMarkup.new
126
- add_common_credit_card_info(xml,'RETURN')
126
+ add_common_credit_card_info(xml, 'RETURN')
127
127
  add_purchase_data(xml, money)
128
128
  transaction_id, cc = authorization_parts_from(authorization)
129
129
  add_transaction_id(xml, transaction_id)
@@ -182,7 +182,7 @@ module ActiveMerchant #:nodoc:
182
182
  xml.tag! 'CreditCardNumber', creditcard.number
183
183
  xml.tag! 'ExpireMonth', format(creditcard.month, :two_digits)
184
184
  xml.tag! 'ExpireYear', format(creditcard.year, :four_digits)
185
- xml.tag!('CVV2', creditcard.verification_value) unless (@options[:ignore_cvv] || creditcard.verification_value.blank? )
185
+ xml.tag!('CVV2', creditcard.verification_value) unless @options[:ignore_cvv] || creditcard.verification_value.blank?
186
186
  end
187
187
 
188
188
  # Where we actually build the full SOAP request using builder
@@ -251,7 +251,7 @@ module ActiveMerchant #:nodoc:
251
251
 
252
252
  def parse_element(reply, node)
253
253
  if node.has_elements?
254
- node.elements.each{|e| parse_element(reply, e) }
254
+ node.elements.each { |e| parse_element(reply, e) }
255
255
  else
256
256
  if node.parent.name =~ /item/
257
257
  parent = node.parent.name + (node.parent.attributes['id'] ? '_' + node.parent.attributes['id'] : '')
@@ -48,7 +48,7 @@ module ActiveMerchant #:nodoc:
48
48
  'PMT-6000' => STANDARD_ERROR_CODE[:processing_error], # A temporary Issue prevented this request from being processed.
49
49
  }
50
50
 
51
- FRAUD_WARNING_CODES = ['PMT-1000','PMT-1001','PMT-1002','PMT-1003']
51
+ FRAUD_WARNING_CODES = ['PMT-1000', 'PMT-1001', 'PMT-1002', 'PMT-1003']
52
52
 
53
53
  def initialize(options = {})
54
54
  requires!(options, :consumer_key, :consumer_secret, :access_token, :token_secret, :realm)
@@ -224,17 +224,17 @@ module ActiveMerchant #:nodoc:
224
224
  }
225
225
 
226
226
  # prepare components for signature
227
- oauth_signature_base_string = [method.to_s.upcase, request_uri.to_s, oauth_parameters.to_param].map{|v| CGI.escape(v) }.join('&')
228
- oauth_signing_key = [@options[:consumer_secret], @options[:token_secret]].map{|v| CGI.escape(v)}.join('&')
227
+ oauth_signature_base_string = [method.to_s.upcase, request_uri.to_s, oauth_parameters.to_param].map { |v| CGI.escape(v) }.join('&')
228
+ oauth_signing_key = [@options[:consumer_secret], @options[:token_secret]].map { |v| CGI.escape(v) }.join('&')
229
229
  hmac_signature = OpenSSL::HMAC.digest(OpenSSL::Digest.new('sha1'), oauth_signing_key, oauth_signature_base_string)
230
230
 
231
231
  # append signature to required OAuth parameters
232
232
  oauth_parameters[:oauth_signature] = CGI.escape(Base64.encode64(hmac_signature).chomp.gsub(/\n/, ''))
233
233
 
234
234
  # prepare Authorization header string
235
- oauth_parameters = Hash[oauth_parameters.sort_by {|k, _| k}]
235
+ oauth_parameters = Hash[oauth_parameters.sort_by { |k, _| k }]
236
236
  oauth_headers = ["OAuth realm=\"#{@options[:realm]}\""]
237
- oauth_headers += oauth_parameters.map {|k, v| "#{k}=\"#{v}\""}
237
+ oauth_headers += oauth_parameters.map { |k, v| "#{k}=\"#{v}\"" }
238
238
 
239
239
  {
240
240
  'Content-type' => 'application/json',
@@ -258,7 +258,7 @@ module ActiveMerchant #:nodoc:
258
258
  end
259
259
 
260
260
  def message_from(response)
261
- response['errors'].present? ? response['errors'].map {|error_hash| error_hash['message'] }.join(' ') : response['status']
261
+ response['errors'].present? ? response['errors'].map { |error_hash| error_hash['message'] }.join(' ') : response['status']
262
262
  end
263
263
 
264
264
  def errors_from(response)
@@ -78,7 +78,7 @@ module ActiveMerchant
78
78
  def store(credit_card, options = {})
79
79
  MultiResponse.run do |r|
80
80
  r.process { create_store(options) }
81
- r.process { authorize_store(r.authorization, credit_card, options)}
81
+ r.process { authorize_store(r.authorization, credit_card, options) }
82
82
  end
83
83
  end
84
84
 
@@ -103,7 +103,7 @@ module ActiveMerchant #:nodoc:
103
103
 
104
104
  private
105
105
 
106
- CURRENCY_CODES = Hash.new{|h,k| raise ArgumentError.new("Unsupported currency: #{k}")}
106
+ CURRENCY_CODES = Hash.new { |h, k| raise ArgumentError.new("Unsupported currency: #{k}") }
107
107
  CURRENCY_CODES['AUD'] = 'AUD'
108
108
  CURRENCY_CODES['INR'] = 'INR'
109
109
 
@@ -197,7 +197,7 @@ module ActiveMerchant #:nodoc:
197
197
 
198
198
  def parse_element(response, node)
199
199
  if node.has_elements?
200
- node.elements.each{|element| parse_element(response, element) }
200
+ node.elements.each { |element| parse_element(response, element) }
201
201
  else
202
202
  response[node.name.underscore.to_sym] = node.text
203
203
  end
@@ -80,6 +80,13 @@ module ActiveMerchant
80
80
  commit(request)
81
81
  end
82
82
 
83
+ def verify(credit_card, options = {})
84
+ requires!(options, :order_id)
85
+
86
+ request = build_verify_request(credit_card, options)
87
+ commit(request)
88
+ end
89
+
83
90
  def supports_scrubbing
84
91
  true
85
92
  end
@@ -111,7 +118,7 @@ module ActiveMerchant
111
118
 
112
119
  doc = Nokogiri::XML(xml)
113
120
  doc.xpath('//response/*').each do |node|
114
- if (node.elements.size == 0)
121
+ if node.elements.size == 0
115
122
  response[node.name.downcase.to_sym] = normalize(node.text)
116
123
  else
117
124
  node.elements.each do |childnode|
@@ -185,6 +192,20 @@ module ActiveMerchant
185
192
  xml.target!
186
193
  end
187
194
 
195
+ # Verify initiates an OTB (Open To Buy) request
196
+ def build_verify_request(credit_card, options)
197
+ timestamp = new_timestamp
198
+ xml = Builder::XmlMarkup.new :indent => 2
199
+ xml.tag! 'request', 'timestamp' => timestamp, 'type' => 'otb' do
200
+ add_merchant_details(xml, options)
201
+ xml.tag! 'orderid', sanitize_order_id(options[:order_id])
202
+ add_card(xml, credit_card)
203
+ add_comments(xml, options)
204
+ add_signed_digest(xml, timestamp, @options[:login], sanitize_order_id(options[:order_id]), credit_card.number)
205
+ end
206
+ xml.target!
207
+ end
208
+
188
209
  def add_address_and_customer_info(xml, options)
189
210
  billing_address = options[:billing_address] || options[:address]
190
211
  shipping_address = options[:shipping_address]
@@ -258,14 +279,14 @@ module ActiveMerchant
258
279
  end
259
280
  xml.tag! 'supplementarydata' do
260
281
  xml.tag! 'item', 'type' => 'mobile' do
261
- xml.tag! 'field01', payment.source.to_s.gsub('_','-')
282
+ xml.tag! 'field01', payment.source.to_s.gsub('_', '-')
262
283
  end
263
284
  end
264
285
  end
265
286
 
266
287
  def format_address_code(address)
267
288
  code = [address[:zip].to_s, address[:address1].to_s + address[:address2].to_s]
268
- code.collect{|e| e.gsub(/\D/, '')}.reject(&:empty?).join('|')
289
+ code.collect { |e| e.gsub(/\D/, '') }.reject(&:empty?).join('|')
269
290
  end
270
291
 
271
292
  def new_timestamp
@@ -286,26 +307,25 @@ module ActiveMerchant
286
307
  end
287
308
 
288
309
  def message_from(response)
289
- message = nil
290
310
  case response[:result]
291
311
  when '00'
292
- message = SUCCESS
312
+ SUCCESS
293
313
  when '101'
294
- message = response[:message]
314
+ response[:message]
295
315
  when '102', '103'
296
- message = DECLINED
316
+ DECLINED
297
317
  when /^2[0-9][0-9]/
298
- message = BANK_ERROR
318
+ BANK_ERROR
299
319
  when /^3[0-9][0-9]/
300
- message = REALEX_ERROR
320
+ REALEX_ERROR
301
321
  when /^5[0-9][0-9]/
302
- message = response[:message]
322
+ response[:message]
303
323
  when '600', '601', '603'
304
- message = ERROR
324
+ ERROR
305
325
  when '666'
306
- message = CLIENT_DEACTIVATED
326
+ CLIENT_DEACTIVATED
307
327
  else
308
- message = DECLINED
328
+ DECLINED
309
329
  end
310
330
  end
311
331