activemerchant 1.110.0 → 1.116.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (200) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG +82 -0
  3. data/lib/active_merchant.rb +1 -1
  4. data/lib/active_merchant/billing/avs_result.rb +1 -1
  5. data/lib/active_merchant/billing/compatibility.rb +3 -3
  6. data/lib/active_merchant/billing/credit_card.rb +1 -1
  7. data/lib/active_merchant/billing/credit_card_methods.rb +6 -6
  8. data/lib/active_merchant/billing/gateway.rb +1 -1
  9. data/lib/active_merchant/billing/gateways/adyen.rb +30 -15
  10. data/lib/active_merchant/billing/gateways/allied_wallet.rb +7 -7
  11. data/lib/active_merchant/billing/gateways/authorize_net.rb +19 -17
  12. data/lib/active_merchant/billing/gateways/authorize_net_arb.rb +3 -4
  13. data/lib/active_merchant/billing/gateways/authorize_net_cim.rb +2 -2
  14. data/lib/active_merchant/billing/gateways/axcessms.rb +8 -9
  15. data/lib/active_merchant/billing/gateways/balanced.rb +5 -4
  16. data/lib/active_merchant/billing/gateways/bambora_apac.rb +8 -8
  17. data/lib/active_merchant/billing/gateways/bank_frick.rb +8 -8
  18. data/lib/active_merchant/billing/gateways/banwire.rb +1 -1
  19. data/lib/active_merchant/billing/gateways/barclaycard_smartpay.rb +6 -4
  20. data/lib/active_merchant/billing/gateways/beanstream.rb +3 -3
  21. data/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb +4 -5
  22. data/lib/active_merchant/billing/gateways/blue_pay.rb +2 -3
  23. data/lib/active_merchant/billing/gateways/blue_snap.rb +83 -23
  24. data/lib/active_merchant/billing/gateways/bogus.rb +19 -19
  25. data/lib/active_merchant/billing/gateways/borgun.rb +12 -12
  26. data/lib/active_merchant/billing/gateways/bpoint.rb +8 -8
  27. data/lib/active_merchant/billing/gateways/braintree.rb +1 -1
  28. data/lib/active_merchant/billing/gateways/braintree_blue.rb +14 -17
  29. data/lib/active_merchant/billing/gateways/bridge_pay.rb +7 -7
  30. data/lib/active_merchant/billing/gateways/cams.rb +8 -8
  31. data/lib/active_merchant/billing/gateways/card_connect.rb +1 -1
  32. data/lib/active_merchant/billing/gateways/card_save.rb +1 -1
  33. data/lib/active_merchant/billing/gateways/card_stream.rb +2 -2
  34. data/lib/active_merchant/billing/gateways/cardknox.rb +8 -8
  35. data/lib/active_merchant/billing/gateways/cardprocess.rb +1 -1
  36. data/lib/active_merchant/billing/gateways/cecabank.rb +5 -5
  37. data/lib/active_merchant/billing/gateways/cenpos.rb +11 -11
  38. data/lib/active_merchant/billing/gateways/checkout.rb +2 -2
  39. data/lib/active_merchant/billing/gateways/checkout_v2.rb +17 -20
  40. data/lib/active_merchant/billing/gateways/clearhaus.rb +7 -7
  41. data/lib/active_merchant/billing/gateways/commercegate.rb +1 -1
  42. data/lib/active_merchant/billing/gateways/conekta.rb +2 -2
  43. data/lib/active_merchant/billing/gateways/creditcall.rb +10 -10
  44. data/lib/active_merchant/billing/gateways/credorax.rb +15 -9
  45. data/lib/active_merchant/billing/gateways/ct_payment.rb +10 -10
  46. data/lib/active_merchant/billing/gateways/culqi.rb +10 -10
  47. data/lib/active_merchant/billing/gateways/cyber_source.rb +58 -37
  48. data/lib/active_merchant/billing/gateways/d_local.rb +11 -11
  49. data/lib/active_merchant/billing/gateways/data_cash.rb +2 -3
  50. data/lib/active_merchant/billing/gateways/decidir.rb +10 -9
  51. data/lib/active_merchant/billing/gateways/dibs.rb +8 -8
  52. data/lib/active_merchant/billing/gateways/digitzs.rb +6 -6
  53. data/lib/active_merchant/billing/gateways/ebanx.rb +9 -9
  54. data/lib/active_merchant/billing/gateways/efsnet.rb +3 -4
  55. data/lib/active_merchant/billing/gateways/elavon.rb +251 -232
  56. data/lib/active_merchant/billing/gateways/element.rb +12 -8
  57. data/lib/active_merchant/billing/gateways/evo_ca.rb +5 -6
  58. data/lib/active_merchant/billing/gateways/eway.rb +3 -4
  59. data/lib/active_merchant/billing/gateways/eway_managed.rb +6 -7
  60. data/lib/active_merchant/billing/gateways/eway_rapid.rb +8 -8
  61. data/lib/active_merchant/billing/gateways/exact.rb +8 -9
  62. data/lib/active_merchant/billing/gateways/ezic.rb +8 -8
  63. data/lib/active_merchant/billing/gateways/fat_zebra.rb +9 -7
  64. data/lib/active_merchant/billing/gateways/federated_canada.rb +2 -3
  65. data/lib/active_merchant/billing/gateways/first_giving.rb +1 -1
  66. data/lib/active_merchant/billing/gateways/first_pay.rb +6 -6
  67. data/lib/active_merchant/billing/gateways/firstdata_e4.rb +7 -7
  68. data/lib/active_merchant/billing/gateways/firstdata_e4_v27.rb +4 -4
  69. data/lib/active_merchant/billing/gateways/flo2cash.rb +9 -9
  70. data/lib/active_merchant/billing/gateways/flo2cash_simple.rb +1 -1
  71. data/lib/active_merchant/billing/gateways/forte.rb +14 -8
  72. data/lib/active_merchant/billing/gateways/global_collect.rb +15 -10
  73. data/lib/active_merchant/billing/gateways/global_transport.rb +7 -7
  74. data/lib/active_merchant/billing/gateways/hdfc.rb +10 -10
  75. data/lib/active_merchant/billing/gateways/hps.rb +16 -13
  76. data/lib/active_merchant/billing/gateways/iats_payments.rb +9 -4
  77. data/lib/active_merchant/billing/gateways/in_context_paypal_express.rb +1 -1
  78. data/lib/active_merchant/billing/gateways/inspire.rb +3 -4
  79. data/lib/active_merchant/billing/gateways/instapay.rb +1 -2
  80. data/lib/active_merchant/billing/gateways/ipp.rb +7 -7
  81. data/lib/active_merchant/billing/gateways/iridium.rb +16 -17
  82. data/lib/active_merchant/billing/gateways/iveri.rb +7 -7
  83. data/lib/active_merchant/billing/gateways/ixopay.rb +7 -7
  84. data/lib/active_merchant/billing/gateways/jetpay.rb +1 -2
  85. data/lib/active_merchant/billing/gateways/jetpay_v2.rb +4 -5
  86. data/lib/active_merchant/billing/gateways/kushki.rb +6 -6
  87. data/lib/active_merchant/billing/gateways/latitude19.rb +14 -14
  88. data/lib/active_merchant/billing/gateways/linkpoint.rb +5 -6
  89. data/lib/active_merchant/billing/gateways/litle.rb +12 -12
  90. data/lib/active_merchant/billing/gateways/mastercard.rb +12 -12
  91. data/lib/active_merchant/billing/gateways/mercado_pago.rb +8 -8
  92. data/lib/active_merchant/billing/gateways/merchant_e_solutions.rb +1 -2
  93. data/lib/active_merchant/billing/gateways/merchant_one.rb +1 -1
  94. data/lib/active_merchant/billing/gateways/merchant_partners.rb +10 -10
  95. data/lib/active_merchant/billing/gateways/merchant_ware.rb +5 -7
  96. data/lib/active_merchant/billing/gateways/merchant_ware_version_four.rb +4 -6
  97. data/lib/active_merchant/billing/gateways/mercury.rb +4 -4
  98. data/lib/active_merchant/billing/gateways/metrics_global.rb +4 -5
  99. data/lib/active_merchant/billing/gateways/micropayment.rb +8 -8
  100. data/lib/active_merchant/billing/gateways/migs.rb +3 -4
  101. data/lib/active_merchant/billing/gateways/modern_payments_cim.rb +2 -4
  102. data/lib/active_merchant/billing/gateways/monei.rb +7 -7
  103. data/lib/active_merchant/billing/gateways/moneris.rb +4 -3
  104. data/lib/active_merchant/billing/gateways/money_movers.rb +2 -3
  105. data/lib/active_merchant/billing/gateways/mundipagg.rb +37 -10
  106. data/lib/active_merchant/billing/gateways/nab_transact.rb +2 -4
  107. data/lib/active_merchant/billing/gateways/ncr_secure_pay.rb +7 -7
  108. data/lib/active_merchant/billing/gateways/net_registry.rb +1 -2
  109. data/lib/active_merchant/billing/gateways/netaxept.rb +6 -6
  110. data/lib/active_merchant/billing/gateways/netbanx.rb +12 -10
  111. data/lib/active_merchant/billing/gateways/netbilling.rb +4 -5
  112. data/lib/active_merchant/billing/gateways/network_merchants.rb +2 -3
  113. data/lib/active_merchant/billing/gateways/nmi.rb +21 -7
  114. data/lib/active_merchant/billing/gateways/ogone.rb +3 -3
  115. data/lib/active_merchant/billing/gateways/omise.rb +13 -13
  116. data/lib/active_merchant/billing/gateways/openpay.rb +4 -5
  117. data/lib/active_merchant/billing/gateways/opp.rb +12 -12
  118. data/lib/active_merchant/billing/gateways/optimal_payment.rb +3 -4
  119. data/lib/active_merchant/billing/gateways/orbital.rb +66 -64
  120. data/lib/active_merchant/billing/gateways/pac_net_raven.rb +3 -4
  121. data/lib/active_merchant/billing/gateways/pagarme.rb +9 -9
  122. data/lib/active_merchant/billing/gateways/pago_facil.rb +2 -2
  123. data/lib/active_merchant/billing/gateways/pay_conex.rb +8 -8
  124. data/lib/active_merchant/billing/gateways/pay_gate_xml.rb +6 -7
  125. data/lib/active_merchant/billing/gateways/pay_hub.rb +7 -8
  126. data/lib/active_merchant/billing/gateways/pay_junction.rb +4 -5
  127. data/lib/active_merchant/billing/gateways/pay_junction_v2.rb +9 -9
  128. data/lib/active_merchant/billing/gateways/pay_secure.rb +2 -3
  129. data/lib/active_merchant/billing/gateways/paybox_direct.rb +23 -1
  130. data/lib/active_merchant/billing/gateways/payeezy.rb +12 -12
  131. data/lib/active_merchant/billing/gateways/payex.rb +11 -12
  132. data/lib/active_merchant/billing/gateways/payflow.rb +4 -1
  133. data/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb +1 -1
  134. data/lib/active_merchant/billing/gateways/payflow/payflow_express_response.rb +1 -1
  135. data/lib/active_merchant/billing/gateways/payment_express.rb +1 -2
  136. data/lib/active_merchant/billing/gateways/paymentez.rb +5 -5
  137. data/lib/active_merchant/billing/gateways/paymill.rb +10 -10
  138. data/lib/active_merchant/billing/gateways/paypal_express.rb +1 -1
  139. data/lib/active_merchant/billing/gateways/paypal_express_common.rb +1 -1
  140. data/lib/active_merchant/billing/gateways/payscout.rb +1 -2
  141. data/lib/active_merchant/billing/gateways/paystation.rb +3 -4
  142. data/lib/active_merchant/billing/gateways/payu_in.rb +3 -3
  143. data/lib/active_merchant/billing/gateways/payu_latam.rb +21 -11
  144. data/lib/active_merchant/billing/gateways/payway.rb +8 -9
  145. data/lib/active_merchant/billing/gateways/plugnpay.rb +2 -3
  146. data/lib/active_merchant/billing/gateways/pro_pay.rb +8 -8
  147. data/lib/active_merchant/billing/gateways/psigate.rb +3 -4
  148. data/lib/active_merchant/billing/gateways/psl_card.rb +1 -2
  149. data/lib/active_merchant/billing/gateways/qbms.rb +4 -5
  150. data/lib/active_merchant/billing/gateways/quantum.rb +1 -2
  151. data/lib/active_merchant/billing/gateways/quickbooks.rb +4 -3
  152. data/lib/active_merchant/billing/gateways/quickpay/quickpay_v10.rb +3 -4
  153. data/lib/active_merchant/billing/gateways/quickpay/quickpay_v4to7.rb +1 -2
  154. data/lib/active_merchant/billing/gateways/qvalent.rb +9 -9
  155. data/lib/active_merchant/billing/gateways/realex.rb +2 -1
  156. data/lib/active_merchant/billing/gateways/redsys.rb +7 -7
  157. data/lib/active_merchant/billing/gateways/s5.rb +7 -7
  158. data/lib/active_merchant/billing/gateways/safe_charge.rb +12 -12
  159. data/lib/active_merchant/billing/gateways/sage.rb +3 -5
  160. data/lib/active_merchant/billing/gateways/sage_pay.rb +6 -7
  161. data/lib/active_merchant/billing/gateways/sallie_mae.rb +1 -2
  162. data/lib/active_merchant/billing/gateways/secure_net.rb +1 -2
  163. data/lib/active_merchant/billing/gateways/secure_pay.rb +3 -4
  164. data/lib/active_merchant/billing/gateways/secure_pay_au.rb +2 -4
  165. data/lib/active_merchant/billing/gateways/secure_pay_tech.rb +1 -2
  166. data/lib/active_merchant/billing/gateways/securion_pay.rb +5 -6
  167. data/lib/active_merchant/billing/gateways/skip_jack.rb +3 -4
  168. data/lib/active_merchant/billing/gateways/smart_ps.rb +5 -6
  169. data/lib/active_merchant/billing/gateways/so_easy_pay.rb +7 -7
  170. data/lib/active_merchant/billing/gateways/spreedly_core.rb +6 -6
  171. data/lib/active_merchant/billing/gateways/stripe.rb +11 -11
  172. data/lib/active_merchant/billing/gateways/stripe_payment_intents.rb +9 -0
  173. data/lib/active_merchant/billing/gateways/swipe_checkout.rb +3 -4
  174. data/lib/active_merchant/billing/gateways/telr.rb +9 -9
  175. data/lib/active_merchant/billing/gateways/trans_first.rb +3 -3
  176. data/lib/active_merchant/billing/gateways/trans_first_transaction_express.rb +14 -14
  177. data/lib/active_merchant/billing/gateways/transact_pro.rb +9 -9
  178. data/lib/active_merchant/billing/gateways/trust_commerce.rb +8 -9
  179. data/lib/active_merchant/billing/gateways/usa_epay.rb +1 -1
  180. data/lib/active_merchant/billing/gateways/usa_epay_advanced.rb +36 -36
  181. data/lib/active_merchant/billing/gateways/usa_epay_transaction.rb +4 -5
  182. data/lib/active_merchant/billing/gateways/vanco.rb +3 -3
  183. data/lib/active_merchant/billing/gateways/verifi.rb +1 -2
  184. data/lib/active_merchant/billing/gateways/viaklix.rb +1 -2
  185. data/lib/active_merchant/billing/gateways/visanet_peru.rb +10 -10
  186. data/lib/active_merchant/billing/gateways/webpay.rb +2 -2
  187. data/lib/active_merchant/billing/gateways/wepay.rb +3 -2
  188. data/lib/active_merchant/billing/gateways/wirecard.rb +1 -2
  189. data/lib/active_merchant/billing/gateways/worldpay.rb +12 -8
  190. data/lib/active_merchant/billing/gateways/worldpay_online_payments.rb +14 -16
  191. data/lib/active_merchant/billing/gateways/worldpay_us.rb +9 -9
  192. data/lib/active_merchant/billing/response.rb +1 -1
  193. data/lib/active_merchant/country.rb +1 -1
  194. data/lib/active_merchant/network_connection_retries.rb +2 -2
  195. data/lib/active_merchant/post_data.rb +1 -1
  196. data/lib/active_merchant/posts_data.rb +1 -1
  197. data/lib/active_merchant/version.rb +1 -1
  198. data/lib/support/ssl_verify.rb +2 -2
  199. data/lib/support/ssl_version.rb +2 -2
  200. metadata +16 -2
