activemerchant 1.112.0 → 1.118.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (204) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG +115 -0
  3. data/README.md +1 -1
  4. data/lib/active_merchant.rb +1 -1
  5. data/lib/active_merchant/billing/avs_result.rb +1 -1
  6. data/lib/active_merchant/billing/compatibility.rb +3 -3
  7. data/lib/active_merchant/billing/credit_card.rb +3 -1
  8. data/lib/active_merchant/billing/credit_card_methods.rb +58 -11
  9. data/lib/active_merchant/billing/gateway.rb +1 -1
  10. data/lib/active_merchant/billing/gateways/adyen.rb +26 -16
  11. data/lib/active_merchant/billing/gateways/allied_wallet.rb +7 -7
  12. data/lib/active_merchant/billing/gateways/authorize_net.rb +50 -18
  13. data/lib/active_merchant/billing/gateways/authorize_net_arb.rb +3 -4
  14. data/lib/active_merchant/billing/gateways/authorize_net_cim.rb +3 -2
  15. data/lib/active_merchant/billing/gateways/axcessms.rb +8 -9
  16. data/lib/active_merchant/billing/gateways/balanced.rb +5 -4
  17. data/lib/active_merchant/billing/gateways/bambora_apac.rb +8 -8
  18. data/lib/active_merchant/billing/gateways/bank_frick.rb +8 -8
  19. data/lib/active_merchant/billing/gateways/banwire.rb +1 -1
  20. data/lib/active_merchant/billing/gateways/barclaycard_smartpay.rb +6 -4
  21. data/lib/active_merchant/billing/gateways/beanstream.rb +3 -3
  22. data/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb +4 -5
  23. data/lib/active_merchant/billing/gateways/blue_pay.rb +2 -3
  24. data/lib/active_merchant/billing/gateways/blue_snap.rb +85 -23
  25. data/lib/active_merchant/billing/gateways/bogus.rb +19 -19
  26. data/lib/active_merchant/billing/gateways/borgun.rb +12 -12
  27. data/lib/active_merchant/billing/gateways/bpoint.rb +8 -8
  28. data/lib/active_merchant/billing/gateways/braintree.rb +1 -1
  29. data/lib/active_merchant/billing/gateways/braintree_blue.rb +20 -17
  30. data/lib/active_merchant/billing/gateways/bridge_pay.rb +7 -7
  31. data/lib/active_merchant/billing/gateways/cams.rb +8 -8
  32. data/lib/active_merchant/billing/gateways/card_connect.rb +1 -1
  33. data/lib/active_merchant/billing/gateways/card_save.rb +1 -1
  34. data/lib/active_merchant/billing/gateways/card_stream.rb +2 -2
  35. data/lib/active_merchant/billing/gateways/cardknox.rb +8 -8
  36. data/lib/active_merchant/billing/gateways/cardprocess.rb +1 -1
  37. data/lib/active_merchant/billing/gateways/cecabank.rb +5 -5
  38. data/lib/active_merchant/billing/gateways/cenpos.rb +11 -11
  39. data/lib/active_merchant/billing/gateways/checkout.rb +2 -2
  40. data/lib/active_merchant/billing/gateways/checkout_v2.rb +18 -21
  41. data/lib/active_merchant/billing/gateways/clearhaus.rb +7 -7
  42. data/lib/active_merchant/billing/gateways/commercegate.rb +1 -1
  43. data/lib/active_merchant/billing/gateways/conekta.rb +2 -2
  44. data/lib/active_merchant/billing/gateways/creditcall.rb +10 -10
  45. data/lib/active_merchant/billing/gateways/credorax.rb +32 -15
  46. data/lib/active_merchant/billing/gateways/ct_payment.rb +10 -10
  47. data/lib/active_merchant/billing/gateways/culqi.rb +10 -10
  48. data/lib/active_merchant/billing/gateways/cyber_source.rb +61 -37
  49. data/lib/active_merchant/billing/gateways/d_local.rb +11 -11
  50. data/lib/active_merchant/billing/gateways/data_cash.rb +2 -3
  51. data/lib/active_merchant/billing/gateways/decidir.rb +24 -9
  52. data/lib/active_merchant/billing/gateways/dibs.rb +8 -8
  53. data/lib/active_merchant/billing/gateways/digitzs.rb +6 -6
  54. data/lib/active_merchant/billing/gateways/ebanx.rb +9 -9
  55. data/lib/active_merchant/billing/gateways/efsnet.rb +3 -4
  56. data/lib/active_merchant/billing/gateways/elavon.rb +279 -227
  57. data/lib/active_merchant/billing/gateways/element.rb +8 -8
  58. data/lib/active_merchant/billing/gateways/evo_ca.rb +5 -6
  59. data/lib/active_merchant/billing/gateways/eway.rb +3 -4
  60. data/lib/active_merchant/billing/gateways/eway_managed.rb +6 -7
  61. data/lib/active_merchant/billing/gateways/eway_rapid.rb +8 -8
  62. data/lib/active_merchant/billing/gateways/exact.rb +8 -9
  63. data/lib/active_merchant/billing/gateways/ezic.rb +8 -8
  64. data/lib/active_merchant/billing/gateways/fat_zebra.rb +4 -4
  65. data/lib/active_merchant/billing/gateways/federated_canada.rb +2 -3
  66. data/lib/active_merchant/billing/gateways/first_giving.rb +1 -1
  67. data/lib/active_merchant/billing/gateways/first_pay.rb +6 -6
  68. data/lib/active_merchant/billing/gateways/firstdata_e4.rb +7 -7
  69. data/lib/active_merchant/billing/gateways/firstdata_e4_v27.rb +21 -10
  70. data/lib/active_merchant/billing/gateways/flo2cash.rb +9 -9
  71. data/lib/active_merchant/billing/gateways/flo2cash_simple.rb +1 -1
  72. data/lib/active_merchant/billing/gateways/forte.rb +14 -8
  73. data/lib/active_merchant/billing/gateways/global_collect.rb +29 -10
  74. data/lib/active_merchant/billing/gateways/global_transport.rb +7 -7
  75. data/lib/active_merchant/billing/gateways/hdfc.rb +10 -10
  76. data/lib/active_merchant/billing/gateways/hps.rb +17 -14
  77. data/lib/active_merchant/billing/gateways/iats_payments.rb +9 -4
  78. data/lib/active_merchant/billing/gateways/in_context_paypal_express.rb +1 -1
  79. data/lib/active_merchant/billing/gateways/inspire.rb +3 -4
  80. data/lib/active_merchant/billing/gateways/instapay.rb +1 -2
  81. data/lib/active_merchant/billing/gateways/ipp.rb +7 -7
  82. data/lib/active_merchant/billing/gateways/iridium.rb +16 -17
  83. data/lib/active_merchant/billing/gateways/iveri.rb +7 -7
  84. data/lib/active_merchant/billing/gateways/ixopay.rb +7 -7
  85. data/lib/active_merchant/billing/gateways/jetpay.rb +1 -2
  86. data/lib/active_merchant/billing/gateways/jetpay_v2.rb +4 -5
  87. data/lib/active_merchant/billing/gateways/kushki.rb +6 -6
  88. data/lib/active_merchant/billing/gateways/latitude19.rb +14 -14
  89. data/lib/active_merchant/billing/gateways/linkpoint.rb +5 -6
  90. data/lib/active_merchant/billing/gateways/litle.rb +28 -12
  91. data/lib/active_merchant/billing/gateways/mastercard.rb +12 -12
  92. data/lib/active_merchant/billing/gateways/mercado_pago.rb +8 -8
  93. data/lib/active_merchant/billing/gateways/merchant_e_solutions.rb +1 -2
  94. data/lib/active_merchant/billing/gateways/merchant_one.rb +1 -1
  95. data/lib/active_merchant/billing/gateways/merchant_partners.rb +10 -10
  96. data/lib/active_merchant/billing/gateways/merchant_ware.rb +5 -7
  97. data/lib/active_merchant/billing/gateways/merchant_ware_version_four.rb +4 -6
  98. data/lib/active_merchant/billing/gateways/mercury.rb +4 -4
  99. data/lib/active_merchant/billing/gateways/metrics_global.rb +4 -5
  100. data/lib/active_merchant/billing/gateways/micropayment.rb +8 -8
  101. data/lib/active_merchant/billing/gateways/migs.rb +3 -4
  102. data/lib/active_merchant/billing/gateways/modern_payments_cim.rb +2 -4
  103. data/lib/active_merchant/billing/gateways/monei.rb +7 -7
  104. data/lib/active_merchant/billing/gateways/moneris.rb +4 -3
  105. data/lib/active_merchant/billing/gateways/money_movers.rb +2 -3
  106. data/lib/active_merchant/billing/gateways/mundipagg.rb +37 -10
  107. data/lib/active_merchant/billing/gateways/nab_transact.rb +2 -4
  108. data/lib/active_merchant/billing/gateways/ncr_secure_pay.rb +7 -7
  109. data/lib/active_merchant/billing/gateways/net_registry.rb +1 -2
  110. data/lib/active_merchant/billing/gateways/netaxept.rb +6 -6
  111. data/lib/active_merchant/billing/gateways/netbanx.rb +12 -10
  112. data/lib/active_merchant/billing/gateways/netbilling.rb +4 -5
  113. data/lib/active_merchant/billing/gateways/network_merchants.rb +2 -3
  114. data/lib/active_merchant/billing/gateways/nmi.rb +21 -7
  115. data/lib/active_merchant/billing/gateways/ogone.rb +3 -3
  116. data/lib/active_merchant/billing/gateways/omise.rb +13 -13
  117. data/lib/active_merchant/billing/gateways/openpay.rb +4 -5
  118. data/lib/active_merchant/billing/gateways/opp.rb +12 -12
  119. data/lib/active_merchant/billing/gateways/optimal_payment.rb +3 -4
  120. data/lib/active_merchant/billing/gateways/orbital.rb +175 -81
  121. data/lib/active_merchant/billing/gateways/pac_net_raven.rb +3 -4
  122. data/lib/active_merchant/billing/gateways/pagarme.rb +9 -9
  123. data/lib/active_merchant/billing/gateways/pago_facil.rb +2 -2
  124. data/lib/active_merchant/billing/gateways/pay_conex.rb +8 -8
  125. data/lib/active_merchant/billing/gateways/pay_gate_xml.rb +6 -7
  126. data/lib/active_merchant/billing/gateways/pay_hub.rb +7 -8
  127. data/lib/active_merchant/billing/gateways/pay_junction.rb +4 -5
  128. data/lib/active_merchant/billing/gateways/pay_junction_v2.rb +9 -9
  129. data/lib/active_merchant/billing/gateways/pay_secure.rb +2 -3
  130. data/lib/active_merchant/billing/gateways/paybox_direct.rb +23 -1
  131. data/lib/active_merchant/billing/gateways/payeezy.rb +35 -17
  132. data/lib/active_merchant/billing/gateways/payex.rb +11 -12
  133. data/lib/active_merchant/billing/gateways/payflow.rb +4 -1
  134. data/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb +1 -1
  135. data/lib/active_merchant/billing/gateways/payflow/payflow_express_response.rb +1 -1
  136. data/lib/active_merchant/billing/gateways/payment_express.rb +1 -2
  137. data/lib/active_merchant/billing/gateways/paymentez.rb +26 -6
  138. data/lib/active_merchant/billing/gateways/paymill.rb +10 -10
  139. data/lib/active_merchant/billing/gateways/paypal.rb +10 -2
  140. data/lib/active_merchant/billing/gateways/paypal/paypal_common_api.rb +1 -0
  141. data/lib/active_merchant/billing/gateways/paypal_express.rb +1 -1
  142. data/lib/active_merchant/billing/gateways/paypal_express_common.rb +1 -1
  143. data/lib/active_merchant/billing/gateways/payscout.rb +1 -2
  144. data/lib/active_merchant/billing/gateways/paystation.rb +3 -4
  145. data/lib/active_merchant/billing/gateways/payu_in.rb +3 -3
  146. data/lib/active_merchant/billing/gateways/payu_latam.rb +17 -10
  147. data/lib/active_merchant/billing/gateways/payway.rb +8 -9
  148. data/lib/active_merchant/billing/gateways/pin.rb +11 -0
  149. data/lib/active_merchant/billing/gateways/plugnpay.rb +2 -3
  150. data/lib/active_merchant/billing/gateways/pro_pay.rb +8 -8
  151. data/lib/active_merchant/billing/gateways/psigate.rb +3 -4
  152. data/lib/active_merchant/billing/gateways/psl_card.rb +1 -2
  153. data/lib/active_merchant/billing/gateways/qbms.rb +4 -5
  154. data/lib/active_merchant/billing/gateways/quantum.rb +1 -2
  155. data/lib/active_merchant/billing/gateways/quickbooks.rb +4 -3
  156. data/lib/active_merchant/billing/gateways/quickpay/quickpay_v10.rb +3 -4
  157. data/lib/active_merchant/billing/gateways/quickpay/quickpay_v4to7.rb +1 -2
  158. data/lib/active_merchant/billing/gateways/qvalent.rb +9 -9
  159. data/lib/active_merchant/billing/gateways/realex.rb +1 -1
  160. data/lib/active_merchant/billing/gateways/redsys.rb +87 -7
  161. data/lib/active_merchant/billing/gateways/s5.rb +7 -7
  162. data/lib/active_merchant/billing/gateways/safe_charge.rb +40 -14
  163. data/lib/active_merchant/billing/gateways/sage.rb +3 -5
  164. data/lib/active_merchant/billing/gateways/sage_pay.rb +6 -7
  165. data/lib/active_merchant/billing/gateways/sallie_mae.rb +1 -2
  166. data/lib/active_merchant/billing/gateways/secure_net.rb +1 -2
  167. data/lib/active_merchant/billing/gateways/secure_pay.rb +3 -4
  168. data/lib/active_merchant/billing/gateways/secure_pay_au.rb +2 -4
  169. data/lib/active_merchant/billing/gateways/secure_pay_tech.rb +1 -2
  170. data/lib/active_merchant/billing/gateways/securion_pay.rb +5 -6
  171. data/lib/active_merchant/billing/gateways/skip_jack.rb +3 -4
  172. data/lib/active_merchant/billing/gateways/smart_ps.rb +5 -6
  173. data/lib/active_merchant/billing/gateways/so_easy_pay.rb +7 -7
  174. data/lib/active_merchant/billing/gateways/spreedly_core.rb +6 -6
  175. data/lib/active_merchant/billing/gateways/stripe.rb +12 -12
  176. data/lib/active_merchant/billing/gateways/stripe_payment_intents.rb +30 -0
  177. data/lib/active_merchant/billing/gateways/swipe_checkout.rb +3 -4
  178. data/lib/active_merchant/billing/gateways/telr.rb +9 -9
  179. data/lib/active_merchant/billing/gateways/trans_first.rb +3 -3
  180. data/lib/active_merchant/billing/gateways/trans_first_transaction_express.rb +14 -14
  181. data/lib/active_merchant/billing/gateways/transact_pro.rb +9 -9
  182. data/lib/active_merchant/billing/gateways/trust_commerce.rb +8 -9
  183. data/lib/active_merchant/billing/gateways/usa_epay.rb +1 -1
  184. data/lib/active_merchant/billing/gateways/usa_epay_advanced.rb +36 -36
  185. data/lib/active_merchant/billing/gateways/usa_epay_transaction.rb +4 -5
  186. data/lib/active_merchant/billing/gateways/vanco.rb +3 -3
  187. data/lib/active_merchant/billing/gateways/verifi.rb +1 -2
  188. data/lib/active_merchant/billing/gateways/viaklix.rb +1 -2
  189. data/lib/active_merchant/billing/gateways/visanet_peru.rb +10 -10
  190. data/lib/active_merchant/billing/gateways/webpay.rb +2 -2
  191. data/lib/active_merchant/billing/gateways/wepay.rb +3 -2
  192. data/lib/active_merchant/billing/gateways/wirecard.rb +1 -2
  193. data/lib/active_merchant/billing/gateways/worldpay.rb +18 -10
  194. data/lib/active_merchant/billing/gateways/worldpay_online_payments.rb +14 -16
  195. data/lib/active_merchant/billing/gateways/worldpay_us.rb +9 -9
  196. data/lib/active_merchant/billing/response.rb +3 -2
  197. data/lib/active_merchant/country.rb +1 -1
  198. data/lib/active_merchant/network_connection_retries.rb +2 -2
  199. data/lib/active_merchant/post_data.rb +1 -1
  200. data/lib/active_merchant/posts_data.rb +1 -1
  201. data/lib/active_merchant/version.rb +1 -1
  202. data/lib/support/ssl_verify.rb +2 -2
  203. data/lib/support/ssl_version.rb +2 -2
  204. metadata +2 -2
