activemerchant 1.114.0 → 1.120.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (206) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG +183 -0
  3. data/README.md +4 -2
  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/check.rb +10 -0
  7. data/lib/active_merchant/billing/compatibility.rb +3 -3
  8. data/lib/active_merchant/billing/credit_card.rb +3 -0
  9. data/lib/active_merchant/billing/credit_card_methods.rb +80 -15
  10. data/lib/active_merchant/billing/gateways/adyen.rb +44 -20
  11. data/lib/active_merchant/billing/gateways/allied_wallet.rb +7 -7
  12. data/lib/active_merchant/billing/gateways/authorize_net.rb +50 -12
  13. data/lib/active_merchant/billing/gateways/authorize_net_arb.rb +3 -4
  14. data/lib/active_merchant/billing/gateways/authorize_net_cim.rb +5 -1
  15. data/lib/active_merchant/billing/gateways/axcessms.rb +8 -9
  16. data/lib/active_merchant/billing/gateways/balanced.rb +4 -3
  17. data/lib/active_merchant/billing/gateways/bambora_apac.rb +7 -7
  18. data/lib/active_merchant/billing/gateways/bank_frick.rb +7 -7
  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 +22 -18
  25. data/lib/active_merchant/billing/gateways/bogus.rb +19 -19
  26. data/lib/active_merchant/billing/gateways/borgun.rb +11 -11
  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 +60 -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 +7 -7
  36. data/lib/active_merchant/billing/gateways/cardprocess.rb +1 -1
  37. data/lib/active_merchant/billing/gateways/cashnet.rb +7 -2
  38. data/lib/active_merchant/billing/gateways/cecabank.rb +5 -5
  39. data/lib/active_merchant/billing/gateways/cenpos.rb +10 -10
  40. data/lib/active_merchant/billing/gateways/checkout.rb +2 -2
  41. data/lib/active_merchant/billing/gateways/checkout_v2.rb +38 -20
  42. data/lib/active_merchant/billing/gateways/clearhaus.rb +7 -7
  43. data/lib/active_merchant/billing/gateways/commercegate.rb +1 -1
  44. data/lib/active_merchant/billing/gateways/conekta.rb +2 -2
  45. data/lib/active_merchant/billing/gateways/creditcall.rb +10 -10
  46. data/lib/active_merchant/billing/gateways/credorax.rb +39 -23
  47. data/lib/active_merchant/billing/gateways/ct_payment.rb +10 -10
  48. data/lib/active_merchant/billing/gateways/culqi.rb +9 -9
  49. data/lib/active_merchant/billing/gateways/cyber_source.rb +81 -39
  50. data/lib/active_merchant/billing/gateways/d_local.rb +12 -12
  51. data/lib/active_merchant/billing/gateways/data_cash.rb +2 -3
  52. data/lib/active_merchant/billing/gateways/decidir.rb +31 -10
  53. data/lib/active_merchant/billing/gateways/dibs.rb +8 -8
  54. data/lib/active_merchant/billing/gateways/digitzs.rb +5 -5
  55. data/lib/active_merchant/billing/gateways/ebanx.rb +9 -9
  56. data/lib/active_merchant/billing/gateways/efsnet.rb +2 -3
  57. data/lib/active_merchant/billing/gateways/elavon.rb +296 -225
  58. data/lib/active_merchant/billing/gateways/element.rb +8 -8
  59. data/lib/active_merchant/billing/gateways/evo_ca.rb +5 -6
  60. data/lib/active_merchant/billing/gateways/eway.rb +3 -4
  61. data/lib/active_merchant/billing/gateways/eway_managed.rb +6 -7
  62. data/lib/active_merchant/billing/gateways/eway_rapid.rb +19 -6
  63. data/lib/active_merchant/billing/gateways/exact.rb +8 -9
  64. data/lib/active_merchant/billing/gateways/ezic.rb +7 -7
  65. data/lib/active_merchant/billing/gateways/fat_zebra.rb +4 -4
  66. data/lib/active_merchant/billing/gateways/federated_canada.rb +2 -3
  67. data/lib/active_merchant/billing/gateways/first_giving.rb +1 -1
  68. data/lib/active_merchant/billing/gateways/first_pay.rb +6 -6
  69. data/lib/active_merchant/billing/gateways/firstdata_e4.rb +7 -7
  70. data/lib/active_merchant/billing/gateways/firstdata_e4_v27.rb +21 -10
  71. data/lib/active_merchant/billing/gateways/flo2cash.rb +8 -8
  72. data/lib/active_merchant/billing/gateways/flo2cash_simple.rb +1 -1
  73. data/lib/active_merchant/billing/gateways/forte.rb +26 -8
  74. data/lib/active_merchant/billing/gateways/global_collect.rb +35 -16
  75. data/lib/active_merchant/billing/gateways/global_transport.rb +7 -7
  76. data/lib/active_merchant/billing/gateways/hdfc.rb +9 -9
  77. data/lib/active_merchant/billing/gateways/hps.rb +72 -9
  78. data/lib/active_merchant/billing/gateways/iats_payments.rb +9 -4
  79. data/lib/active_merchant/billing/gateways/in_context_paypal_express.rb +1 -1
  80. data/lib/active_merchant/billing/gateways/inspire.rb +3 -4
  81. data/lib/active_merchant/billing/gateways/instapay.rb +1 -2
  82. data/lib/active_merchant/billing/gateways/ipp.rb +5 -5
  83. data/lib/active_merchant/billing/gateways/iridium.rb +14 -15
  84. data/lib/active_merchant/billing/gateways/iveri.rb +7 -7
  85. data/lib/active_merchant/billing/gateways/ixopay.rb +7 -7
  86. data/lib/active_merchant/billing/gateways/jetpay.rb +1 -2
  87. data/lib/active_merchant/billing/gateways/jetpay_v2.rb +4 -5
  88. data/lib/active_merchant/billing/gateways/kushki.rb +6 -6
  89. data/lib/active_merchant/billing/gateways/latitude19.rb +14 -14
  90. data/lib/active_merchant/billing/gateways/linkpoint.rb +4 -5
  91. data/lib/active_merchant/billing/gateways/litle.rb +32 -16
  92. data/lib/active_merchant/billing/gateways/mastercard.rb +10 -10
  93. data/lib/active_merchant/billing/gateways/mercado_pago.rb +9 -9
  94. data/lib/active_merchant/billing/gateways/merchant_e_solutions.rb +1 -2
  95. data/lib/active_merchant/billing/gateways/merchant_one.rb +1 -1
  96. data/lib/active_merchant/billing/gateways/merchant_partners.rb +10 -10
  97. data/lib/active_merchant/billing/gateways/merchant_ware.rb +5 -7
  98. data/lib/active_merchant/billing/gateways/merchant_ware_version_four.rb +4 -6
  99. data/lib/active_merchant/billing/gateways/mercury.rb +4 -4
  100. data/lib/active_merchant/billing/gateways/metrics_global.rb +4 -5
  101. data/lib/active_merchant/billing/gateways/micropayment.rb +8 -8
  102. data/lib/active_merchant/billing/gateways/migs.rb +3 -4
  103. data/lib/active_merchant/billing/gateways/modern_payments_cim.rb +2 -4
  104. data/lib/active_merchant/billing/gateways/monei.rb +7 -7
  105. data/lib/active_merchant/billing/gateways/moneris.rb +4 -3
  106. data/lib/active_merchant/billing/gateways/money_movers.rb +2 -3
  107. data/lib/active_merchant/billing/gateways/mundipagg.rb +37 -10
  108. data/lib/active_merchant/billing/gateways/nab_transact.rb +2 -4
  109. data/lib/active_merchant/billing/gateways/ncr_secure_pay.rb +7 -7
  110. data/lib/active_merchant/billing/gateways/net_registry.rb +1 -2
  111. data/lib/active_merchant/billing/gateways/netaxept.rb +6 -6
  112. data/lib/active_merchant/billing/gateways/netbanx.rb +45 -10
  113. data/lib/active_merchant/billing/gateways/netbilling.rb +4 -5
  114. data/lib/active_merchant/billing/gateways/network_merchants.rb +2 -3
  115. data/lib/active_merchant/billing/gateways/nmi.rb +21 -7
  116. data/lib/active_merchant/billing/gateways/ogone.rb +3 -3
  117. data/lib/active_merchant/billing/gateways/omise.rb +13 -13
  118. data/lib/active_merchant/billing/gateways/openpay.rb +3 -4
  119. data/lib/active_merchant/billing/gateways/opp.rb +9 -9
  120. data/lib/active_merchant/billing/gateways/optimal_payment.rb +2 -3
  121. data/lib/active_merchant/billing/gateways/orbital.rb +225 -105
  122. data/lib/active_merchant/billing/gateways/pac_net_raven.rb +3 -4
  123. data/lib/active_merchant/billing/gateways/pagarme.rb +8 -8
  124. data/lib/active_merchant/billing/gateways/pago_facil.rb +2 -2
  125. data/lib/active_merchant/billing/gateways/pay_conex.rb +8 -8
  126. data/lib/active_merchant/billing/gateways/pay_gate_xml.rb +6 -7
  127. data/lib/active_merchant/billing/gateways/pay_hub.rb +7 -8
  128. data/lib/active_merchant/billing/gateways/pay_junction.rb +2 -3
  129. data/lib/active_merchant/billing/gateways/pay_junction_v2.rb +9 -9
  130. data/lib/active_merchant/billing/gateways/pay_secure.rb +2 -3
  131. data/lib/active_merchant/billing/gateways/paybox_direct.rb +23 -1
  132. data/lib/active_merchant/billing/gateways/payeezy.rb +62 -20
  133. data/lib/active_merchant/billing/gateways/payex.rb +6 -7
  134. data/lib/active_merchant/billing/gateways/payflow.rb +1 -1
  135. data/lib/active_merchant/billing/gateways/payment_express.rb +11 -7
  136. data/lib/active_merchant/billing/gateways/paymentez.rb +26 -6
  137. data/lib/active_merchant/billing/gateways/paymill.rb +7 -7
  138. data/lib/active_merchant/billing/gateways/paypal.rb +10 -2
  139. data/lib/active_merchant/billing/gateways/paypal/paypal_common_api.rb +1 -0
  140. data/lib/active_merchant/billing/gateways/paypal_express.rb +1 -1
  141. data/lib/active_merchant/billing/gateways/paypal_express_common.rb +1 -1
  142. data/lib/active_merchant/billing/gateways/payscout.rb +1 -2
  143. data/lib/active_merchant/billing/gateways/paystation.rb +3 -4
  144. data/lib/active_merchant/billing/gateways/payu_in.rb +3 -3
  145. data/lib/active_merchant/billing/gateways/payu_latam.rb +17 -10
  146. data/lib/active_merchant/billing/gateways/payway.rb +8 -9
  147. data/lib/active_merchant/billing/gateways/payway_dot_com.rb +253 -0
  148. data/lib/active_merchant/billing/gateways/pin.rb +11 -0
  149. data/lib/active_merchant/billing/gateways/plugnpay.rb +1 -2
  150. data/lib/active_merchant/billing/gateways/pro_pay.rb +8 -8
  151. data/lib/active_merchant/billing/gateways/psigate.rb +2 -3
  152. data/lib/active_merchant/billing/gateways/psl_card.rb +1 -2
  153. data/lib/active_merchant/billing/gateways/qbms.rb +1 -2
  154. data/lib/active_merchant/billing/gateways/quantum.rb +1 -2
  155. data/lib/active_merchant/billing/gateways/quickbooks.rb +1 -1
  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 +31 -17
  159. data/lib/active_merchant/billing/gateways/realex.rb +1 -1
  160. data/lib/active_merchant/billing/gateways/redsys.rb +105 -9
  161. data/lib/active_merchant/billing/gateways/s5.rb +7 -7
  162. data/lib/active_merchant/billing/gateways/safe_charge.rb +51 -18
  163. data/lib/active_merchant/billing/gateways/sage.rb +3 -5
  164. data/lib/active_merchant/billing/gateways/sage_pay.rb +2 -3
  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 +2 -3
  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 +18 -18
  176. data/lib/active_merchant/billing/gateways/stripe_payment_intents.rb +91 -25
  177. data/lib/active_merchant/billing/gateways/swipe_checkout.rb +3 -4
  178. data/lib/active_merchant/billing/gateways/telr.rb +8 -8
  179. data/lib/active_merchant/billing/gateways/trans_first.rb +2 -2
  180. data/lib/active_merchant/billing/gateways/trans_first_transaction_express.rb +12 -12
  181. data/lib/active_merchant/billing/gateways/transact_pro.rb +9 -9
  182. data/lib/active_merchant/billing/gateways/trust_commerce.rb +1 -2
  183. data/lib/active_merchant/billing/gateways/usa_epay.rb +1 -1
  184. data/lib/active_merchant/billing/gateways/usa_epay_advanced.rb +32 -32
  185. data/lib/active_merchant/billing/gateways/usa_epay_transaction.rb +3 -4
  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/vpos.rb +172 -0
  191. data/lib/active_merchant/billing/gateways/webpay.rb +2 -2
  192. data/lib/active_merchant/billing/gateways/wepay.rb +3 -2
  193. data/lib/active_merchant/billing/gateways/wirecard.rb +1 -2
  194. data/lib/active_merchant/billing/gateways/worldpay.rb +43 -22
  195. data/lib/active_merchant/billing/gateways/worldpay_online_payments.rb +14 -16
  196. data/lib/active_merchant/billing/gateways/worldpay_us.rb +7 -7
  197. data/lib/active_merchant/billing/response.rb +3 -2
  198. data/lib/active_merchant/country.rb +1 -1
  199. data/lib/active_merchant/network_connection_retries.rb +2 -2
  200. data/lib/active_merchant/post_data.rb +1 -1
  201. data/lib/active_merchant/posts_data.rb +1 -1
  202. data/lib/active_merchant/version.rb +1 -1
  203. data/lib/certs/cacert.pem +1582 -2431
  204. data/lib/support/ssl_verify.rb +2 -2
  205. data/lib/support/ssl_version.rb +2 -2
  206. metadata +5 -3
