activemerchant 1.112.0 → 1.118.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (204) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG +115 -0
  3. data/README.md +1 -1
  4. data/lib/active_merchant.rb +1 -1
  5. data/lib/active_merchant/billing/avs_result.rb +1 -1
  6. data/lib/active_merchant/billing/compatibility.rb +3 -3
  7. data/lib/active_merchant/billing/credit_card.rb +3 -1
  8. data/lib/active_merchant/billing/credit_card_methods.rb +58 -11
  9. data/lib/active_merchant/billing/gateway.rb +1 -1
  10. data/lib/active_merchant/billing/gateways/adyen.rb +26 -16
  11. data/lib/active_merchant/billing/gateways/allied_wallet.rb +7 -7
  12. data/lib/active_merchant/billing/gateways/authorize_net.rb +50 -18
  13. data/lib/active_merchant/billing/gateways/authorize_net_arb.rb +3 -4
  14. data/lib/active_merchant/billing/gateways/authorize_net_cim.rb +3 -2
  15. data/lib/active_merchant/billing/gateways/axcessms.rb +8 -9
  16. data/lib/active_merchant/billing/gateways/balanced.rb +5 -4
  17. data/lib/active_merchant/billing/gateways/bambora_apac.rb +8 -8
  18. data/lib/active_merchant/billing/gateways/bank_frick.rb +8 -8
  19. data/lib/active_merchant/billing/gateways/banwire.rb +1 -1
  20. data/lib/active_merchant/billing/gateways/barclaycard_smartpay.rb +6 -4
  21. data/lib/active_merchant/billing/gateways/beanstream.rb +3 -3
  22. data/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb +4 -5
  23. data/lib/active_merchant/billing/gateways/blue_pay.rb +2 -3
  24. data/lib/active_merchant/billing/gateways/blue_snap.rb +85 -23
  25. data/lib/active_merchant/billing/gateways/bogus.rb +19 -19
  26. data/lib/active_merchant/billing/gateways/borgun.rb +12 -12
  27. data/lib/active_merchant/billing/gateways/bpoint.rb +8 -8
  28. data/lib/active_merchant/billing/gateways/braintree.rb +1 -1
  29. data/lib/active_merchant/billing/gateways/braintree_blue.rb +20 -17
  30. data/lib/active_merchant/billing/gateways/bridge_pay.rb +7 -7
  31. data/lib/active_merchant/billing/gateways/cams.rb +8 -8
  32. data/lib/active_merchant/billing/gateways/card_connect.rb +1 -1
  33. data/lib/active_merchant/billing/gateways/card_save.rb +1 -1
  34. data/lib/active_merchant/billing/gateways/card_stream.rb +2 -2
  35. data/lib/active_merchant/billing/gateways/cardknox.rb +8 -8
  36. data/lib/active_merchant/billing/gateways/cardprocess.rb +1 -1
  37. data/lib/active_merchant/billing/gateways/cecabank.rb +5 -5
  38. data/lib/active_merchant/billing/gateways/cenpos.rb +11 -11
  39. data/lib/active_merchant/billing/gateways/checkout.rb +2 -2
  40. data/lib/active_merchant/billing/gateways/checkout_v2.rb +18 -21
  41. data/lib/active_merchant/billing/gateways/clearhaus.rb +7 -7
  42. data/lib/active_merchant/billing/gateways/commercegate.rb +1 -1
  43. data/lib/active_merchant/billing/gateways/conekta.rb +2 -2
  44. data/lib/active_merchant/billing/gateways/creditcall.rb +10 -10
  45. data/lib/active_merchant/billing/gateways/credorax.rb +32 -15
  46. data/lib/active_merchant/billing/gateways/ct_payment.rb +10 -10
  47. data/lib/active_merchant/billing/gateways/culqi.rb +10 -10
  48. data/lib/active_merchant/billing/gateways/cyber_source.rb +61 -37
  49. data/lib/active_merchant/billing/gateways/d_local.rb +11 -11
  50. data/lib/active_merchant/billing/gateways/data_cash.rb +2 -3
  51. data/lib/active_merchant/billing/gateways/decidir.rb +24 -9
  52. data/lib/active_merchant/billing/gateways/dibs.rb +8 -8
  53. data/lib/active_merchant/billing/gateways/digitzs.rb +6 -6
  54. data/lib/active_merchant/billing/gateways/ebanx.rb +9 -9
  55. data/lib/active_merchant/billing/gateways/efsnet.rb +3 -4
  56. data/lib/active_merchant/billing/gateways/elavon.rb +279 -227
  57. data/lib/active_merchant/billing/gateways/element.rb +8 -8
  58. data/lib/active_merchant/billing/gateways/evo_ca.rb +5 -6
  59. data/lib/active_merchant/billing/gateways/eway.rb +3 -4
  60. data/lib/active_merchant/billing/gateways/eway_managed.rb +6 -7
  61. data/lib/active_merchant/billing/gateways/eway_rapid.rb +8 -8
  62. data/lib/active_merchant/billing/gateways/exact.rb +8 -9
  63. data/lib/active_merchant/billing/gateways/ezic.rb +8 -8
  64. data/lib/active_merchant/billing/gateways/fat_zebra.rb +4 -4
  65. data/lib/active_merchant/billing/gateways/federated_canada.rb +2 -3
  66. data/lib/active_merchant/billing/gateways/first_giving.rb +1 -1
  67. data/lib/active_merchant/billing/gateways/first_pay.rb +6 -6
  68. data/lib/active_merchant/billing/gateways/firstdata_e4.rb +7 -7
  69. data/lib/active_merchant/billing/gateways/firstdata_e4_v27.rb +21 -10
  70. data/lib/active_merchant/billing/gateways/flo2cash.rb +9 -9
  71. data/lib/active_merchant/billing/gateways/flo2cash_simple.rb +1 -1
  72. data/lib/active_merchant/billing/gateways/forte.rb +14 -8
  73. data/lib/active_merchant/billing/gateways/global_collect.rb +29 -10
  74. data/lib/active_merchant/billing/gateways/global_transport.rb +7 -7
  75. data/lib/active_merchant/billing/gateways/hdfc.rb +10 -10
  76. data/lib/active_merchant/billing/gateways/hps.rb +17 -14
  77. data/lib/active_merchant/billing/gateways/iats_payments.rb +9 -4
  78. data/lib/active_merchant/billing/gateways/in_context_paypal_express.rb +1 -1
  79. data/lib/active_merchant/billing/gateways/inspire.rb +3 -4
  80. data/lib/active_merchant/billing/gateways/instapay.rb +1 -2
  81. data/lib/active_merchant/billing/gateways/ipp.rb +7 -7
  82. data/lib/active_merchant/billing/gateways/iridium.rb +16 -17
  83. data/lib/active_merchant/billing/gateways/iveri.rb +7 -7
  84. data/lib/active_merchant/billing/gateways/ixopay.rb +7 -7
  85. data/lib/active_merchant/billing/gateways/jetpay.rb +1 -2
  86. data/lib/active_merchant/billing/gateways/jetpay_v2.rb +4 -5
  87. data/lib/active_merchant/billing/gateways/kushki.rb +6 -6
  88. data/lib/active_merchant/billing/gateways/latitude19.rb +14 -14
  89. data/lib/active_merchant/billing/gateways/linkpoint.rb +5 -6
  90. data/lib/active_merchant/billing/gateways/litle.rb +28 -12
  91. data/lib/active_merchant/billing/gateways/mastercard.rb +12 -12
  92. data/lib/active_merchant/billing/gateways/mercado_pago.rb +8 -8
  93. data/lib/active_merchant/billing/gateways/merchant_e_solutions.rb +1 -2
  94. data/lib/active_merchant/billing/gateways/merchant_one.rb +1 -1
  95. data/lib/active_merchant/billing/gateways/merchant_partners.rb +10 -10
  96. data/lib/active_merchant/billing/gateways/merchant_ware.rb +5 -7
  97. data/lib/active_merchant/billing/gateways/merchant_ware_version_four.rb +4 -6
  98. data/lib/active_merchant/billing/gateways/mercury.rb +4 -4
  99. data/lib/active_merchant/billing/gateways/metrics_global.rb +4 -5
  100. data/lib/active_merchant/billing/gateways/micropayment.rb +8 -8
  101. data/lib/active_merchant/billing/gateways/migs.rb +3 -4
  102. data/lib/active_merchant/billing/gateways/modern_payments_cim.rb +2 -4
  103. data/lib/active_merchant/billing/gateways/monei.rb +7 -7
  104. data/lib/active_merchant/billing/gateways/moneris.rb +4 -3
  105. data/lib/active_merchant/billing/gateways/money_movers.rb +2 -3
  106. data/lib/active_merchant/billing/gateways/mundipagg.rb +37 -10
  107. data/lib/active_merchant/billing/gateways/nab_transact.rb +2 -4
  108. data/lib/active_merchant/billing/gateways/ncr_secure_pay.rb +7 -7
  109. data/lib/active_merchant/billing/gateways/net_registry.rb +1 -2
  110. data/lib/active_merchant/billing/gateways/netaxept.rb +6 -6
  111. data/lib/active_merchant/billing/gateways/netbanx.rb +12 -10
  112. data/lib/active_merchant/billing/gateways/netbilling.rb +4 -5
  113. data/lib/active_merchant/billing/gateways/network_merchants.rb +2 -3
  114. data/lib/active_merchant/billing/gateways/nmi.rb +21 -7
  115. data/lib/active_merchant/billing/gateways/ogone.rb +3 -3
  116. data/lib/active_merchant/billing/gateways/omise.rb +13 -13
  117. data/lib/active_merchant/billing/gateways/openpay.rb +4 -5
  118. data/lib/active_merchant/billing/gateways/opp.rb +12 -12
  119. data/lib/active_merchant/billing/gateways/optimal_payment.rb +3 -4
  120. data/lib/active_merchant/billing/gateways/orbital.rb +175 -81
  121. data/lib/active_merchant/billing/gateways/pac_net_raven.rb +3 -4
  122. data/lib/active_merchant/billing/gateways/pagarme.rb +9 -9
  123. data/lib/active_merchant/billing/gateways/pago_facil.rb +2 -2
  124. data/lib/active_merchant/billing/gateways/pay_conex.rb +8 -8
  125. data/lib/active_merchant/billing/gateways/pay_gate_xml.rb +6 -7
  126. data/lib/active_merchant/billing/gateways/pay_hub.rb +7 -8
  127. data/lib/active_merchant/billing/gateways/pay_junction.rb +4 -5
  128. data/lib/active_merchant/billing/gateways/pay_junction_v2.rb +9 -9
  129. data/lib/active_merchant/billing/gateways/pay_secure.rb +2 -3
  130. data/lib/active_merchant/billing/gateways/paybox_direct.rb +23 -1
  131. data/lib/active_merchant/billing/gateways/payeezy.rb +35 -17
  132. data/lib/active_merchant/billing/gateways/payex.rb +11 -12
  133. data/lib/active_merchant/billing/gateways/payflow.rb +4 -1
  134. data/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb +1 -1
  135. data/lib/active_merchant/billing/gateways/payflow/payflow_express_response.rb +1 -1
  136. data/lib/active_merchant/billing/gateways/payment_express.rb +1 -2
  137. data/lib/active_merchant/billing/gateways/paymentez.rb +26 -6
  138. data/lib/active_merchant/billing/gateways/paymill.rb +10 -10
  139. data/lib/active_merchant/billing/gateways/paypal.rb +10 -2
  140. data/lib/active_merchant/billing/gateways/paypal/paypal_common_api.rb +1 -0
  141. data/lib/active_merchant/billing/gateways/paypal_express.rb +1 -1
  142. data/lib/active_merchant/billing/gateways/paypal_express_common.rb +1 -1
  143. data/lib/active_merchant/billing/gateways/payscout.rb +1 -2
  144. data/lib/active_merchant/billing/gateways/paystation.rb +3 -4
  145. data/lib/active_merchant/billing/gateways/payu_in.rb +3 -3
  146. data/lib/active_merchant/billing/gateways/payu_latam.rb +17 -10
  147. data/lib/active_merchant/billing/gateways/payway.rb +8 -9
  148. data/lib/active_merchant/billing/gateways/pin.rb +11 -0
  149. data/lib/active_merchant/billing/gateways/plugnpay.rb +2 -3
  150. data/lib/active_merchant/billing/gateways/pro_pay.rb +8 -8
  151. data/lib/active_merchant/billing/gateways/psigate.rb +3 -4
  152. data/lib/active_merchant/billing/gateways/psl_card.rb +1 -2
  153. data/lib/active_merchant/billing/gateways/qbms.rb +4 -5
  154. data/lib/active_merchant/billing/gateways/quantum.rb +1 -2
  155. data/lib/active_merchant/billing/gateways/quickbooks.rb +4 -3
  156. data/lib/active_merchant/billing/gateways/quickpay/quickpay_v10.rb +3 -4
  157. data/lib/active_merchant/billing/gateways/quickpay/quickpay_v4to7.rb +1 -2
  158. data/lib/active_merchant/billing/gateways/qvalent.rb +9 -9
  159. data/lib/active_merchant/billing/gateways/realex.rb +1 -1
  160. data/lib/active_merchant/billing/gateways/redsys.rb +87 -7
  161. data/lib/active_merchant/billing/gateways/s5.rb +7 -7
  162. data/lib/active_merchant/billing/gateways/safe_charge.rb +40 -14
  163. data/lib/active_merchant/billing/gateways/sage.rb +3 -5
  164. data/lib/active_merchant/billing/gateways/sage_pay.rb +6 -7
  165. data/lib/active_merchant/billing/gateways/sallie_mae.rb +1 -2
  166. data/lib/active_merchant/billing/gateways/secure_net.rb +1 -2
  167. data/lib/active_merchant/billing/gateways/secure_pay.rb +3 -4
  168. data/lib/active_merchant/billing/gateways/secure_pay_au.rb +2 -4
  169. data/lib/active_merchant/billing/gateways/secure_pay_tech.rb +1 -2
  170. data/lib/active_merchant/billing/gateways/securion_pay.rb +5 -6
  171. data/lib/active_merchant/billing/gateways/skip_jack.rb +3 -4
  172. data/lib/active_merchant/billing/gateways/smart_ps.rb +5 -6
  173. data/lib/active_merchant/billing/gateways/so_easy_pay.rb +7 -7
  174. data/lib/active_merchant/billing/gateways/spreedly_core.rb +6 -6
  175. data/lib/active_merchant/billing/gateways/stripe.rb +12 -12
  176. data/lib/active_merchant/billing/gateways/stripe_payment_intents.rb +30 -0
  177. data/lib/active_merchant/billing/gateways/swipe_checkout.rb +3 -4
  178. data/lib/active_merchant/billing/gateways/telr.rb +9 -9
  179. data/lib/active_merchant/billing/gateways/trans_first.rb +3 -3
  180. data/lib/active_merchant/billing/gateways/trans_first_transaction_express.rb +14 -14
  181. data/lib/active_merchant/billing/gateways/transact_pro.rb +9 -9
  182. data/lib/active_merchant/billing/gateways/trust_commerce.rb +8 -9
  183. data/lib/active_merchant/billing/gateways/usa_epay.rb +1 -1
  184. data/lib/active_merchant/billing/gateways/usa_epay_advanced.rb +36 -36
  185. data/lib/active_merchant/billing/gateways/usa_epay_transaction.rb +4 -5
  186. data/lib/active_merchant/billing/gateways/vanco.rb +3 -3
  187. data/lib/active_merchant/billing/gateways/verifi.rb +1 -2
  188. data/lib/active_merchant/billing/gateways/viaklix.rb +1 -2
  189. data/lib/active_merchant/billing/gateways/visanet_peru.rb +10 -10
  190. data/lib/active_merchant/billing/gateways/webpay.rb +2 -2
  191. data/lib/active_merchant/billing/gateways/wepay.rb +3 -2
  192. data/lib/active_merchant/billing/gateways/wirecard.rb +1 -2
  193. data/lib/active_merchant/billing/gateways/worldpay.rb +18 -10
  194. data/lib/active_merchant/billing/gateways/worldpay_online_payments.rb +14 -16
  195. data/lib/active_merchant/billing/gateways/worldpay_us.rb +9 -9
  196. data/lib/active_merchant/billing/response.rb +3 -2
  197. data/lib/active_merchant/country.rb +1 -1
  198. data/lib/active_merchant/network_connection_retries.rb +2 -2
  199. data/lib/active_merchant/post_data.rb +1 -1
  200. data/lib/active_merchant/posts_data.rb +1 -1
  201. data/lib/active_merchant/version.rb +1 -1
  202. data/lib/support/ssl_verify.rb +2 -2
  203. data/lib/support/ssl_version.rb +2 -2
  204. metadata +2 -2