@@ -28,48 +28,50 @@ module ActiveMerchant #:nodoc:
28
28
  '500' => 'An internal error occurred;'
29
29
  }
30
30
 
31
- def initialize(options={})
31
+ def initialize(options = {})
32
32
  requires!(options, :api_key)
33
33
  super
34
34
  end
35
35
 
36
- def purchase(money, payment, options={})
36
+ def purchase(money, payment, options = {})
37
37
  post = {}
38
38
  add_invoice(post, money, options)
39
39
  add_customer_data(post, options) unless payment.is_a?(String)
40
40
  add_shipping_address(post, options)
41
41
  add_payment(post, payment, options)
42
+ add_submerchant(post, options)
42
43
 
43
44
  commit('sale', post)
44
45
  end
45
46
 
46
- def authorize(money, payment, options={})
47
+ def authorize(money, payment, options = {})
47
48
  post = {}
48
49
  add_invoice(post, money, options)
49
50
  add_customer_data(post, options) unless payment.is_a?(String)
50
51
  add_shipping_address(post, options)
51
52
  add_payment(post, payment, options)
52
53
  add_capture_flag(post, payment)
54
+ add_submerchant(post, options)
53
55
  commit('authonly', post)
54
56
  end
55
57
 
56
- def capture(money, authorization, options={})
58
+ def capture(money, authorization, options = {})
57
59
  post = {}
