activemerchant 1.114.0 → 1.116.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (196) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG +45 -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_methods.rb +5 -5
  7. data/lib/active_merchant/billing/gateways/adyen.rb +23 -13
  8. data/lib/active_merchant/billing/gateways/allied_wallet.rb +7 -7
  9. data/lib/active_merchant/billing/gateways/authorize_net.rb +13 -11
  10. data/lib/active_merchant/billing/gateways/authorize_net_arb.rb +3 -4
  11. data/lib/active_merchant/billing/gateways/authorize_net_cim.rb +1 -1
  12. data/lib/active_merchant/billing/gateways/axcessms.rb +8 -9
  13. data/lib/active_merchant/billing/gateways/balanced.rb +4 -3
  14. data/lib/active_merchant/billing/gateways/bambora_apac.rb +7 -7
  15. data/lib/active_merchant/billing/gateways/bank_frick.rb +7 -7
  16. data/lib/active_merchant/billing/gateways/banwire.rb +1 -1
  17. data/lib/active_merchant/billing/gateways/barclaycard_smartpay.rb +6 -4
  18. data/lib/active_merchant/billing/gateways/beanstream.rb +3 -3
  19. data/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb +4 -5
  20. data/lib/active_merchant/billing/gateways/blue_pay.rb +2 -3
  21. data/lib/active_merchant/billing/gateways/blue_snap.rb +19 -17
  22. data/lib/active_merchant/billing/gateways/bogus.rb +19 -19
  23. data/lib/active_merchant/billing/gateways/borgun.rb +11 -11
  24. data/lib/active_merchant/billing/gateways/bpoint.rb +8 -8
  25. data/lib/active_merchant/billing/gateways/braintree.rb +1 -1
  26. data/lib/active_merchant/billing/gateways/braintree_blue.rb +7 -10
  27. data/lib/active_merchant/billing/gateways/bridge_pay.rb +7 -7
  28. data/lib/active_merchant/billing/gateways/cams.rb +8 -8
  29. data/lib/active_merchant/billing/gateways/card_connect.rb +1 -1
  30. data/lib/active_merchant/billing/gateways/card_save.rb +1 -1
  31. data/lib/active_merchant/billing/gateways/card_stream.rb +2 -2
  32. data/lib/active_merchant/billing/gateways/cardknox.rb +7 -7
  33. data/lib/active_merchant/billing/gateways/cardprocess.rb +1 -1
  34. data/lib/active_merchant/billing/gateways/cecabank.rb +5 -5
  35. data/lib/active_merchant/billing/gateways/cenpos.rb +10 -10
  36. data/lib/active_merchant/billing/gateways/checkout.rb +2 -2
  37. data/lib/active_merchant/billing/gateways/checkout_v2.rb +16 -19
  38. data/lib/active_merchant/billing/gateways/clearhaus.rb +7 -7
  39. data/lib/active_merchant/billing/gateways/commercegate.rb +1 -1
  40. data/lib/active_merchant/billing/gateways/conekta.rb +2 -2
  41. data/lib/active_merchant/billing/gateways/creditcall.rb +10 -10
  42. data/lib/active_merchant/billing/gateways/credorax.rb +9 -9
  43. data/lib/active_merchant/billing/gateways/ct_payment.rb +10 -10
  44. data/lib/active_merchant/billing/gateways/culqi.rb +9 -9
  45. data/lib/active_merchant/billing/gateways/cyber_source.rb +30 -31
  46. data/lib/active_merchant/billing/gateways/d_local.rb +11 -11
  47. data/lib/active_merchant/billing/gateways/data_cash.rb +2 -3
  48. data/lib/active_merchant/billing/gateways/decidir.rb +9 -8
  49. data/lib/active_merchant/billing/gateways/dibs.rb +8 -8
  50. data/lib/active_merchant/billing/gateways/digitzs.rb +5 -5
  51. data/lib/active_merchant/billing/gateways/ebanx.rb +9 -9
  52. data/lib/active_merchant/billing/gateways/efsnet.rb +2 -3
  53. data/lib/active_merchant/billing/gateways/elavon.rb +251 -232
  54. data/lib/active_merchant/billing/gateways/element.rb +8 -8
  55. data/lib/active_merchant/billing/gateways/evo_ca.rb +5 -6
  56. data/lib/active_merchant/billing/gateways/eway.rb +3 -4
  57. data/lib/active_merchant/billing/gateways/eway_managed.rb +6 -7
  58. data/lib/active_merchant/billing/gateways/eway_rapid.rb +6 -6
  59. data/lib/active_merchant/billing/gateways/exact.rb +8 -9
  60. data/lib/active_merchant/billing/gateways/ezic.rb +7 -7
  61. data/lib/active_merchant/billing/gateways/fat_zebra.rb +4 -4
  62. data/lib/active_merchant/billing/gateways/federated_canada.rb +2 -3
  63. data/lib/active_merchant/billing/gateways/first_giving.rb +1 -1
  64. data/lib/active_merchant/billing/gateways/first_pay.rb +6 -6
  65. data/lib/active_merchant/billing/gateways/firstdata_e4.rb +7 -7
  66. data/lib/active_merchant/billing/gateways/firstdata_e4_v27.rb +4 -4
  67. data/lib/active_merchant/billing/gateways/flo2cash.rb +8 -8
  68. data/lib/active_merchant/billing/gateways/flo2cash_simple.rb +1 -1
  69. data/lib/active_merchant/billing/gateways/forte.rb +14 -8
  70. data/lib/active_merchant/billing/gateways/global_collect.rb +10 -10
  71. data/lib/active_merchant/billing/gateways/global_transport.rb +7 -7
  72. data/lib/active_merchant/billing/gateways/hdfc.rb +9 -9
  73. data/lib/active_merchant/billing/gateways/hps.rb +7 -7
  74. data/lib/active_merchant/billing/gateways/iats_payments.rb +9 -4
  75. data/lib/active_merchant/billing/gateways/in_context_paypal_express.rb +1 -1
  76. data/lib/active_merchant/billing/gateways/inspire.rb +3 -4
  77. data/lib/active_merchant/billing/gateways/instapay.rb +1 -2
  78. data/lib/active_merchant/billing/gateways/ipp.rb +5 -5
  79. data/lib/active_merchant/billing/gateways/iridium.rb +14 -15
  80. data/lib/active_merchant/billing/gateways/iveri.rb +7 -7
  81. data/lib/active_merchant/billing/gateways/ixopay.rb +7 -7
  82. data/lib/active_merchant/billing/gateways/jetpay.rb +1 -2
  83. data/lib/active_merchant/billing/gateways/jetpay_v2.rb +4 -5
  84. data/lib/active_merchant/billing/gateways/kushki.rb +6 -6
  85. data/lib/active_merchant/billing/gateways/latitude19.rb +14 -14
  86. data/lib/active_merchant/billing/gateways/linkpoint.rb +4 -5
  87. data/lib/active_merchant/billing/gateways/litle.rb +11 -11
  88. data/lib/active_merchant/billing/gateways/mastercard.rb +10 -10
  89. data/lib/active_merchant/billing/gateways/mercado_pago.rb +7 -7
  90. data/lib/active_merchant/billing/gateways/merchant_e_solutions.rb +1 -2
  91. data/lib/active_merchant/billing/gateways/merchant_one.rb +1 -1
  92. data/lib/active_merchant/billing/gateways/merchant_partners.rb +10 -10
  93. data/lib/active_merchant/billing/gateways/merchant_ware.rb +5 -7
  94. data/lib/active_merchant/billing/gateways/merchant_ware_version_four.rb +4 -6
  95. data/lib/active_merchant/billing/gateways/mercury.rb +4 -4
  96. data/lib/active_merchant/billing/gateways/metrics_global.rb +4 -5
  97. data/lib/active_merchant/billing/gateways/micropayment.rb +8 -8
  98. data/lib/active_merchant/billing/gateways/migs.rb +3 -4
  99. data/lib/active_merchant/billing/gateways/modern_payments_cim.rb +2 -4
  100. data/lib/active_merchant/billing/gateways/monei.rb +7 -7
  101. data/lib/active_merchant/billing/gateways/moneris.rb +4 -3
  102. data/lib/active_merchant/billing/gateways/money_movers.rb +2 -3
  103. data/lib/active_merchant/billing/gateways/mundipagg.rb +37 -10
  104. data/lib/active_merchant/billing/gateways/nab_transact.rb +2 -4
  105. data/lib/active_merchant/billing/gateways/ncr_secure_pay.rb +7 -7
  106. data/lib/active_merchant/billing/gateways/net_registry.rb +1 -2
  107. data/lib/active_merchant/billing/gateways/netaxept.rb +6 -6
  108. data/lib/active_merchant/billing/gateways/netbanx.rb +8 -8
  109. data/lib/active_merchant/billing/gateways/netbilling.rb +4 -5
  110. data/lib/active_merchant/billing/gateways/network_merchants.rb +2 -3
  111. data/lib/active_merchant/billing/gateways/nmi.rb +21 -7
  112. data/lib/active_merchant/billing/gateways/ogone.rb +3 -3
  113. data/lib/active_merchant/billing/gateways/omise.rb +13 -13
  114. data/lib/active_merchant/billing/gateways/openpay.rb +3 -4
  115. data/lib/active_merchant/billing/gateways/opp.rb +9 -9
  116. data/lib/active_merchant/billing/gateways/optimal_payment.rb +2 -3
  117. data/lib/active_merchant/billing/gateways/orbital.rb +61 -66
  118. data/lib/active_merchant/billing/gateways/pac_net_raven.rb +3 -4
  119. data/lib/active_merchant/billing/gateways/pagarme.rb +8 -8
  120. data/lib/active_merchant/billing/gateways/pago_facil.rb +2 -2
  121. data/lib/active_merchant/billing/gateways/pay_conex.rb +8 -8
  122. data/lib/active_merchant/billing/gateways/pay_gate_xml.rb +6 -7
  123. data/lib/active_merchant/billing/gateways/pay_hub.rb +7 -8
  124. data/lib/active_merchant/billing/gateways/pay_junction.rb +2 -3
  125. data/lib/active_merchant/billing/gateways/pay_junction_v2.rb +9 -9
  126. data/lib/active_merchant/billing/gateways/pay_secure.rb +2 -3
  127. data/lib/active_merchant/billing/gateways/paybox_direct.rb +23 -1
  128. data/lib/active_merchant/billing/gateways/payeezy.rb +9 -9
  129. data/lib/active_merchant/billing/gateways/payex.rb +6 -7
  130. data/lib/active_merchant/billing/gateways/payflow.rb +1 -1
  131. data/lib/active_merchant/billing/gateways/payment_express.rb +1 -2
  132. data/lib/active_merchant/billing/gateways/paymentez.rb +5 -5
  133. data/lib/active_merchant/billing/gateways/paymill.rb +7 -7
  134. data/lib/active_merchant/billing/gateways/paypal_express.rb +1 -1
  135. data/lib/active_merchant/billing/gateways/paypal_express_common.rb +1 -1
  136. data/lib/active_merchant/billing/gateways/payscout.rb +1 -2
  137. data/lib/active_merchant/billing/gateways/paystation.rb +3 -4
  138. data/lib/active_merchant/billing/gateways/payu_in.rb +3 -3
  139. data/lib/active_merchant/billing/gateways/payu_latam.rb +17 -10
  140. data/lib/active_merchant/billing/gateways/payway.rb +8 -9
  141. data/lib/active_merchant/billing/gateways/plugnpay.rb +1 -2
  142. data/lib/active_merchant/billing/gateways/pro_pay.rb +8 -8
  143. data/lib/active_merchant/billing/gateways/psigate.rb +2 -3
  144. data/lib/active_merchant/billing/gateways/psl_card.rb +1 -2
  145. data/lib/active_merchant/billing/gateways/qbms.rb +1 -2
  146. data/lib/active_merchant/billing/gateways/quantum.rb +1 -2
  147. data/lib/active_merchant/billing/gateways/quickbooks.rb +1 -1
  148. data/lib/active_merchant/billing/gateways/quickpay/quickpay_v10.rb +3 -4
  149. data/lib/active_merchant/billing/gateways/quickpay/quickpay_v4to7.rb +1 -2
  150. data/lib/active_merchant/billing/gateways/qvalent.rb +8 -8
  151. data/lib/active_merchant/billing/gateways/realex.rb +1 -1
  152. data/lib/active_merchant/billing/gateways/redsys.rb +4 -4
  153. data/lib/active_merchant/billing/gateways/s5.rb +7 -7
  154. data/lib/active_merchant/billing/gateways/safe_charge.rb +12 -12
  155. data/lib/active_merchant/billing/gateways/sage.rb +3 -5
  156. data/lib/active_merchant/billing/gateways/sage_pay.rb +2 -3
  157. data/lib/active_merchant/billing/gateways/sallie_mae.rb +1 -2
  158. data/lib/active_merchant/billing/gateways/secure_net.rb +1 -2
  159. data/lib/active_merchant/billing/gateways/secure_pay.rb +3 -4
  160. data/lib/active_merchant/billing/gateways/secure_pay_au.rb +2 -4
  161. data/lib/active_merchant/billing/gateways/secure_pay_tech.rb +1 -2
  162. data/lib/active_merchant/billing/gateways/securion_pay.rb +5 -6
  163. data/lib/active_merchant/billing/gateways/skip_jack.rb +2 -3
  164. data/lib/active_merchant/billing/gateways/smart_ps.rb +5 -6
  165. data/lib/active_merchant/billing/gateways/so_easy_pay.rb +7 -7
  166. data/lib/active_merchant/billing/gateways/spreedly_core.rb +6 -6
  167. data/lib/active_merchant/billing/gateways/stripe.rb +9 -9
  168. data/lib/active_merchant/billing/gateways/stripe_payment_intents.rb +9 -0
  169. data/lib/active_merchant/billing/gateways/swipe_checkout.rb +3 -4
  170. data/lib/active_merchant/billing/gateways/telr.rb +8 -8
  171. data/lib/active_merchant/billing/gateways/trans_first.rb +2 -2
  172. data/lib/active_merchant/billing/gateways/trans_first_transaction_express.rb +12 -12
  173. data/lib/active_merchant/billing/gateways/transact_pro.rb +9 -9
  174. data/lib/active_merchant/billing/gateways/trust_commerce.rb +1 -2
  175. data/lib/active_merchant/billing/gateways/usa_epay.rb +1 -1
  176. data/lib/active_merchant/billing/gateways/usa_epay_advanced.rb +32 -32
  177. data/lib/active_merchant/billing/gateways/usa_epay_transaction.rb +3 -4
  178. data/lib/active_merchant/billing/gateways/vanco.rb +3 -3
  179. data/lib/active_merchant/billing/gateways/verifi.rb +1 -2
  180. data/lib/active_merchant/billing/gateways/viaklix.rb +1 -2
  181. data/lib/active_merchant/billing/gateways/visanet_peru.rb +10 -10
  182. data/lib/active_merchant/billing/gateways/webpay.rb +2 -2
  183. data/lib/active_merchant/billing/gateways/wepay.rb +3 -2
  184. data/lib/active_merchant/billing/gateways/wirecard.rb +1 -2
  185. data/lib/active_merchant/billing/gateways/worldpay.rb +12 -8
  186. data/lib/active_merchant/billing/gateways/worldpay_online_payments.rb +14 -16
  187. data/lib/active_merchant/billing/gateways/worldpay_us.rb +7 -7
  188. data/lib/active_merchant/billing/response.rb +1 -1
  189. data/lib/active_merchant/country.rb +1 -1
  190. data/lib/active_merchant/network_connection_retries.rb +2 -2
  191. data/lib/active_merchant/post_data.rb +1 -1
  192. data/lib/active_merchant/posts_data.rb +1 -1
  193. data/lib/active_merchant/version.rb +1 -1
  194. data/lib/support/ssl_verify.rb +2 -2
  195. data/lib/support/ssl_version.rb +2 -2
  196. metadata +2 -2