@@ -68,7 +68,7 @@ module ActiveMerchant
68
68
  commit(synchronized_path("/payments/#{identification}/refund"), post)
69
69
  end
70
70
 
71
- def verify(credit_card, options={})
71
+ def verify(credit_card, options = {})
72
72
  MultiResponse.run(:use_first_response) do |r|
73
73
  r.process { authorize(100, credit_card, options) }
74
74
  r.process(:ignore_result) { void(r.authorization, options) }
@@ -155,8 +155,7 @@ module ActiveMerchant
155
155
 
156
156
  Response.new(success, message_from(success, response), response,
157
157
  test: test?,
158
- authorization: authorization_from(response)
159
- )
158
+ authorization: authorization_from(response))
160
159
  end
161
160
 
162
161
  def authorization_from(response)
@@ -264,7 +263,7 @@ module ActiveMerchant
264
263
  end
265
264
 
266
265
  def format_order_id(order_id)
267
- truncate(order_id.to_s.gsub(/#/, ''), 20)
266
+ truncate(order_id.to_s.delete('#'), 20)
268
267
  end
269
268
 
270
269
  def headers
@@ -166,8 +166,7 @@ module ActiveMerchant #:nodoc:
166
166
 
167
167
  Response.new(successful?(response), message_from(response), response,
168
168
  test: test?,
169
- authorization: response[:transaction]
170
- )
169
+ authorization: response[:transaction])
171
170
  end
172
171
 
173
172
  def successful?(response)
@@ -16,12 +16,12 @@ module ActiveMerchant #:nodoc:
16
16
  'S' => 'D'
17
17
  }