@@ -70,7 +70,7 @@ module ActiveMerchant #:nodoc:
70
70
 
71
71
  # MiGS works by merchants being either purchase only or authorize/capture
72
72
  # So authorize is the same as purchase when in authorize mode
73
- alias_method :authorize, :purchase
73
+ alias authorize purchase
74
74
 
75
75
  # ==== Options
76
76
  #
@@ -123,7 +123,7 @@ module ActiveMerchant #:nodoc:
123
123
  refund(money, authorization, options)
124
124
  end
125
125
 
126
- def verify(credit_card, options={})
126
+ def verify(credit_card, options = {})
127
127
  MultiResponse.run do |r|
128
128
  r.process { authorize(100, credit_card, options) }
129
129
  r.process(:ignore_result) { void(r.authorization, options) }
@@ -286,8 +286,7 @@ module ActiveMerchant #:nodoc:
286
286
  authorization: response[:TransactionNo],
287
287
  fraud_review: fraud_review?(response),
288
288
  avs_result: { code: avs_response_code },
289
- cvv_result: cvv_result_code
290
- )
289
+ cvv_result: cvv_result_code)
291
290
  end
292
291
 
293
292
  def success?(response)
@@ -148,15 +148,13 @@ module ActiveMerchant #:nodoc:
148
148
  def commit(action, params)
