activemerchant 1.130.0 → 1.137.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (184) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG +268 -0
  3. data/lib/active_merchant/billing/check.rb +2 -2
  4. data/lib/active_merchant/billing/compatibility.rb +4 -4
  5. data/lib/active_merchant/billing/credit_card.rb +13 -8
  6. data/lib/active_merchant/billing/credit_card_formatting.rb +4 -0
  7. data/lib/active_merchant/billing/credit_card_methods.rb +64 -7
  8. data/lib/active_merchant/billing/gateway.rb +9 -0
  9. data/lib/active_merchant/billing/gateways/adyen.rb +240 -41
  10. data/lib/active_merchant/billing/gateways/airwallex.rb +26 -12
  11. data/lib/active_merchant/billing/gateways/alelo.rb +23 -5
  12. data/lib/active_merchant/billing/gateways/authorize_net.rb +44 -36
  13. data/lib/active_merchant/billing/gateways/authorize_net_arb.rb +10 -6
  14. data/lib/active_merchant/billing/gateways/authorize_net_cim.rb +1 -3
  15. data/lib/active_merchant/billing/gateways/axcessms.rb +6 -2
  16. data/lib/active_merchant/billing/gateways/banwire.rb +4 -2
  17. data/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb +7 -3
  18. data/lib/active_merchant/billing/gateways/blue_pay.rb +13 -5
  19. data/lib/active_merchant/billing/gateways/blue_snap.rb +5 -5
  20. data/lib/active_merchant/billing/gateways/borgun.rb +6 -4
  21. data/lib/active_merchant/billing/gateways/braintree/token_nonce.rb +65 -20
  22. data/lib/active_merchant/billing/gateways/braintree_blue.rb +226 -73
  23. data/lib/active_merchant/billing/gateways/braintree_orange.rb +1 -1
  24. data/lib/active_merchant/billing/gateways/card_connect.rb +5 -2
  25. data/lib/active_merchant/billing/gateways/card_stream.rb +4 -6
  26. data/lib/active_merchant/billing/gateways/cashnet.rb +1 -1
  27. data/lib/active_merchant/billing/gateways/cecabank/cecabank_common.rb +36 -0
  28. data/lib/active_merchant/billing/gateways/cecabank/cecabank_json.rb +316 -0
  29. data/lib/active_merchant/billing/gateways/cecabank/cecabank_xml.rb +220 -0
  30. data/lib/active_merchant/billing/gateways/cecabank.rb +7 -240
  31. data/lib/active_merchant/billing/gateways/checkout_v2.rb +252 -41
  32. data/lib/active_merchant/billing/gateways/commerce_hub.rb +69 -8
  33. data/lib/active_merchant/billing/gateways/credorax.rb +3 -5
  34. data/lib/active_merchant/billing/gateways/cyber_source.rb +192 -41
  35. data/lib/active_merchant/billing/gateways/cyber_source_rest.rb +102 -58
  36. data/lib/active_merchant/billing/gateways/d_local.rb +26 -15
  37. data/lib/active_merchant/billing/gateways/data_cash.rb +21 -17
  38. data/lib/active_merchant/billing/gateways/datatrans.rb +279 -0
  39. data/lib/active_merchant/billing/gateways/decidir.rb +53 -18
  40. data/lib/active_merchant/billing/gateways/decidir_plus.rb +4 -1
  41. data/lib/active_merchant/billing/gateways/deepstack.rb +382 -0
  42. data/lib/active_merchant/billing/gateways/ebanx.rb +40 -36
  43. data/lib/active_merchant/billing/gateways/efsnet.rb +6 -2
  44. data/lib/active_merchant/billing/gateways/elavon.rb +99 -33
  45. data/lib/active_merchant/billing/gateways/element.rb +36 -7
  46. data/lib/active_merchant/billing/gateways/epay.rb +6 -2
  47. data/lib/active_merchant/billing/gateways/evo_ca.rb +6 -2
  48. data/lib/active_merchant/billing/gateways/eway.rb +4 -2
  49. data/lib/active_merchant/billing/gateways/eway_managed.rb +6 -2
  50. data/lib/active_merchant/billing/gateways/exact.rb +6 -2
  51. data/lib/active_merchant/billing/gateways/fat_zebra.rb +31 -3
  52. data/lib/active_merchant/billing/gateways/federated_canada.rb +6 -2
  53. data/lib/active_merchant/billing/gateways/first_pay/first_pay_common.rb +15 -0
  54. data/lib/active_merchant/billing/gateways/first_pay/first_pay_json.rb +190 -0
  55. data/lib/active_merchant/billing/gateways/first_pay/first_pay_xml.rb +183 -0
  56. data/lib/active_merchant/billing/gateways/first_pay.rb +6 -172
  57. data/lib/active_merchant/billing/gateways/firstdata_e4.rb +6 -2
  58. data/lib/active_merchant/billing/gateways/firstdata_e4_v27.rb +7 -3
  59. data/lib/active_merchant/billing/gateways/flex_charge.rb +347 -0
  60. data/lib/active_merchant/billing/gateways/garanti.rb +4 -2
  61. data/lib/active_merchant/billing/gateways/global_collect.rb +45 -37
  62. data/lib/active_merchant/billing/gateways/hi_pay.rb +286 -0
  63. data/lib/active_merchant/billing/gateways/hps.rb +1 -1
  64. data/lib/active_merchant/billing/gateways/iats_payments.rb +7 -2
  65. data/lib/active_merchant/billing/gateways/inspire.rb +6 -4
  66. data/lib/active_merchant/billing/gateways/instapay.rb +7 -4
  67. data/lib/active_merchant/billing/gateways/ipg.rb +10 -6
  68. data/lib/active_merchant/billing/gateways/iridium.rb +15 -5
  69. data/lib/active_merchant/billing/gateways/itransact.rb +6 -2
  70. data/lib/active_merchant/billing/gateways/iveri.rb +3 -3
  71. data/lib/active_merchant/billing/gateways/ixopay.rb +2 -2
  72. data/lib/active_merchant/billing/gateways/jetpay.rb +4 -2
  73. data/lib/active_merchant/billing/gateways/jetpay_v2.rb +4 -2
  74. data/lib/active_merchant/billing/gateways/kushki.rb +73 -13
  75. data/lib/active_merchant/billing/gateways/linkpoint.rb +6 -2
  76. data/lib/active_merchant/billing/gateways/litle.rb +33 -50
  77. data/lib/active_merchant/billing/gateways/mastercard.rb +4 -4
  78. data/lib/active_merchant/billing/gateways/maxipago.rb +2 -2
  79. data/lib/active_merchant/billing/gateways/merchant_e_solutions.rb +8 -5
  80. data/lib/active_merchant/billing/gateways/merchant_ware.rb +11 -4
  81. data/lib/active_merchant/billing/gateways/merchant_ware_version_four.rb +11 -4
  82. data/lib/active_merchant/billing/gateways/merchant_warrior.rb +19 -3
  83. data/lib/active_merchant/billing/gateways/mercury.rb +6 -2
  84. data/lib/active_merchant/billing/gateways/metrics_global.rb +8 -6
  85. data/lib/active_merchant/billing/gateways/migs/migs_codes.rb +1 -0
  86. data/lib/active_merchant/billing/gateways/migs.rb +6 -2
  87. data/lib/active_merchant/billing/gateways/mit.rb +25 -20
  88. data/lib/active_merchant/billing/gateways/modern_payments_cim.rb +18 -10
  89. data/lib/active_merchant/billing/gateways/monei.rb +1 -1
  90. data/lib/active_merchant/billing/gateways/moneris.rb +9 -3
  91. data/lib/active_merchant/billing/gateways/money_movers.rb +6 -2
  92. data/lib/active_merchant/billing/gateways/nab_transact.rb +12 -4
  93. data/lib/active_merchant/billing/gateways/net_registry.rb +6 -2
  94. data/lib/active_merchant/billing/gateways/netbanx.rb +1 -3
  95. data/lib/active_merchant/billing/gateways/netbilling.rb +6 -2
  96. data/lib/active_merchant/billing/gateways/network_merchants.rb +6 -2
  97. data/lib/active_merchant/billing/gateways/nmi.rb +23 -6
  98. data/lib/active_merchant/billing/gateways/ogone.rb +6 -2
  99. data/lib/active_merchant/billing/gateways/openpay.rb +4 -2
  100. data/lib/active_merchant/billing/gateways/opp.rb +1 -2
  101. data/lib/active_merchant/billing/gateways/optimal_payment.rb +6 -2
  102. data/lib/active_merchant/billing/gateways/orbital/orbital_soft_descriptors.rb +1 -3
  103. data/lib/active_merchant/billing/gateways/orbital.rb +83 -24
  104. data/lib/active_merchant/billing/gateways/pac_net_raven.rb +7 -4
  105. data/lib/active_merchant/billing/gateways/pay_gate_xml.rb +6 -2
  106. data/lib/active_merchant/billing/gateways/pay_hub.rb +4 -2
  107. data/lib/active_merchant/billing/gateways/pay_junction.rb +6 -2
  108. data/lib/active_merchant/billing/gateways/pay_secure.rb +6 -2
  109. data/lib/active_merchant/billing/gateways/pay_trace.rb +31 -18
  110. data/lib/active_merchant/billing/gateways/payeezy.rb +19 -8
  111. data/lib/active_merchant/billing/gateways/payex.rb +4 -2
  112. data/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb +1 -1
  113. data/lib/active_merchant/billing/gateways/payflow.rb +1 -3
  114. data/lib/active_merchant/billing/gateways/payment_express.rb +8 -4
  115. data/lib/active_merchant/billing/gateways/paymentez.rb +23 -11
  116. data/lib/active_merchant/billing/gateways/paysafe.rb +12 -11
  117. data/lib/active_merchant/billing/gateways/payscout.rb +7 -4
  118. data/lib/active_merchant/billing/gateways/paystation.rb +7 -3
  119. data/lib/active_merchant/billing/gateways/payway.rb +6 -2
  120. data/lib/active_merchant/billing/gateways/payway_dot_com.rb +3 -3
  121. data/lib/active_merchant/billing/gateways/pin.rb +22 -4
  122. data/lib/active_merchant/billing/gateways/plexo.rb +49 -10
  123. data/lib/active_merchant/billing/gateways/plugnpay.rb +6 -2
  124. data/lib/active_merchant/billing/gateways/priority.rb +6 -5
  125. data/lib/active_merchant/billing/gateways/psigate.rb +6 -2
  126. data/lib/active_merchant/billing/gateways/psl_card.rb +6 -2
  127. data/lib/active_merchant/billing/gateways/qbms.rb +6 -2
  128. data/lib/active_merchant/billing/gateways/quantum.rb +6 -2
  129. data/lib/active_merchant/billing/gateways/quickbooks.rb +6 -5
  130. data/lib/active_merchant/billing/gateways/quickpay/quickpay_v10.rb +7 -4
  131. data/lib/active_merchant/billing/gateways/quickpay/quickpay_v4to7.rb +6 -2
  132. data/lib/active_merchant/billing/gateways/rapyd.rb +148 -46
  133. data/lib/active_merchant/billing/gateways/reach.rb +11 -4
  134. data/lib/active_merchant/billing/gateways/redsys.rb +3 -11
  135. data/lib/active_merchant/billing/gateways/redsys_rest.rb +507 -0
  136. data/lib/active_merchant/billing/gateways/s5.rb +3 -3
  137. data/lib/active_merchant/billing/gateways/safe_charge.rb +38 -17
  138. data/lib/active_merchant/billing/gateways/sage.rb +12 -4
  139. data/lib/active_merchant/billing/gateways/sage_pay.rb +79 -5
  140. data/lib/active_merchant/billing/gateways/sallie_mae.rb +6 -2
  141. data/lib/active_merchant/billing/gateways/secure_net.rb +6 -2
  142. data/lib/active_merchant/billing/gateways/secure_pay.rb +8 -6
  143. data/lib/active_merchant/billing/gateways/secure_pay_au.rb +12 -4
  144. data/lib/active_merchant/billing/gateways/secure_pay_tech.rb +6 -2
  145. data/lib/active_merchant/billing/gateways/securion_pay.rb +24 -10
  146. data/lib/active_merchant/billing/gateways/shift4.rb +17 -20
  147. data/lib/active_merchant/billing/gateways/shift4_v2.rb +117 -0
  148. data/lib/active_merchant/billing/gateways/simetrik.rb +17 -11
  149. data/lib/active_merchant/billing/gateways/skip_jack.rb +6 -2
  150. data/lib/active_merchant/billing/gateways/smart_ps.rb +7 -4
  151. data/lib/active_merchant/billing/gateways/so_easy_pay.rb +4 -2
  152. data/lib/active_merchant/billing/gateways/spreedly_core.rb +2 -4
  153. data/lib/active_merchant/billing/gateways/stripe.rb +63 -19
  154. data/lib/active_merchant/billing/gateways/stripe_payment_intents.rb +280 -88
  155. data/lib/active_merchant/billing/gateways/sum_up.rb +223 -0
  156. data/lib/active_merchant/billing/gateways/swipe_checkout.rb +4 -2
  157. data/lib/active_merchant/billing/gateways/telr.rb +3 -4
  158. data/lib/active_merchant/billing/gateways/trans_first.rb +1 -2
  159. data/lib/active_merchant/billing/gateways/trans_first_transaction_express.rb +8 -16
  160. data/lib/active_merchant/billing/gateways/transact_pro.rb +1 -1
  161. data/lib/active_merchant/billing/gateways/trust_commerce.rb +6 -2
  162. data/lib/active_merchant/billing/gateways/usa_epay_advanced.rb +9 -8
  163. data/lib/active_merchant/billing/gateways/usa_epay_transaction.rb +6 -2
  164. data/lib/active_merchant/billing/gateways/vanco.rb +2 -4
  165. data/lib/active_merchant/billing/gateways/vantiv_express.rb +587 -0
  166. data/lib/active_merchant/billing/gateways/verifi.rb +6 -2
  167. data/lib/active_merchant/billing/gateways/viaklix.rb +6 -2
  168. data/lib/active_merchant/billing/gateways/visanet_peru.rb +2 -2
  169. data/lib/active_merchant/billing/gateways/vpos.rb +4 -4
  170. data/lib/active_merchant/billing/gateways/wirecard.rb +7 -3
  171. data/lib/active_merchant/billing/gateways/wompi.rb +5 -0
  172. data/lib/active_merchant/billing/gateways/worldpay.rb +147 -93
  173. data/lib/active_merchant/billing/gateways/worldpay_online_payments.rb +13 -10
  174. data/lib/active_merchant/billing/gateways/xpay.rb +242 -0
  175. data/lib/active_merchant/billing/network_tokenization_credit_card.rb +1 -1
  176. data/lib/active_merchant/billing/response.rb +2 -2
  177. data/lib/active_merchant/connection.rb +3 -17
  178. data/lib/active_merchant/country.rb +1 -0
  179. data/lib/active_merchant/errors.rb +10 -0
  180. data/lib/active_merchant/version.rb +1 -1
  181. data/lib/support/gateway_support.rb +2 -2
  182. data/lib/support/ssl_verify.rb +4 -4
  183. data/lib/support/ssl_version.rb +6 -6
  184. metadata +30 -9