@@ -198,7 +198,7 @@ module ActiveMerchant #:nodoc:
198
198
  post[:description] = options[:description]
199
199
  end
200
200
 
201
- def add_payment(post, payment, options={})
201
+ def add_payment(post, payment, options = {})
202
202
  if payment.respond_to?(:routing_number)
203
203
  post[:checkformat] = options[:check_format] if options[:check_format]
204
204
  if payment.account_type
@@ -279,7 +279,7 @@ module ActiveMerchant #:nodoc:
279
279
 
280
280
  {
281
281
  quantity: 'qty',
282
- unit: 'um',
282
+ unit: 'um'
283
283
  }.each do |key, umkey|
284
284
  post["line#{index}#{umkey}"] = line_item[key.to_sym] if line_item.has_key?(key.to_sym)
285
285
  end
@@ -310,7 +310,7 @@ module ActiveMerchant #:nodoc:
310
310
  error_code: fields['UMerrorcode'],
311
311
  acs_url: fields['UMacsurl'],
312
312
  payload: fields['UMpayload']
313
- }.delete_if { |k, v| v.nil? }
313
+ }.delete_if { |_k, v| v.nil? }
314
314
  end
315
315
 
316
316
  def commit(action, parameters)
@@ -324,8 +324,7 @@ module ActiveMerchant #:nodoc:
324
324
  authorization: response[:ref_num],