149
149
  data = ssl_post(url(action), build_request(action, params),
150
150
  { 'Content-Type' => 'text/xml; charset=utf-8',
151
- 'SOAPAction' => "#{xmlns(action)}#{action}" }
152
- )
151
+ 'SOAPAction' => "#{xmlns(action)}#{action}" })
153
152
 
154
153
  response = parse(action, data)
155
154
  Response.new(successful?(action, response), message_from(action, response), response,
156
155
  test: test?,
157
156
  authorization: authorization_from(action, response),
158
- avs_result: { code: response[:avs_code] }
159
- )
157
+ avs_result: { code: response[:avs_code] })
160
158
  end
161
159
 
162
160
  def authorization_from(action, response)
@@ -29,7 +29,7 @@ module ActiveMerchant #:nodoc:
29
29
  # :login User login
30
30
  # :pwd User password
31
31
  #
32
- def initialize(options={})
32
+ def initialize(options = {})
33
33
  requires!(options, :sender_id, :channel_id, :login, :pwd)
34
34
  super
35
35
  end
@@ -45,7 +45,7 @@ module ActiveMerchant #:nodoc:
45
45
  # :currency Sale currency to override money object or default (optional)
46
46
  #
47
47
  # Returns Active Merchant response object
48
- def purchase(money, credit_card, options={})
48
+ def purchase(money, credit_card, options = {})
49
49
  execute_new_order(:purchase, money, credit_card, options)