@@ -21,7 +21,7 @@ module ActiveMerchant #:nodoc:
21
21
  CECA_UI_LESS_REFUND_PAGE = 'anulacion_xml'
22
22
  CECA_ACTION_REFUND = 'anulaciones/anularParcial' # use partial refund's URL to avoid time frame limitations and decision logic on client side
23
23
  CECA_ACTION_PURCHASE = 'tpv/compra'
24
- CECA_CURRENCIES_DICTIONARY = {'EUR' => 978, 'USD' => 840, 'GBP' => 826}
24
+ CECA_CURRENCIES_DICTIONARY = { 'EUR' => 978, 'USD' => 840, 'GBP' => 826 }
25
25
 
26
26
  # Creates a new CecabankGateway
27
27
  #
@@ -57,14 +57,14 @@ module ActiveMerchant #:nodoc:
57
57
  def purchase(money, creditcard, options = {})
58
58
  requires!(options, :order_id)
59
59
 
60
- post = {'Descripcion' => options[:description],
60
+ post = { 'Descripcion' => options[:description],
61
61
  'Num_operacion' => options[:order_id],
62
62
  'Idioma' => CECA_UI_LESS_LANGUAGE,
63
63
  'Pago_soportado' => CECA_MODE,
64
64
  'URL_OK' => CECA_NOTIFICATIONS_URL,
65
65
  'URL_NOK' => CECA_NOTIFICATIONS_URL,
66
66
  'Importe' => amount(money),
67
- 'TipoMoneda' => CECA_CURRENCIES_DICTIONARY[options[:currency] || currency(money)]}
67
+ 'TipoMoneda' => CECA_CURRENCIES_DICTIONARY[options[:currency] || currency(money)] }
68
68
 