325
325
  cvv_result: response[:cvv2_result_code],
326
326
  avs_result: { code: response[:avs_result_code] },
327
- error_code: error_code
328
- )
327
+ error_code: error_code)
329
328
  end
330
329
 
331
330
  def message_from(response)
@@ -15,19 +15,19 @@ module ActiveMerchant
15
15
  self.homepage_url = 'http://vancopayments.com/'
16
16
  self.display_name = 'Vanco Payment Solutions'
17
17
 
18
- def initialize(options={})
18
+ def initialize(options = {})
19
19
  requires!(options, :user_id, :password, :client_id)
20
20
  super
21
21
  end
22
22
 
23
- def purchase(money, payment_method, options={})
23
+ def purchase(money, payment_method, options = {})
24
24
  MultiResponse.run do |r|
25
25
  r.process { login }
26
26
  r.process { commit(purchase_request(money, payment_method, r.params['response_sessionid'], options), :response_transactionref) }
27
27
  end
28
28
  end
29
29
 
30
- def refund(money, authorization, options={})
30
+ def refund(money, authorization, options = {})
31
31
  MultiResponse.run do |r|
32
32
  r.process { login }
33
33
  r.process { commit(refund_request(money, authorization, r.params['response_sessionid']), :response_creditrequestreceived) }