58
60
  post[:code] = authorization
59
61
  add_invoice(post, money, options)
60
62
  commit('capture', post, authorization)
61
63
  end
62
64
 
63
- def refund(money, authorization, options={})
65
+ def refund(money, authorization, options = {})
64
66
  add_invoice(post = {}, money, options)
65
67
  commit('refund', post, authorization)
66
68
  end
67
69
 
68
- def void(authorization, options={})
70
+ def void(authorization, options = {})
69
71
  commit('void', nil, authorization)
70
72
  end
71
73
 
72
- def store(payment, options={})
74
+ def store(payment, options = {})
73
75
  post = {}
74
76
  options.update(name: payment.name)
75
77
  options = add_customer(options) unless options[:customer_id]
@@ -77,7 +79,7 @@ module ActiveMerchant #:nodoc:
77
79
  commit('store', post, options[:customer_id])
78
80
  end
79
81
 
80
- def verify(credit_card, options={})
82
+ def verify(credit_card, options = {})
81
83
  MultiResponse.run(:use_first_response) do |r|
82
84
  r.process { authorize(100, credit_card, options) }
83
85
  r.process(:ignore_result) { void(r.authorization, options) }
@@ -202,6 +204,31 @@ module ActiveMerchant #:nodoc:
202
204
  %w[sodexo vr].include? card_brand(payment)