50
50
  end
51
51
 
@@ -60,7 +60,7 @@ module ActiveMerchant #:nodoc:
60
60
  # :currency Sale currency to override money object or default (optional)
61
61
  #
62
62
  # Returns Active Merchant response object
63
- def authorize(money, credit_card, options={})
63
+ def authorize(money, credit_card, options = {})
64
64
  execute_new_order(:authorize, money, credit_card, options)
65
65
  end
66
66
 
@@ -76,7 +76,7 @@ module ActiveMerchant #:nodoc:
76
76
  # Note: you should pass either order_id or description
77
77
  #
78
78
  # Returns Active Merchant response object
79
- def capture(money, authorization, options={})
79
+ def capture(money, authorization, options = {})
80
80
  execute_dependant(:capture, money, authorization, options)
81
81
  end
82
82
 
@@ -92,7 +92,7 @@ module ActiveMerchant #:nodoc:
92
92
  # Note: you should pass either order_id or description
93
93
  #
94
94
  # Returns Active Merchant response object
95
- def refund(money, authorization, options={})
95
+ def refund(money, authorization, options = {})
96
96
  execute_dependant(:refund, money, authorization, options)
97
97
  end
98
98
 
@@ -103,7 +103,7 @@ module ActiveMerchant #:nodoc:
103
103
  # :order_id Merchant created id for the authorization (optional)