18
18
 
19
- def initialize(options={})
19
+ def initialize(options = {})
20
20
  requires!(options, :username, :password, :merchant, :pem, :pem_password)
21
21
  super
22
22
  end
23
23
 
24
- def purchase(amount, payment_method, options={})
24
+ def purchase(amount, payment_method, options = {})
25
25
  post = {}
26
26
  add_invoice(post, amount, options)
27
27
  add_order_number(post, options)
@@ -34,7 +34,7 @@ module ActiveMerchant #:nodoc:
34
34
  commit('capture', post)
35
35
  end
36
36
 
37
- def authorize(amount, payment_method, options={})
37
+ def authorize(amount, payment_method, options = {})
38
38
  post = {}
39
39
  add_invoice(post, amount, options)
40
40
  add_order_number(post, options)
@@ -47,7 +47,7 @@ module ActiveMerchant #:nodoc:
47
47
  commit('preauth', post)
48
48
  end
49
49
 
50
- def capture(amount, authorization, options={})
50
+ def capture(amount, authorization, options = {})
51
51
  post = {}
52
52
  add_invoice(post, amount, options)
53
53
  add_reference(post, authorization, options)
@@ -57,7 +57,7 @@ module ActiveMerchant #:nodoc:
57
57
  commit('captureWithoutAuth', post)