@@ -198,8 +198,7 @@ module ActiveMerchant #:nodoc:
198
198
  test: test?,
199
199
  authorization: response[:transactionid],
200
200
  avs_result: { code: response[:avsresponse] },
201
- cvv_result: response[:cvvresponse]
202
- )
201
+ cvv_result: response[:cvvresponse])
203
202
  end
204
203
 
205
204
  def message_from(response)
@@ -140,8 +140,7 @@ module ActiveMerchant #:nodoc:
140
140
  test: @options[:test] || test?,
141
141
  authorization: authorization_from(response),
142
142
  avs_result: { code: response['avs_response'] },
143
- cvv_result: response['cvv2_response']
144
- )
143
+ cvv_result: response['cvv2_response'])
145
144
  end
146
145
 
147
146
  def authorization_from(response)
@@ -13,19 +13,19 @@ module ActiveMerchant #:nodoc:
13
13
  self.money_format = :dollars
14
14
  self.supported_cardtypes = %i[visa master american_express discover]
15
15
 
16
- def initialize(options={})
16
+ def initialize(options = {})
17
17
  requires!(options, :access_key_id, :secret_access_key, :merchant_id)
18
18
  super
19
19
  end
20
20
 
21
- def purchase(amount, payment_method, options={})
21
+ def purchase(amount, payment_method, options = {})
22
22
  MultiResponse.run() do |r|