69
69
  add_creditcard(post, creditcard)
70
70
 
@@ -84,12 +84,12 @@ module ActiveMerchant #:nodoc:
84
84
  def refund(money, identification, options = {})
85
85
  reference, order_id = split_authorization(identification)
86
86
 
87
- post = {'Referencia' => reference,
87
+ post = { 'Referencia' => reference,
88
88
  'Num_operacion' => order_id,
89
89
  'Idioma' => CECA_UI_LESS_LANGUAGE_REFUND,
90
90
  'Pagina' => CECA_UI_LESS_REFUND_PAGE,
91
91
  'Importe' => amount(money),
92
- 'TipoMoneda' => CECA_CURRENCIES_DICTIONARY[options[:currency] || currency(money)]}
92
+ 'TipoMoneda' => CECA_CURRENCIES_DICTIONARY[options[:currency] || currency(money)] }
93
93
 
94
94
  commit(CECA_ACTION_REFUND, post)
95
95
  end
@@ -13,12 +13,12 @@ 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, :merchant_id, :password, :user_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
  post = {}
23
23
  add_invoice(post, amount, options)
24
24
  add_payment_method(post, payment_method)
@@ -27,7 +27,7 @@ module ActiveMerchant #:nodoc:
27
27
  commit('Sale', post)
