activemerchant 1.133.0 → 1.137.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (183) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG +240 -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 +11 -8
  6. data/lib/active_merchant/billing/credit_card_formatting.rb +4 -0
  7. data/lib/active_merchant/billing/credit_card_methods.rb +59 -6
  8. data/lib/active_merchant/billing/gateway.rb +9 -0
  9. data/lib/active_merchant/billing/gateways/adyen.rb +162 -43
  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 +43 -35
  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/braintree/token_nonce.rb +65 -20
  21. data/lib/active_merchant/billing/gateways/braintree_blue.rb +226 -73
  22. data/lib/active_merchant/billing/gateways/braintree_orange.rb +1 -1
  23. data/lib/active_merchant/billing/gateways/card_connect.rb +5 -2
  24. data/lib/active_merchant/billing/gateways/card_stream.rb +4 -6
  25. data/lib/active_merchant/billing/gateways/cashnet.rb +1 -1
  26. data/lib/active_merchant/billing/gateways/cecabank/cecabank_common.rb +36 -0
  27. data/lib/active_merchant/billing/gateways/cecabank/cecabank_json.rb +316 -0
  28. data/lib/active_merchant/billing/gateways/cecabank/cecabank_xml.rb +220 -0
  29. data/lib/active_merchant/billing/gateways/cecabank.rb +7 -240
  30. data/lib/active_merchant/billing/gateways/checkout_v2.rb +238 -34
  31. data/lib/active_merchant/billing/gateways/commerce_hub.rb +63 -6
  32. data/lib/active_merchant/billing/gateways/credorax.rb +3 -5
  33. data/lib/active_merchant/billing/gateways/cyber_source.rb +185 -47
  34. data/lib/active_merchant/billing/gateways/cyber_source_rest.rb +102 -58
  35. data/lib/active_merchant/billing/gateways/d_local.rb +26 -15
  36. data/lib/active_merchant/billing/gateways/data_cash.rb +21 -17
  37. data/lib/active_merchant/billing/gateways/datatrans.rb +279 -0
  38. data/lib/active_merchant/billing/gateways/decidir.rb +53 -18
  39. data/lib/active_merchant/billing/gateways/decidir_plus.rb +4 -1
  40. data/lib/active_merchant/billing/gateways/deepstack.rb +382 -0
  41. data/lib/active_merchant/billing/gateways/ebanx.rb +40 -36
  42. data/lib/active_merchant/billing/gateways/efsnet.rb +6 -2
  43. data/lib/active_merchant/billing/gateways/elavon.rb +99 -33
  44. data/lib/active_merchant/billing/gateways/element.rb +36 -7
  45. data/lib/active_merchant/billing/gateways/epay.rb +6 -2
  46. data/lib/active_merchant/billing/gateways/evo_ca.rb +6 -2
  47. data/lib/active_merchant/billing/gateways/eway.rb +4 -2
  48. data/lib/active_merchant/billing/gateways/eway_managed.rb +6 -2
  49. data/lib/active_merchant/billing/gateways/exact.rb +6 -2
  50. data/lib/active_merchant/billing/gateways/fat_zebra.rb +31 -3
  51. data/lib/active_merchant/billing/gateways/federated_canada.rb +6 -2
  52. data/lib/active_merchant/billing/gateways/first_pay/first_pay_common.rb +15 -0
  53. data/lib/active_merchant/billing/gateways/first_pay/first_pay_json.rb +190 -0
  54. data/lib/active_merchant/billing/gateways/first_pay/first_pay_xml.rb +183 -0
  55. data/lib/active_merchant/billing/gateways/first_pay.rb +6 -172
  56. data/lib/active_merchant/billing/gateways/firstdata_e4.rb +6 -2
  57. data/lib/active_merchant/billing/gateways/firstdata_e4_v27.rb +7 -3
  58. data/lib/active_merchant/billing/gateways/flex_charge.rb +347 -0
  59. data/lib/active_merchant/billing/gateways/garanti.rb +4 -2
  60. data/lib/active_merchant/billing/gateways/global_collect.rb +45 -37
  61. data/lib/active_merchant/billing/gateways/hi_pay.rb +286 -0
  62. data/lib/active_merchant/billing/gateways/hps.rb +1 -1
  63. data/lib/active_merchant/billing/gateways/iats_payments.rb +7 -2
  64. data/lib/active_merchant/billing/gateways/inspire.rb +6 -4
  65. data/lib/active_merchant/billing/gateways/instapay.rb +7 -4
  66. data/lib/active_merchant/billing/gateways/ipg.rb +9 -5
  67. data/lib/active_merchant/billing/gateways/iridium.rb +15 -5
  68. data/lib/active_merchant/billing/gateways/itransact.rb +6 -2
  69. data/lib/active_merchant/billing/gateways/iveri.rb +3 -3
  70. data/lib/active_merchant/billing/gateways/ixopay.rb +2 -2
  71. data/lib/active_merchant/billing/gateways/jetpay.rb +4 -2
  72. data/lib/active_merchant/billing/gateways/jetpay_v2.rb +4 -2
  73. data/lib/active_merchant/billing/gateways/kushki.rb +72 -12
  74. data/lib/active_merchant/billing/gateways/linkpoint.rb +6 -2
  75. data/lib/active_merchant/billing/gateways/litle.rb +33 -50
  76. data/lib/active_merchant/billing/gateways/mastercard.rb +4 -4
  77. data/lib/active_merchant/billing/gateways/maxipago.rb +2 -2
  78. data/lib/active_merchant/billing/gateways/merchant_e_solutions.rb +8 -5
  79. data/lib/active_merchant/billing/gateways/merchant_ware.rb +11 -4
  80. data/lib/active_merchant/billing/gateways/merchant_ware_version_four.rb +11 -4
  81. data/lib/active_merchant/billing/gateways/merchant_warrior.rb +19 -3
  82. data/lib/active_merchant/billing/gateways/mercury.rb +6 -2
  83. data/lib/active_merchant/billing/gateways/metrics_global.rb +8 -6
  84. data/lib/active_merchant/billing/gateways/migs/migs_codes.rb +1 -0
  85. data/lib/active_merchant/billing/gateways/migs.rb +6 -2
  86. data/lib/active_merchant/billing/gateways/mit.rb +8 -3
  87. data/lib/active_merchant/billing/gateways/modern_payments_cim.rb +18 -10
  88. data/lib/active_merchant/billing/gateways/monei.rb +1 -1
  89. data/lib/active_merchant/billing/gateways/moneris.rb +9 -3
  90. data/lib/active_merchant/billing/gateways/money_movers.rb +6 -2
  91. data/lib/active_merchant/billing/gateways/nab_transact.rb +12 -4
  92. data/lib/active_merchant/billing/gateways/net_registry.rb +6 -2
  93. data/lib/active_merchant/billing/gateways/netbanx.rb +1 -3
  94. data/lib/active_merchant/billing/gateways/netbilling.rb +6 -2
  95. data/lib/active_merchant/billing/gateways/network_merchants.rb +6 -2
  96. data/lib/active_merchant/billing/gateways/nmi.rb +18 -6
  97. data/lib/active_merchant/billing/gateways/ogone.rb +6 -2
  98. data/lib/active_merchant/billing/gateways/openpay.rb +4 -2
  99. data/lib/active_merchant/billing/gateways/opp.rb +1 -2
  100. data/lib/active_merchant/billing/gateways/optimal_payment.rb +6 -2
  101. data/lib/active_merchant/billing/gateways/orbital/orbital_soft_descriptors.rb +1 -3
  102. data/lib/active_merchant/billing/gateways/orbital.rb +83 -24
  103. data/lib/active_merchant/billing/gateways/pac_net_raven.rb +7 -4
  104. data/lib/active_merchant/billing/gateways/pay_gate_xml.rb +6 -2
  105. data/lib/active_merchant/billing/gateways/pay_hub.rb +4 -2
  106. data/lib/active_merchant/billing/gateways/pay_junction.rb +6 -2
  107. data/lib/active_merchant/billing/gateways/pay_secure.rb +6 -2
  108. data/lib/active_merchant/billing/gateways/pay_trace.rb +31 -18
  109. data/lib/active_merchant/billing/gateways/payeezy.rb +19 -8
  110. data/lib/active_merchant/billing/gateways/payex.rb +4 -2
  111. data/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb +1 -1
  112. data/lib/active_merchant/billing/gateways/payflow.rb +1 -3
  113. data/lib/active_merchant/billing/gateways/payment_express.rb +8 -4
  114. data/lib/active_merchant/billing/gateways/paymentez.rb +23 -11
  115. data/lib/active_merchant/billing/gateways/paysafe.rb +12 -11
  116. data/lib/active_merchant/billing/gateways/payscout.rb +7 -4
  117. data/lib/active_merchant/billing/gateways/paystation.rb +7 -3
  118. data/lib/active_merchant/billing/gateways/payway.rb +6 -2
  119. data/lib/active_merchant/billing/gateways/payway_dot_com.rb +2 -2
  120. data/lib/active_merchant/billing/gateways/pin.rb +22 -4
  121. data/lib/active_merchant/billing/gateways/plexo.rb +49 -10
  122. data/lib/active_merchant/billing/gateways/plugnpay.rb +6 -2
  123. data/lib/active_merchant/billing/gateways/priority.rb +6 -5
  124. data/lib/active_merchant/billing/gateways/psigate.rb +6 -2
  125. data/lib/active_merchant/billing/gateways/psl_card.rb +6 -2
  126. data/lib/active_merchant/billing/gateways/qbms.rb +6 -2
  127. data/lib/active_merchant/billing/gateways/quantum.rb +6 -2
  128. data/lib/active_merchant/billing/gateways/quickbooks.rb +6 -5
  129. data/lib/active_merchant/billing/gateways/quickpay/quickpay_v10.rb +7 -4
  130. data/lib/active_merchant/billing/gateways/quickpay/quickpay_v4to7.rb +6 -2
  131. data/lib/active_merchant/billing/gateways/rapyd.rb +148 -46
  132. data/lib/active_merchant/billing/gateways/reach.rb +11 -4
  133. data/lib/active_merchant/billing/gateways/redsys.rb +2 -10
  134. data/lib/active_merchant/billing/gateways/redsys_rest.rb +507 -0
  135. data/lib/active_merchant/billing/gateways/s5.rb +3 -3
  136. data/lib/active_merchant/billing/gateways/safe_charge.rb +36 -16
  137. data/lib/active_merchant/billing/gateways/sage.rb +12 -4
  138. data/lib/active_merchant/billing/gateways/sage_pay.rb +79 -5
  139. data/lib/active_merchant/billing/gateways/sallie_mae.rb +6 -2
  140. data/lib/active_merchant/billing/gateways/secure_net.rb +6 -2
  141. data/lib/active_merchant/billing/gateways/secure_pay.rb +8 -6
  142. data/lib/active_merchant/billing/gateways/secure_pay_au.rb +12 -4
  143. data/lib/active_merchant/billing/gateways/secure_pay_tech.rb +6 -2
  144. data/lib/active_merchant/billing/gateways/securion_pay.rb +24 -10
  145. data/lib/active_merchant/billing/gateways/shift4.rb +17 -20
  146. data/lib/active_merchant/billing/gateways/shift4_v2.rb +117 -0
  147. data/lib/active_merchant/billing/gateways/simetrik.rb +17 -11
  148. data/lib/active_merchant/billing/gateways/skip_jack.rb +6 -2
  149. data/lib/active_merchant/billing/gateways/smart_ps.rb +7 -4
  150. data/lib/active_merchant/billing/gateways/so_easy_pay.rb +4 -2
  151. data/lib/active_merchant/billing/gateways/spreedly_core.rb +2 -4
  152. data/lib/active_merchant/billing/gateways/stripe.rb +53 -21
  153. data/lib/active_merchant/billing/gateways/stripe_payment_intents.rb +199 -50
  154. data/lib/active_merchant/billing/gateways/sum_up.rb +223 -0
  155. data/lib/active_merchant/billing/gateways/swipe_checkout.rb +4 -2
  156. data/lib/active_merchant/billing/gateways/telr.rb +3 -4
  157. data/lib/active_merchant/billing/gateways/trans_first.rb +1 -2
  158. data/lib/active_merchant/billing/gateways/trans_first_transaction_express.rb +8 -16
  159. data/lib/active_merchant/billing/gateways/transact_pro.rb +1 -1
  160. data/lib/active_merchant/billing/gateways/trust_commerce.rb +6 -2
  161. data/lib/active_merchant/billing/gateways/usa_epay_advanced.rb +9 -8
  162. data/lib/active_merchant/billing/gateways/usa_epay_transaction.rb +6 -2
  163. data/lib/active_merchant/billing/gateways/vanco.rb +2 -4
  164. data/lib/active_merchant/billing/gateways/vantiv_express.rb +587 -0
  165. data/lib/active_merchant/billing/gateways/verifi.rb +6 -2
  166. data/lib/active_merchant/billing/gateways/viaklix.rb +6 -2
  167. data/lib/active_merchant/billing/gateways/visanet_peru.rb +2 -2
  168. data/lib/active_merchant/billing/gateways/vpos.rb +3 -3
  169. data/lib/active_merchant/billing/gateways/wirecard.rb +7 -3
  170. data/lib/active_merchant/billing/gateways/wompi.rb +5 -0
  171. data/lib/active_merchant/billing/gateways/worldpay.rb +140 -73
  172. data/lib/active_merchant/billing/gateways/worldpay_online_payments.rb +13 -10
  173. data/lib/active_merchant/billing/gateways/xpay.rb +242 -0
  174. data/lib/active_merchant/billing/network_tokenization_credit_card.rb +1 -1
  175. data/lib/active_merchant/billing/response.rb +2 -2
  176. data/lib/active_merchant/connection.rb +3 -17
  177. data/lib/active_merchant/country.rb +1 -0
  178. data/lib/active_merchant/errors.rb +10 -0
  179. data/lib/active_merchant/version.rb +1 -1
  180. data/lib/support/gateway_support.rb +2 -2
  181. data/lib/support/ssl_verify.rb +4 -4
  182. data/lib/support/ssl_version.rb +6 -6
  183. metadata +30 -9