@@ -34,7 +34,7 @@ module ActiveMerchant #:nodoc:
34
34
  28 => :card_declined
35
35
  }.freeze
36
36
 
37
- SUCCESS_STATUS = ['success', 'pending', 1, 0]
37
+ SUCCESS_STATUS = ['APPROVED', 'PENDING', 'pending', 'success', 1, 0]
38
38
 
39
39
  CARD_MAPPING = {
40
40
  'visa' => 'vi',
@@ -218,7 +218,7 @@ module ActiveMerchant #:nodoc:
218
218
  xid: three_d_secure_options[:xid],
219
219
  eci: three_d_secure_options[:eci],
220
220
  version: three_d_secure_options[:version],
221
- reference_id: three_d_secure_options[:three_ds_server_trans_id],
221
+ reference_id: three_d_secure_options[:ds_transaction_id],
222
222
  status: three_d_secure_options[:authentication_response_status] || three_d_secure_options[:directory_response_status]
223
223
  }.compact
224
224
 
@@ -237,14 +237,14 @@ module ActiveMerchant #:nodoc:
237
237
 
238
238
  def commit_raw(object, action, parameters)
239
239
  if action == 'inquire'
240
- url = "#{(test? ? test_url : live_url)}#{object}/#{parameters}"
240
+ url = "#{test? ? test_url : live_url}#{object}/#{parameters}"
241
241
  begin