23
23
  r.process { authorize(amount, payment_method, options) }
24
24
  r.process { capture(amount, r.authorization, options) }
25
25
  end
26
26
  end
27
27
 
28
- def authorize(amount, payment_method, options={})
28
+ def authorize(amount, payment_method, options = {})
29
29
  params = {}
30
30
 
31
31
  add_invoice(params, amount, options)
@@ -37,20 +37,20 @@ module ActiveMerchant #:nodoc:
37
37
  commit('authorize', params, options)
38
38
  end
39
39
 
40
- def capture(amount, authorization, options={})
40
+ def capture(amount, authorization, options = {})
41
41
  params = {}
42
42
  options[:id_unico] = split_authorization(authorization)[1]
43
43
  add_auth_order_id(params, authorization, options)
44
44
  commit('deposit', params, options)
45
45
  end
46
46
 
47
- def void(authorization, options={})
47
+ def void(authorization, options = {})
48
48
  params = {}
49
49
  add_auth_order_id(params, authorization, options)
50
50
  commit('void', params, options)
51
51
  end
52
52
 
53
- def refund(amount, authorization, options={})
53
+ def refund(amount, authorization, options = {})
54
54
  params = {}
55
55
  params[:amount] = amount(amount) if amount
56
56
  add_auth_order_id(params, authorization, options)
@@ -65,7 +65,7 @@ module ActiveMerchant #:nodoc:
65
65
  commit('refund', params, options)
66
66
  end
67
67
 
68
- def verify(credit_card, options={})
68
+ def verify(credit_card, options = {})
69
69
  MultiResponse.run(:use_first_response) do |r|
70
70
  r.process { authorize(100, credit_card, options) }
71
71
  r.process(:ignore_result) { void(r.authorization, options) }
@@ -85,7 +85,7 @@ module ActiveMerchant #:nodoc:
85
85
 
86
86
  private
87
87
 
88
- CURRENCY_CODES = Hash.new { |h, k| raise ArgumentError.new("Unsupported currency: #{k}") }
88
+ CURRENCY_CODES = Hash.new { |_h, k| raise ArgumentError.new("Unsupported currency: #{k}") }
89
89
  CURRENCY_CODES['USD'] = 840
90
90
  CURRENCY_CODES['PEN'] = 604
91
91
 
@@ -142,7 +142,7 @@ module ActiveMerchant #:nodoc:
142
142
  authorization.split('|')
143
143
  end
144
144
 
145
- def commit(action, params, options={})
145
+ def commit(action, params, options = {})
146
146
  raw_response = ssl_request(method(action), url(action, params, options), params.to_json, headers)
147
147
  response = parse(raw_response)
148
148
  rescue ResponseError => e
@@ -168,7 +168,7 @@ module ActiveMerchant #:nodoc:
168
168
  }
169
169
  end
170
170
 
171
- def url(action, params, options={})
171
+ def url(action, params, options = {})
172
172
  if action == 'authorize'
173
173
  "#{base_url}/#{@options[:merchant_id]}"
174
174
  elsif action == 'refund'
@@ -51,7 +51,7 @@ module ActiveMerchant #:nodoc:
51
51
  MultiResponse.run(:first) do |r|
52
52
  r.process { commit(:post, "customers/#{CGI.escape(options[:customer])}/", post, options) }
53
53
 
54
- return r unless options[:set_default] and r.success? and !r.params['id'].blank?
54
+ return r unless options[:set_default] && r.success? && !r.params['id'].blank?
55
55
 
56
56
  r.process { update_customer(options[:customer], default_card: r.params['id']) }
57
57
  end
@@ -89,7 +89,7 @@ module ActiveMerchant #:nodoc:
89
89
  'Authorization' => 'Basic ' + Base64.encode64(@api_key.to_s + ':').strip,
