activemerchant 1.131.0 → 1.137.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (184) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG +262 -0
  3. data/lib/active_merchant/billing/check.rb +2 -2
  4. data/lib/active_merchant/billing/compatibility.rb +4 -4
  5. data/lib/active_merchant/billing/credit_card.rb +13 -8
  6. data/lib/active_merchant/billing/credit_card_formatting.rb +4 -0
  7. data/lib/active_merchant/billing/credit_card_methods.rb +64 -7
  8. data/lib/active_merchant/billing/gateway.rb +9 -0
  9. data/lib/active_merchant/billing/gateways/adyen.rb +240 -41
  10. data/lib/active_merchant/billing/gateways/airwallex.rb +26 -12
  11. data/lib/active_merchant/billing/gateways/alelo.rb +23 -5
  12. data/lib/active_merchant/billing/gateways/authorize_net.rb +43 -35
  13. data/lib/active_merchant/billing/gateways/authorize_net_arb.rb +10 -6
  14. data/lib/active_merchant/billing/gateways/authorize_net_cim.rb +1 -3
  15. data/lib/active_merchant/billing/gateways/axcessms.rb +6 -2
  16. data/lib/active_merchant/billing/gateways/banwire.rb +4 -2
  17. data/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb +7 -3
  18. data/lib/active_merchant/billing/gateways/blue_pay.rb +13 -5
  19. data/lib/active_merchant/billing/gateways/blue_snap.rb +5 -5
  20. data/lib/active_merchant/billing/gateways/borgun.rb +6 -4
  21. data/lib/active_merchant/billing/gateways/braintree/token_nonce.rb +65 -20
  22. data/lib/active_merchant/billing/gateways/braintree_blue.rb +226 -73
  23. data/lib/active_merchant/billing/gateways/braintree_orange.rb +1 -1
  24. data/lib/active_merchant/billing/gateways/card_connect.rb +5 -2
  25. data/lib/active_merchant/billing/gateways/card_stream.rb +4 -6
  26. data/lib/active_merchant/billing/gateways/cashnet.rb +1 -1
  27. data/lib/active_merchant/billing/gateways/cecabank/cecabank_common.rb +36 -0
  28. data/lib/active_merchant/billing/gateways/cecabank/cecabank_json.rb +316 -0
  29. data/lib/active_merchant/billing/gateways/cecabank/cecabank_xml.rb +220 -0
  30. data/lib/active_merchant/billing/gateways/cecabank.rb +7 -240
  31. data/lib/active_merchant/billing/gateways/checkout_v2.rb +242 -41
  32. data/lib/active_merchant/billing/gateways/commerce_hub.rb +69 -8
  33. data/lib/active_merchant/billing/gateways/credorax.rb +3 -5
  34. data/lib/active_merchant/billing/gateways/cyber_source.rb +192 -41
  35. data/lib/active_merchant/billing/gateways/cyber_source_rest.rb +102 -58
  36. data/lib/active_merchant/billing/gateways/d_local.rb +26 -15
  37. data/lib/active_merchant/billing/gateways/data_cash.rb +21 -17
  38. data/lib/active_merchant/billing/gateways/datatrans.rb +279 -0
  39. data/lib/active_merchant/billing/gateways/decidir.rb +53 -18
  40. data/lib/active_merchant/billing/gateways/decidir_plus.rb +4 -1
  41. data/lib/active_merchant/billing/gateways/deepstack.rb +382 -0
  42. data/lib/active_merchant/billing/gateways/ebanx.rb +40 -36
  43. data/lib/active_merchant/billing/gateways/efsnet.rb +6 -2
  44. data/lib/active_merchant/billing/gateways/elavon.rb +99 -33
  45. data/lib/active_merchant/billing/gateways/element.rb +36 -7
  46. data/lib/active_merchant/billing/gateways/epay.rb +6 -2
  47. data/lib/active_merchant/billing/gateways/evo_ca.rb +6 -2
  48. data/lib/active_merchant/billing/gateways/eway.rb +4 -2
  49. data/lib/active_merchant/billing/gateways/eway_managed.rb +6 -2
  50. data/lib/active_merchant/billing/gateways/exact.rb +6 -2
  51. data/lib/active_merchant/billing/gateways/fat_zebra.rb +31 -3
  52. data/lib/active_merchant/billing/gateways/federated_canada.rb +6 -2
  53. data/lib/active_merchant/billing/gateways/first_pay/first_pay_common.rb +15 -0
  54. data/lib/active_merchant/billing/gateways/first_pay/first_pay_json.rb +190 -0
  55. data/lib/active_merchant/billing/gateways/first_pay/first_pay_xml.rb +183 -0
  56. data/lib/active_merchant/billing/gateways/first_pay.rb +6 -172
  57. data/lib/active_merchant/billing/gateways/firstdata_e4.rb +6 -2
  58. data/lib/active_merchant/billing/gateways/firstdata_e4_v27.rb +7 -3
  59. data/lib/active_merchant/billing/gateways/flex_charge.rb +347 -0
  60. data/lib/active_merchant/billing/gateways/garanti.rb +4 -2
  61. data/lib/active_merchant/billing/gateways/global_collect.rb +45 -37
  62. data/lib/active_merchant/billing/gateways/hi_pay.rb +286 -0
  63. data/lib/active_merchant/billing/gateways/hps.rb +1 -1
  64. data/lib/active_merchant/billing/gateways/iats_payments.rb +7 -2
  65. data/lib/active_merchant/billing/gateways/inspire.rb +6 -4
  66. data/lib/active_merchant/billing/gateways/instapay.rb +7 -4
  67. data/lib/active_merchant/billing/gateways/ipg.rb +10 -6
  68. data/lib/active_merchant/billing/gateways/iridium.rb +15 -5
  69. data/lib/active_merchant/billing/gateways/itransact.rb +6 -2
  70. data/lib/active_merchant/billing/gateways/iveri.rb +3 -3
  71. data/lib/active_merchant/billing/gateways/ixopay.rb +2 -2
  72. data/lib/active_merchant/billing/gateways/jetpay.rb +4 -2
  73. data/lib/active_merchant/billing/gateways/jetpay_v2.rb +4 -2
  74. data/lib/active_merchant/billing/gateways/kushki.rb +73 -13
  75. data/lib/active_merchant/billing/gateways/linkpoint.rb +6 -2
  76. data/lib/active_merchant/billing/gateways/litle.rb +33 -50
  77. data/lib/active_merchant/billing/gateways/mastercard.rb +4 -4
  78. data/lib/active_merchant/billing/gateways/maxipago.rb +2 -2
  79. data/lib/active_merchant/billing/gateways/merchant_e_solutions.rb +8 -5
  80. data/lib/active_merchant/billing/gateways/merchant_ware.rb +11 -4
  81. data/lib/active_merchant/billing/gateways/merchant_ware_version_four.rb +11 -4
  82. data/lib/active_merchant/billing/gateways/merchant_warrior.rb +19 -3
  83. data/lib/active_merchant/billing/gateways/mercury.rb +6 -2
  84. data/lib/active_merchant/billing/gateways/metrics_global.rb +8 -6
  85. data/lib/active_merchant/billing/gateways/migs/migs_codes.rb +1 -0
  86. data/lib/active_merchant/billing/gateways/migs.rb +6 -2
  87. data/lib/active_merchant/billing/gateways/mit.rb +25 -20
  88. data/lib/active_merchant/billing/gateways/modern_payments_cim.rb +18 -10
  89. data/lib/active_merchant/billing/gateways/monei.rb +1 -1
  90. data/lib/active_merchant/billing/gateways/moneris.rb +9 -3
  91. data/lib/active_merchant/billing/gateways/money_movers.rb +6 -2
  92. data/lib/active_merchant/billing/gateways/nab_transact.rb +12 -4
  93. data/lib/active_merchant/billing/gateways/net_registry.rb +6 -2
  94. data/lib/active_merchant/billing/gateways/netbanx.rb +1 -3
  95. data/lib/active_merchant/billing/gateways/netbilling.rb +6 -2
  96. data/lib/active_merchant/billing/gateways/network_merchants.rb +6 -2
  97. data/lib/active_merchant/billing/gateways/nmi.rb +23 -6
  98. data/lib/active_merchant/billing/gateways/ogone.rb +6 -2
  99. data/lib/active_merchant/billing/gateways/openpay.rb +4 -2
  100. data/lib/active_merchant/billing/gateways/opp.rb +1 -2
  101. data/lib/active_merchant/billing/gateways/optimal_payment.rb +6 -2
  102. data/lib/active_merchant/billing/gateways/orbital/orbital_soft_descriptors.rb +1 -3
  103. data/lib/active_merchant/billing/gateways/orbital.rb +83 -24
  104. data/lib/active_merchant/billing/gateways/pac_net_raven.rb +7 -4
  105. data/lib/active_merchant/billing/gateways/pay_gate_xml.rb +6 -2
  106. data/lib/active_merchant/billing/gateways/pay_hub.rb +4 -2
  107. data/lib/active_merchant/billing/gateways/pay_junction.rb +6 -2
  108. data/lib/active_merchant/billing/gateways/pay_secure.rb +6 -2
  109. data/lib/active_merchant/billing/gateways/pay_trace.rb +31 -18
  110. data/lib/active_merchant/billing/gateways/payeezy.rb +19 -8
  111. data/lib/active_merchant/billing/gateways/payex.rb +4 -2
  112. data/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb +1 -1
  113. data/lib/active_merchant/billing/gateways/payflow.rb +1 -3
  114. data/lib/active_merchant/billing/gateways/payment_express.rb +8 -4
  115. data/lib/active_merchant/billing/gateways/paymentez.rb +23 -11
  116. data/lib/active_merchant/billing/gateways/paysafe.rb +12 -11
  117. data/lib/active_merchant/billing/gateways/payscout.rb +7 -4
  118. data/lib/active_merchant/billing/gateways/paystation.rb +7 -3
  119. data/lib/active_merchant/billing/gateways/payway.rb +6 -2
  120. data/lib/active_merchant/billing/gateways/payway_dot_com.rb +3 -3
  121. data/lib/active_merchant/billing/gateways/pin.rb +22 -4
  122. data/lib/active_merchant/billing/gateways/plexo.rb +49 -10
  123. data/lib/active_merchant/billing/gateways/plugnpay.rb +6 -2
  124. data/lib/active_merchant/billing/gateways/priority.rb +6 -5
  125. data/lib/active_merchant/billing/gateways/psigate.rb +6 -2
  126. data/lib/active_merchant/billing/gateways/psl_card.rb +6 -2
  127. data/lib/active_merchant/billing/gateways/qbms.rb +6 -2
  128. data/lib/active_merchant/billing/gateways/quantum.rb +6 -2
  129. data/lib/active_merchant/billing/gateways/quickbooks.rb +6 -5
  130. data/lib/active_merchant/billing/gateways/quickpay/quickpay_v10.rb +7 -4
  131. data/lib/active_merchant/billing/gateways/quickpay/quickpay_v4to7.rb +6 -2
  132. data/lib/active_merchant/billing/gateways/rapyd.rb +148 -46
  133. data/lib/active_merchant/billing/gateways/reach.rb +11 -4
  134. data/lib/active_merchant/billing/gateways/redsys.rb +2 -10
  135. data/lib/active_merchant/billing/gateways/redsys_rest.rb +507 -0
  136. data/lib/active_merchant/billing/gateways/s5.rb +3 -3
  137. data/lib/active_merchant/billing/gateways/safe_charge.rb +38 -17
  138. data/lib/active_merchant/billing/gateways/sage.rb +12 -4
  139. data/lib/active_merchant/billing/gateways/sage_pay.rb +79 -5
  140. data/lib/active_merchant/billing/gateways/sallie_mae.rb +6 -2
  141. data/lib/active_merchant/billing/gateways/secure_net.rb +6 -2
  142. data/lib/active_merchant/billing/gateways/secure_pay.rb +8 -6
  143. data/lib/active_merchant/billing/gateways/secure_pay_au.rb +12 -4
  144. data/lib/active_merchant/billing/gateways/secure_pay_tech.rb +6 -2
  145. data/lib/active_merchant/billing/gateways/securion_pay.rb +24 -10
  146. data/lib/active_merchant/billing/gateways/shift4.rb +17 -20
  147. data/lib/active_merchant/billing/gateways/shift4_v2.rb +117 -0
  148. data/lib/active_merchant/billing/gateways/simetrik.rb +17 -11
  149. data/lib/active_merchant/billing/gateways/skip_jack.rb +6 -2
  150. data/lib/active_merchant/billing/gateways/smart_ps.rb +7 -4
  151. data/lib/active_merchant/billing/gateways/so_easy_pay.rb +4 -2
  152. data/lib/active_merchant/billing/gateways/spreedly_core.rb +2 -4
  153. data/lib/active_merchant/billing/gateways/stripe.rb +63 -19
  154. data/lib/active_merchant/billing/gateways/stripe_payment_intents.rb +280 -88
  155. data/lib/active_merchant/billing/gateways/sum_up.rb +223 -0
  156. data/lib/active_merchant/billing/gateways/swipe_checkout.rb +4 -2
  157. data/lib/active_merchant/billing/gateways/telr.rb +3 -4
  158. data/lib/active_merchant/billing/gateways/trans_first.rb +1 -2
  159. data/lib/active_merchant/billing/gateways/trans_first_transaction_express.rb +8 -16
  160. data/lib/active_merchant/billing/gateways/transact_pro.rb +1 -1
  161. data/lib/active_merchant/billing/gateways/trust_commerce.rb +6 -2
  162. data/lib/active_merchant/billing/gateways/usa_epay_advanced.rb +9 -8
  163. data/lib/active_merchant/billing/gateways/usa_epay_transaction.rb +6 -2
  164. data/lib/active_merchant/billing/gateways/vanco.rb +2 -4
  165. data/lib/active_merchant/billing/gateways/vantiv_express.rb +587 -0
  166. data/lib/active_merchant/billing/gateways/verifi.rb +6 -2
  167. data/lib/active_merchant/billing/gateways/viaklix.rb +6 -2
  168. data/lib/active_merchant/billing/gateways/visanet_peru.rb +2 -2
  169. data/lib/active_merchant/billing/gateways/vpos.rb +4 -4
  170. data/lib/active_merchant/billing/gateways/wirecard.rb +7 -3
  171. data/lib/active_merchant/billing/gateways/wompi.rb +5 -0
  172. data/lib/active_merchant/billing/gateways/worldpay.rb +141 -93
  173. data/lib/active_merchant/billing/gateways/worldpay_online_payments.rb +13 -10
  174. data/lib/active_merchant/billing/gateways/xpay.rb +242 -0
  175. data/lib/active_merchant/billing/network_tokenization_credit_card.rb +1 -1
  176. data/lib/active_merchant/billing/response.rb +2 -2
  177. data/lib/active_merchant/connection.rb +3 -17
  178. data/lib/active_merchant/country.rb +1 -0
  179. data/lib/active_merchant/errors.rb +10 -0
  180. data/lib/active_merchant/version.rb +1 -1
  181. data/lib/support/gateway_support.rb +2 -2
  182. data/lib/support/ssl_verify.rb +4 -4
  183. data/lib/support/ssl_version.rb +6 -6
  184. metadata +30 -9