@@ -182,14 +182,16 @@ module ActiveMerchant #:nodoc:
182
182
  response = json_error(raw_response)
183
183
  end
184
184
 
185
- Response.new(success,
185
+ Response.new(
186
+ success,
186
187
  response_message(response),
187
188
  response,
188
189
  test: test?,
189
190
  avs_result: { code: response['AVS_RESULT_CODE'] },
190
191
  cvv_result: response['VERIFICATION_RESULT_CODE'],
191
192
  error_code: (success ? nil : STANDARD_ERROR_CODE_MAPPING[response['RESPONSE_CODE']]),
192
- authorization: response['TRANSACTION_ID'])
193
+ authorization: response['TRANSACTION_ID']
194
+ )
193
195
  end
194
196
 
195
197
  def response_error(raw_response)
@@ -337,9 +337,13 @@ module ActiveMerchant #:nodoc:
337
337
 
338
338
  response = parse(ssl_post(url, post_data(action, parameters)))
339
339
 
340
- Response.new(successful?(response), message_from(response), response,
340
+ Response.new(
341
+ successful?(response),
342
+ message_from(response),
343
+ response,
341
344
  test: test?,
342
- authorization: response[:transaction_id] || parameters[:transaction_id])
345
+ authorization: response[:transaction_id] || parameters[:transaction_id]
346
+ )
343
347
  end