242
242
  raw_response = ssl_get(url, headers)
243
243
  rescue ResponseError => e
244
244
  raw_response = e.response.body
245
245
  end
246
246
  else
247
- url = "#{(test? ? test_url : live_url)}#{object}/#{action}"
247
+ url = "#{test? ? test_url : live_url}#{object}/#{action}"
248
248
  begin
249
249
  raw_response = ssl_post(url, post_data(parameters), headers)
250
250
  rescue ResponseError => e
@@ -262,7 +262,7 @@ module ActiveMerchant #:nodoc:
262
262
  def commit_transaction(action, parameters)
263
263
  response = commit_raw('transaction', action, parameters)
264
264
  Response.new(
265
- success_from(response),
265
+ success_from(response, action),
266
266
  message_from(response),
267
267
  response,
268
268
  authorization: authorization_from(response),
@@ -290,10 +290,22 @@ module ActiveMerchant #:nodoc:
290
290
  }
291
291
  end
292
292
 
293
- def success_from(response)
294
- return false if response.include?('error')
293
+ def success_from(response, action = nil)
294
+ transaction_current_status = response.dig('transaction', 'current_status')
295
+ request_status = response['status']
296
+ transaction_status = response.dig('transaction', 'status')
297
+ default_response = SUCCESS_STATUS.include?(transaction_current_status || request_status || transaction_status)
295
298
 