@@ -33,6 +33,15 @@ module ActiveMerchant #:nodoc:
33
33
  discover: 'pb',
34
34
  diners_club: 'pb'
35
35
  }.freeze
36
+ THREEDS_EXEMPTIONS = {
37
+ authentication_outage: 'authenticationOutageExemptionIndicator',
38
+ corporate_card: 'secureCorporatePaymentIndicator',
39
+ delegated_authentication: 'delegatedAuthenticationExemptionIndicator',
40
+ low_risk: 'riskAnalysisExemptionIndicator',
41
+ low_value: 'lowValueExemptionIndicator',
42
+ stored_credential: 'stored_credential',
43
+ trusted_merchant: 'trustedMerchantExemptionIndicator'
44
+ }
36
45
  DEFAULT_COLLECTION_INDICATOR = 2
37
46
 
38
47
  self.supported_cardtypes = %i[visa master american_express discover diners_club jcb dankort maestro elo]
@@ -53,7 +62,8 @@ module ActiveMerchant #:nodoc:
53
62
  jcb: '007',
54
63
  dankort: '034',
55
64
  maestro: '042',
56
- elo: '054'
65
+ elo: '054',
66
+ carnet: '058'
57
67
  }
58
68
 
59
69
  @@decision_codes = {
@@ -132,6 +142,16 @@ module ActiveMerchant #:nodoc:
132
142
  r703: 'Export hostname_country/ip_country match'
133
143
  }