344
348
 
345
349
  def successful?(response)
@@ -68,9 +68,13 @@ module ActiveMerchant #:nodoc:
68
68
  def commit(action, money, parameters)
69
69
  response = parse(ssl_post(self.live_url, post_data(action, parameters)))
70
70
 
71
- Response.new(successful?(response), message_from(response), response,
71
+ Response.new(
72
+ successful?(response),
73
+ message_from(response),
74
+ response,
72
75
  test: test_response?(response),
73
- authorization: authorization_from(response))
76
+ authorization: authorization_from(response)
77
+ )
74
78
  end
75
79
 
76
80
  def successful?(response)
@@ -1,7 +1,7 @@
1
1
  module ActiveMerchant #:nodoc:
2
2
  module Billing #:nodoc:
3
3
  class PayTraceGateway < Gateway
4
- self.test_url = 'https://api.paytrace.com'
4
+ self.test_url = 'https://api.sandbox.paytrace.com'
5
5
  self.live_url = 'https://api.paytrace.com'
6
6
 
7
7
  self.supported_countries = ['US']
@@ -46,7 +46,7 @@ module ActiveMerchant #:nodoc:
46
46
  def initialize(options = {})
47
47
  requires!(options, :username, :password, :integrator_id)
48
48
  super
49
- acquire_access_token
49
+ acquire_access_token unless options[:access_token]
50
50
  end