58
58
  end
59
59
 
60
- def refund(amount, authorization, options={})
60
+ def refund(amount, authorization, options = {})
61
61
  post = {}
62
62
  add_invoice(post, amount, options)
63
63
  add_reference(post, authorization, options)
@@ -69,7 +69,7 @@ module ActiveMerchant #:nodoc:
69
69
  end
70
70
 
71
71
  # Credit requires the merchant account to be enabled for "Adhoc Refunds"
72
- def credit(amount, payment_method, options={})
72
+ def credit(amount, payment_method, options = {})
73
73
  post = {}
74
74
  add_invoice(post, amount, options)
75
75
  add_order_number(post, options)
@@ -80,7 +80,7 @@ module ActiveMerchant #:nodoc:
80
80
  commit('refund', post)
81
81
  end
82
82
 
83
- def void(authorization, options={})
83
+ def void(authorization, options = {})
84
84
  post = {}
85
85
  add_reference(post, authorization, options)
86
86
  add_customer_data(post, options)
@@ -110,7 +110,7 @@ module ActiveMerchant #:nodoc:
110
110
 
111
111
  private
112
112
 
113
- CURRENCY_CODES = Hash.new { |h, k| raise ArgumentError.new("Unsupported currency: #{k}") }
113
+ CURRENCY_CODES = Hash.new { |_h, k| raise ArgumentError.new("Unsupported currency: #{k}") }
114
114
  CURRENCY_CODES['AUD'] = 'AUD'