134
144
 
145
+ @@wallet_payment_solution = {
146
+ apple_pay: '001',
147
+ google_pay: '012'
148
+ }
149
+
150
+ NT_PAYMENT_SOLUTION = {
151
+ 'master' => '014',
152
+ 'visa' => '015'
153
+ }
154
+
135
155
  # These are the options that can be used when creating a new CyberSource
136
156
  # Gateway object.
137
157
  #
@@ -156,9 +176,15 @@ module ActiveMerchant #:nodoc:
156
176
  super
157
177
  end
158
178
 
159
- def authorize(money, creditcard_or_reference, options = {})
160
- setup_address_hash(options)
161
- commit(build_auth_request(money, creditcard_or_reference, options), :authorize, money, options)
179
+ def authorize(money, payment_method, options = {})
180
+ if valid_payment_method?(payment_method)
181
+ setup_address_hash(options)
182
+ commit(build_auth_request(money, payment_method, options), :authorize, money, options)
183
+ else
184
+ # this is for NetworkToken, ApplePay or GooglePay brands that aren't supported at CyberSource
185
+ payment_type = payment_method.source.to_s.gsub('_', ' ').titleize.gsub(' ', '')
186
+ Response.new(false, "#{card_brand(payment_method).capitalize} is not supported by #{payment_type} at CyberSource, check https://developer.cybersource.com/docs/cybs/en-us/payments/developer/all/rest/payments/CreatingOnlineAuth/CreatingAuthReqPNT.html")
187
+ end
162
188
  end