203
205
  end
204
206
 
207
+ def add_submerchant(post, options)
208
+ if submerchant = options[:submerchant]
209
+ post[:SubMerchant] = {}
210
+ post[:SubMerchant][:Merchant_Category_Code] = submerchant[:merchant_category_code] if submerchant[:merchant_category_code]
211
+ post[:SubMerchant][:Payment_Facilitator_Code] = submerchant[:payment_facilitator_code] if submerchant[:payment_facilitator_code]
212
+ post[:SubMerchant][:Code] = submerchant[:code] if submerchant[:code]
213
+ post[:SubMerchant][:Name] = submerchant[:name] if submerchant[:name]
214
+ post[:SubMerchant][:Document] = submerchant[:document] if submerchant[:document]
215
+ post[:SubMerchant][:Type] = submerchant[:type] if submerchant[:type]
216
+ post[:SubMerchant][:Phone] = {}
217
+ post[:SubMerchant][:Phone][:Country_Code] = submerchant[:phone][:country_code] if submerchant.dig(:phone, :country_code)
218
+ post[:SubMerchant][:Phone][:Number] = submerchant[:phone][:number] if submerchant.dig(:phone, :number)
219
+ post[:SubMerchant][:Phone][:Area_Code] = submerchant[:phone][:area_code] if submerchant.dig(:phone, :area_code)
220
+ post[:SubMerchant][:Address] = {}
221
+ post[:SubMerchant][:Address][:Street] = submerchant[:address][:street] if submerchant.dig(:address, :street)
222
+ post[:SubMerchant][:Address][:Number] = submerchant[:address][:number] if submerchant.dig(:address, :number)
223
+ post[:SubMerchant][:Address][:Complement] = submerchant[:address][:complement] if submerchant.dig(:address, :complement)
224
+ post[:SubMerchant][:Address][:Neighborhood] = submerchant[:address][:neighborhood] if submerchant.dig(:address, :neighborhood)
225
+ post[:SubMerchant][:Address][:City] = submerchant[:address][:city] if submerchant.dig(:address, :city)
226
+ post[:SubMerchant][:Address][:State] = submerchant[:address][:state] if submerchant.dig(:address, :state)
227
+ post[:SubMerchant][:Address][:Country] = submerchant[:address][:country] if submerchant.dig(:address, :country)
228
+ post[:SubMerchant][:Address][:Zip_Code] = submerchant[:address][:zip_code] if submerchant.dig(:address, :zip_code)
229
+ end
230
+ end
231
+
205
232
  def headers