51
51
 
52
52
  def purchase(money, payment_or_customer_id, options = {})
@@ -169,28 +169,35 @@ module ActiveMerchant #:nodoc:
169
169
  transcript.
170
170
  gsub(%r((Authorization: Bearer )[a-zA-Z0-9:_]+), '\1[FILTERED]').
171
171
  gsub(%r(("credit_card\\?":{\\?"number\\?":\\?")\d+), '\1[FILTERED]').
172
- gsub(%r(("cvv\\?":\\?")\d+), '\1[FILTERED]').
172
+ gsub(%r(("csc\\?":\\?")\d+), '\1[FILTERED]').
173
173
  gsub(%r(("username\\?":\\?")\w+@+\w+.+\w+), '\1[FILTERED]').
174
+ gsub(%r(("username\\?":\\?")\w+), '\1[FILTERED]').
174
175
  gsub(%r(("password\\?":\\?")\w+), '\1[FILTERED]').
175
176
  gsub(%r(("integrator_id\\?":\\?")\w+), '\1[FILTERED]')
176
177
  end
177
178
 
178
179
  def acquire_access_token
179
180
  post = {}
181
+ base_url = (test? ? test_url : live_url)
180
182
  post[:grant_type] = 'password'
181
183
  post[:username] = @options[:username]
182
184
  post[:password] = @options[:password]
183
185
  data = post.collect { |key, value| "#{key}=#{CGI.escape(value.to_s)}" }.join('&')
184
- url = live_url + '/oauth/token'
186
+ url = base_url + '/oauth/token'
185
187
  oauth_headers = {
186
188
  'Accept' => '*/*',
187
189
  'Content-Type' => 'application/x-www-form-urlencoded'
188
190
  }
189
191
  response = ssl_post(url, data, oauth_headers)
190
- json_response = JSON.parse(response)
192
+ json_response = parse(response)
191
193
 
192
- @options[:access_token] = json_response['access_token'] if json_response['access_token']
193
- response
194
+ if json_response.include?('error')
195
+ oauth_response = Response.new(false, json_response['error_description'])
196
+ raise OAuthResponseError.new(oauth_response)
197
+ else
198
+ @options[:access_token] = json_response['access_token'] if json_response['access_token']
199
+ response
200
+ end
194
201
  end
195
202
 
196
203
  private
@@ -237,11 +244,11 @@ module ActiveMerchant #:nodoc:
237
244
  end
238
245
 
239
246
  def customer_id?(payment_or_customer_id)
240
- payment_or_customer_id.class == String
247
+ payment_or_customer_id.instance_of?(String)
241
248
  end
242
249
 
243
250
  def string_literal_to_boolean(value)
244
- return value unless value.class == String
251
+ return value unless value.instance_of?(String)
245
252
 
246
253
  if value.casecmp('true').zero?
247
254
  true
@@ -258,15 +265,16 @@ module ActiveMerchant #:nodoc:
258
265
  end
259
266
 
260
267
  def add_address(post, creditcard, options)
261
- return unless options[:billing_address] || options[:address]
262
-
263
- address = options[:billing_address] || options[:address]
264
268
  post[:billing_address] = {}
269
+
270
+ if (address = options[:billing_address] || options[:address])
271
+ post[:billing_address][:street_address] = address[:address1]
272
+ post[:billing_address][:city] = address[:city]
273
+ post[:billing_address][:state] = address[:state]
274
+ post[:billing_address][:zip] = address[:zip]
275
+ end
276
+
265
277
  post[:billing_address][:name] = creditcard.name
266
- post[:billing_address][:street_address] = address[:address1]
267
- post[:billing_address][:city] = address[:city]
268
- post[:billing_address][:state] = address[:state]
269
- post[:billing_address][:zip] = address[:zip]
270
278
  end
271
279
 
272
280
  def add_amount(post, money, options)
@@ -283,6 +291,7 @@ module ActiveMerchant #:nodoc:
283
291
  post[:credit_card][:number] = payment.number
284
292
  post[:credit_card][:expiration_month] = payment.month
285
293
  post[:credit_card][:expiration_year] = payment.year
294
+ post[:csc] = payment.verification_value
286
295
  end
287
296
  end
288
297
 
@@ -373,6 +382,12 @@ module ActiveMerchant #:nodoc:
373
382
  url = base_url + '/v1/' + action
374
383
  raw_response = ssl_post(url, post_data(parameters), headers)
375
384
  response = parse(raw_response)
385
+ handle_final_response(action, response)
386
+ rescue JSON::ParserError
387
+ unparsable_response(raw_response)
388
+ end
389
+
390
+ def handle_final_response(action, response)
376
391
  success = success_from(response)
377
392
 
378
393
  Response.new(
@@ -385,8 +400,6 @@ module ActiveMerchant #:nodoc:
385
400
  test: test?,
386
401
  error_code: success ? nil : error_code_from(response)
387
402
  )
388
- rescue JSON::ParserError
389
- unparsable_response(raw_response)
390
403
  end
391
404
 
392
405
  def unparsable_response(raw_response)
@@ -35,6 +35,8 @@ module ActiveMerchant
35
35
 
36
36
  add_invoice(params, options)
37
37
  add_reversal_id(params, options)
38
+ add_customer_ref(params, options)
39
+ add_reference_3(params, options)
38
40
  add_payment_method(params, payment_method, options)
39
41
  add_address(params, options)
40
42
  add_amount(params, amount, options)
@@ -51,6 +53,8 @@ module ActiveMerchant
51
53
 
52
54
  add_invoice(params, options)
53
55
  add_reversal_id(params, options)
56
+ add_customer_ref(params, options)
57
+ add_reference_3(params, options)
54
58
  add_payment_method(params, payment_method, options)
55
59
  add_address(params, options)
56
60
  add_amount(params, amount, options)
@@ -170,6 +174,14 @@ module ActiveMerchant
170
174
  params[:reversal_id] = options[:reversal_id] if options[:reversal_id]
171
175
  end
172
176
 
177
+ def add_customer_ref(params, options)
178
+ params[:customer_ref] = options[:customer_ref] if options[:customer_ref]
179
+ end
180
+
181
+ def add_reference_3(params, options)
182
+ params[:reference_3] = options[:reference_3] if options[:reference_3]
183
+ end
184
+
173
185
  def amount_from_authorization(authorization)
174
186
  authorization.split('|').last.to_i
175
187
  end
@@ -192,7 +204,7 @@ module ActiveMerchant
192
204
  params[:apikey] = @options[:apikey]
193
205
  params[:ta_token] = options[:ta_token]
194
206
  params[:type] = 'FDToken'
195
- params[:credit_card] = add_card_data(payment_method)
207
+ params[:credit_card] = add_card_data(payment_method, options)
196
208
  params[:auth] = 'false'
197
209
  end
198
210
 
@@ -208,7 +220,7 @@ module ActiveMerchant
208
220
  elsif payment_method.is_a? NetworkTokenizationCreditCard
209
221
  add_network_tokenization(params, payment_method, options)
210
222
  else
211
- add_creditcard(params, payment_method)
223
+ add_creditcard(params, payment_method, options)
212
224
  end
213
225
  end
214
226
 
@@ -245,17 +257,17 @@ module ActiveMerchant
245
257
  params[:token] = token
246
258
  end
247
259
 
248
- def add_creditcard(params, creditcard)
249
- credit_card = add_card_data(creditcard)
260
+ def add_creditcard(params, creditcard, options)
261
+ credit_card = add_card_data(creditcard, options)
250
262
 
251
263
  params[:method] = 'credit_card'
252
264
  params[:credit_card] = credit_card
253
265
  end
254
266
 
255
- def add_card_data(payment_method)
267
+ def add_card_data(payment_method, options = {})
256
268
  card = {}
257
269
  card[:type] = CREDIT_CARD_BRAND[payment_method.brand]
258
- card[:cardholder_name] = payment_method.name
270
+ card[:cardholder_name] = name_from_payment_method(payment_method) || name_from_address(options)
259
271
  card[:card_number] = payment_method.number
260
272
  card[:exp_date] = format_exp_date(payment_method.month, payment_method.year)
261
273
  card[:cvv] = payment_method.verification_value if payment_method.verification_value?
@@ -412,8 +424,7 @@ module ActiveMerchant
412
424
  @options[:token],
413
425
  payload
414
426
  ].join('')
415
- hash = Base64.strict_encode64(OpenSSL::HMAC.hexdigest('sha256', @options[:apisecret], message))
416
- hash
427
+ Base64.strict_encode64(OpenSSL::HMAC.hexdigest('sha256', @options[:apisecret], message))
417
428
  end
418
429
 
419
430
  def headers(payload)
@@ -385,11 +385,13 @@ module ActiveMerchant #:nodoc:
385
385
  'Content-Length' => request.size.to_s
386
386
  }
387
387
  response = parse(ssl_post(url, request, headers))
388
- Response.new(success?(response),
388
+ Response.new(
389
+ success?(response),
389
390
  message_from(response),
390
391
  response,
391
392
  test: test?,
392
- authorization: build_authorization(response))
393
+ authorization: build_authorization(response)
394
+ )
393
395
  end
394
396
 
395
397
  def build_authorization(response)
@@ -99,7 +99,7 @@ module ActiveMerchant #:nodoc:
99
99
  end
100
100
  xml.tag! 'RequestAuth' do
101
101
  xml.tag! 'UserPass' do
102
- xml.tag! 'User', !@options[:user].blank? ? @options[:user] : @options[:login]
102
+ xml.tag! 'User', @options[:user].blank? ? @options[:login] : @options[:user]
103
103
  xml.tag! 'Password', @options[:password]
104
104
  end
105
105
  end
@@ -192,9 +192,7 @@ module ActiveMerchant #:nodoc:
192
192
  xml.tag! 'TotalAmt', amount(money), 'Currency' => options[:currency] || currency(money)
193
193
  end
194
194
 
195
- if %i(authorization purchase).include? action
196
- add_mpi_3ds(xml, options[:three_d_secure]) if options[:three_d_secure]
197
- end
195
+ add_mpi_3ds(xml, options[:three_d_secure]) if %i(authorization purchase).include?(action) && (options[:three_d_secure])
198
196
 
199
197
  xml.tag! 'Tender' do
200
198
  add_credit_card(xml, credit_card, options)
@@ -20,8 +20,8 @@ module ActiveMerchant #:nodoc:
20
20
  self.homepage_url = 'https://www.windcave.com/'
21
21
  self.display_name = 'Windcave (formerly PaymentExpress)'
22
22
 
23
- self.live_url = 'https://sec.paymentexpress.com/pxpost.aspx'
24
- self.test_url = 'https://uat.paymentexpress.com/pxpost.aspx'
23
+ self.live_url = 'https://sec.windcave.com/pxpost.aspx'
24
+ self.test_url = 'https://uat.windcave.com/pxpost.aspx'
25
25
 
26
26
  APPROVED = '1'
27
27
 
@@ -306,9 +306,13 @@ module ActiveMerchant #:nodoc:
306
306
  response = parse(ssl_post(url, request.to_s))
307
307
 
308
308
  # Return a response
309
- PaymentExpressResponse.new(response[:success] == APPROVED, message_from(response), response,
309
+ PaymentExpressResponse.new(
310
+ response[:success] == APPROVED,
311
+ message_from(response),
312
+ response,
310
313
  test: response[:test_mode] == '1',
311
- authorization: authorization_from(action, response))
314
+ authorization: authorization_from(action, response)
315
+ )
312
316
  end
313
317
 
314
318
  # Response XML documentation: http://www.paymentexpress.com/technical_resources/ecommerce_nonhosted/pxpost.html#XMLTxnOutput
@@ -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
 
@@ -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