163
189
 
164
190
  def capture(money, authorization, options = {})
@@ -166,9 +192,15 @@ module ActiveMerchant #:nodoc:
166
192
  commit(build_capture_request(money, authorization, options), :capture, money, options)
167
193
  end
168
194
 
169
- def purchase(money, payment_method_or_reference, options = {})
170
- setup_address_hash(options)
171
- commit(build_purchase_request(money, payment_method_or_reference, options), :purchase, money, options)
195
+ def purchase(money, payment_method, options = {})
196
+ if valid_payment_method?(payment_method)
197
+ setup_address_hash(options)
198
+ commit(build_purchase_request(money, payment_method, options), :purchase, money, options)
199
+ else
200
+ # this is for NetworkToken, ApplePay or GooglePay brands that aren't supported at CyberSource
201
+ payment_type = payment_method.source.to_s.gsub('_', ' ').titleize.gsub(' ', '')
202
+ Response.new(false, "#{card_brand(payment_method).capitalize} is not supported by #{payment_type} at CyberSource, check https://developer.cybersource.com/docs/cybs/en-us/payments/developer/all/rest/payments/CreatingOnlineAuth/CreatingAuthReqPNT.html")
203
+ end
172
204
  end
173
205
 
174
206
  def void(identification, options = {})
@@ -201,8 +233,14 @@ module ActiveMerchant #:nodoc:
201
233
  # To charge the card while creating a profile, pass
202
234
  # options[:setup_fee] => money
203
235
  def store(payment_method, options = {})
204
- setup_address_hash(options)
205
- commit(build_create_subscription_request(payment_method, options), :store, nil, options)
236
+ if valid_payment_method?(payment_method)
237
+ setup_address_hash(options)
238
+ commit(build_create_subscription_request(payment_method, options), :store, nil, options)
239
+ else
240
+ # this is for NetworkToken, ApplePay or GooglePay brands that aren't supported at CyberSource
241
+ payment_type = payment_method.source.to_s.gsub('_', ' ').titleize.gsub(' ', '')
242
+ Response.new(false, "#{card_brand(payment_method).capitalize} is not supported by #{payment_type} at CyberSource, check https://developer.cybersource.com/docs/cybs/en-us/payments/developer/all/rest/payments/CreatingOnlineAuth/CreatingAuthReqPNT.html")
243
+ end
206
244
  end
207
245
 
208
246
  # Updates a customer subscription/profile
@@ -267,6 +305,8 @@ module ActiveMerchant #:nodoc:
267
305
  gsub(%r((<cvNumber>)[^<]*(</cvNumber>))i, '\1[FILTERED]\2').