28
28
  end
29
29
 
30
- def authorize(amount, payment_method, options={})
30
+ def authorize(amount, payment_method, options = {})
31
31
  post = {}
32
32
  add_invoice(post, amount, options)
33
33
  add_payment_method(post, payment_method)
@@ -36,7 +36,7 @@ module ActiveMerchant #:nodoc:
36
36
  commit('Auth', post)
37
37
  end
38
38
 
39
- def capture(amount, authorization, options={})
39
+ def capture(amount, authorization, options = {})
40
40
  post = {}
41
41
  add_invoice(post, amount, options)
42
42
  add_reference(post, authorization)
@@ -45,7 +45,7 @@ module ActiveMerchant #:nodoc:
45
45
  commit('SpecialForce', post)
46
46
  end
47
47
 
48
- def void(authorization, options={})
48
+ def void(authorization, options = {})
49
49
  post = {}
50
50
  add_void_required_elements(post)
51
51
  add_reference(post, authorization)
@@ -56,7 +56,7 @@ module ActiveMerchant #:nodoc:
56
56
  commit('Void', post)
57
57
  end
58
58
 
59
- def refund(amount, authorization, options={})
59
+ def refund(amount, authorization, options = {})
60
60
  post = {}
61
61
  add_invoice(post, amount, options)