296
- SUCCESS_STATUS.include?(response['status'] || response['transaction']['status'])
299
+ case action
300
+ when 'refund'
301
+ if transaction_current_status && request_status
302
+ transaction_current_status&.upcase == 'CANCELLED' && request_status&.downcase == 'success'
303
+ else
304
+ default_response
305
+ end
306
+ else
307
+ default_response
308
+ end
297
309
  end
298
310
 
299
311
  def card_success_from(response)
@@ -314,10 +326,10 @@ module ActiveMerchant #:nodoc:
314
326
  end
315
327
 
316
328
  def card_message_from(response)
317
- if !response.include?('error')
318
- response['message'] || response['card']['message']
319
- else
329
+ if response.include?('error')
320
330
  response['error']['type']
331
+ else
332
+ response['message'] || response['card']['message']
321
333
  end
322
334
  end
323
335
 
@@ -124,12 +124,13 @@ module ActiveMerchant #:nodoc:
124
124
  return unless address = options[:billing_address] || options[:address]
125
125
 
126
126
  post[:billingDetails] = {}
127
- post[:billingDetails][:street] = address[:address1]
128
- post[:billingDetails][:city] = address[:city]
129
- post[:billingDetails][:state] = address[:state]
127
+ post[:billingDetails][:street] = truncate(address[:address1], 50)
128
+ post[:billingDetails][:street2] = truncate(address[:address2], 50)
129
+ post[:billingDetails][:city] = truncate(address[:city], 40)
130
+ post[:billingDetails][:state] = truncate(address[:state], 40)
130
131
  post[:billingDetails][:country] = address[:country]
131
- post[:billingDetails][:zip] = address[:zip]
132
- post[:billingDetails][:phone] = address[:phone]
132
+ post[:billingDetails][:zip] = truncate(address[:zip], 10)
133
+ post[:billingDetails][:phone] = truncate(address[:phone], 40)
133
134
  end
134
135
 
135
136
  # The add_address_for_vaulting method is applicable to the store method, as the APIs address
@@ -138,12 +139,12 @@ module ActiveMerchant #:nodoc:
138
139
  return unless address = options[:billing_address] || options[:address]
139
140
 
140
141
  post[:card][:billingAddress] = {}
141
- post[:card][:billingAddress][:street] = address[:address1]
142
- post[:card][:billingAddress][:street2] = address[:address2]
143
- post[:card][:billingAddress][:city] = address[:city]
144
- post[:card][:billingAddress][:zip] = address[:zip]
142
+ post[:card][:billingAddress][:street] = truncate(address[:address1], 50)
143
+ post[:card][:billingAddress][:street2] = truncate(address[:address2], 50)
144
+ post[:card][:billingAddress][:city] = truncate(address[:city], 40)
145
+ post[:card][:billingAddress][:zip] = truncate(address[:zip], 10)
145
146
  post[:card][:billingAddress][:country] = address[:country]
146
- post[:card][:billingAddress][:state] = address[:state] if address[:state]
147
+ post[:card][:billingAddress][:state] = truncate(address[:state], 40) if address[:state]
147
148
  end
148
149
 
149
150
  # This data is specific to creating a profile at the gateway's vault level
@@ -401,7 +402,7 @@ module ActiveMerchant #:nodoc:
401
402
  def post_data(parameters = {}, options = {})
402
403
  return unless parameters.present?
403
404
 
404
- parameters[:merchantRefNum] = options[:merchant_ref_num] || SecureRandom.hex(16).to_s
405
+ parameters[:merchantRefNum] = options[:merchant_ref_num] || options[:order_id] || SecureRandom.hex(16).to_s
405
406
 
406
407
  parameters.to_json
407
408
  end
@@ -115,12 +115,16 @@ module ActiveMerchant #:nodoc:
115
115
 
116
116
  message = message_from(response)
117
117
  test_mode = (test? || message =~ /TESTMODE/)