268
306
  gsub(%r((<cavv>)[^<]*(</cavv>))i, '\1[FILTERED]\2').
269
307
  gsub(%r((<xid>)[^<]*(</xid>))i, '\1[FILTERED]\2').
308
+ gsub(%r((<networkTokenCryptogram>)[^<]*(</networkTokenCryptogram>))i, '\1[FILTERED]\2').
309
+ gsub(%r((<requestorID>)[^<]*(</requestorID>))i, '\1[FILTERED]\2').
270
310
  gsub(%r((<authenticationData>)[^<]*(</authenticationData>))i, '\1[FILTERED]\2')
271
311
  end
272
312
 
@@ -281,6 +321,12 @@ module ActiveMerchant #:nodoc:
281
321
 
282
322
  private
283
323
 
324
+ def valid_payment_method?(payment_method)
325
+ return true unless payment_method.is_a?(NetworkTokenizationCreditCard)
326
+
327
+ %w(visa master american_express).include?(card_brand(payment_method))
328
+ end
329
+
284
330
  # Create all required address hash key value pairs
285
331
  # If a value of nil is received, that value will be passed on to the gateway and will not be replaced with a default value
286
332
  # Billing address fields received without an override value or with an empty string value will be replaced with the default_address values
@@ -312,16 +358,19 @@ module ActiveMerchant #:nodoc:
312
358
  xml = Builder::XmlMarkup.new indent: 2
313
359
  add_customer_id(xml, options)
314
360
  add_payment_method_or_subscription(xml, money, creditcard_or_reference, options)
315
- add_other_tax(xml, options)
316
361
  add_threeds_2_ucaf_data(xml, creditcard_or_reference, options)
362
+ add_mastercard_network_tokenization_ucaf_data(xml, creditcard_or_reference, options)
317
363
  add_decision_manager_fields(xml, options)
364
+ add_other_tax(xml, options)
318
365
  add_mdd_fields(xml, options)
319
366
  add_auth_service(xml, creditcard_or_reference, options)
367
+ add_capture_service_fields_with_run_false(xml, options)
320
368
  add_threeds_services(xml, options)
321
369
  add_business_rules_data(xml, creditcard_or_reference, options)
322
370
  add_airline_data(xml, options)
323
371
  add_sales_slip_number(xml, options)
324
- add_payment_network_token(xml) if network_tokenization?(creditcard_or_reference)
372
+ add_payment_network_token(xml, creditcard_or_reference, options)
373
+ add_payment_solution(xml, creditcard_or_reference)
325
374
  add_tax_management_indicator(xml, options)
326
375
  add_stored_credential_subsequent_auth(xml, options)
327
376
  add_issuer_additional_data(xml, options)
@@ -374,9 +423,10 @@ module ActiveMerchant #:nodoc:
374
423
  xml = Builder::XmlMarkup.new indent: 2
375
424
  add_customer_id(xml, options)
376
425
  add_payment_method_or_subscription(xml, money, payment_method_or_reference, options)
377
- add_other_tax(xml, options)
378
426
  add_threeds_2_ucaf_data(xml, payment_method_or_reference, options)
427
+ add_mastercard_network_tokenization_ucaf_data(xml, payment_method_or_reference, options)
379
428
  add_decision_manager_fields(xml, options)
429
+ add_other_tax(xml, options)
380
430
  add_mdd_fields(xml, options)
381
431
  if (!payment_method_or_reference.is_a?(String) && card_brand(payment_method_or_reference) == 'check') || reference_is_a_check?(payment_method_or_reference)
382
432
  add_check_service(xml)
@@ -392,7 +442,8 @@ module ActiveMerchant #:nodoc:
392
442
  add_business_rules_data(xml, payment_method_or_reference, options)
393
443
  add_airline_data(xml, options)
394
444
  add_sales_slip_number(xml, options)
395
- add_payment_network_token(xml) if network_tokenization?(payment_method_or_reference)
445
+ add_payment_network_token(xml, payment_method_or_reference, options)
446
+ add_payment_solution(xml, payment_method_or_reference)
396
447
  add_tax_management_indicator(xml, options)
397
448
  add_stored_credential_subsequent_auth(xml, options)
398
449
  add_issuer_additional_data(xml, options)
@@ -480,7 +531,7 @@ module ActiveMerchant #:nodoc:
480
531
  add_check_service(xml)
481
532
  else
482
533
  add_purchase_service(xml, payment_method, options)
483
- add_payment_network_token(xml) if network_tokenization?(payment_method)
534
+ add_payment_network_token(xml, payment_method, options)
484
535
  end
485
536
  end
486
537
  add_subscription_create_service(xml, options)
@@ -549,7 +600,7 @@ module ActiveMerchant #:nodoc:
549
600
  end
550
601
 
551
602
  def add_merchant_data(xml, options)
552
- xml.tag! 'merchantID', @options[:login]
603
+ xml.tag! 'merchantID', options[:merchant_id] || @options[:login]
553
604
  xml.tag! 'merchantReferenceCode', options[:order_id] || generate_unique_id
554
605
  xml.tag! 'clientLibrary', 'Ruby Active Merchant'
555
606
  xml.tag! 'clientLibraryVersion', VERSION
@@ -559,12 +610,24 @@ module ActiveMerchant #:nodoc:
559
610
  end
560
611
 