206
233
  {
207
234
  'Authorization' => 'Basic ' + Base64.strict_encode64("#{@options[:api_key]}:"),
@@ -275,7 +302,7 @@ module ActiveMerchant #:nodoc:
275
302
  parsed_response_body = parse(error.response.body)
276
303
  message = parsed_response_body['message']
277
304
 
278
- parsed_response_body['errors']&.each do |type, descriptions|
305
+ parsed_response_body['errors']&.each do |_type, descriptions|
279
306
  message += ' | '
280
307
  message += descriptions.join(', ')
281
308
  end
@@ -291,7 +318,7 @@ module ActiveMerchant #:nodoc:
291
318
  error_string = ''
292
319
 
293
320
  response['last_transaction']['gateway_response']['errors']&.each do |error|
294
- error.each do |key, value|
321
+ error.each do |_key, value|
295
322
  error_string += ' | ' unless error_string.blank?
296
323
  error_string += value
297
324
  end
@@ -235,16 +235,14 @@ module ActiveMerchant #:nodoc:
235
235
 
236
236
  Response.new(success?(response), message_from(response), response,
237
237
  test: test?,
238
- authorization: authorization_from(action, response)
239
- )
238
+ authorization: authorization_from(action, response))
240
239
  end
241
240
 
242
241
  def commit_periodic(action, request)
243
242
  response = parse(ssl_post(test? ? self.test_periodic_url : self.live_periodic_url, build_periodic_request(action, request)))
244
243
  Response.new(success?(response), message_from(response), response,
245
244
  test: test?,
246
- authorization: authorization_from(action, response)
247
- )
245
+ authorization: authorization_from(action, response))
248
246
  end
