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
@@ -140,7 +140,7 @@ module ActiveMerchant #:nodoc:
140
140
  end
141
141
 
142
142
  def post_data(action, params)
143
- params.map {|k, v| "#{CGI.escape(k.to_s)}=#{CGI.escape(v.to_s)}"}.join('&')
143
+ params.map { |k, v| "#{CGI.escape(k.to_s)}=#{CGI.escape(v.to_s)}" }.join('&')
144
144
  end
145
145
 
146
146
  def url(action)
@@ -17,7 +17,7 @@ module ActiveMerchant #:nodoc:
17
17
  # MiGS is supported throughout Asia Pacific, Middle East and Africa
18
18
  # MiGS is used in Australia (AU) by ANZ (eGate), CBA (CommWeb) and more
19
19
  # Source of Country List: http://www.scribd.com/doc/17811923
20
- self.supported_countries = %w(AU AE BD BN EG HK ID IN JO KW LB LK MU MV MY NZ OM PH QA SA SG TT VN)
20
+ self.supported_countries = %w(AU AE BD BN EG HK ID JO KW LB LK MU MV MY NZ OM PH QA SA SG TT VN)
21
21
 
22
22
  # The card types supported by the payment gateway
23
23
  self.supported_cardtypes = [:visa, :master, :american_express, :diners_club, :jcb]
@@ -169,10 +169,8 @@ module ActiveMerchant #:nodoc:
169
169
  add_invoice(post, options)
170
170
  add_creditcard_type(post, options[:card_type]) if options[:card_type]
171
171
 
172
- post.merge!(
173
- :Locale => options[:locale] || 'en',
174
- :ReturnURL => options[:return_url]
175
- )
172
+ post[:Locale] = options[:locale] || 'en'
173
+ post[:ReturnURL] = options[:return_url]
176
174
 
177
175
  add_standard_parameters('pay', post, options[:unique_id])
178
176
 
@@ -251,7 +249,7 @@ module ActiveMerchant #:nodoc:
251
249
 
252
250
  def add_creditcard_type(post, card_type)
253
251
  post[:Gateway] = 'ssl'
254
- post[:card] = CARD_TYPES.detect{|ct| ct.am_code == card_type}.migs_long_code
252
+ post[:card] = CARD_TYPES.detect { |ct| ct.am_code == card_type }.migs_long_code
255
253
  end
256
254
 
257
255
  def parse(body)
@@ -122,7 +122,7 @@ module ActiveMerchant #:nodoc:
122
122
  xml.tag! action, { 'xmlns' => xmlns(action) } do
123
123
  xml.tag! 'clientId', @options[:login]
124
124
  xml.tag! 'clientCode', @options[:password]
125
- params.each {|key, value| xml.tag! key, value }
125
+ params.each { |key, value| xml.tag! key, value }
126
126
  end
127
127
  end
128
128
  end
@@ -207,7 +207,7 @@ module ActiveMerchant #:nodoc:
207
207
 
208
208
  def parse_element(response, node)
209
209
  if node.has_elements?
210
- node.elements.each{|e| parse_element(response, e) }
210
+ node.elements.each { |e| parse_element(response, e) }
211
211
  else
212
212
  response[node.name.underscore.to_sym] = node.text.to_s.strip
213
213
  end
@@ -33,7 +33,8 @@ module ActiveMerchant #:nodoc:
33
33
  requires!(options, :login, :password)
34
34
  @cvv_enabled = options[:cvv_enabled]
35
35
  @avs_enabled = options[:avs_enabled]
36
- options = { :crypt_type => 7 }.merge(options)
36
+ @cof_enabled = options[:cof_enabled]
37
+ options[:crypt_type] = 7 unless options.has_key?(:crypt_type)
37
38
  super
38
39
  end
39
40
 
@@ -46,17 +47,18 @@ module ActiveMerchant #:nodoc:
46
47
  requires!(options, :order_id)
47
48
  post = {}
48
49
  add_payment_source(post, creditcard_or_datakey, options)