561
612
  def add_merchant_descriptor(xml, options)
562
- return unless options[:merchant_descriptor] || options[:user_po] || options[:taxable] || options[:reference_data_code] || options[:invoice_number]
613
+ return unless options[:merchant_descriptor] ||
614
+ options[:user_po] ||
615
+ options[:taxable] ||
616
+ options[:reference_data_code] ||
617
+ options[:invoice_number] ||
618
+ options[:merchant_descriptor_city] ||
619
+ options[:submerchant_id] ||
620
+ options[:merchant_descriptor_state] ||
621
+ options[:merchant_descriptor_country]
563
622
 
564
623
  xml.tag! 'invoiceHeader' do
565
624
  xml.tag! 'merchantDescriptor', options[:merchant_descriptor] if options[:merchant_descriptor]
625
+ xml.tag! 'merchantDescriptorCity', options[:merchant_descriptor_city] if options[:merchant_descriptor_city]
626
+ xml.tag! 'merchantDescriptorState', options[:merchant_descriptor_state] if options[:merchant_descriptor_state]
627
+ xml.tag! 'merchantDescriptorCountry', options[:merchant_descriptor_country] if options[:merchant_descriptor_country]
566
628
  xml.tag! 'userPO', options[:user_po] if options[:user_po]
567
629
  xml.tag! 'taxable', options[:taxable] if options[:taxable]
630
+ xml.tag! 'submerchantID', options[:submerchant_id] if options[:submerchant_id]
568
631
  xml.tag! 'referenceDataCode', options[:reference_data_code] if options[:reference_data_code]
569
632
  xml.tag! 'invoiceNumber', options[:invoice_number] if options[:invoice_number]
570
633
  end
@@ -670,6 +733,18 @@ module ActiveMerchant #:nodoc:
670
733
  end
671
734
  end
672
735
 
736
+ def add_payment_solution(xml, payment_method)
737
+ return unless network_tokenization?(payment_method)
738
+
739
+ case payment_method.source
740
+ when :network_token
741
+ payment_solution = NT_PAYMENT_SOLUTION[payment_method.brand]
742
+ xml.tag! 'paymentSolution', payment_solution if payment_solution
743
+ when :apple_pay, :google_pay
744
+ xml.tag! 'paymentSolution', @@wallet_payment_solution[payment_method.source]
745
+ end
746
+ end
747
+
673
748
  def add_issuer_additional_data(xml, options)
674
749
  return unless options[:issuer_additional_data]
675
750
 
@@ -679,7 +754,7 @@ module ActiveMerchant #:nodoc:
679
754
  end
680
755
 
681
756
  def add_other_tax(xml, options)
682
- return unless options[:local_tax_amount] || options[:national_tax_amount] || options[:national_tax_indicator]
757
+ return unless %i[vat_tax_rate local_tax_amount national_tax_amount national_tax_indicator].any? { |gsf| options.include?(gsf) }
683
758
 
684
759
  xml.tag! 'otherTax' do
685
760
  xml.tag! 'vatTaxRate', options[:vat_tax_rate] if options[:vat_tax_rate]
@@ -718,21 +793,39 @@ module ActiveMerchant #:nodoc:
718
793
 
719
794
  def add_auth_service(xml, payment_method, options)
720
795
  if network_tokenization?(payment_method)
721
- add_auth_network_tokenization(xml, payment_method, options)
796
+ if payment_method.source == :network_token
797
+ add_auth_network_tokenization(xml, payment_method, options)
798
+ else
799
+ add_auth_wallet(xml, payment_method, options)
800
+ end
722
801
  else
723
802
  xml.tag! 'ccAuthService', { 'run' => 'true' } do
724
803
  if options[:three_d_secure]
725
804
  add_normalized_threeds_2_data(xml, payment_method, options)
805
+ add_threeds_exemption_data(xml, options) if options[:three_ds_exemption_type]
726
806
  else
727
807
  indicator = options[:commerce_indicator] || stored_credential_commerce_indicator(options)
728
808
  xml.tag!('commerceIndicator', indicator) if indicator
729
809
  end
810
+ xml.tag!('aggregatorID', options[:aggregator_id]) if options[:aggregator_id]
730
811
  xml.tag!('reconciliationID', options[:reconciliation_id]) if options[:reconciliation_id]
812
+ xml.tag!('firstRecurringPayment', options[:first_recurring_payment]) if options[:first_recurring_payment]
731
813
  xml.tag!('mobileRemotePaymentType', options[:mobile_remote_payment_type]) if options[:mobile_remote_payment_type]
732
814
  end
733
815
  end
734
816
  end
735
817
 
818
+ def add_threeds_exemption_data(xml, options)
819
+ return unless options[:three_ds_exemption_type]
820
+
821
+ exemption = options[:three_ds_exemption_type].to_sym
822
+
823
+ case exemption
824
+ when :authentication_outage, :corporate_card, :delegated_authentication, :low_risk, :low_value, :trusted_merchant
825
+ xml.tag!(THREEDS_EXEMPTIONS[exemption], '1')
826
+ end
827
+ end
828
+
736
829
  def add_incremental_auth_service(xml, authorization, options)
737
830
  xml.tag! 'ccIncrementalAuthService', { 'run' => 'true' } do
738
831
  xml.tag! 'authRequestID', authorization