249
247
 
250
248
  def success?(response)
@@ -13,12 +13,12 @@ module ActiveMerchant #:nodoc:
13
13
  self.homepage_url = 'http://www.ncrretailonline.com'
14
14
  self.display_name = 'NCR Secure Pay'
15
15
 
16
- def initialize(options={})
16
+ def initialize(options = {})
17
17
  requires!(options, :username, :password)
18
18
  super
19
19
  end
20
20
 
21
- def purchase(money, payment, options={})
21
+ def purchase(money, payment, options = {})
22
22
  post = {}
23
23
  add_invoice(post, money, options)
24
24
  add_payment(post, payment)
@@ -27,7 +27,7 @@ module ActiveMerchant #:nodoc:
27
27
  commit('sale', post)
28
28
  end
29
29
 
30
- def authorize(money, payment, options={})
30
+ def authorize(money, payment, options = {})
31
31
  post = {}
32
32
  add_invoice(post, money, options)
33
33
  add_payment(post, payment)
@@ -36,7 +36,7 @@ module ActiveMerchant #:nodoc:
36
36
  commit('preauth', post)
37
37
  end
38
38
 
39
- def capture(money, authorization, options={})
39
+ def capture(money, authorization, options = {})
40
40
  post = {}
41
41
  add_reference(post, authorization)
42
42
  add_invoice(post, money, options)
@@ -44,7 +44,7 @@ module ActiveMerchant #:nodoc:
44
44
  commit('preauthcomplete', post)
45
45
  end
46
46
 
47
- def refund(money, authorization, options={})
47
+ def refund(money, authorization, options = {})
48
48
  post = {}
49
49
  add_reference(post, authorization)
50
50
  add_invoice(post, money, options)
@@ -52,13 +52,13 @@ module ActiveMerchant #:nodoc:
52
52
  commit('credit', post)
53
53
  end
54
54
 
55
- def void(authorization, options={})
55
+ def void(authorization, options = {})
56
56
  post = {}
57
57
  add_reference(post, authorization)
58
58
  commit('void', post)
59
59
  end
60
60
 
61
- def verify(credit_card, options={})
61
+ def verify(credit_card, options = {})
62
62
  MultiResponse.run(:use_first_response) do |r|
63
63
  r.process { authorize(100, credit_card, options) }
64
64
  r.process(:ignore_result) { void(r.authorization, options) }
@@ -145,8 +145,7 @@ module ActiveMerchant
145
145
  response = parse(ssl_post(self.live_url, post_data(action, params)))
146
146
 
147
147
  Response.new(response['status'] == 'approved', message_from(response), response,
148
- authorization: authorization_from(response, action)
149
- )
148
+ authorization: authorization_from(response, action))
150
149
  end
151
150
 
152
151
  def post_data(action, params)
@@ -94,12 +94,12 @@ module ActiveMerchant #:nodoc:
94
94
  commit('Netaxept/query.aspx', post)
95
95
  end
96
96
 
97
- def add_credentials(post, options, secure=true)
97
+ def add_credentials(post, options, secure = true)
98
98
  post[:merchantId] = @options[:login]
99
99
  post[:token] = @options[:password] if secure
100
100
  end
101
101
 
102
- def add_authorization(post, authorization, money=nil)
102
+ def add_authorization(post, authorization, money = nil)
103
103
  post[:transactionId] = authorization
104
104
  post[:transactionAmount] = amount(money) if money
105
105
  end
@@ -118,7 +118,7 @@ module ActiveMerchant #:nodoc:
118
118
  post[:securityCode] = options.verification_value
119
119
  end
120
120
 
121
- def commit(path, parameters, xml=true)
121
+ def commit(path, parameters, xml = true)
122
122
  raw = parse(ssl_get(build_url(path, parameters)), xml)
123
123
 
124
124
  success = false
@@ -141,12 +141,12 @@ module ActiveMerchant #:nodoc:
141
141
  )
142
142
  end
143
143
 
144
- def parse(result, expects_xml=true)
144
+ def parse(result, expects_xml = true)
145
145
  if expects_xml
146
146
  doc = REXML::Document.new(result)
147
147
  extract_xml(doc.root).merge(container: doc.root.name)
148
148
  else
149
- {result: result}
149
+ { result: result }
150
150
  end
151
151
  end
152
152
 
@@ -162,7 +162,7 @@ module ActiveMerchant #:nodoc:
162
162
  end
163
163
  end
164
164
 
165
- def build_url(base, parameters=nil)
165
+ def build_url(base, parameters = nil)
166
166
  url = (test? ? self.test_url : self.live_url).dup
167
167
  url << base
168
168
  if parameters
@@ -22,12 +22,12 @@ module ActiveMerchant #:nodoc:
22
22
  self.homepage_url = 'https://processing.paysafe.com/'