90
90
  'User-Agent' => "Webpay/v1 ActiveMerchantBindings/#{ActiveMerchant::VERSION}",
91
91
  'X-Webpay-Client-User-Agent' => user_agent,
92
- 'X-Webpay-Client-User-Metadata' => {ip: options[:ip]}.to_json
92
+ 'X-Webpay-Client-User-Metadata' => { ip: options[:ip] }.to_json
93
93
  }
94
94
  end
95
95
  end
@@ -168,14 +168,15 @@ module ActiveMerchant #:nodoc:
168
168
  JSON.parse(response)
169
169
  end
170
170
 
171
- def commit(action, params, options={})
171
+ def commit(action, params, options = {})
172
172
  begin
173
173
  response = parse(
174
174
  ssl_post(
175
175
  ((test? ? test_url : live_url) + action),
176
176
  params.to_json,
177
177
  headers(options)
178
- ))
178
+ )
179
+ )
179
180
  rescue ResponseError => e
180
181
  response = parse(e.response.body)
181
182
  end
@@ -183,8 +183,7 @@ module ActiveMerchant #:nodoc:
183
183
  test: test?,
184
184
  authorization: authorization,
185
185
  avs_result: { code: avs_code(response, options) },
186
- cvv_result: response[:CVCResponseCode]
187
- )
186
+ cvv_result: response[:CVCResponseCode])
188
187
  rescue ResponseError => e
189
188
  if e.response.code == '401'
190
189
  return Response.new(false, 'Invalid Login')
@@ -9,7 +9,7 @@ module ActiveMerchant #:nodoc:
9
9
  self.default_currency = 'GBP'
10
10
  self.money_format = :cents
11
11
  self.supported_countries = %w(HK GB AU AD AR BE BR CA CH CN CO CR CY CZ DE DK ES FI FR GI GR HU IE IN IT JP LI LU MC MT MY MX NL NO NZ PA PE PL PT SE SG SI SM TR UM VA)
12
- self.supported_cardtypes = %i[visa master american_express discover jcb maestro elo naranja cabal]
12
+ self.supported_cardtypes = %i[visa master american_express discover jcb maestro elo naranja cabal unionpay]
13
13
  self.currencies_without_fractions = %w(HUF IDR ISK JPY KRW)
14
14
  self.currencies_with_three_decimal_places = %w(BHD KWD OMR RSD TND)
15
15
  self.homepage_url = 'http://www.worldpay.com/'
@@ -26,6 +26,7 @@ module ActiveMerchant #:nodoc:
26
26
  'elo' => 'ELO-SSL',
27
27
  'naranja' => 'NARANJA-SSL',
28
28
  'cabal' => 'CABAL-SSL',
29
+ 'unionpay' => 'CHINAUNIONPAY-SSL',
29
30
  'unknown' => 'CARD-SSL'
30
31
  }
31
32
 
@@ -111,14 +112,14 @@ module ActiveMerchant #:nodoc:
111
112
  credit_request(money, payment_method, payment_details.merge(credit: true, **options))
112
113
  end
113
114
 
114
- def verify(payment_method, options={})
115
+ def verify(payment_method, options = {})
115
116
  MultiResponse.run(:use_first_response) do |r|
116
117
  r.process { authorize(100, payment_method, options) }
117
118
  r.process(:ignore_result) { void(r.authorization, options.merge(authorization_validated: true)) }
118
119
  end
119
120
  end
120
121
 
121
- def store(credit_card, options={})
122
+ def store(credit_card, options = {})
122
123
  requires!(options, :customer)
123
124
  store_request(credit_card, options)
124
125
  end
@@ -259,7 +260,10 @@ module ActiveMerchant #:nodoc:
259
260
  end
260
261
 
261
262
  def add_additional_3ds_data(xml, options)
262
- xml.additional3DSData 'dfReferenceId' => options[:session_id]
263
+ additional_data = { 'dfReferenceId' => options[:session_id] }
264
+ additional_data['challengeWindowSize'] = options[:browser_size] if options[:browser_size]
265
+
266
+ xml.additional3DSData additional_data
263
267
  end
264
268
 
265
269
  def add_3ds_exemption(xml, options)
@@ -432,7 +436,7 @@ module ActiveMerchant #:nodoc:
432
436
  add_address(xml, (options[:billing_address] || options[:address]), options)
433
437
  end
434
438
 
435
- def add_stored_credential_options(xml, options={})
439
+ def add_stored_credential_options(xml, options = {})
436
440
  if options[:stored_credential]
437
441
  add_stored_credential_using_normalized_fields(xml, options)
438
442
  else
@@ -510,7 +514,7 @@ module ActiveMerchant #:nodoc:
510
514
  def add_hcg_additional_data(xml, options)
511
515
  xml.hcgAdditionalData do
512
516
  options[:hcg_additional_data].each do |k, v|
513
- xml.param({name: k.to_s}, v)
517
+ xml.param({ name: k.to_s }, v)
514
518
  end
515
519
  end
516
520
  end