104
104
  #
105
105
  # Returns Active Merchant response object
106
- def void(authorization, options={})
106
+ def void(authorization, options = {})
107
107
  execute_dependant(:void, nil, authorization, options)
108
108
  end
109
109
 
@@ -117,7 +117,7 @@ module ActiveMerchant #:nodoc:
117
117
  # :currency Sale currency to override money object or default (optional)
118
118
  #
119
119
  # Returns Active Merchant response object of Authorization operation
120
- def verify(credit_card, options={})
120
+ def verify(credit_card, options = {})
121
121
  MultiResponse.run(:use_first_response) do |r|
122
122
  r.process { authorize(100, credit_card, options) }
123
123
  r.process(:ignore_result) { void(r.authorization, options) }
@@ -133,7 +133,7 @@ module ActiveMerchant #:nodoc:
133
133
  commit 'refund', crediting_params(authorization, amount: amount(money))
134
134
  end
135
135
 
136
- def verify(credit_card, options={})
136
+ def verify(credit_card, options = {})
137
137
  requires!(options, :order_id)
138
138
  post = {}
139
139
  add_payment_source(post, credit_card, options)
@@ -302,9 +302,10 @@ module ActiveMerchant #:nodoc:
302
302
  message_from(response[:message]),
303
303
  response,
304
304
  test: test?,
305
- avs_result: {code: response[:avs_result_code]},
305
+ avs_result: { code: response[:avs_result_code] },
306
306
  cvv_result: response[:cvd_result_code] && response[:cvd_result_code][-1, 1],
307
- authorization: authorization_from(response))
307
+ authorization: authorization_from(response)
308
+ )
308
309
  end
309
310
 
310
311
  # Generates a Moneris authorization string of the form 'trans_id;receipt_id'.
@@ -116,9 +116,8 @@ module ActiveMerchant #:nodoc:
116
116
  Response.new(success?(response), message, response,
117
117
  test: test?,
118
118
  authorization: response['transactionid'],
119
- avs_result: {code: response['avsresponse']},
120
- cvv_result: response['cvvresponse']
121
- )
119
+ avs_result: { code: response['avsresponse'] },
120
+ cvv_result: response['cvvresponse'])
122
121
  end
123
122
 
124
123
  def success?(response)
@@ -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,28 @@ 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
+ AVS_CODE_CONVERTER = {
26
+ 'MATCH' => 'X',
27
+ 'MATCH_ADDRESS_ONLY' => 'A',
28
+ 'MATCH_ZIP_ONLY' => 'Z',
29
+ 'NO_MATCH' => 'N',
30
+ 'NOT_PROCESSED' => 'U',
31
+ 'UNKNOWN' => 'Q'
32
+ }
33
+
34
+ CVV_CODE_CONVERTER = {
35
+ 'MATCH' => 'M',
36
+ 'NO_MATCH' => 'N',
37
+ 'NOT_PROCESSED' => 'P',
38
+ 'UNKNOWN' => 'U'
39
+ }
40
+
41
+ def initialize(options = {})
26
42
  requires!(options, :account_number, :api_key)
27
43
  super
28
44
  end
29
45
 
30
- def purchase(money, payment, options={})
46
+ def purchase(money, payment, options = {})
31
47
  # Do a Verification with AVS prior to purchase
32
48
  verification_response = verify(payment, options)