115
115
  CURRENCY_CODES['INR'] = 'INR'
116
116
 
@@ -280,7 +280,7 @@ module ActiveMerchant #:nodoc:
280
280
  '12' => STANDARD_ERROR_CODE[:card_declined],
281
281
  '06' => STANDARD_ERROR_CODE[:processing_error],
282
282
  '01' => STANDARD_ERROR_CODE[:call_issuer],
283
- '04' => STANDARD_ERROR_CODE[:pickup_card],
283
+ '04' => STANDARD_ERROR_CODE[:pickup_card]
284
284
  }
285
285
 
286
286
  def error_code_from(succeeded, response)
@@ -300,7 +300,7 @@ module ActiveMerchant
300
300
  end
301
301
  xml.tag! 'supplementarydata' do
302
302
  xml.tag! 'item', 'type' => 'mobile' do
303
- xml.tag! 'field01', payment.source.to_s.gsub('_', '-')
303
+ xml.tag! 'field01', payment.source.to_s.tr('_', '-')
304
304
  end
305
305
  end
306
306
  end
@@ -170,6 +170,10 @@ module ActiveMerchant #:nodoc:
170
170
  9914 => 'KO Confirmation'
171
171
  }
172
172
 
173
+ # Expected values as per documentation
174
+ THREE_DS_V1 = '1.0.2'
175
+ THREE_DS_V2 = '2.1.0'
176
+
173
177
  # Creates a new instance
174
178
  #
175
179
  # Redsys requires a login and secret_key, and optionally also accepts a
@@ -197,7 +201,9 @@ module ActiveMerchant #:nodoc:
197
201
  add_amount(data, money, options)
198
202
  add_order(data, options[:order_id])
199
203
  add_payment(data, payment)
204
+ add_external_mpi_fields(data, options)
200
205
  add_threeds(data, options) if options[:execute_threed]
206
+ add_stored_credential_options(data, options)
201
207
  data[:description] = options[:description]
202
208
  data[:store_in_vault] = options[:store]
203
209
  data[:sca_exemption] = options[:sca_exemption]
@@ -213,7 +219,9 @@ module ActiveMerchant #:nodoc:
213
219
  add_amount(data, money, options)
214
220
  add_order(data, options[:order_id])
215
221
  add_payment(data, payment)
222
+ add_external_mpi_fields(data, options)
216
223
  add_threeds(data, options) if options[:execute_threed]
224
+ add_stored_credential_options(data, options)
217
225
  data[:description] = options[:description]
218
226
  data[:store_in_vault] = options[:store]
219
227
  data[:sca_exemption] = options[:sca_exemption]
@@ -321,8 +329,48 @@ module ActiveMerchant #:nodoc:
321
329
  end
322
330
  end
323
331
 
332
+ def add_external_mpi_fields(data, options)
333
+ return unless options[:three_d_secure]
334
+
335
+ if options[:three_d_secure][:version] == THREE_DS_V2
336
+ data[:threeDSServerTransID] = options[:three_d_secure][:three_ds_server_trans_id] if options[:three_d_secure][:three_ds_server_trans_id]
337
+ data[:dsTransID] = options[:three_d_secure][:ds_transaction_id] if options[:three_d_secure][:ds_transaction_id]
338
+ data[:authenticacionValue] = options[:three_d_secure][:cavv] if options[:three_d_secure][:cavv]
339
+ data[:protocolVersion] = options[:three_d_secure][:version] if options[:three_d_secure][:version]
340
+ data[:authenticacionMethod] = options[:authentication_method] if options[:authentication_method]
341
+ data[:authenticacionType] = options[:authentication_type] if options[:authentication_type]
342
+ data[:authenticacionFlow] = options[:authentication_flow] if options[:authentication_flow]
343
+ data[:eci_v2] = options[:three_d_secure][:eci] if options[:three_d_secure][:eci]
344
+ elsif options[:three_d_secure][:version] == THREE_DS_V1
345
+ data[:txid] = options[:three_d_secure][:xid] if options[:three_d_secure][:xid]
346
+ data[:cavv] = options[:three_d_secure][:cavv] if options[:three_d_secure][:cavv]
347
+ data[:eci_v1] = options[:three_d_secure][:eci] if options[:three_d_secure][:eci]
348
+ end
349
+ end
350
+
351
+ def add_stored_credential_options(data, options)
352
+ return unless options[:stored_credential]
353
+
354
+ case options[:stored_credential][:initial_transaction]
355
+ when true
356
+ data[:DS_MERCHANT_COF_INI] = 'S'
357
+ when false
358
+ data[:DS_MERCHANT_COF_INI] = 'N'
359
+ data[:DS_MERCHANT_COF_TXNID] = options[:stored_credential][:network_transaction_id] if options[:stored_credential][:network_transaction_id]
360
+ end
361
+
362
+ case options[:stored_credential][:reason_type]
363
+ when 'recurring'
364
+ data[:DS_MERCHANT_COF_TYPE] = 'R'
365
+ when 'installment'
366
+ data[:DS_MERCHANT_COF_TYPE] = 'I'
367
+ when 'unscheduled'
368
+ return
369
+ end
370
+ end
371
+
324
372
  def add_threeds(data, options)