62
62
  add_reference(post, authorization)
@@ -65,7 +65,7 @@ module ActiveMerchant #:nodoc:
65
65
  commit('SpecialReturn', post)
66
66
  end
67
67
 
68
- def credit(amount, payment_method, options={})
68
+ def credit(amount, payment_method, options = {})
69
69
  post = {}
70
70
  add_invoice(post, amount, options)
71
71
  add_payment_method(post, payment_method)
@@ -73,7 +73,7 @@ module ActiveMerchant #:nodoc:
73
73
  commit('Credit', post)
74
74
  end
75
75
 
76
- def verify(credit_card, options={})
76
+ def verify(credit_card, options = {})
77
77
  MultiResponse.run(:use_first_response) do |r|
78
78
  r.process { authorize(100, credit_card, options) }
79
79
  r.process(:ignore_result) { void(r.authorization, options) }
@@ -198,7 +198,7 @@ module ActiveMerchant #:nodoc:
198
198
  end
199
199
 
200
200
  def envelope(body)
201
- <<~EOS
201
+ <<~XML
202
202
  <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tem="http://tempuri.org/" xmlns:acr="http://schemas.datacontract.org/2004/07/Acriter.ABI.CenPOS.EPayment.VirtualTerminal.Common" xmlns:acr1="http://schemas.datacontract.org/2004/07/Acriter.ABI.CenPOS.EPayment.VirtualTerminal.v6.Common" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
203
203
  <soapenv:Header/>
204
204
  <soapenv:Body>
@@ -209,7 +209,7 @@ module ActiveMerchant #:nodoc:
209
209
  </tem:ProcessCreditCard>
210
210
  </soapenv:Body>
211
211
  </soapenv:Envelope>
212
- EOS
212
+ XML
213
213
  end
214
214
 
215
215
  def parse(xml)
@@ -83,7 +83,7 @@ module ActiveMerchant #:nodoc:
83
83
  end
84
84
  end
85
85
 
86
- def verify(credit_card, options={})
86
+ def verify(credit_card, options = {})
87
87
  MultiResponse.run(:use_first_response) do |r|
88
88
  r.process { authorize(100, credit_card, options) }
89
89
  r.process(:ignore_result) { void(r.authorization, options) }
@@ -159,7 +159,7 @@ module ActiveMerchant #:nodoc:
159
159
  xml.trackid(trackid) if trackid
160
160
  end
161
161
 
162
- def commit(action, amount=nil, options={}, &builder)
162
+ def commit(action, amount = nil, options = {}, &builder)
163
163
  response = parse_xml(ssl_post(live_url, build_xml(action, &builder)))