23
23
  self.display_name = 'Netbanx by PaySafe'
24
24
 
25
- def initialize(options={})
25
+ def initialize(options = {})
26
26
  requires!(options, :account_number, :api_key)
27
27
  super
28
28
  end
29
29
 
30
- def purchase(money, payment, options={})
30
+ def purchase(money, payment, options = {})
31
31
  # Do a Verification with AVS prior to purchase
32
32
  verification_response = verify(payment, options)
33
33
  return verification_response if verification_response.message != 'OK'
@@ -40,7 +40,7 @@ module ActiveMerchant #:nodoc:
40
40
  commit(:post, 'auths', post)
41
41
  end
42
42
 
43
- def authorize(money, payment, options={})
43
+ def authorize(money, payment, options = {})
44
44
  # Do a Verification with AVS prior to Auth + Settle
45
45
  verification_response = verify(payment, options)
46
46
  return verification_response if verification_response.message != 'OK'
@@ -52,22 +52,24 @@ module ActiveMerchant #:nodoc:
52
52
  commit(:post, 'auths', post)
53
53
  end
54
54
 
55
- def capture(money, authorization, options={})
55
+ def capture(money, authorization, options = {})
56
56
  post = {}
57
57
  add_invoice(post, money, options)
58
58
 
59
59
  commit(:post, "auths/#{authorization}/settlements", post)
60
60
  end
61
61
 
62
- def refund(money, authorization, options={})
62
+ def refund(money, authorization, options = {})
63
63
  # If the transactions that are pending, API call needs to be Cancellation
64
64
  settlement_data = get_settlement(authorization)
65
65
  return settlement_data if settlement_data.message != 'OK'
66
66
 
67
67
  post = {}
68
- if settlement_data.params['status'] == 'PENDING'
68
+ if settlement_data.params['status'] == 'PENDING' && money == settlement_data.params['amount']
69
69
  post[:status] = 'CANCELLED'
70
70
  commit(:put, "settlements/#{authorization}", post)
71
+ elsif settlement_data.params['status'] == 'PENDING' && (money < settlement_data.params['amount'] || money > settlement_data.params['amount'])
72
+ return Response.new(false, 'Transaction not settled. Either do a full refund or try partial refund after settlement.')
71
73
  else
72
74
  add_invoice(post, money, options)
73
75
 
@@ -84,14 +86,14 @@ module ActiveMerchant #:nodoc:
84
86
  commit(:get, "settlements/#{authorization}", post)
85
87
  end
86
88
 
87
- def void(authorization, options={})
89
+ def void(authorization, options = {})
88
90
  post = {}
89
91
  add_order_id(post, options)
90
92
 
91
93
  commit(:post, "auths/#{authorization}/voidauths", post)
92
94
  end
93
95
 
94
- def verify(credit_card, options={})
96
+ def verify(credit_card, options = {})
95
97
  post = {}
96
98
  add_payment(post, credit_card, options)
97
99
  add_order_id(post, options)
@@ -101,7 +103,7 @@ module ActiveMerchant #:nodoc:
101
103
 
102
104
  # note: when passing options[:customer] we only attempt to add the
103
105
  # card to the profile_id passed as the options[:customer]
104
- def store(credit_card, options={})
106
+ def store(credit_card, options = {})
105
107
  # locale can only be one of en_US, fr_CA, en_GB
106
108
  requires!(options, :locale)
107
109
  post = {}
@@ -196,7 +198,7 @@ module ActiveMerchant #:nodoc:
196
198
  street: address[:address1],
197
199
  city: address[:city],
198
200
  zip: address[:zip],
199
- state: address[:state],
201
+ state: address[:state]
200
202
  }
201
203
  mapped[:country] = country.code(:alpha2).value unless country.blank?
202
204
 
@@ -196,13 +196,12 @@ module ActiveMerchant #:nodoc:
196
196
  Response.new(success?(response), message_from(response), response,
197
197
  test: test_response?(response),
198
198
  authorization: response[:trans_id],
199
- avs_result: { code: response[:avs_code]},
200
- cvv_result: response[:cvv2_code]
201
- )
199
+ avs_result: { code: response[:avs_code] },
200
+ cvv_result: response[:cvv2_code])
202
201
  rescue ActiveMerchant::ResponseError => e
203
202
  raise unless e.response.code =~ /^[67]\d\d$/
204
203
 
205
- return Response.new(false, e.response.message, {status_code: e.response.code}, test: test?)
204
+ return Response.new(false, e.response.message, { status_code: e.response.code }, test: test?)
206
205
  end
207
206
 
208
207
  def test_response?(response)
@@ -223,7 +222,7 @@ module ActiveMerchant #:nodoc:
223
222
  parameters[:pay_type] = 'C'