@@ -546,7 +550,7 @@ module ActiveMerchant #:nodoc:
546
550
  xml = xml.strip.gsub(/\&/, '&')
547
551
  doc = Nokogiri::XML(xml, &:strict)
548
552
  doc.remove_namespaces!
549
- resp_params = {action: action}
553
+ resp_params = { action: action }
550
554
 
551
555
  parse_elements(doc.root, resp_params)
552
556
  resp_params
@@ -568,6 +572,8 @@ module ActiveMerchant #:nodoc:
568
572
  end
569
573
 
570
574
  def headers(options)
575
+ idempotency_key = options[:idempotency_key]
576
+
571
577
  headers = {
572
578
  'Content-Type' => 'text/xml',
573
579
  'Authorization' => encoded_credentials
@@ -575,6 +581,8 @@ module ActiveMerchant #:nodoc:
575
581
  if options[:cookie]
576
582
  headers['Cookie'] = options[:cookie] if options[:cookie]
577
583
  end
584
+
585
+ headers['Idempotency-Key'] = idempotency_key if idempotency_key
578
586
  headers
579
587
  end
580
588
 
@@ -683,11 +691,11 @@ module ActiveMerchant #:nodoc:
683
691
  end
684
692
 
685
693
  def order_id_from(raw)
686
- pair = raw.detect { |k, v| k.to_s =~ /_order_code$/ }
694
+ pair = raw.detect { |k, _v| k.to_s =~ /_order_code$/ }
687
695
  (pair ? pair.last : nil)
688
696
  end
689
697
 
690
- def authorization_from_token_details(options={})
698
+ def authorization_from_token_details(options = {})
691
699
  [options[:order_id], options[:token_id], options[:token_scope], options[:customer]].join('|')
692
700
  end
693
701
 
@@ -727,7 +735,7 @@ module ActiveMerchant #:nodoc:
727
735
  def credit_fund_transfer_attribute(options)
728
736
  return unless options[:credit]
729
737
 
730
- {'action' => 'REFUND'}
738
+ { 'action' => 'REFUND' }
731
739
  end
732
740
 
733
741
  def encoded_credentials
@@ -13,14 +13,14 @@ module ActiveMerchant #:nodoc:
13
13
  self.homepage_url = 'http://online.worldpay.com'
14
14
  self.display_name = 'Worldpay Online Payments'
15
15
 
16
- def initialize(options={})
16
+ def initialize(options = {})
17
17
  requires!(options, :client_key, :service_key)
18
18
  @client_key = options[:client_key]
19
19
  @service_key = options[:service_key]
20
20
  super
21
21
  end
22
22
 
23
- def authorize(money, credit_card, options={})
23
+ def authorize(money, credit_card, options = {})
24
24
  response = create_token(true, credit_card.first_name + ' ' + credit_card.last_name, credit_card.month, credit_card.year, credit_card.number, credit_card.verification_value)
25
25
  if response.success?
26
26
  options[:authorizeOnly] = true
@@ -30,9 +30,9 @@ module ActiveMerchant #:nodoc:
30
30
  response
31
31
  end
32
32
 
33
- def capture(money, authorization, options={})
33
+ def capture(money, authorization, options = {})
34
34
  if authorization
35
- commit(:post, "orders/#{CGI.escape(authorization)}/capture", {'captureAmount' => money}, options, 'capture')
35
+ commit(:post, "orders/#{CGI.escape(authorization)}/capture", { 'captureAmount' => money }, options, 'capture')
36
36
  else
37
37
  Response.new(false,
38
38
  'FAILED',
@@ -41,12 +41,11 @@ module ActiveMerchant #:nodoc:
41
41
  authorization: false,
42
42
  avs_result: {},
43
43
  cvv_result: {},
44
- error_code: false
45
- )
44
+ error_code: false)
46
45
  end
47
46
  end
48
47
 
49
- def purchase(money, credit_card, options={})
48
+ def purchase(money, credit_card, options = {})
50
49
  response = create_token(true, credit_card.first_name + ' ' + credit_card.last_name, credit_card.month, credit_card.year, credit_card.number, credit_card.verification_value)
51
50
  if response.success?
52
51
  post = create_post_for_auth_or_purchase(response.authorization, money, options)
@@ -55,18 +54,18 @@ module ActiveMerchant #:nodoc:
55
54
  response
56
55
  end
57
56
 
58
- def refund(money, orderCode, options={})
59
- obj = money ? {'refundAmount' => money} : {}
57
+ def refund(money, orderCode, options = {})
58
+ obj = money ? { 'refundAmount' => money } : {}
60
59
  commit(:post, "orders/#{CGI.escape(orderCode)}/refund", obj, options, 'refund')
61
60
  end
62
61
 
63
- def void(orderCode, options={})
62
+ def void(orderCode, options = {})
64
63
  response = commit(:delete, "orders/#{CGI.escape(orderCode)}", nil, options, 'void')
65
64
  response = refund(nil, orderCode) if !response.success? && (response.params && response.params['customCode'] != 'ORDER_NOT_FOUND')
66
65
  response
67
66
  end