118
- Response.new(success?(response), message, response,
118
+ Response.new(
119
+ success?(response),
120
+ message,
121
+ response,
119
122
  test: test_mode,
120
123
  authorization: response['transactionid'],
121
124
  fraud_review: fraud_review?(response),
122
125
  avs_result: { code: response['avsresponse'] },
123
- cvv_result: response['cvvresponse'])
126
+ cvv_result: response['cvvresponse']
127
+ )
124
128
  end
125
129
 
126
130
  def message_from(response)
@@ -151,8 +155,7 @@ module ActiveMerchant #:nodoc:
151
155
  post[:password] = @options[:password]
152
156
  post[:type] = action
153
157
 
154
- request = post.merge(parameters).collect { |key, value| "#{key}=#{CGI.escape(value.to_s)}" }.join('&')
155
- request
158
+ post.merge(parameters).collect { |key, value| "#{key}=#{CGI.escape(value.to_s)}" }.join('&')
156
159
  end
157
160
  end
158
161
  end
@@ -177,9 +177,13 @@ module ActiveMerchant #:nodoc:
177
177
  response = parse(data)
178
178
  message = message_from(response)
179
179
 
180
- PaystationResponse.new(success?(response), message, response,
181
- test: (response[:tm]&.casecmp('t')&.zero?),
182
- authorization: response[:paystation_transaction_id])
180
+ PaystationResponse.new(
181
+ success?(response),
182
+ message,
183
+ response,
184
+ test: response[:tm]&.casecmp('t')&.zero?,
185
+ authorization: response[:paystation_transaction_id]
186
+ )
183
187
  end
184
188
 
185
189
  def success?(response)
@@ -192,9 +192,13 @@ module ActiveMerchant
192
192
 
193
193
  success = (params[:summary_code] ? (params[:summary_code] == '0') : (params[:response_code] == '00'))
194
194
 
195
- Response.new(success, message, params,
195
+ Response.new(
196
+ success,
197
+ message,
198
+ params,
196
199
  test: (@options[:merchant].to_s == 'TEST'),
197
- authorization: post[:order_number])
200
+ authorization: post[:order_number]
201
+ )
198
202
  rescue ActiveMerchant::ResponseError => e
199
203
  raise unless e.response.code == '403'
200
204
 
@@ -2,7 +2,7 @@ module ActiveMerchant #:nodoc:
2
2
  module Billing #:nodoc:
3
3
  class PaywayDotComGateway < Gateway
4
4
  self.test_url = 'https://paywaywsdev.com/PaywayWS/Payment/CreditCard'
5
- self.live_url = 'https://paywayws.com/PaywayWS/Payment/CreditCard'
5
+ self.live_url = 'https://paywayws.net/PaywayWS/Payment/CreditCard'
6
6
 
7
7
  self.supported_countries = %w[US CA]
8
8
  self.default_currency = 'USD'
@@ -48,7 +48,7 @@ module ActiveMerchant #:nodoc:
48
48
  'I5' => 'M', # +4 and Address Match
49
49
  'I6' => 'W', # +4 Match
50
50
  'I7' => 'A', # Address Match
51
- 'I8' => 'C', # No Match
51
+ 'I8' => 'C' # No Match
52
52
  }
53
53
 
54
54
  PAYWAY_WS_SUCCESS = '5000'
@@ -224,7 +224,7 @@ module ActiveMerchant #:nodoc:
224
224
  def error_code_from(response)
225
225
  return '' if success_from(response)
226
226
 
227
- error = !STANDARD_ERROR_CODE_MAPPING[response['paywayCode']].nil? ? STANDARD_ERROR_CODE_MAPPING[response['paywayCode']] : STANDARD_ERROR_CODE[:processing_error]
227
+ error = STANDARD_ERROR_CODE_MAPPING[response['paywayCode']].nil? ? STANDARD_ERROR_CODE[:processing_error] : STANDARD_ERROR_CODE_MAPPING[response['paywayCode']]
228
228
  return error
229
229
  end
230
230
 
@@ -31,6 +31,7 @@ module ActiveMerchant #:nodoc:
31
31
  add_capture(post, options)
32
32
  add_metadata(post, options)
33
33
  add_3ds(post, options)
34
+ add_platform_adjustment(post, options)
34
35
 
35
36
  commit(:post, 'charges', post, options)
36
37
  end
@@ -81,6 +82,11 @@ module ActiveMerchant #:nodoc:
81
82
  commit(:put, "charges/#{CGI.escape(token)}/void", {}, options)
82
83
  end
83
84
 
85
+ # Verify a previously authorized charge.
86
+ def verify_3ds(session_token, options = {})
87
+ commit(:get, "/charges/verify?session_token=#{session_token}", nil, options)
88
+ end
89
+
84
90
  # Updates the credit card for the customer.
85
91
  def update(token, creditcard, options = {})
86
92
  post = {}
@@ -175,13 +181,23 @@ module ActiveMerchant #:nodoc:
175
181
  post[:metadata] = options[:metadata] if options[:metadata]
176
182
  end
177
183
 
184
+ def add_platform_adjustment(post, options)
185
+ post[:platform_adjustment] = options[:platform_adjustment] if options[:platform_adjustment]
186
+ end
187
+
178
188
  def add_3ds(post, options)
179
189
  if options[:three_d_secure]
180
190
  post[:three_d_secure] = {}