325
- data[:threeds] = {threeDSInfo: 'CardData'} if options[:execute_threed] == true
373
+ data[:threeds] = { threeDSInfo: 'CardData' } if options[:execute_threed] == true
326
374
  end
327
375
 
328
376
  def determine_3ds_action(threeds_hash)
@@ -334,7 +382,7 @@ module ActiveMerchant #:nodoc:
334
382
  def commit(data, options = {})
335
383
  if data[:threeds]
336
384
  action = determine_3ds_action(data[:threeds])
337
- request = <<-EOS
385
+ request = <<-REQUEST
338
386
  <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:apachesoap="http://xml.apache.org/xml-soap" xmlns:impl="http://webservice.sis.sermepa.es" xmlns:intf="http://webservice.sis.sermepa.es" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" >
339
387
  <soapenv:Header/>
340
388
  <soapenv:Body>
@@ -345,14 +393,14 @@ module ActiveMerchant #:nodoc:
345
393
  </intf:#{action}>
346
394
  </soapenv:Body>
347
395
  </soapenv:Envelope>
348
- EOS
396
+ REQUEST
349
397
  parse(ssl_post(threeds_url, request, headers(action)), action)
350
398
  else
351
399
  parse(ssl_post(url, "entrada=#{CGI.escape(xml_request_from(data, options))}", headers), action)
352
400
  end
353
401
  end
354
402
 
355
- def headers(action=nil)
403
+ def headers(action = nil)
356
404
  if action
357
405
  {
358
406
  'Content-Type' => 'text/xml',
@@ -419,6 +467,8 @@ module ActiveMerchant #:nodoc:
419
467
  end
420
468
 
421
469
  def build_merchant_data(xml, data, options = {})
470
+ # See https://sis-t.redsys.es:25443/sis/services/SerClsWSEntradaV2/wsdl/SerClsWSEntradaV2.wsdl
471
+ # (which results from calling #threeds_url + '?WSDL', https://sis-t.redsys.es:25443/sis/services/SerClsWSEntradaV2?WSDL)
422
472
  xml.DATOSENTRADA do
423
473
  # Basic elements
424
474
  xml.DS_Version 0.1
@@ -447,6 +497,9 @@ module ActiveMerchant #:nodoc:
447
497
  xml.DS_MERCHANT_EXPIRYDATE data[:card][:date]
448
498
  xml.DS_MERCHANT_CVV2 data[:card][:cvv]
449
499
  xml.DS_MERCHANT_IDENTIFIER 'REQUIRED' if data[:store_in_vault]
500
+
501
+ build_merchant_mpi_external(xml, data)
502
+
450
503
  elsif data[:credit_card_token]
451
504
  xml.DS_MERCHANT_IDENTIFIER data[:credit_card_token]
452
505
  xml.DS_MERCHANT_DIRECTPAYMENT 'true'
@@ -457,9 +510,36 @@ module ActiveMerchant #:nodoc:
457
510
  xml.DS_MERCHANT_DIRECTPAYMENT 'moto' if options.dig(:moto) && options.dig(:metadata, :manual_entry)
458
511
 
459
512
  xml.DS_MERCHANT_EMV3DS data[:threeds].to_json if data[:threeds]
513
+
514
+ if options[:stored_credential]
515
+ xml.DS_MERCHANT_COF_INI data[:DS_MERCHANT_COF_INI]
516
+ xml.DS_MERCHANT_COF_TYPE data[:DS_MERCHANT_COF_TYPE]
517
+ xml.DS_MERCHANT_COF_TXNID data[:DS_MERCHANT_COF_TXNID] if data[:DS_MERCHANT_COF_TXNID]
518
+ end
460
519
  end
461
520
  end
462
521
 
522
+ def build_merchant_mpi_external(xml, data)
523
+ return unless data[:txid] || data[:threeDSServerTransID]
524
+
525
+ ds_merchant_mpi_external = {}
526
+ ds_merchant_mpi_external[:TXID] = data[:txid] if data[:txid]
527
+ ds_merchant_mpi_external[:CAVV] = data[:cavv] if data[:cavv]
528
+ ds_merchant_mpi_external[:ECI] = data[:eci_v1] if data[:eci_v1]
529
+
530
+ ds_merchant_mpi_external[:threeDSServerTransID] = data[:threeDSServerTransID] if data[:threeDSServerTransID]
531
+ ds_merchant_mpi_external[:dsTransID] = data[:dsTransID] if data[:dsTransID]
532
+ ds_merchant_mpi_external[:authenticacionValue] = data[:authenticacionValue] if data[:authenticacionValue]
533
+ ds_merchant_mpi_external[:protocolVersion] = data[:protocolVersion] if data[:protocolVersion]
534
+ ds_merchant_mpi_external[:Eci] = data[:eci_v2] if data[:eci_v2]
535
+ ds_merchant_mpi_external[:authenticacionMethod] = data[:authenticacionMethod] if data[:authenticacionMethod]
536
+ ds_merchant_mpi_external[:authenticacionType] = data[:authenticacionType] if data[:authenticacionType]
537
+ ds_merchant_mpi_external[:authenticacionFlow] = data[:authenticacionFlow] if data[:authenticacionFlow]
538
+
539
+ xml.DS_MERCHANT_MPIEXTERNAL ds_merchant_mpi_external.to_json unless ds_merchant_mpi_external.empty?
540
+ xml.target!
541
+ end
542
+
463
543
  def parse(data, action)
464
544
  params = {}
465
545
  success = false
@@ -476,7 +556,7 @@ module ActiveMerchant #:nodoc:
476
556
  if validate_signature(params)
477
557
  message = response_text(params[:ds_response])
478
558
  options[:authorization] = build_authorization(params)
479
- success = is_success_response?(params[:ds_response])
559
+ success = success_response?(params[:ds_response])
480
560
  else
481
561
  message = 'Response failed validation check'
482
562
  end
@@ -490,7 +570,7 @@ module ActiveMerchant #:nodoc:
490
570
  end
491
571
  message = response_text_3ds(xml, params)
492
572
  options[:authorization] = build_authorization(params)
493
- success = params.size > 0 && is_success_response?(params[:ds_response])
573
+ success = params.size > 0 && success_response?(params[:ds_response])
494
574
  else
495
575
  # Some kind of programmer error with the request!
496
576
  message = "#{code} ERROR"
@@ -559,7 +639,7 @@ module ActiveMerchant #:nodoc:
559
639
  message
560
640
  end
561
641
 
562
- def is_success_response?(code)
642
+ def success_response?(code)
563
643
  (code.to_i < 100) || [400, 481, 500, 900].include?(code.to_i)
564
644
  end
565
645
 
@@ -22,12 +22,12 @@ module ActiveMerchant #:nodoc:
22
22
  'store' => 'CC.RG'
23
23
  }