164
164
  Response.new(
165
165
  (response[:responsecode] == '0'),
@@ -19,25 +19,16 @@ module ActiveMerchant #:nodoc:
19
19
  end
20
20
 
21
21
  def purchase(amount, payment_method, options = {})
22
- multi = MultiResponse.run do |r|
23
- r.process { authorize(amount, payment_method, options) }
24
- r.process { capture(amount, r.authorization, options) }
25
- end
26
-
27
- merged_params = multi.responses.map(&:params).reduce({}, :merge)
28
- succeeded = success_from(merged_params)
22
+ post = {}
23
+ build_auth_or_purchase(post, amount, payment_method, options)
29
24
 
30
- response(:purchase, succeeded, merged_params)
25
+ commit(:purchase, post)
31
26
  end
32
27
 
33
28
  def authorize(amount, payment_method, options = {})
34
29
  post = {}
35
30
  post[:capture] = false
36
- add_invoice(post, amount, options)
37
- add_payment_method(post, payment_method, options)
38
- add_customer_data(post, options)
39
- add_transaction_data(post, options)
40
- add_3ds(post, options)
31
+ build_auth_or_purchase(post, amount, payment_method, options)
41
32
 
42
33
  commit(:authorize, post)
43
34
  end
@@ -64,13 +55,10 @@ module ActiveMerchant #:nodoc:
64
55
  end
65
56
 
66
57
  def verify(credit_card, options = {})
67
- MultiResponse.run(:use_first_response) do |r|
68
- r.process { authorize(100, credit_card, options) }
69
- r.process(:ignore_result) { void(r.authorization, options) }
70
- end
58
+ authorize(0, credit_card, options)
71
59
  end
72
60
 
73
- def verify_payment(authorization, option={})
61
+ def verify_payment(authorization, option = {})
74
62
  commit(:verify_payment, authorization)
75
63
  end
76
64
 
@@ -87,6 +75,14 @@ module ActiveMerchant #:nodoc:
87
75
 
88
76
  private
89
77
 
78
+ def build_auth_or_purchase(post, amount, payment_method, options)
79
+ add_invoice(post, amount, options)
80
+ add_payment_method(post, payment_method, options)
81
+ add_customer_data(post, options)
82
+ add_transaction_data(post, options)
83
+ add_3ds(post, options)
84
+ end
85
+
90
86
  def add_invoice(post, money, options)
91
87
  post[:amount] = localized_amount(money, options[:currency])
92
88
  post[:reference] = options[:order_id]
@@ -155,6 +151,7 @@ module ActiveMerchant #:nodoc:
155
151
  post[:'3ds'][:cryptogram] = options[:three_d_secure][:cavv] if options[:three_d_secure][:cavv]
156
152
  post[:'3ds'][:version] = options[:three_d_secure][:version] if options[:three_d_secure][:version]
157
153
  post[:'3ds'][:xid] = options[:three_d_secure][:ds_transaction_id] || options[:three_d_secure][:xid]
154
+ post[:'3ds'][:attempt_n3d] = options[:attempt_n3d] if options[:attempt_n3d]
158
155
  end
159
156
  end
160
157
 
@@ -199,7 +196,7 @@ module ActiveMerchant #:nodoc:
199
196
  end
200
197
 
201
198
  def url(_post, action, authorization)
202
- if action == :authorize
199
+ if %i[authorize purchase].include?(action)
203
200
  "#{base_url}/payments"
204
201
  elsif action == :capture
205
202
  "#{base_url}/payments/#{authorization}/captures"
@@ -36,20 +36,20 @@ module ActiveMerchant #:nodoc:
36
36
  50000 => 'Clearhaus error'
37
37
  }
38
38
 
39
- def initialize(options={})
39
+ def initialize(options = {})
40
40
  requires!(options, :api_key)
41
41
  options[:private_key] = options[:private_key].strip if options[:private_key]
42
42
  super
43
43
  end
44
44
 
45
- def purchase(amount, payment, options={})
45
+ def purchase(amount, payment, options = {})
46
46
  MultiResponse.run(:use_first_response) do |r|
47
47
  r.process { authorize(amount, payment, options) }
48
48
  r.process { capture(amount, r.authorization, options) }
49
49
  end
50
50
  end
51
51
 
52
- def authorize(amount, payment, options={})
52
+ def authorize(amount, payment, options = {})
53
53
  post = {}
54
54
  add_invoice(post, amount, options)
55
55
 
@@ -69,14 +69,14 @@ module ActiveMerchant #:nodoc:
69
69
  commit(action, post)
70
70
  end
71
71
 
72
- def capture(amount, authorization, options={})
72
+ def capture(amount, authorization, options = {})
73
73
  post = {}
74
74
  add_invoice(post, amount, options)
75
75
 
76
76
  commit("/authorizations/#{authorization}/captures", post)
77
77
  end
78
78
 
79
- def refund(amount, authorization, options={})
79
+ def refund(amount, authorization, options = {})
80
80
  post = {}
81
81
  add_amount(post, amount, options)
82
82
 
@@ -87,14 +87,14 @@ module ActiveMerchant #:nodoc:
87
87
  commit("/authorizations/#{authorization}/voids", options)