224
223
  parameters[:tran_type] = TRANSACTIONS[action]
225
224
 
226
- parameters.reject { |k, v| v.blank? }.collect { |key, value| "#{key}=#{CGI.escape(value.to_s)}" }.join('&')
225
+ parameters.reject { |_k, v| v.blank? }.collect { |key, value| "#{key}=#{CGI.escape(value.to_s)}" }.join('&')
227
226
  end
228
227
  end
229
228
  end
@@ -203,9 +203,8 @@ module ActiveMerchant #:nodoc:
203
203
  Response.new(success, raw['responsetext'], raw,
204
204
  test: test?,
205
205
  authorization: authorization,
206
- avs_result: { code: raw['avsresponse']},
207
- cvv_result: raw['cvvresponse']
208
- )
206
+ avs_result: { code: raw['avsresponse'] },
207
+ cvv_result: raw['cvvresponse'])
209
208
  end
210
209
 
211
210
  def build_request(action, parameters)
@@ -27,7 +27,7 @@ module ActiveMerchant #:nodoc:
27
27
  super
28
28
  end
29
29
 
30
- def purchase(amount, payment_method, options={})
30
+ def purchase(amount, payment_method, options = {})
31
31
  post = {}
32
32
  add_invoice(post, amount, options)
33
33
  add_payment_method(post, payment_method, options)
@@ -36,11 +36,12 @@ module ActiveMerchant #:nodoc:
36
36
  add_vendor_data(post, options)
37
37
  add_merchant_defined_fields(post, options)
38
38
  add_level3_fields(post, options)
39
+ add_three_d_secure(post, options)
39
40
 
40
41
  commit('sale', post)
41
42
  end
42
43
 
43
- def authorize(amount, payment_method, options={})
44
+ def authorize(amount, payment_method, options = {})
44
45
  post = {}
45
46
  add_invoice(post, amount, options)
46
47
  add_payment_method(post, payment_method, options)
@@ -49,11 +50,12 @@ module ActiveMerchant #:nodoc:
49
50
  add_vendor_data(post, options)
50
51
  add_merchant_defined_fields(post, options)
51
52
  add_level3_fields(post, options)
53
+ add_three_d_secure(post, options)
52
54
 
53
55
  commit('auth', post)
54
56
  end
55
57
 
56
- def capture(amount, authorization, options={})
58
+ def capture(amount, authorization, options = {})
57
59
  post = {}
58
60
  add_invoice(post, amount, options)
59
61
  add_reference(post, authorization)
@@ -62,7 +64,7 @@ module ActiveMerchant #:nodoc:
62
64
  commit('capture', post)
63
65
  end
64
66
 
65
- def void(authorization, options={})
67
+ def void(authorization, options = {})
66
68
  post = {}
67
69
  add_reference(post, authorization)
68
70
  add_payment_type(post, authorization)
@@ -70,7 +72,7 @@ module ActiveMerchant #:nodoc:
70
72
  commit('void', post)
71
73
  end
72
74
 
73
- def refund(amount, authorization, options={})
75
+ def refund(amount, authorization, options = {})
74
76
  post = {}
75
77
  add_invoice(post, amount, options)
76
78
  add_reference(post, authorization)
@@ -79,7 +81,7 @@ module ActiveMerchant #:nodoc:
79
81
  commit('refund', post)
80
82
  end
81
83
 
82
- def credit(amount, payment_method, options={})
84
+ def credit(amount, payment_method, options = {})
83
85
  post = {}
84
86
  add_invoice(post, amount, options)
85
87
  add_payment_method(post, payment_method, options)
@@ -90,7 +92,7 @@ module ActiveMerchant #:nodoc:
90
92
  commit('credit', post)
91
93
  end
92
94
 
93
- def verify(payment_method, options={})
95
+ def verify(payment_method, options = {})
94
96
  post = {}
95
97
  add_payment_method(post, payment_method, options)
96
98
  add_customer_data(post, options)
@@ -248,6 +250,18 @@ module ActiveMerchant #:nodoc:
248
250
  end
249
251
  end
250
252
 
253
+ def add_three_d_secure(post, options)
254
+ return unless options[:three_d_secure]
255
+
256
+ if (three_d_secure = options[:three_d_secure])
257
+ post[:eci] = three_d_secure[:eci]
258
+ post[:cavv] = three_d_secure[:cavv]
259
+ post[:xid] = three_d_secure[:xid]
260
+ post[:three_ds_version] = three_d_secure[:version]
261
+ post[:directory_server_id] = three_d_secure[:ds_transaction_id]
262
+ end
263
+ end
264
+
251
265
  def add_reference(post, authorization)
252
266
  transaction_id, = split_authorization(authorization)
253
267
  post[:transactionid] = transaction_id