33
49
  return verification_response if verification_response.message != 'OK'
@@ -36,11 +52,12 @@ module ActiveMerchant #:nodoc:
36
52
  add_invoice(post, money, options)
37
53
  add_settle_with_auth(post)
38
54
  add_payment(post, payment, options)
55
+ add_customer_detail_data(post, options)
39
56
 
40
57
  commit(:post, 'auths', post)
41
58
  end
42
59
 
43
- def authorize(money, payment, options={})
60
+ def authorize(money, payment, options = {})
44
61
  # Do a Verification with AVS prior to Auth + Settle
45
62
  verification_response = verify(payment, options)
46
63
  return verification_response if verification_response.message != 'OK'
@@ -48,18 +65,19 @@ module ActiveMerchant #:nodoc:
48
65
  post = {}
49
66
  add_invoice(post, money, options)
50
67
  add_payment(post, payment, options)
68
+ add_customer_detail_data(post, options)
51
69
 
52
70
  commit(:post, 'auths', post)
53
71
  end
54
72
 
55
- def capture(money, authorization, options={})
73
+ def capture(money, authorization, options = {})
56
74
  post = {}
57
75
  add_invoice(post, money, options)
58
76
 
59
77
  commit(:post, "auths/#{authorization}/settlements", post)
60
78
  end
61
79
 
62
- def refund(money, authorization, options={})
80
+ def refund(money, authorization, options = {})
63
81
  # If the transactions that are pending, API call needs to be Cancellation
64
82
  settlement_data = get_settlement(authorization)
65
83
  return settlement_data if settlement_data.message != 'OK'
@@ -86,14 +104,14 @@ module ActiveMerchant #:nodoc:
86
104
  commit(:get, "settlements/#{authorization}", post)
87
105
  end
88
106
 
89
- def void(authorization, options={})
107
+ def void(authorization, options = {})
90
108
  post = {}
91
109
  add_order_id(post, options)
92
110
 
93
111
  commit(:post, "auths/#{authorization}/voidauths", post)
94
112
  end
95
113
 
96
- def verify(credit_card, options={})
114
+ def verify(credit_card, options = {})
97
115
  post = {}
98
116
  add_payment(post, credit_card, options)
99
117
  add_order_id(post, options)
@@ -103,7 +121,7 @@ module ActiveMerchant #:nodoc:
103
121
 
104
122
  # note: when passing options[:customer] we only attempt to add the
105
123
  # card to the profile_id passed as the options[:customer]
106
- def store(credit_card, options={})
124
+ def store(credit_card, options = {})
107
125
  # locale can only be one of en_US, fr_CA, en_GB
108
126
  requires!(options, :locale)
109
127
  post = {}
@@ -147,6 +165,15 @@ module ActiveMerchant #:nodoc:
147
165
  post[:locale] = options[:locale]
148
166
  end
149
167
 
168
+ def add_customer_detail_data(post, options)
169
+ post[:profile] ||= {}
170
+ post[:profile][:email] = options[:email] if options[:email]
171
+ post[:customerIp] = options[:ip] if options[:ip]
172
+ if (billing_address = options[:billing_address])
173
+ post[:profile][:firstName], post[:profile][:lastName] = split_names(billing_address[:name])
174
+ end
175
+ end
176
+
150
177
  def add_credit_card(post, credit_card, options = {})
151
178
  post[:card] ||= {}
152
179
  post[:card][:cardNum] = credit_card.number
@@ -245,11 +272,19 @@ module ActiveMerchant #:nodoc:
245
272
  test: test?,
246
273
  error_code: error_code_from(response),
247
274
  authorization: authorization_from(success, get_url(uri), method, response),
248
- avs_result: AVSResult.new(code: response['avsResponse']),
249
- cvv_result: CVVResult.new(response['cvvVerification'])
275
+ avs_result: avs_result(response),
276
+ cvv_result: cvv_result(response)
250
277
  )
251
278
  end
252
279
 
280
+ def avs_result(response)
281
+ AVSResult.new(code: AVS_CODE_CONVERTER[response['avsResponse']])
282
+ end
283
+
284
+ def cvv_result(response)
285
+ CVVResult.new(CVV_CODE_CONVERTER[response['cvvVerification']])
286
+ end
287
+
253
288
  def get_url(uri)
254
289
  url = (test? ? test_url : live_url)
255
290
  if /^customervault/.match?(uri)