@@ -780,13 +873,15 @@ module ActiveMerchant #:nodoc:
780
873
  end
781
874
 
782
875
  def stored_credential_commerce_indicator(options)
783
- return unless options[:stored_credential]
876
+ return unless (reason_type = options.dig(:stored_credential, :reason_type))
784
877
 
785
- return if options[:stored_credential][:initial_transaction]
786
-
787
- case options[:stored_credential][:reason_type]
788
- when 'installment' then 'install'
789
- when 'recurring' then 'recurring'
878
+ case reason_type
879
+ when 'installment'
880
+ 'install'
881
+ when 'recurring'
882
+ 'recurring'
883
+ else
884
+ 'internet'
790
885
  end
791
886
  end
792
887
 
@@ -794,26 +889,38 @@ module ActiveMerchant #:nodoc:
794
889
  payment_method.is_a?(NetworkTokenizationCreditCard)
795
890
  end
796
891
 
892
+ def subsequent_nt_apple_pay_auth(source, options)
893
+ return unless options[:stored_credential] || options[:stored_credential_overrides]
894
+ return unless @@wallet_payment_solution[source]
895
+
896
+ options.dig(:stored_credential_overrides, :subsequent_auth) || options.dig(:stored_credential, :initiator) == 'merchant'
897
+ end
898
+
797
899
  def add_auth_network_tokenization(xml, payment_method, options)
798
- return unless network_tokenization?(payment_method)
900
+ commerce_indicator = stored_credential_commerce_indicator(options) || 'internet'
901
+ xml.tag! 'ccAuthService', { 'run' => 'true' } do
902
+ xml.tag!('networkTokenCryptogram', payment_method.payment_cryptogram)
903
+ xml.tag!('commerceIndicator', commerce_indicator)
904
+ xml.tag!('reconciliationID', options[:reconciliation_id]) if options[:reconciliation_id]
905
+ end
906
+ end
907
+
908
+ def add_auth_wallet(xml, payment_method, options)
909
+ commerce_indicator = 'internet' if subsequent_nt_apple_pay_auth(payment_method.source, options)
799
910
 
800
911
  brand = card_brand(payment_method).to_sym
801
912
 
802
913
  case brand
803
914
  when :visa
804
915
  xml.tag! 'ccAuthService', { 'run' => 'true' } do
805
- xml.tag!('cavv', payment_method.payment_cryptogram)
806
- xml.tag!('commerceIndicator', ECI_BRAND_MAPPING[brand])
807
- xml.tag!('xid', payment_method.payment_cryptogram)
916
+ xml.tag!('cavv', payment_method.payment_cryptogram) unless commerce_indicator
917
+ xml.commerceIndicator commerce_indicator.nil? ? ECI_BRAND_MAPPING[brand] : commerce_indicator
918
+ xml.tag!('xid', payment_method.payment_cryptogram) unless commerce_indicator
808
919
  xml.tag!('reconciliationID', options[:reconciliation_id]) if options[:reconciliation_id]
809
920
  end
810
921
  when :master
811
- xml.tag! 'ucaf' do
812
- xml.tag!('authenticationData', payment_method.payment_cryptogram)
813
- xml.tag!('collectionIndicator', DEFAULT_COLLECTION_INDICATOR)
814
- end
815
922
  xml.tag! 'ccAuthService', { 'run' => 'true' } do
816
- xml.tag!('commerceIndicator', ECI_BRAND_MAPPING[brand])
923
+ xml.commerceIndicator commerce_indicator.nil? ? ECI_BRAND_MAPPING[brand] : commerce_indicator
817
924
  xml.tag!('reconciliationID', options[:reconciliation_id]) if options[:reconciliation_id]
818
925
  end
819
926
  when :american_express
@@ -824,14 +931,28 @@ module ActiveMerchant #:nodoc:
824
931
  xml.tag!('xid', Base64.encode64(cryptogram[20...40])) if cryptogram.bytes.count > 20
825
932
  xml.tag!('reconciliationID', options[:reconciliation_id]) if options[:reconciliation_id]
826
933
  end
827
- else
828
- raise ArgumentError.new("Payment method #{brand} is not supported, check https://developer.cybersource.com/docs/cybs/en-us/payments/developer/all/rest/payments/CreatingOnlineAuth/CreatingAuthReqPNT.html")
829
934
  end
830
935
  end
831
936
 
832
- def add_payment_network_token(xml)
937
+ def add_mastercard_network_tokenization_ucaf_data(xml, payment_method, options)
938
+ return unless network_tokenization?(payment_method) && card_brand(payment_method).to_sym == :master
939
+ return if payment_method.source == :network_token
940
+
941
+ commerce_indicator = 'internet' if subsequent_nt_apple_pay_auth(payment_method.source, options)
942
+
943
+ xml.tag! 'ucaf' do
944
+ xml.tag!('authenticationData', payment_method.payment_cryptogram) unless commerce_indicator
945
+ xml.tag!('collectionIndicator', DEFAULT_COLLECTION_INDICATOR)
946
+ end
947
+ end
948
+
949
+ def add_payment_network_token(xml, payment_method, options)
950
+ return unless network_tokenization?(payment_method)
951
+
952
+ transaction_type = payment_method.source == :network_token ? '3' : '1'
833
953
  xml.tag! 'paymentNetworkToken' do