68
67
 
69
- def verify(credit_card, options={})
68
+ def verify(credit_card, options = {})
70
69
  authorize(0, credit_card, options)
71
70
  end
72
71
 
@@ -85,7 +84,7 @@ module ActiveMerchant #:nodoc:
85
84
  },
86
85
  'clientKey' => @client_key
87
86
  }
88
- token_response = commit(:post, 'tokens', obj, {'Authorization' => @service_key}, 'token')
87
+ token_response = commit(:post, 'tokens', obj, { 'Authorization' => @service_key }, 'token')
89
88
  token_response
90
89
  end
91
90
 
@@ -121,13 +120,13 @@ module ActiveMerchant #:nodoc:
121
120
  'Content-Type' => 'application/json',
122
121
  'User-Agent' => "Worldpay/v1 ActiveMerchantBindings/#{ActiveMerchant::VERSION}",
123
122
  'X-Worldpay-Client-User-Agent' => user_agent,
124
- 'X-Worldpay-Client-User-Metadata' => {ip: options[:ip]}.to_json
123
+ 'X-Worldpay-Client-User-Metadata' => { ip: options[:ip] }.to_json
125
124
  }
126
125
  headers['Authorization'] = options['Authorization'] if options['Authorization']
127
126
  headers
128
127
  end
129
128
 
130
- def commit(method, url, parameters=nil, options = {}, type = false)
129
+ def commit(method, url, parameters = nil, options = {}, type = false)
131
130
  raw_response = response = nil
132
131
  success = false
133
132
  begin
@@ -178,8 +177,7 @@ module ActiveMerchant #:nodoc:
178
177
  authorization: authorization,
179
178
  avs_result: {},
180
179
  cvv_result: {},
181
- error_code: success ? nil : response['customCode']
182
- )
180
+ error_code: success ? nil : response['customCode'])
183
181
  end
184
182
 
185
183
  def test?
@@ -17,12 +17,12 @@ module ActiveMerchant #:nodoc:
17
17
  self.money_format = :dollars
18
18
  self.supported_cardtypes = %i[visa master american_express discover jcb]
19
19
 
20
- def initialize(options={})
20
+ def initialize(options = {})
21
21
  requires!(options, :acctid, :subid, :merchantpin)
22
22
  super
23
23
  end
24
24
 
25
- def purchase(money, payment_method, options={})
25
+ def purchase(money, payment_method, options = {})
26
26
  post = {}
27
27
  add_invoice(post, money, options)
28
28
  add_payment_method(post, payment_method)
@@ -31,7 +31,7 @@ module ActiveMerchant #:nodoc:
31
31
  commit('purchase', options, post)
32
32
  end
33
33
 
34
- def authorize(money, payment, options={})
34
+ def authorize(money, payment, options = {})
35
35
  post = {}
36
36
  add_invoice(post, money, options)
37
37
  add_credit_card(post, payment)
@@ -40,7 +40,7 @@ module ActiveMerchant #:nodoc:
40
40
  commit('authorize', options, post)
41
41
  end
42
42
 
43
- def capture(amount, authorization, options={})
43
+ def capture(amount, authorization, options = {})
44
44
  post = {}
45
45
  add_invoice(post, amount, options)
46
46
  add_reference(post, authorization)
@@ -49,7 +49,7 @@ module ActiveMerchant #:nodoc:
49
49
  commit('capture', options, post)
50
50
  end
51
51
 
52
- def refund(amount, authorization, options={})
52
+ def refund(amount, authorization, options = {})
53
53
  post = {}
54
54
  add_invoice(post, amount, options)
55
55
  add_reference(post, authorization)
@@ -58,14 +58,14 @@ module ActiveMerchant #:nodoc:
58
58
  commit('refund', options, post)
59
59
  end
60
60
 
61
- def void(authorization, options={})
61
+ def void(authorization, options = {})
62
62
  post = {}
63
63
  add_reference(post, authorization)
64
64
 
65
65
  commit('void', options, post)
66
66
  end
67
67
 
68
- def verify(credit_card, options={})
68
+ def verify(credit_card, options = {})
69
69
  MultiResponse.run(:use_first_response) do |r|
70
70
  r.process { authorize(100, credit_card, options) }
71
71
  r.process(:ignore_result) { void(r.authorization, options) }
@@ -139,7 +139,7 @@ module ActiveMerchant #:nodoc:
139
139
 
140
140
  ACCOUNT_TYPES = {
141
141
  'checking' => '1',
142
- 'savings' => '2',
142
+ 'savings' => '2'
143
143
  }
144
144
 
145
145
  def add_check(post, payment_method)
@@ -178,7 +178,7 @@ module ActiveMerchant #:nodoc:
178
178
  'refund' => 'ns_credit',
179
179
  'authorize' => 'ns_quicksale_cc',
180
180
  'capture' => 'ns_quicksale_cc',
181
- 'void' => 'ns_void',
181
+ 'void' => 'ns_void'
182
182
  }
183
183
 
184
184
  def commit(action, options, post)