181
- post[:three_d_secure][:version] = options[:three_d_secure][:version] if options[:three_d_secure][:version]
182
- post[:three_d_secure][:eci] = options[:three_d_secure][:eci] if options[:three_d_secure][:eci]
183
- post[:three_d_secure][:cavv] = options[:three_d_secure][:cavv] if options[:three_d_secure][:cavv]
184
- post[:three_d_secure][:transaction_id] = options[:three_d_secure][:ds_transaction_id] || options[:three_d_secure][:xid]
191
+ if options[:three_d_secure][:enabled]
192
+ post[:three_d_secure][:enabled] = true
193
+ post[:three_d_secure][:fallback_ok] = options[:three_d_secure][:fallback_ok] unless options[:three_d_secure][:fallback_ok].nil?
194
+ post[:three_d_secure][:callback_url] = options[:three_d_secure][:callback_url] if options[:three_d_secure][:callback_url]
195
+ else
196
+ post[:three_d_secure][:version] = options[:three_d_secure][:version] if options[:three_d_secure][:version]
197
+ post[:three_d_secure][:eci] = options[:three_d_secure][:eci] if options[:three_d_secure][:eci]
198
+ post[:three_d_secure][:cavv] = options[:three_d_secure][:cavv] if options[:three_d_secure][:cavv]
199
+ post[:three_d_secure][:transaction_id] = options[:three_d_secure][:ds_transaction_id] || options[:three_d_secure][:xid]
200
+ end
185
201
  end
186
202
  end
187
203
 
@@ -266,6 +282,8 @@ module ActiveMerchant #:nodoc:
266
282
  end
267
283
 
268
284
  def post_data(parameters = {})
285
+ return nil unless parameters
286
+
269
287
  parameters.to_json
270
288
  end
271
289
  end
@@ -67,6 +67,7 @@ module ActiveMerchant #:nodoc:
67
67
  def verify(credit_card, options = {})
68
68
  post = {}
69
69
  post[:ReferenceId] = options[:reference_id] || generate_unique_id
70
+ post[:Flow] = 'direct'
70
71
  post[:MerchantId] = options[:merchant_id] || @credentials[:merchant_id]
71
72
  post[:StatementDescriptor] = options[:statement_descriptor] if options[:statement_descriptor]
72
73
  post[:CustomerId] = options[:customer_id] if options[:customer_id]
@@ -76,6 +77,7 @@ module ActiveMerchant #:nodoc:
76
77
  add_metadata(post, options[:metadata])
77
78
  add_amount(money, post, options)
78
79
  add_browser_details(post, options)
80
+ add_invoice_number(post, options)
79
81
 
80
82
  commit('/verify', post, options)
81
83
  end
@@ -90,7 +92,8 @@ module ActiveMerchant #:nodoc:
90
92
  gsub(%r(("Number\\?"\s*:\s*\\?")[^"]*)i, '\1[FILTERED]').
91
93
  gsub(%r(("Cvc\\?"\s*:\s*\\?")[^"]*)i, '\1[FILTERED]').
92
94
  gsub(%r(("InvoiceNumber\\?"\s*:\s*\\?")[^"]*)i, '\1[FILTERED]').
93
- gsub(%r(("MerchantId\\?"\s*:\s*\\?")[^"]*)i, '\1[FILTERED]')
95
+ gsub(%r(("MerchantId\\?"\s*:\s*\\?")[^"]*)i, '\1[FILTERED]').
96
+ gsub(%r(("Cryptogram\\?"\s*:\s*\\?")[^"]*)i, '\1[FILTERED]')
94
97
  end
95
98
 
96
99
  private
@@ -105,12 +108,14 @@ module ActiveMerchant #:nodoc:
105
108
  post[:Installments] = options[:installments] if options[:installments]
106
109
  post[:StatementDescriptor] = options[:statement_descriptor] if options[:statement_descriptor]
107
110
  post[:CustomerId] = options[:customer_id] if options[:customer_id]
111
+ post[:Flow] = 'direct'
108
112
 
109
113
  add_payment_method(post, payment, options)
110
114
  add_items(post, options[:items])
111
115
  add_metadata(post, options[:metadata])
112
116
  add_amount(money, post, options)
113
117
  add_browser_details(post, options)
118
+ add_invoice_number(post, options)
114
119
  end
115
120
 
116
121
  def header(parameters = {})
@@ -186,21 +191,55 @@ module ActiveMerchant #:nodoc:
186
191
  post[:BrowserDetails][:IpAddress] = browser_details[:ip] if browser_details[:ip]
187
192
  end
188
193
 
194
+ def add_invoice_number(post, options)
195
+ post[:InvoiceNumber] = options[:invoice_number] if options[:invoice_number]
196
+ end
197
+
189
198
  def add_payment_method(post, payment, options)
190
- post[:paymentMethod] = {}
199
+ payment_method = build_payment_method(payment)
191
200
 
192
- if payment&.is_a?(CreditCard)
193
- post[:paymentMethod][:type] = 'card'
194
- post[:paymentMethod][:Card] = {}
195
- post[:paymentMethod][:Card][:Number] = payment.number
196
- post[:paymentMethod][:Card][:ExpMonth] = format(payment.month, :two_digits) if payment.month
197
- post[:paymentMethod][:Card][:ExpYear] = format(payment.year, :two_digits) if payment.year
198
- post[:paymentMethod][:Card][:Cvc] = payment.verification_value if payment.verification_value
201
+ if payment_method.present?
202
+ add_card_holder(payment_method[:NetworkToken] || payment_method[:Card], payment, options)
203
+ post[:paymentMethod] = payment_method
204
+ end
205
+ end
199
206
 