834
- xml.tag!('transactionType', '1')
954
+ xml.tag!('requestorID', options[:trid]) if transaction_type == '3' && options[:trid]
955
+ xml.tag!('transactionType', transaction_type)
835
956
  end
836
957
  end
837
958
 
@@ -844,10 +965,19 @@ module ActiveMerchant #:nodoc:
844
965
  end
845
966
  end
846
967
 
968
+ def add_capture_service_fields_with_run_false(xml, options)
969
+ return unless options[:gratuity_amount]
970
+
971
+ xml.tag! 'ccCaptureService', { 'run' => 'false' } do
972
+ xml.tag! 'gratuityAmount', options[:gratuity_amount]
973
+ end
974
+ end
975
+
847
976
  def add_purchase_service(xml, payment_method, options)
848
977
  add_auth_service(xml, payment_method, options)
849
978
  xml.tag! 'ccCaptureService', { 'run' => 'true' } do
850
979
  xml.tag!('reconciliationID', options[:reconciliation_id]) if options[:reconciliation_id]
980
+ xml.tag!('gratuityAmount', options[:gratuity_amount]) if options[:gratuity_amount]
851
981
  end
852
982
  end
853
983
 
@@ -990,9 +1120,9 @@ module ActiveMerchant #:nodoc:
990
1120
  def add_stored_credential_options(xml, options = {})
991
1121
  return unless options[:stored_credential] || options[:stored_credential_overrides]
992
1122
 
993
- stored_credential_subsequent_auth_first = 'true' if options.dig(:stored_credential, :initial_transaction)
1123
+ stored_credential_subsequent_auth_first = 'true' if cardholder_or_initiated_transaction?(options)
994
1124
  stored_credential_transaction_id = options.dig(:stored_credential, :network_transaction_id) if options.dig(:stored_credential, :initiator) == 'merchant'
995
- stored_credential_subsequent_auth_stored_cred = 'true' if options.dig(:stored_credential, :initiator) == 'cardholder' && !options.dig(:stored_credential, :initial_transaction) || options.dig(:stored_credential, :initiator) == 'merchant' && options.dig(:stored_credential, :reason_type) == 'unscheduled'
1125
+ stored_credential_subsequent_auth_stored_cred = 'true' if subsequent_cardholder_initiated_transaction?(options) || unscheduled_merchant_initiated_transaction?(options) || threeds_stored_credential_exemption?(options)
996
1126
 
997
1127
  override_subsequent_auth_first = options.dig(:stored_credential_overrides, :subsequent_auth_first)
998
1128
  override_subsequent_auth_transaction_id = options.dig(:stored_credential_overrides, :subsequent_auth_transaction_id)
@@ -1003,6 +1133,22 @@ module ActiveMerchant #:nodoc:
1003
1133
  xml.subsequentAuthStoredCredential override_subsequent_auth_stored_cred.nil? ? stored_credential_subsequent_auth_stored_cred : override_subsequent_auth_stored_cred
1004
1134
  end
1005
1135
 
1136
+ def cardholder_or_initiated_transaction?(options)
1137
+ options.dig(:stored_credential, :initiator) == 'cardholder' || options.dig(:stored_credential, :initial_transaction)
1138
+ end
1139
+
1140
+ def subsequent_cardholder_initiated_transaction?(options)
1141
+ options.dig(:stored_credential, :initiator) == 'cardholder' && !options.dig(:stored_credential, :initial_transaction)
1142
+ end
1143
+
1144
+ def unscheduled_merchant_initiated_transaction?(options)
1145
+ options.dig(:stored_credential, :initiator) == 'merchant' && options.dig(:stored_credential, :reason_type) == 'unscheduled'
1146
+ end
1147
+
1148
+ def threeds_stored_credential_exemption?(options)
1149
+ options[:three_ds_exemption_type] == THREEDS_EXEMPTIONS[:stored_credential]
1150
+ end
1151
+
1006
1152
  def add_partner_solution_id(xml)
1007
1153
  return unless application_id
1008
1154
 
@@ -1055,12 +1201,16 @@ module ActiveMerchant #:nodoc:
1055
1201
 
1056
1202
  message = auto_void?(authorization_from(response, action, amount, options), response, message, options)
1057
1203
 
1058
- Response.new(success, message, response,
1204
+ Response.new(
1205
+ success,
1206
+ message,
1207
+ response,
1059
1208
  test: test?,
1060
1209
  authorization: authorization,
1061
1210
  fraud_review: in_fraud_review?(response),
1062
1211
  avs_result: { code: response[:avsCode] },
1063
- cvv_result: response[:cvCode])
1212
+ cvv_result: response[:cvCode]
1213
+ )
1064
1214
  end
1065
1215
 
1066
1216
  def auto_void?(authorization, response, message, options = {})
@@ -1102,6 +1252,7 @@ module ActiveMerchant #:nodoc:
1102
1252
  parent += '_' + node.parent.attributes['id'] if node.parent.attributes['id']
1103
1253
  parent += '_'
1104
1254
  end
1255
+ reply[:reconciliationID2] = node.text if node.name == 'reconciliationID' && reply[:reconciliationID]
1105
1256
  reply["#{parent}#{node.name}".to_sym] ||= node.text
1106
1257
  end
1107
1258
  return reply