88
88
  end
89
89
 
90
- def verify(credit_card, options={})
90
+ def verify(credit_card, options = {})
91
91
  MultiResponse.run(:use_first_response) do |r|
92
92
  r.process { authorize(0, credit_card, options) }
93
93
  r.process(:ignore_result) { void(r.authorization, options) }
94
94
  end
95
95
  end
96
96
 
97
- def store(credit_card, options={})
97
+ def store(credit_card, options = {})
98
98
  post = {}
99
99
  add_payment(post, credit_card)
100
100
 
@@ -102,7 +102,7 @@ module ActiveMerchant #:nodoc:
102
102
  response,
103
103
  authorization: response['transID'],
104
104
  test: test?,
105
- avs_result: {code: response['avsCode']},
105
+ avs_result: { code: response['avsCode'] },
106
106
  cvv_result: response['cvvCode']
107
107
  )
108
108
  end
@@ -180,7 +180,7 @@ module ActiveMerchant #:nodoc:
180
180
  'Accept-Language' => 'es',
181
181
  'Authorization' => 'Basic ' + Base64.encode64("#{@options[:key]}:"),
182
182
  'RaiseHtmlError' => 'false',
183
- 'Conekta-Client-User-Agent' => {'agent' => "Conekta ActiveMerchantBindings/#{ActiveMerchant::VERSION}"}.to_json,
183
+ 'Conekta-Client-User-Agent' => { 'agent' => "Conekta ActiveMerchantBindings/#{ActiveMerchant::VERSION}" }.to_json,
184
184
  'X-Conekta-Client-User-Agent' => conekta_client_user_agent(options),
185
185
  'X-Conekta-Client-User-Metadata' => options[:meta].to_json
186
186
  }
@@ -189,7 +189,7 @@ module ActiveMerchant #:nodoc:
189
189
  def conekta_client_user_agent(options)
190
190
  return user_agent unless options[:application]
191
191
 
192
- JSON.dump(JSON.parse(user_agent).merge!({application: options[:application]}))
192
+ JSON.dump(JSON.parse(user_agent).merge!({ application: options[:application] }))
193
193
  end
194
194
 
195
195
  def commit(method, url, parameters, options = {})
@@ -41,12 +41,12 @@ module ActiveMerchant #:nodoc:
41
41
  'partialmatched;partialmatch' => 'C'
42
42
  }
43
43
 
44
- def initialize(options={})
44
+ def initialize(options = {})
45
45
  requires!(options, :terminal_id, :transaction_key)
46
46
  super
47
47
  end
48
48
 
49
- def purchase(money, payment_method, options={})
49
+ def purchase(money, payment_method, options = {})
50
50
  multi_response = MultiResponse.run do |r|
51
51
  r.process { authorize(money, payment_method, options) }
52
52
  r.process { capture(money, r.authorization, options) }
@@ -66,7 +66,7 @@ module ActiveMerchant #:nodoc:
66
66
  )
67
67
  end
68
68
 
69
- def authorize(money, payment_method, options={})
69
+ def authorize(money, payment_method, options = {})
70
70
  request = build_xml_request do |xml|
71
71
  add_transaction_details(xml, money, nil, 'Auth', options)
72
72
  add_terminal_details(xml, options)
@@ -76,7 +76,7 @@ module ActiveMerchant #:nodoc:
76
76
  commit(request)
77
77
  end
78
78
 
79
- def capture(money, authorization, options={})
79
+ def capture(money, authorization, options = {})
80
80
  request = build_xml_request do |xml|
81
81
  add_transaction_details(xml, money, authorization, 'Conf', options)
82
82
  add_terminal_details(xml, options)
@@ -85,7 +85,7 @@ module ActiveMerchant #:nodoc:
85
85
  commit(request)
86
86
  end
87
87
 
88
- def refund(money, authorization, options={})
88
+ def refund(money, authorization, options = {})
89
89
  request = build_xml_request do |xml|
90
90
  add_transaction_details(xml, money, authorization, 'Refund', options)
91
91
  add_terminal_details(xml, options)
@@ -94,7 +94,7 @@ module ActiveMerchant #:nodoc:
94
94
  commit(request)
95
95
  end
96
96
 
97
- def void(authorization, options={})
97
+ def void(authorization, options = {})
98
98
  request = build_xml_request do |xml|
99
99
  add_transaction_details(xml, nil, authorization, 'Void', options)
100
100
  add_terminal_details(xml, options)
@@ -103,7 +103,7 @@ module ActiveMerchant #:nodoc:
103
103
  commit(request)
104
104
  end
105
105
 
106
- def verify(credit_card, options={})
106
+ def verify(credit_card, options = {})
107
107
  MultiResponse.run(:use_first_response) do |r|