200
- add_card_holder(post[:paymentMethod][:Card], payment, options)
207
+ def build_payment_method(payment)
208
+ case payment
209
+ when NetworkTokenizationCreditCard
210
+ {
211
+ source: 'network-token',
212
+ id: payment.brand,
213
+ NetworkToken: {
214
+ Number: payment.number,
215
+ Bin: get_last_eight_digits(payment.number),
216
+ Last4: get_last_four_digits(payment.number),
217
+ ExpMonth: (format(payment.month, :two_digits) if payment.month),
218
+ ExpYear: (format(payment.year, :two_digits) if payment.year),
219
+ Cryptogram: payment.payment_cryptogram
220
+ }
221
+ }
222
+ when CreditCard
223
+ {
224
+ type: 'card',
225
+ Card: {
226
+ Number: payment.number,
227
+ ExpMonth: (format(payment.month, :two_digits) if payment.month),
228
+ ExpYear: (format(payment.year, :two_digits) if payment.year),
229
+ Cvc: payment.verification_value
230
+ }
231
+ }
201
232
  end
202
233
  end
203
234
 
235
+ def get_last_eight_digits(number)
236
+ number[-8..-1]
237
+ end
238
+
239
+ def get_last_four_digits(number)
240
+ number[-4..-1]
241
+ end
242
+
204
243
  def add_card_holder(card, payment, options)
205
244
  requires!(options, :email)
206
245
 
@@ -178,11 +178,15 @@ module ActiveMerchant
178
178
  success = SUCCESS_CODES.include?(response[:finalstatus])
179
179
  message = success ? 'Success' : message_from(response)
180
180
 
181
- Response.new(success, message, response,
181
+ Response.new(
182
+ success,
183
+ message,
184
+ response,
182
185
  test: test?,
183
186
  authorization: response[:orderid],
184
187
  avs_result: { code: response[:avs_code] },
185
- cvv_result: response[:cvvresp])
188
+ cvv_result: response[:cvvresp]
189
+ )
186
190
  end
187
191
 
188
192
  def parse(body)
@@ -55,7 +55,8 @@ module ActiveMerchant #:nodoc:
55
55
 
56
56
  add_merchant_id(params)
57
57
  add_amount(params, amount, options)
58
- add_auth_purchase_params(params, credit_card, options)
58
+ add_auth_purchase_params(params, options)
59
+ add_credit_card(params, credit_card, 'purchase', options)
59
60
 
60
61
  commit('purchase', params: params)
61
62
  end
@@ -67,7 +68,8 @@ module ActiveMerchant #:nodoc:
67
68
 
68
69
  add_merchant_id(params)
69
70
  add_amount(params, amount, options)
70
- add_auth_purchase_params(params, credit_card, options)
71
+ add_auth_purchase_params(params, options)
72
+ add_credit_card(params, credit_card, 'purchase', options)
71
73
 
72
74
  commit('purchase', params: params)
73
75
  end
@@ -100,7 +102,7 @@ module ActiveMerchant #:nodoc:
100
102
  add_merchant_id(params)
101
103
  add_amount(params, amount, options)
102
104
  params['paymentToken'] = payment_token(authorization) || options[:payment_token]
103
- params['tenderType'] = options[:tender_type].present? ? options[:tender_type] : 'Card'
105
+ add_auth_purchase_params(params, options)
104
106
 
105
107
  commit('capture', params: params)
106
108
  end
@@ -150,9 +152,8 @@ module ActiveMerchant #:nodoc:
150
152
  params['merchantId'] = @options[:merchant_id]
151
153
  end
152
154
 
153
- def add_auth_purchase_params(params, credit_card, options)
155
+ def add_auth_purchase_params(params, options)
154
156
  add_replay_id(params, options)
155
- add_credit_card(params, credit_card, 'purchase', options)
156
157
  add_purchases_data(params, options)
157
158
  add_shipping_data(params, options)
158
159
  add_pos_data(params, options)
@@ -102,11 +102,15 @@ module ActiveMerchant #:nodoc:
102
102
  def commit(money, creditcard, options = {})
103
103
  response = parse(ssl_post(url, post_data(money, creditcard, options)))
104
104
 
105
- Response.new(successful?(response), message_from(response), response,
105
+ Response.new(
106
+ successful?(response),
107
+ message_from(response),
108
+ response,
106
109
  test: test?,
107
110
  authorization: build_authorization(response),
108
111
  avs_result: { code: response[:avsresult] },
109
- cvv_result: response[:cardidresult])
112
+ cvv_result: response[:cardidresult]
113
+ )
110
114
  end
111
115
 
112
116
  def url
@@ -259,11 +259,15 @@ module ActiveMerchant
259
259
  def commit(request)
260
260
  response = parse(ssl_post(self.live_url, post_data(request)))
261
261
 
262
- Response.new(response[:ResponseCode] == APPROVED, response[:Message], response,
262
+ Response.new(
263
+ response[:ResponseCode] == APPROVED,
264
+ response[:Message],
265
+ response,
263
266
  test: test?,
264
267
  authorization: response[:CrossReference],
265
268
  cvv_result: CVV_CODE[response[:AVSCV2Check]],
266
- avs_result: { code: AVS_CODE[response[:AVSCV2Check]] })
269
+ avs_result: { code: AVS_CODE[response[:AVSCV2Check]] }
270
+ )
267
271
  end
268
272
 
269
273
  # Put the passed data into a format that can be submitted to PSL
@@ -142,12 +142,16 @@ module ActiveMerchant #:nodoc:
142
142
  response = parse(type, data)
143
143
  message = (response[:status_message] || '').strip
144
144
 