24
24
 
25
- def initialize(options={})
25
+ def initialize(options = {})
26
26
  requires!(options, :sender, :channel, :login, :password)
27
27
  super
28
28
  end
29
29
 
30
- def purchase(money, payment, options={})
30
+ def purchase(money, payment, options = {})
31
31
  request = build_xml_request do |xml|
32
32
  add_identification(xml, options)
33
33
  add_payment(xml, money, 'sale', options)
@@ -39,7 +39,7 @@ module ActiveMerchant #:nodoc:
39
39
  commit(request)
40
40
  end
41
41
 
42
- def refund(money, authorization, options={})
42
+ def refund(money, authorization, options = {})
43
43
  request = build_xml_request do |xml|
44
44
  add_identification(xml, options, authorization)
45
45
  add_payment(xml, money, 'refund', options)
@@ -48,7 +48,7 @@ module ActiveMerchant #:nodoc:
48
48
  commit(request)
49
49
  end
50
50
 
51
- def authorize(money, payment, options={})
51
+ def authorize(money, payment, options = {})
52
52
  request = build_xml_request do |xml|
53
53
  add_identification(xml, options)
54
54
  add_payment(xml, money, 'authonly', options)
@@ -60,7 +60,7 @@ module ActiveMerchant #:nodoc:
60
60
  commit(request)
61
61
  end
62
62
 
63
- def capture(money, authorization, options={})
63
+ def capture(money, authorization, options = {})
64
64
  request = build_xml_request do |xml|
65
65
  add_identification(xml, options, authorization)
66
66
  add_payment(xml, money, 'capture', options)
@@ -69,7 +69,7 @@ module ActiveMerchant #:nodoc:
69
69
  commit(request)
70
70
  end
71
71
 
72
- def void(authorization, options={})
72
+ def void(authorization, options = {})
73
73
  request = build_xml_request do |xml|
74
74
  add_identification(xml, options, authorization)
75
75
  add_payment(xml, nil, 'void', options)
@@ -89,7 +89,7 @@ module ActiveMerchant #:nodoc:
89
89
  commit(request)
90
90
  end
91
91
 
92
- def verify(credit_card, options={})
92
+ def verify(credit_card, options = {})
93
93
  MultiResponse.run(:use_first_response) do |r|
94
94
  r.process { authorize(100, credit_card, options) }
95
95
  r.process(:ignore_result) { void(r.authorization, options) }
@@ -15,15 +15,26 @@ module ActiveMerchant #:nodoc:
15
15
 
16
16
  VERSION = '4.1.0'
17
17
 
18
- def initialize(options={})
18
+ def initialize(options = {})
19
19
  requires!(options, :client_login_id, :client_password)
20
20
  super
21
21
  end
22
22
 
23
- def purchase(money, payment, options={})
23
+ def purchase(money, payment, options = {})
24
24
  post = {}
25
- post[:sg_APIType] = 1 if options[:three_d_secure]
26
- trans_type = options[:three_d_secure] ? 'Sale3D' : 'Sale'
25
+
26
+ # Determine if 3DS is requested, or there is standard external MPI data
27
+ if options[:three_d_secure]
28
+ if options[:three_d_secure].is_a?(Hash)
29
+ add_external_mpi_data(post, options)
30
+ else
31
+ post[:sg_APIType] = 1
32
+ trans_type = 'Sale3D'
33
+ end
34
+ end
35
+
36
+ trans_type ||= 'Sale'
37
+
27
38
  add_transaction_data(trans_type, post, money, options)