108
108
  r.process { authorize(100, credit_card, options) }
109
109
  r.process(:ignore_result) { void(r.authorization, options) }
@@ -144,7 +144,7 @@ module ActiveMerchant #:nodoc:
144
144
  builder.to_xml
145
145
  end
146
146
 
147
- def add_transaction_details(xml, amount, authorization, type, options={})
147
+ def add_transaction_details(xml, amount, authorization, type, options = {})
148
148
  xml.TransactionDetails do
149
149
  xml.MessageType type
150
150
  xml.Amount(unit: 'Minor') { xml.text(amount) } if amount
@@ -153,7 +153,7 @@ module ActiveMerchant #:nodoc:
153
153
  end
154
154
  end
155
155
 
156
- def add_terminal_details(xml, options={})
156
+ def add_terminal_details(xml, options = {})
157
157
  xml.TerminalDetails do
158
158
  xml.TerminalID @options[:terminal_id]
159
159
  xml.TransactionKey @options[:transaction_key]
@@ -161,7 +161,7 @@ module ActiveMerchant #:nodoc:
161
161
  end
162
162
  end
163
163
 
164
- def add_card_details(xml, payment_method, options={})
164
+ def add_card_details(xml, payment_method, options = {})
165
165
  xml.CardDetails do
166
166
  xml.Manual(type: manual_type(options)) do
167
167
  xml.PAN payment_method.number
@@ -120,12 +120,12 @@ module ActiveMerchant #:nodoc:
120
120
  'R3' => 'Revocation of all Authorisations Order'
121
121
  }
122
122
 
123
- def initialize(options={})
123
+ def initialize(options = {})
124
124
  requires!(options, :merchant_id, :cipher_key)
125
125
  super
126
126
  end
127
127
 
128
- def purchase(amount, payment_method, options={})
128
+ def purchase(amount, payment_method, options = {})
129
129
  post = {}
130
130
  add_invoice(post, amount, options)
131
131
  add_payment_method(post, payment_method)
@@ -141,7 +141,7 @@ module ActiveMerchant #:nodoc:
141
141
  commit(:purchase, post)
142
142
  end
143
143
 
144
- def authorize(amount, payment_method, options={})
144
+ def authorize(amount, payment_method, options = {})
145
145
  post = {}
146
146
  add_invoice(post, amount, options)
147
147
  add_payment_method(post, payment_method)
@@ -158,7 +158,7 @@ module ActiveMerchant #:nodoc:
158
158
  commit(:authorize, post)
159
159
  end
160
160
 
161
- def capture(amount, authorization, options={})
161
+ def capture(amount, authorization, options = {})
162
162
  post = {}
163
163
  add_invoice(post, amount, options)
164
164
  add_reference(post, authorization)
@@ -170,7 +170,7 @@ module ActiveMerchant #:nodoc:
170
170
  commit(:capture, post)
171
171
  end
172
172
 
173
- def void(authorization, options={})
173
+ def void(authorization, options = {})
174
174
  post = {}
175
175
  add_customer_data(post, options)
176
176
  reference_action = add_reference(post, authorization)
@@ -182,7 +182,7 @@ module ActiveMerchant #:nodoc:
182
182
  commit(:void, post, reference_action)
183
183
  end
184
184
 
185
- def refund(amount, authorization, options={})
185
+ def refund(amount, authorization, options = {})
186
186
  post = {}
187
187
  add_invoice(post, amount, options)
188
188
  add_reference(post, authorization)
@@ -200,7 +200,7 @@ module ActiveMerchant #:nodoc:
200
200
  end
201
201
  end
202
202
 
203
- def credit(amount, payment_method, options={})
203
+ def credit(amount, payment_method, options = {})
204
204
  post = {}
205
205
  add_invoice(post, amount, options)
206
206
  add_payment_method(post, payment_method)
@@ -214,7 +214,7 @@ module ActiveMerchant #:nodoc:
214
214
  commit(:credit, post)
215
215
  end
216
216
 
217
- def verify(credit_card, options={})
217
+ def verify(credit_card, options = {})
218
218
  MultiResponse.run(:use_first_response) do |r|
219
219
  r.process { authorize(100, credit_card, options) }
220
220
  r.process(:ignore_result) { void(r.authorization, options) }
@@ -372,7 +372,7 @@ module ActiveMerchant #:nodoc:
372
372
  post[:'3ds_dstrxid'] = three_d_secure_options[:ds_transaction_id]
373
373
  end
374
374
 
375
- def build_i8(eci, cavv=nil, xid=nil)
375
+ def build_i8(eci, cavv = nil, xid = nil)
376
376
  "#{eci}:#{cavv || 'none'}:#{xid || 'none'}"
377
377
  end
378
378