49
- post[:amount] = amount(money)
50
- post[:order_id] = options[:order_id]
51
- post[:address] = options[:billing_address] || options[:address]
50
+ post[:amount] = amount(money)
51
+ post[:order_id] = options[:order_id]
52
+ post[:address] = options[:billing_address] || options[:address]
52
53
  post[:crypt_type] = options[:crypt_type] || @options[:crypt_type]
54
+ add_cof(post, options) if @cof_enabled
53
55
  action = if post[:cavv]
54
- 'cavv_preauth'
55
- elsif post[:data_key].blank?
56
- 'preauth'
57
- else
58
- 'res_preauth_cc'
59
- end
56
+ 'cavv_preauth'
57
+ elsif post[:data_key].blank?
58
+ 'preauth'
59
+ else
60
+ 'res_preauth_cc'
61
+ end
60
62
  commit(action, post)
61
63
  end
62
64
 
@@ -68,17 +70,18 @@ module ActiveMerchant #:nodoc:
68
70
  requires!(options, :order_id)
69
71
  post = {}
70
72
  add_payment_source(post, creditcard_or_datakey, options)
71
- post[:amount] = amount(money)
72
- post[:order_id] = options[:order_id]
73
- post[:address] = options[:billing_address] || options[:address]
73
+ post[:amount] = amount(money)
74
+ post[:order_id] = options[:order_id]
75
+ post[:address] = options[:billing_address] || options[:address]
74
76
  post[:crypt_type] = options[:crypt_type] || @options[:crypt_type]
77
+ add_cof(post, options) if @cof_enabled
75
78
  action = if post[:cavv]
76
- 'cavv_purchase'
77
- elsif post[:data_key].blank?
78
- 'purchase'
79
- else
80
- 'res_purchase_cc'
81
- end
79
+ 'cavv_purchase'
80
+ elsif post[:data_key].blank?
81
+ 'purchase'
82
+ else
83
+ 'res_purchase_cc'
84
+ end
82
85
  commit(action, post)
83
86
  end
84
87
 
@@ -182,16 +185,16 @@ module ActiveMerchant #:nodoc:
182
185
 
183
186
  def add_payment_source(post, payment_method, options)
184
187
  if payment_method.is_a?(String)
185
- post[:data_key] = payment_method
186
- post[:cust_id] = options[:customer]
188
+ post[:data_key] = payment_method
189
+ post[:cust_id] = options[:customer]
187
190
  else
188
191
  if payment_method.respond_to?(:track_data) && payment_method.track_data.present?
189
- post[:pos_code] = '00'
190
- post[:track2] = payment_method.track_data
192
+ post[:pos_code] = '00'
193
+ post[:track2] = payment_method.track_data
191
194
  else
192
- post[:pan] = payment_method.number
193
- post[:expdate] = expdate(payment_method)
194
- post[:cvd_value] = payment_method.verification_value if payment_method.verification_value?
195
+ post[:pan] = payment_method.number
196
+ post[:expdate] = expdate(payment_method)
197
+ post[:cvd_value] = payment_method.verification_value if payment_method.verification_value?
195
198
  post[:cavv] = payment_method.payment_cryptogram if payment_method.is_a?(NetworkTokenizationCreditCard)
196
199
  post[:wallet_indicator] = wallet_indicator(payment_method.source.to_s) if payment_method.is_a?(NetworkTokenizationCreditCard)
197
200
  post[:crypt_type] = (payment_method.eci || 7) if payment_method.is_a?(NetworkTokenizationCreditCard)
@@ -200,6 +203,12 @@ module ActiveMerchant #:nodoc:
200
203
  end
201
204
  end
202
205
 
206
+ def add_cof(post, options)
207
+ post[:issuer_id] = options[:issuer_id] if options[:issuer_id]
208
+ post[:payment_indicator] = options[:payment_indicator] if options[:payment_indicator]
209
+ post[:payment_information] = options[:payment_information] if options[:payment_information]
210
+ end
211
+
203
212
  # Common params used amongst the +credit+, +void+ and +capture+ methods
204
213
  def crediting_params(authorization, options = {})