28
39
  add_payment(post, payment, options)
29
40
  add_customer_details(post, payment, options)
@@ -31,8 +42,10 @@ module ActiveMerchant #:nodoc:
31
42
  commit(post)
32
43
  end
33
44
 
34
- def authorize(money, payment, options={})
45
+ def authorize(money, payment, options = {})
35
46
  post = {}
47
+
48
+ add_external_mpi_data(post, options) if options[:three_d_secure]&.is_a?(Hash)
36
49
  add_transaction_data('Auth', post, money, options)
37
50
  add_payment(post, payment, options)
38
51
  add_customer_details(post, payment, options)
@@ -40,10 +53,10 @@ module ActiveMerchant #:nodoc:
40
53
  commit(post)
41
54
  end
42
55
 
43
- def capture(money, authorization, options={})
56
+ def capture(money, authorization, options = {})
44
57
  post = {}
45
58
  auth, transaction_id, token, exp_month, exp_year, _, original_currency = authorization.split('|')
46
- add_transaction_data('Settle', post, money, options.merge!({currency: original_currency}))
59
+ add_transaction_data('Settle', post, money, options.merge!({ currency: original_currency }))
47
60
  post[:sg_AuthCode] = auth
48
61
  post[:sg_TransactionID] = transaction_id
49
62
  post[:sg_CCToken] = token
@@ -53,10 +66,10 @@ module ActiveMerchant #:nodoc:
53
66
  commit(post)
54
67
  end
55
68
 
56
- def refund(money, authorization, options={})
69
+ def refund(money, authorization, options = {})
57
70
  post = {}
58
71
  auth, transaction_id, token, exp_month, exp_year, _, original_currency = authorization.split('|')
59
- add_transaction_data('Credit', post, money, options.merge!({currency: original_currency}))
72
+ add_transaction_data('Credit', post, money, options.merge!({ currency: original_currency }))
60
73
  post[:sg_CreditType] = 2
61
74
  post[:sg_AuthCode] = auth
62
75
  post[:sg_TransactionID] = transaction_id
@@ -67,19 +80,21 @@ module ActiveMerchant #:nodoc:
67
80
  commit(post)
68
81
  end
69
82
 
70
- def credit(money, payment, options={})
83
+ def credit(money, payment, options = {})
71
84
  post = {}
85
+
72
86
  add_payment(post, payment, options)
73
87
  add_transaction_data('Credit', post, money, options)
88
+
74
89
  post[:sg_CreditType] = 1
75
90
 
76
91
  commit(post)
77
92
  end
78
93
 
79
- def void(authorization, options={})
94
+ def void(authorization, options = {})
80
95
  post = {}
81
96
  auth, transaction_id, token, exp_month, exp_year, original_amount, original_currency = authorization.split('|')
82
- add_transaction_data('Void', post, (original_amount.to_f * 100), options.merge!({currency: original_currency}))
97
+ add_transaction_data('Void', post, (original_amount.to_f * 100), options.merge!({ currency: original_currency }))
83
98
  post[:sg_CreditType] = 2
84
99
  post[:sg_AuthCode] = auth
85
100
  post[:sg_TransactionID] = transaction_id
@@ -90,7 +105,7 @@ module ActiveMerchant #:nodoc:
90
105
  commit(post)
91
106
  end
92
107
 
93
- def verify(credit_card, options={})
108
+ def verify(credit_card, options = {})
94
109
  MultiResponse.run(:use_first_response) do |r|
95
110
  r.process { authorize(100, credit_card, options) }
96
111
  r.process(:ignore_result) { void(r.authorization, options) }
@@ -130,7 +145,7 @@ module ActiveMerchant #:nodoc:
130
145
  post[:sg_MerchantName] = options[:merchant_name] if options[:merchant_name]
131
146
  end
132
147
 
133
- def add_payment(post, payment, options={})
148
+ def add_payment(post, payment, options = {})
134
149
  post[:sg_NameOnCard] = payment.name
135
150
  post[:sg_CardNumber] = payment.number
136
151
  post[:sg_ExpMonth] = format(payment.month, :two_digits)
@@ -154,6 +169,17 @@ module ActiveMerchant #:nodoc:
154
169
  post[:sg_Email] = options[:email]
155
170
  end
156
171
 
172
+ def add_external_mpi_data(post, options)
173
+ version = options[:three_d_secure][:ds_transaction_id] ? '2' : '1'
174
+
175
+ post[:sg_eci] = options[:three_d_secure][:eci] if options[:three_d_secure][:eci]
176
+ post[:sg_cavv] = options[:three_d_secure][:cavv] if options[:three_d_secure][:cavv]
177
+ post[:sg_dsTransID] = options[:three_d_secure][:ds_transaction_id] if version == '2'
178
+ post[:sg_threeDSProtocolVersion] = version
179
+ post[:sg_xid] = options[:three_d_secure][:xid] if version == '1'
180
+ post[:sg_IsExternalMPI] = 1
181
+ end
182
+
157
183
  def parse(xml)
158
184
  response = {}
159
185