145
- Response.new(success?(response), message, response,
145
+ Response.new(
146
+ success?(response),
147
+ message,
148
+ response,
146
149
  test: test?,
147
150
  authorization: response[:credit_card_trans_id],
148
151
  fraud_review: fraud_review?(response),
149
152
  avs_result: { code: avs_result(response) },
150
- cvv_result: cvv_result(response))
153
+ cvv_result: cvv_result(response)
154
+ )
151
155
  end
152
156
 
153
157
  def success?(response)
@@ -215,11 +215,15 @@ module ActiveMerchant #:nodoc:
215
215
  authorization = success ? authorization_for(response) : nil
216
216
  end
217
217
 
218
- Response.new(success, message, response,
218
+ Response.new(
219
+ success,
220
+ message,
221
+ response,
219
222
  test: test?,
220
223
  authorization: authorization,
221
224
  avs_result: { code: response[:AVSResponseCode] },
222
- cvv_result: response[:CVV2ResponseCode])
225
+ cvv_result: response[:CVV2ResponseCode]
226
+ )
223
227
  end
224
228
 
225
229
  # Parse the SOAP response
@@ -42,10 +42,10 @@ module ActiveMerchant #:nodoc:
42
42
  'PMT-5001' => STANDARD_ERROR_CODE[:card_declined], # Merchant does not support given payment method
43
43
 
44
44
  # System Error
45
- 'PMT-6000' => STANDARD_ERROR_CODE[:processing_error], # A temporary Issue prevented this request from being processed.
45
+ 'PMT-6000' => STANDARD_ERROR_CODE[:processing_error] # A temporary Issue prevented this request from being processed.
46
46
  }
47
47
 
48
- FRAUD_WARNING_CODES = ['PMT-1000', 'PMT-1001', 'PMT-1002', 'PMT-1003']
48
+ FRAUD_WARNING_CODES = %w(PMT-1000 PMT-1001 PMT-1002 PMT-1003)
49
49
 
50
50
  def initialize(options = {})
51
51
  # Quickbooks is deprecating OAuth 1.0 on December 17, 2019.
@@ -128,8 +128,8 @@ module ActiveMerchant #:nodoc:
128
128
  gsub(%r((oauth_nonce=\")\w+), '\1[FILTERED]').
129
129
  gsub(%r((oauth_signature=\")[a-zA-Z%0-9]+), '\1[FILTERED]').
130
130
  gsub(%r((oauth_token=\")\w+), '\1[FILTERED]').
131
- gsub(%r((number\D+)\d{16}), '\1[FILTERED]').
132
- gsub(%r((cvc\D+)\d{3}), '\1[FILTERED]').
131
+ gsub(%r((number\\\":\\\")\d+), '\1[FILTERED]').
132
+ gsub(%r((cvc\\\":\\\")\d+), '\1[FILTERED]').
133
133
  gsub(%r((Authorization: Basic )\w+), '\1[FILTERED]').
134
134
  gsub(%r((access_token\\?":\\?")[\w\-\.]+)i, '\1[FILTERED]').
135
135
  gsub(%r((refresh_token\\?":\\?")\w+), '\1[FILTERED]').
@@ -263,7 +263,7 @@ module ActiveMerchant #:nodoc:
263
263
  oauth_parameters[:oauth_signature] = CGI.escape(Base64.encode64(hmac_signature).chomp.delete("\n"))
264
264
 
265
265
  # prepare Authorization header string
266
- oauth_parameters = Hash[oauth_parameters.sort_by { |k, _| k }]
266
+ oauth_parameters = oauth_parameters.sort_by { |k, _| k }.to_h
267
267
  oauth_headers = ["OAuth realm=\"#{@options[:realm]}\""]
268
268
  oauth_headers += oauth_parameters.map { |k, v| "#{k}=\"#{v}\"" }
269
269
 
@@ -358,6 +358,7 @@ module ActiveMerchant #:nodoc:
358
358
  rescue JSON::ParserError
359
359
  raise response_error
360
360
  end
361
+
361
362
  response_error.response.body
362
363
  end
363
364
 
@@ -153,9 +153,13 @@ module ActiveMerchant
153
153
  response = json_error(response)
154
154
  end
155
155
 
156
- Response.new(success, message_from(success, response), response,
156
+ Response.new(
157
+ success,
158
+ message_from(success, response),
159
+ response,
157
160
  test: test?,
158
- authorization: authorization_from(response))
161
+ authorization: authorization_from(response)
162
+ )
159
163
  end
160
164
 
161
165
  def authorization_from(response)
@@ -251,7 +255,7 @@ module ActiveMerchant
251
255
 
252
256
  requires!(address, :name, :address1, :city, :zip, :country)
253
257
  country = Country.find(address[:country])
254
- mapped = {
258
+ {
255
259
  name: address[:name],
256
260
  street: address[:address1],
257
261
  city: address[:city],
@@ -259,7 +263,6 @@ module ActiveMerchant
259
263
  zip_code: address[:zip],
260
264
  country_code: country.code(:alpha3).value
261
265
  }
262
- mapped
263
266
  end
264
267
 
265
268
  def format_order_id(order_id)
@@ -164,9 +164,13 @@ module ActiveMerchant #:nodoc:
164
164
  def commit(action, params)
165
165
  response = parse(ssl_post(self.live_url, post_data(action, params)))
166
166
 
167
- Response.new(successful?(response), message_from(response), response,
167
+ Response.new(
168
+ successful?(response),
169
+ message_from(response),
170
+ response,
168
171
  test: test?,
169
- authorization: response[:transaction])
172
+ authorization: response[:transaction]
173
+ )
170
174
  end
171
175
 
172
176
  def successful?(response)