205
214
  {
@@ -225,12 +234,14 @@ module ActiveMerchant #:nodoc:
225
234
  raw = ssl_post(url, data)
226
235
  response = parse(raw)
227
236
 
228
- Response.new(successful?(response), message_from(response[:message]), response,
229
- :test => test?,
230
- :avs_result => { :code => response[:avs_result_code] },
231
- :cvv_result => response[:cvd_result_code] && response[:cvd_result_code][-1,1],
232
- :authorization => authorization_from(response)
233
- )
237
+ Response.new(
238
+ successful?(response),
239
+ message_from(response[:message]),
240
+ response,
241
+ :test => test?,
242
+ :avs_result => {:code => response[:avs_result_code]},
243
+ :cvv_result => response[:cvd_result_code] && response[:cvd_result_code][-1, 1],
244
+ :authorization => authorization_from(response))
234
245
  end
235
246
 
236
247
  # Generates a Moneris authorization string of the form 'trans_id;receipt_id'.
@@ -244,7 +255,7 @@ module ActiveMerchant #:nodoc:
244
255
  def successful?(response)
245
256
  response[:response_code] &&
246
257
  response[:complete] &&
247
- (0..49).include?(response[:response_code].to_i)
258
+ (0..49).cover?(response[:response_code].to_i)
248
259
  end
249
260
 
250
261
  def parse(xml)
@@ -262,9 +273,9 @@ module ActiveMerchant #:nodoc:
262
273
  end
263
274
 
264
275
  def post_data(action, parameters = {})
265
- xml = REXML::Document.new
266
- root = xml.add_element('request')
267
- root.add_element('store_id').text = options[:login]
276
+ xml = REXML::Document.new
277
+ root = xml.add_element('request')
278
+ root.add_element('store_id').text = options[:login]
268
279
  root.add_element('api_token').text = options[:password]
269
280
  root.add_element(transaction_element(action, parameters))
270
281
 
@@ -281,6 +292,8 @@ module ActiveMerchant #:nodoc:
281
292
  transaction.add_element(avs_element(parameters[:address])) if @avs_enabled && parameters[:address]
282
293
  when :cvd_info
283
294
  transaction.add_element(cvd_element(parameters[:cvd_value])) if @cvv_enabled
295
+ when :cof_info
296
+ transaction.add_element(credential_on_file(parameters)) if @cof_enabled && cof_details_present?(parameters)
284
297
  else
285
298
  transaction.add_element(key.to_s).text = parameters[key] unless parameters[key].blank?
286
299
  end
@@ -294,8 +307,8 @@ module ActiveMerchant #:nodoc:
294
307
  tokens = full_address.split(/\s+/)
295
308
 
296
309
  element = REXML::Element.new('avs_info')
297
- element.add_element('avs_street_number').text = tokens.select{|x| x =~ /\d/}.join(' ')
298
- element.add_element('avs_street_name').text = tokens.reject{|x| x =~ /\d/}.join(' ')
310
+ element.add_element('avs_street_number').text = tokens.select { |x| x =~ /\d/ }.join(' ')
311
+ element.add_element('avs_street_name').text = tokens.reject { |x| x =~ /\d/ }.join(' ')
299
312
  element.add_element('avs_zipcode').text = address[:zip]
300
313
  element
301
314
  end
@@ -311,6 +324,22 @@ module ActiveMerchant #:nodoc:
311
324
  element
312
325
  end
313
326
 
327
+ def cof_details_present?(parameters)
328
+ parameters[:issuer_id] && parameters[:payment_indicator] && parameters[:payment_information]
329
+ end
330
+
331
+ def credential_on_file(parameters)
332
+ issuer_id = parameters[:issuer_id]
333
+ payment_indicator = parameters[:payment_indicator]
334
+ payment_information = parameters[:payment_information]
335
+
336
+ cof_info = REXML::Element.new('cof_info')
337
+ cof_info.add_element('issuer_id').text = issuer_id
338
+ cof_info.add_element('payment_indicator').text = payment_indicator
339
+ cof_info.add_element('payment_information').text = payment_information
340
+ cof_info
341
+ end
342
+
314
343
  def wallet_indicator(token_source)
315
344
  return 'APP' if token_source == 'apple_pay'
316
345
  return 'ANP' if token_source == 'android_pay'
@@ -324,24 +353,24 @@ module ActiveMerchant #:nodoc:
324
353
 
325
354
  def actions
326
355
  {
327
- 'purchase' => [:order_id, :cust_id, :amount, :pan, :expdate, :crypt_type, :avs_info, :cvd_info, :track2, :pos_code],
328
- 'preauth' => [:order_id, :cust_id, :amount, :pan, :expdate, :crypt_type, :avs_info, :cvd_info, :track2, :pos_code],
329
- 'command' => [:order_id],
330
- 'refund' => [:order_id, :amount, :txn_number, :crypt_type],
331
- 'indrefund' => [:order_id, :cust_id, :amount, :pan, :expdate, :crypt_type],
332
- 'completion' => [:order_id, :comp_amount, :txn_number, :crypt_type],
333
- 'purchasecorrection' => [:order_id, :txn_number, :crypt_type],
334
- 'cavv_preauth' => [:order_id, :cust_id, :amount, :pan, :expdate, :cavv, :crypt_type, :wallet_indicator],
335
- 'cavv_purchase' => [:order_id, :cust_id, :amount, :pan, :expdate, :cavv, :crypt_type, :wallet_indicator],
336
- 'transact' => [:order_id, :cust_id, :amount, :pan, :expdate, :crypt_type],
337
- 'Batchcloseall' => [],
338
- 'opentotals' => [:ecr_number],
339
- 'batchclose' => [:ecr_number],
340
- 'res_add_cc' => [:pan, :expdate, :crypt_type],
341
- 'res_delete' => [:data_key],
342
- 'res_update_cc' => [:data_key, :pan, :expdate, :crypt_type],
343
- 'res_purchase_cc' => [:data_key, :order_id, :cust_id, :amount, :crypt_type],
344
- 'res_preauth_cc' => [:data_key, :order_id, :cust_id, :amount, :crypt_type]
356
+ 'purchase' => [:order_id, :cust_id, :amount, :pan, :expdate, :crypt_type, :avs_info, :cvd_info, :track2, :pos_code, :cof_info],
357
+ 'preauth' => [:order_id, :cust_id, :amount, :pan, :expdate, :crypt_type, :avs_info, :cvd_info, :track2, :pos_code, :cof_info],
358
+ 'command' => [:order_id],
359
+ 'refund' => [:order_id, :amount, :txn_number, :crypt_type],
360
+ 'indrefund' => [:order_id, :cust_id, :amount, :pan, :expdate, :crypt_type],
361
+ 'completion' => [:order_id, :comp_amount, :txn_number, :crypt_type],
362
+ 'purchasecorrection' => [:order_id, :txn_number, :crypt_type],
363
+ 'cavv_preauth' => [:order_id, :cust_id, :amount, :pan, :expdate, :cavv, :crypt_type, :wallet_indicator],
364
+ 'cavv_purchase' => [:order_id, :cust_id, :amount, :pan, :expdate, :cavv, :crypt_type, :wallet_indicator],
365
+ 'transact' => [:order_id, :cust_id, :amount, :pan, :expdate, :crypt_type],
366
+ 'Batchcloseall' => [],
367
+ 'opentotals' => [:ecr_number],
368
+ 'batchclose' => [:ecr_number],
369
+ 'res_add_cc' => [:pan, :expdate, :crypt_type, :cof_info],
370
+ 'res_delete' => [:data_key],
371
+ 'res_update_cc' => [:data_key, :pan, :expdate, :crypt_type],
372
+ 'res_purchase_cc' => [:data_key, :order_id, :cust_id, :amount, :crypt_type, :cof_info],
373
+ 'res_preauth_cc' => [:data_key, :order_id, :cust_id, :amount, :crypt_type, :cof_info]
345
374
  }
346
375
  end
347
376
  end
@@ -74,11 +74,11 @@ module ActiveMerchant #:nodoc:
74
74
  add_address(post, creditcard_or_datakey, options)
75
75
  post[:crypt_type] = options[:crypt_type] || @options[:crypt_type]
76
76
  action = if creditcard_or_datakey.is_a?(String)
77
- 'us_res_purchase_cc'
78
- elsif card_brand(creditcard_or_datakey) == 'check'
79
- 'us_ach_debit'
80
- elsif post[:data_key].blank?
81
- 'us_purchase'
77
+ 'us_res_purchase_cc'
78
+ elsif card_brand(creditcard_or_datakey) == 'check'
79
+ 'us_ach_debit'
80
+ elsif post[:data_key].blank?
81
+ 'us_purchase'
82
82
  end
83
83
  commit(action, post)
84
84
  end
@@ -223,7 +223,7 @@ module ActiveMerchant #:nodoc:
223
223
  Response.new(successful?(response), message_from(response[:message]), response,
224
224
  :test => test?,
225
225
  :avs_result => { :code => response[:avs_result_code] },
226
- :cvv_result => response[:cvd_result_code] && response[:cvd_result_code][-1,1],
226
+ :cvv_result => response[:cvd_result_code] && response[:cvd_result_code][-1, 1],
227
227
  :authorization => authorization_from(response)
228
228
  )
229
229
  end
@@ -239,7 +239,7 @@ module ActiveMerchant #:nodoc:
239
239
  def successful?(response)
240
240
  response[:response_code] &&
241
241
  response[:complete] &&
242
- (0..49).include?(response[:response_code].to_i)
242
+ (0..49).cover?(response[:response_code].to_i)
243
243
  end
244
244
 
245
245
  def parse(xml)
@@ -291,8 +291,8 @@ module ActiveMerchant #:nodoc:
291
291
  tokens = full_address.split(/\s+/)
292
292
 
293
293
  element = REXML::Element.new('avs_info')
294
- element.add_element('avs_street_number').text = tokens.select{|x| x =~ /\d/}.join(' ')
295
- element.add_element('avs_street_name').text = tokens.reject{|x| x =~ /\d/}.join(' ')
294
+ element.add_element('avs_street_number').text = tokens.select { |x| x =~ /\d/ }.join(' ')
295
+ element.add_element('avs_street_name').text = tokens.reject { |x| x =~ /\d/ }.join(' ')
296
296
  element.add_element('avs_zipcode').text = address[:zip]
297
297
  element
298
298
  end
@@ -144,7 +144,7 @@ module ActiveMerchant #:nodoc:
144
144
  parameters[:type] = action
145
145
  parameters[:username] = @options[:login]
146
146
  parameters[:password] = @options[:password]
147
- parameters.map{|k, v| "#{k}=#{CGI.escape(v.to_s)}"}.join('&')
147
+ parameters.map { |k, v| "#{k}=#{CGI.escape(v.to_s)}" }.join('&')
148
148
  end
149
149
  end
150
150
  end
@@ -177,7 +177,7 @@ module ActiveMerchant #:nodoc:
177
177
  post[:payment][:credit_card][:card][:exp_year] = payment.year
178
178
  post[:payment][:credit_card][:card][:cvv] = payment.verification_value
179
179
  post[:payment][:credit_card][:card][:holder_document] = options[:holder_document] if options[:holder_document]
180
- add_billing_address(post,'credit_card', options)
180
+ add_billing_address(post, 'credit_card', options)
181
181
  end
182
182
  end
183
183
 
@@ -280,7 +280,7 @@ module ActiveMerchant #:nodoc:
280
280
 
281
281
  def parse_element(response, node)
282
282
  if node.has_elements?
283
- node.elements.each{|element| parse_element(response, element) }
283
+ node.elements.each { |element| parse_element(response, element) }
284
284
  else
285
285
  response[node.name.underscore.to_sym] = node.text
286
286
  end
@@ -142,7 +142,7 @@ module ActiveMerchant
142
142
  # omitted if nil.
143
143
  def commit(action, params)
144
144
  # get gateway response
145
- response = parse( ssl_post(self.live_url, post_data(action, params)) )
145
+ response = parse(ssl_post(self.live_url, post_data(action, params)))
146
146
 
147
147
  Response.new(response['status'] == 'approved', message_from(response), response,
148
148
  :authorization => authorization_from(response, action)
@@ -152,7 +152,7 @@ module ActiveMerchant
152
152
  def post_data(action, params)
153
153
  params['COMMAND'] = TRANSACTIONS[action]
154
154
  params['LOGIN'] = "#{@options[:login]}/#{@options[:password]}"
155
- escape_uri(params.map{|k,v| "#{k}=#{v}"}.join('&'))
155
+ escape_uri(params.map { |k, v| "#{k}=#{v}" }.join('&'))
156
156
  end
157
157
 
158
158
  # The upstream is picky and so we can't use CGI.escape like we want to
@@ -31,8 +31,8 @@ module ActiveMerchant #:nodoc:
31
31
  requires!(options, :order_id)
32
32
 
33
33
  MultiResponse.run do |r|
34
- r.process{authorize(money, creditcard, options)}
35
- r.process{capture(money, r.authorization, options)}
34
+ r.process { authorize(money, creditcard, options) }
35
+ r.process { capture(money, r.authorization, options) }
36
36
  end
37
37
  end
38
38
 
@@ -40,9 +40,9 @@ module ActiveMerchant #:nodoc:
40
40
  requires!(options, :order_id)
41
41
 
42
42
  MultiResponse.run do |r|
43
- r.process{setup_transaction(money, options)}
44
- r.process{add_and_auth_credit_card(r.authorization, creditcard, options)}
45
- r.process{query_transaction(r.authorization, options)}
43
+ r.process { setup_transaction(money, options) }
44
+ r.process { add_and_auth_credit_card(r.authorization, creditcard, options) }
45
+ r.process { query_transaction(r.authorization, options) }
46
46
  end
47
47
  end
48
48
 
@@ -173,7 +173,7 @@ module ActiveMerchant #:nodoc:
173
173
  end
174
174
 
175
175
  def encode(hash)
176
- hash.collect{|(k,v)| "#{CGI.escape(k.to_s)}=#{CGI.escape(v.to_s)}"}.join('&')
176
+ hash.collect { |(k, v)| "#{CGI.escape(k.to_s)}=#{CGI.escape(v.to_s)}" }.join('&')
177
177
  end
178
178
  end
179
179
  end
@@ -170,7 +170,7 @@ module ActiveMerchant #:nodoc:
170
170
  :zip => address[:zip],
171
171
  :state => address[:state],
172
172
  }
173
- mapped.merge!({:country => country.code(:alpha2).value}) unless country.blank?
173
+ mapped[:country] = country.code(:alpha2).value unless country.blank?
174
174
 
175
175
  mapped
176
176
  end
@@ -247,41 +247,41 @@ module ActiveMerchant #:nodoc:
247
247
  def error_code_from(response)
248
248
  unless success_from(response)
249
249
  case response['errorCode']
250
- when '3002' then STANDARD_ERROR_CODE[:invalid_number] # You submitted an invalid card number or brand or combination of card number and brand with your request.
251
- when '3004' then STANDARD_ERROR_CODE[:incorrect_zip] # The zip/postal code must be provided for an AVS check request.
252
- when '3005' then STANDARD_ERROR_CODE[:incorrect_cvc] # You submitted an incorrect CVC value with your request.
253
- when '3006' then STANDARD_ERROR_CODE[:expired_card] # You submitted an expired credit card number with your request.
254
- when '3009' then STANDARD_ERROR_CODE[:card_declined] # Your request has been declined by the issuing bank.
255
- when '3011' then STANDARD_ERROR_CODE[:card_declined] # Your request has been declined by the issuing bank because the card used is a restricted card. Contact the cardholder's credit card company for further investigation.
256
- when '3012' then STANDARD_ERROR_CODE[:card_declined] # Your request has been declined by the issuing bank because the credit card expiry date submitted is invalid.
257
- when '3013' then STANDARD_ERROR_CODE[:card_declined] # Your request has been declined by the issuing bank due to problems with the credit card account.
258
- when '3014' then STANDARD_ERROR_CODE[:card_declined] # Your request has been declined - the issuing bank has returned an unknown response. Contact the card holder's credit card company for further investigation.
259
- when '3015' then STANDARD_ERROR_CODE[:card_declined] # The bank has requested that you process the transaction manually by calling the cardholder's credit card company.
260
- when '3016' then STANDARD_ERROR_CODE[:card_declined] # The bank has requested that you retrieve the card from the cardholder – it may be a lost or stolen card.
261
- when '3017' then STANDARD_ERROR_CODE[:invalid_number] # You submitted an invalid credit card number with your request.
262
- when '3022' then STANDARD_ERROR_CODE[:card_declined] # The card has been declined due to insufficient funds.
263
- when '3023' then STANDARD_ERROR_CODE[:card_declined] # Your request has been declined by the issuing bank due to its proprietary card activity regulations.
264
- when '3024' then STANDARD_ERROR_CODE[:card_declined] # Your request has been declined because the issuing bank does not permit the transaction for this card.
265
- when '3032' then STANDARD_ERROR_CODE[:card_declined] # Your request has been declined by the issuing bank or external gateway because the card is probably in one of their negative databases.
266
- when '3035' then STANDARD_ERROR_CODE[:card_declined] # Your request has been declined due to exceeded PIN attempts.
267
- when '3036' then STANDARD_ERROR_CODE[:card_declined] # Your request has been declined due to an invalid issuer.
268
- when '3037' then STANDARD_ERROR_CODE[:card_declined] # Your request has been declined because it is invalid.
269
- when '3038' then STANDARD_ERROR_CODE[:card_declined] # Your request has been declined due to customer cancellation.
270
- when '3039' then STANDARD_ERROR_CODE[:card_declined] # Your request has been declined due to an invalid authentication value.
271
- when '3040' then STANDARD_ERROR_CODE[:card_declined] # Your request has been declined because the request type is not permitted on the card.
272
- when '3041' then STANDARD_ERROR_CODE[:card_declined] # Your request has been declined due to a timeout.
273
- when '3042' then STANDARD_ERROR_CODE[:card_declined] # Your request has been declined due to a cryptographic error.
274
- when '3045' then STANDARD_ERROR_CODE[:invalid_expiry_date] # You submitted an invalid date format for this request.
275
- when '3046' then STANDARD_ERROR_CODE[:card_declined] # The transaction was declined because the amount was set to zero.
276
- when '3047' then STANDARD_ERROR_CODE[:card_declined] # The transaction was declined because the amount exceeds the floor limit.
277
- when '3048' then STANDARD_ERROR_CODE[:card_declined] # The transaction was declined because the amount is less than the floor limit.
278
- when '3049' then STANDARD_ERROR_CODE[:card_declined] # The bank has requested that you retrieve the card from the cardholder – the credit card has expired.
279
- when '3050' then STANDARD_ERROR_CODE[:card_declined] # The bank has requested that you retrieve the card from the cardholder – fraudulent activity is suspected.
280
- when '3051' then STANDARD_ERROR_CODE[:card_declined] # The bank has requested that you retrieve the card from the cardholder – contact the acquirer for more information.
281
- when '3052' then STANDARD_ERROR_CODE[:card_declined] # The bank has requested that you retrieve the card from the cardholder – the credit card is restricted.
282
- when '3053' then STANDARD_ERROR_CODE[:card_declined] # The bank has requested that you retrieve the card from the cardholder – please call the acquirer.
283
- when '3054' then STANDARD_ERROR_CODE[:card_declined] # The transaction was declined due to suspected fraud.
284
- else STANDARD_ERROR_CODE[:processing_error]
250
+ when '3002' then STANDARD_ERROR_CODE[:invalid_number] # You submitted an invalid card number or brand or combination of card number and brand with your request.
251
+ when '3004' then STANDARD_ERROR_CODE[:incorrect_zip] # The zip/postal code must be provided for an AVS check request.
252
+ when '3005' then STANDARD_ERROR_CODE[:incorrect_cvc] # You submitted an incorrect CVC value with your request.
253
+ when '3006' then STANDARD_ERROR_CODE[:expired_card] # You submitted an expired credit card number with your request.
254
+ when '3009' then STANDARD_ERROR_CODE[:card_declined] # Your request has been declined by the issuing bank.
255
+ when '3011' then STANDARD_ERROR_CODE[:card_declined] # Your request has been declined by the issuing bank because the card used is a restricted card. Contact the cardholder's credit card company for further investigation.
256
+ when '3012' then STANDARD_ERROR_CODE[:card_declined] # Your request has been declined by the issuing bank because the credit card expiry date submitted is invalid.
257
+ when '3013' then STANDARD_ERROR_CODE[:card_declined] # Your request has been declined by the issuing bank due to problems with the credit card account.
258
+ when '3014' then STANDARD_ERROR_CODE[:card_declined] # Your request has been declined - the issuing bank has returned an unknown response. Contact the card holder's credit card company for further investigation.
259
+ when '3015' then STANDARD_ERROR_CODE[:card_declined] # The bank has requested that you process the transaction manually by calling the cardholder's credit card company.
260
+ when '3016' then STANDARD_ERROR_CODE[:card_declined] # The bank has requested that you retrieve the card from the cardholder – it may be a lost or stolen card.
261
+ when '3017' then STANDARD_ERROR_CODE[:invalid_number] # You submitted an invalid credit card number with your request.
262
+ when '3022' then STANDARD_ERROR_CODE[:card_declined] # The card has been declined due to insufficient funds.
263
+ when '3023' then STANDARD_ERROR_CODE[:card_declined] # Your request has been declined by the issuing bank due to its proprietary card activity regulations.
264
+ when '3024' then STANDARD_ERROR_CODE[:card_declined] # Your request has been declined because the issuing bank does not permit the transaction for this card.
265
+ when '3032' then STANDARD_ERROR_CODE[:card_declined] # Your request has been declined by the issuing bank or external gateway because the card is probably in one of their negative databases.
266
+ when '3035' then STANDARD_ERROR_CODE[:card_declined] # Your request has been declined due to exceeded PIN attempts.
267
+ when '3036' then STANDARD_ERROR_CODE[:card_declined] # Your request has been declined due to an invalid issuer.
268
+ when '3037' then STANDARD_ERROR_CODE[:card_declined] # Your request has been declined because it is invalid.
269
+ when '3038' then STANDARD_ERROR_CODE[:card_declined] # Your request has been declined due to customer cancellation.
270
+ when '3039' then STANDARD_ERROR_CODE[:card_declined] # Your request has been declined due to an invalid authentication value.
271
+ when '3040' then STANDARD_ERROR_CODE[:card_declined] # Your request has been declined because the request type is not permitted on the card.
272
+ when '3041' then STANDARD_ERROR_CODE[:card_declined] # Your request has been declined due to a timeout.
273
+ when '3042' then STANDARD_ERROR_CODE[:card_declined] # Your request has been declined due to a cryptographic error.
274
+ when '3045' then STANDARD_ERROR_CODE[:invalid_expiry_date] # You submitted an invalid date format for this request.
275
+ when '3046' then STANDARD_ERROR_CODE[:card_declined] # The transaction was declined because the amount was set to zero.
276
+ when '3047' then STANDARD_ERROR_CODE[:card_declined] # The transaction was declined because the amount exceeds the floor limit.
277
+ when '3048' then STANDARD_ERROR_CODE[:card_declined] # The transaction was declined because the amount is less than the floor limit.
278
+ when '3049' then STANDARD_ERROR_CODE[:card_declined] # The bank has requested that you retrieve the card from the cardholder – the credit card has expired.
279
+ when '3050' then STANDARD_ERROR_CODE[:card_declined] # The bank has requested that you retrieve the card from the cardholder – fraudulent activity is suspected.
280
+ when '3051' then STANDARD_ERROR_CODE[:card_declined] # The bank has requested that you retrieve the card from the cardholder – contact the acquirer for more information.
281
+ when '3052' then STANDARD_ERROR_CODE[:card_declined] # The bank has requested that you retrieve the card from the cardholder – the credit card is restricted.
282
+ when '3053' then STANDARD_ERROR_CODE[:card_declined] # The bank has requested that you retrieve the card from the cardholder – please call the acquirer.
283
+ when '3054' then STANDARD_ERROR_CODE[:card_declined] # The transaction was declined due to suspected fraud.
284
+ else STANDARD_ERROR_CODE[:processing_error]
285
285
  end
286
286
  end
287
287
  end