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
@@ -25,7 +25,7 @@ module ActiveMerchant #:nodoc:
25
25
  self.currencies_with_three_decimal_places = %w(BHD IQD JOD KWD LYD OMR TND)
26
26
 
27
27
  self.money_format = :cents
28
- self.supported_cardtypes = %i[visa master maestro]
28
+ self.supported_cardtypes = %i[visa master maestro american_express]
29
29
 
30
30
  RESPONSE_MESSAGES = {
31
31
  '00' => 'Approved or completed successfully',
@@ -117,15 +117,16 @@ module ActiveMerchant #:nodoc:
117
117
  '96' => 'System malfunction',
118
118
  'R0' => 'Stop Payment Order',
119
119
  'R1' => 'Revocation of Authorisation Order',
120
- 'R3' => 'Revocation of all Authorisations Order'
120
+ 'R3' => 'Revocation of all Authorisations Order',
121
+ '1A' => 'Strong Customer Authentication required'
121
122
  }
122
123
 
123
- def initialize(options={})
124
+ def initialize(options = {})
124
125
  requires!(options, :merchant_id, :cipher_key)
125
126
  super
126
127
  end
127
128
 
128
- def purchase(amount, payment_method, options={})
129
+ def purchase(amount, payment_method, options = {})
129
130
  post = {}
130
131
  add_invoice(post, amount, options)
131
132
  add_payment_method(post, payment_method)
@@ -141,7 +142,7 @@ module ActiveMerchant #:nodoc:
141
142
  commit(:purchase, post)
142
143
  end
143
144
 
144
- def authorize(amount, payment_method, options={})
145
+ def authorize(amount, payment_method, options = {})
145
146
  post = {}
146
147
  add_invoice(post, amount, options)
147
148
  add_payment_method(post, payment_method)
@@ -158,7 +159,7 @@ module ActiveMerchant #:nodoc:
158
159
  commit(:authorize, post)
159
160
  end
160
161
 
161
- def capture(amount, authorization, options={})
162
+ def capture(amount, authorization, options = {})
162
163
  post = {}
163
164
  add_invoice(post, amount, options)
164
165
  add_reference(post, authorization)
@@ -170,7 +171,7 @@ module ActiveMerchant #:nodoc:
170
171
  commit(:capture, post)
171
172
  end
172
173
 
173
- def void(authorization, options={})
174
+ def void(authorization, options = {})
174
175
  post = {}
175
176
  add_customer_data(post, options)
176
177
  reference_action = add_reference(post, authorization)
@@ -182,7 +183,7 @@ module ActiveMerchant #:nodoc:
182
183
  commit(:void, post, reference_action)
183
184
  end
184
185
 
185
- def refund(amount, authorization, options={})
186
+ def refund(amount, authorization, options = {})
186
187
  post = {}
187
188
  add_invoice(post, amount, options)
188
189
  add_reference(post, authorization)
@@ -193,13 +194,14 @@ module ActiveMerchant #:nodoc:
193
194
  add_email(post, options)
194
195
 
195
196
  if options[:referral_cft]
197
+ add_customer_name(post, options)
196
198
  commit(:referral_cft, post)
197
199
  else
198
200
  commit(:refund, post)
199
201
  end
200
202
  end
201
203
 
202
- def credit(amount, payment_method, options={})
204
+ def credit(amount, payment_method, options = {})
203
205
  post = {}
204
206
  add_invoice(post, amount, options)
205
207
  add_payment_method(post, payment_method)
@@ -213,7 +215,7 @@ module ActiveMerchant #:nodoc:
213
215
  commit(:credit, post)
214
216
  end
215
217
 
216
- def verify(credit_card, options={})
218
+ def verify(credit_card, options = {})
217
219
  MultiResponse.run(:use_first_response) do |r|
218
220
  r.process { authorize(100, credit_card, options) }
219
221
  r.process(:ignore_result) { void(r.authorization, options) }
@@ -317,13 +319,19 @@ module ActiveMerchant #:nodoc:
317
319
  post[:c3] = options[:email] || 'unspecified@example.com'
318
320
  end
319
321
 
322
+ def add_customer_name(post, options)
323
+ post[:j5] = options[:first_name] if options[:first_name]
324
+ post[:j13] = options[:last_name] if options[:last_name]
325
+ end
326
+
320
327
  def add_3d_secure(post, options)
321
- if options[:eci] && options[:xid]
328
+ if (options[:eci] && options[:xid]) || (options[:three_d_secure] && options[:three_d_secure][:version]&.start_with?('1'))
322
329
  add_3d_secure_1_data(post, options)
323
330
  elsif options[:execute_threed] && options[:three_ds_2]
324
331
  three_ds_2_options = options[:three_ds_2]
325
332
  browser_info = three_ds_2_options[:browser_info]
326
333
  post[:'3ds_initiate'] = options[:three_ds_initiate] || '01'
334
+ post[:f23] = options[:f23] if options[:f23]
327
335
  post[:'3ds_purchasedate'] = Time.now.utc.strftime('%Y%m%d%I%M%S')
328
336
  options.dig(:stored_credential, :initiator) == 'merchant' ? post[:'3ds_channel'] = '03' : post[:'3ds_channel'] = '02'
329
337
  post[:'3ds_redirect_url'] = three_ds_2_options[:notification_url]
@@ -351,8 +359,17 @@ module ActiveMerchant #:nodoc:
351
359
  end
352
360
 
353
361
  def add_3d_secure_1_data(post, options)
354
- post[:i8] = build_i8(options[:eci], options[:cavv], options[:xid])
355
- post[:'3ds_version'] = options[:three_ds_version].nil? || options[:three_ds_version] == '1' ? '1.0' : options[:three_ds_version]
362
+ if three_d_secure_options = options[:three_d_secure]
363
+ post[:i8] = build_i8(
364
+ three_d_secure_options[:eci],
365
+ three_d_secure_options[:cavv],
366
+ three_d_secure_options[:xid]
367
+ )
368
+ post[:'3ds_version'] = three_d_secure_options[:version]&.start_with?('1') ? '1.0' : three_d_secure_options[:version]
369
+ else
370
+ post[:i8] = build_i8(options[:eci], options[:cavv], options[:xid])
371
+ post[:'3ds_version'] = options[:three_ds_version].nil? || options[:three_ds_version]&.start_with?('1') ? '1.0' : options[:three_ds_version]
372
+ end
356
373
  end
357
374
 
358
375
  def add_normalized_3d_secure_2_data(post, options)
@@ -362,11 +379,11 @@ module ActiveMerchant #:nodoc:
362
379
  three_d_secure_options[:eci],
363
380
  three_d_secure_options[:cavv]
364
381
  )
365
- post[:'3ds_version'] = three_d_secure_options[:version] == '2' ? '2.0' : three_d_secure_options[:version]
382
+ post[:'3ds_version'] = three_d_secure_options[:version]&.start_with?('2') ? '2.0' : three_d_secure_options[:version]
366
383
  post[:'3ds_dstrxid'] = three_d_secure_options[:ds_transaction_id]
367
384
  end
368
385
 
369
- def build_i8(eci, cavv=nil, xid=nil)
386
+ def build_i8(eci, cavv = nil, xid = nil)
370
387
  "#{eci}:#{cavv || 'none'}:#{xid || 'none'}"
371
388
  end
372
389
 
@@ -26,12 +26,12 @@ module ActiveMerchant #:nodoc:
26
26
  'discover' => 'O'
27
27
  }
28
28
 
29
- def initialize(options={})
29
+ def initialize(options = {})
30
30
  requires!(options, :api_key, :company_number, :merchant_number)
31
31
  super
32
32
  end
33
33
 
34
- def purchase(money, payment, options={})
34
+ def purchase(money, payment, options = {})
35
35
  requires!(options, :order_id)
36
36
  post = {}
37
37
  add_terminal_number(post, options)
@@ -45,7 +45,7 @@ module ActiveMerchant #:nodoc:
45
45
  payment.is_a?(String) ? commit('purchaseWithToken', post) : commit('purchase', post)
46
46
  end
47
47
 
48
- def authorize(money, payment, options={})
48
+ def authorize(money, payment, options = {})
49
49
  requires!(options, :order_id)
50
50
  post = {}
51
51
  add_money(post, money)
@@ -59,7 +59,7 @@ module ActiveMerchant #:nodoc:
59
59
  payment.is_a?(String) ? commit('preAuthorizationWithToken', post) : commit('preAuthorization', post)
60
60
  end
61
61
 
62
- def capture(money, authorization, options={})
62
+ def capture(money, authorization, options = {})
63
63
  requires!(options, :order_id)
64
64
  post = {}
65
65
  add_invoice(post, money, options)
@@ -73,7 +73,7 @@ module ActiveMerchant #:nodoc:
73
73
  commit('completion', post)
74
74
  end
75
75
 
76
- def refund(money, authorization, options={})
76
+ def refund(money, authorization, options = {})
77
77
  requires!(options, :order_id)
78
78
  post = {}
79
79
  add_invoice(post, money, options)
@@ -86,7 +86,7 @@ module ActiveMerchant #:nodoc:
86
86
  commit('refundWithoutCard', post)
87
87
  end
88
88
 
89
- def credit(money, payment, options={})
89
+ def credit(money, payment, options = {})
90
90
  requires!(options, :order_id)
91
91
  post = {}
92
92
  add_terminal_number(post, options)
@@ -100,7 +100,7 @@ module ActiveMerchant #:nodoc:
100
100
  payment.is_a?(String) ? commit('refundWithToken', post) : commit('refund', post)
101
101
  end
102
102
 
103
- def void(authorization, options={})
103
+ def void(authorization, options = {})
104
104
  post = {}
105
105
  post[:InputType] = 'I'
106
106
  post[:LanguageCode] = 'E'
@@ -113,7 +113,7 @@ module ActiveMerchant #:nodoc:
113
113
  commit('void', post)
114
114
  end
115
115
 
116
- def verify(credit_card, options={})
116
+ def verify(credit_card, options = {})
117
117
  requires!(options, :order_id)
118
118
  post = {}
119
119
  add_terminal_number(post, options)
@@ -126,7 +126,7 @@ module ActiveMerchant #:nodoc:
126
126
  commit('verifyAccount', post)
127
127
  end
128
128
 
129
- def store(credit_card, options={})
129
+ def store(credit_card, options = {})
130
130
  requires!(options, :email)
131
131
  post = {
132
132
  LanguageCode: 'E',
@@ -228,7 +228,7 @@ module ActiveMerchant #:nodoc:
228
228
  r.process {
229
229
  split_auth = split_authorization(r.authorization)
230
230
  auth = (action.include?('recur') ? split_auth[4] : split_auth[0])
231
- action.include?('recur') ? commit_raw('recur/ack', {ID: auth}) : commit_raw('ack', {TransactionNumber: auth})
231
+ action.include?('recur') ? commit_raw('recur/ack', { ID: auth }) : commit_raw('ack', { TransactionNumber: auth })
232
232
  }
233
233
  end
234
234
  end
@@ -20,16 +20,16 @@ module ActiveMerchant #:nodoc:
20
20
  self.money_format = :dollars
21
21
  self.supported_cardtypes = %i[visa master diners_club american_express]
22
22
 
23
- def initialize(options={})
23
+ def initialize(options = {})
24
24
  requires!(options, :merchant_id, :terminal_id, :secret_key)
25
25
  super
26
26
  end
27
27
 
28
- def purchase(amount, payment_method, options={})
28
+ def purchase(amount, payment_method, options = {})
29
29
  authorize(amount, payment_method, options)
30
30
  end
31
31
 
32
- def authorize(amount, payment_method, options={})
32
+ def authorize(amount, payment_method, options = {})
33
33
  if payment_method.is_a?(String)
34
34
  action = :tokenpay
35
35
  else
@@ -45,7 +45,7 @@ module ActiveMerchant #:nodoc:
45
45
  commit(action, post)
46
46
  end
47
47
 
48
- def capture(amount, authorization, options={})
48
+ def capture(amount, authorization, options = {})
49
49
  action = :capture
50
50
  post = {}
51
51
  add_credentials(post)
@@ -56,7 +56,7 @@ module ActiveMerchant #:nodoc:
56
56
  commit(action, post)
57
57
  end
58
58
 
59
- def void(authorization, options={})
59
+ def void(authorization, options = {})
60
60
  action = :void
61
61
  post = {}
62
62
  add_credentials(post)
@@ -67,7 +67,7 @@ module ActiveMerchant #:nodoc:
67
67
  commit(action, post)
68
68
  end
69
69
 
70
- def refund(amount, authorization, options={})
70
+ def refund(amount, authorization, options = {})
71
71
  action = :refund
72
72
  post = {}
73
73
  add_credentials(post)
@@ -78,7 +78,7 @@ module ActiveMerchant #:nodoc:
78
78
  commit(action, post)
79
79
  end
80
80
 
81
- def verify(credit_card, options={})
81
+ def verify(credit_card, options = {})
82
82
  MultiResponse.run(:use_first_response) do |r|
83
83
  r.process { authorize(1000, credit_card, options) }
84
84
  r.process(:ignore_result) { void(r.authorization, options) }
@@ -90,7 +90,7 @@ module ActiveMerchant #:nodoc:
90
90
  response.message.include? 'Transaction not found'
91
91
  end
92
92
 
93
- def store(credit_card, options={})
93
+ def store(credit_card, options = {})
94
94
  action = :tokenize
95
95
  post = {}
96
96
  post[:partnerid] = options[:partner_id] if options[:partner_id]
@@ -103,7 +103,7 @@ module ActiveMerchant #:nodoc:
103
103
  commit(action, post)
104
104
  end
105
105
 
106
- def invalidate(authorization, options={})
106
+ def invalidate(authorization, options = {})
107
107
  action = :invalidate
108
108
  post = {}
109
109
  post[:partnerid] = options[:partner_id] if options[:partner_id]
@@ -205,7 +205,7 @@ module ActiveMerchant #:nodoc:
205
205
  refund: 'SingleCallGenericReverse',
206
206
  tokenize: 'SingleCallTokenServlet',
207
207
  invalidate: 'SingleCallInvalidateToken',
208
- tokenpay: 'SingleCallTokenTransaction',
208
+ tokenpay: 'SingleCallTokenTransaction'
209
209
  }
210
210
 
211
211
  def commit(action, params)
@@ -34,7 +34,7 @@ module ActiveMerchant #:nodoc:
34
34
  american_express: 'aesk',
35
35
  jcb: 'js',
36
36
  discover: 'pb',
37
- diners_club: 'pb',
37
+ diners_club: 'pb'
38
38
  }.freeze
39
39
  DEFAULT_COLLECTION_INDICATOR = 2
40
40
 
@@ -256,8 +256,9 @@ module ActiveMerchant #:nodoc:
256
256
 
257
257
  private
258
258
 
259
- # Create all address hash key value pairs so that we still function if we
260
- # were only provided with one or two of them or even none
259
+ # Create all required address hash key value pairs
260
+ # 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
261
+ # Billing address fields received without an override value or with an empty string value will be replaced with the default_address values
261
262
  def setup_address_hash(options)
262
263
  default_address = {
263
264
  address1: 'Unspecified',
@@ -266,10 +267,22 @@ module ActiveMerchant #:nodoc:
266
267
  zip: '00000',
267
268
  country: 'US'
268
269
  }
269
- options[:billing_address] = options[:billing_address] || options[:address] || default_address
270
+
271
+ submitted_address = options[:billing_address] || options[:address] || default_address
272
+ options[:billing_address] = default_address.merge(submitted_address.symbolize_keys) { |_k, default, submitted| check_billing_field_value(default, submitted) }
270
273
  options[:shipping_address] = options[:shipping_address] || {}
271
274
  end
272
275
 
276
+ def check_billing_field_value(default, submitted)
277
+ if submitted.nil?
278
+ nil
279
+ elsif submitted.blank?
280
+ default
281
+ else
282
+ submitted
283
+ end
284
+ end
285
+
273
286
  def build_auth_request(money, creditcard_or_reference, options)
274
287
  xml = Builder::XmlMarkup.new indent: 2
275
288
  add_payment_method_or_subscription(xml, money, creditcard_or_reference, options)
@@ -388,7 +401,7 @@ module ActiveMerchant #:nodoc:
388
401
  end
389
402
 
390
403
  def build_create_subscription_request(payment_method, options)
391
- default_subscription_params = {frequency: 'on-demand', amount: 0, automatic_renew: false}
404
+ default_subscription_params = { frequency: 'on-demand', amount: 0, automatic_renew: false }
392
405
  options[:subscription] = default_subscription_params.update(
393
406
  options[:subscription] || {}
394
407
  )
@@ -470,7 +483,7 @@ module ActiveMerchant #:nodoc:
470
483
 
471
484
  def add_line_item_data(xml, options)
472
485
  options[:line_items].each_with_index do |value, index|
473
- xml.tag! 'item', {'id' => index} do
486
+ xml.tag! 'item', { 'id' => index } do
474
487
  xml.tag! 'unitPrice', localized_amount(value[:declared_value].to_i, options[:currency] || default_currency)
475
488
  xml.tag! 'quantity', value[:quantity]
476
489
  xml.tag! 'productCode', value[:code] || 'shipping_only'
@@ -510,7 +523,7 @@ module ActiveMerchant #:nodoc:
510
523
  end
511
524
  end
512
525
 
513
- def add_purchase_data(xml, money = 0, include_grand_total = false, options={})
526
+ def add_purchase_data(xml, money = 0, include_grand_total = false, options = {})
514
527
  xml.tag! 'purchaseTotals' do
515
528
  xml.tag! 'currency', options[:currency] || currency(money)
516
529
  xml.tag!('grandTotalAmount', localized_amount(money.to_i, options[:currency] || default_currency)) if include_grand_total
@@ -518,9 +531,11 @@ module ActiveMerchant #:nodoc:
518
531
  end
519
532
 
520
533
  def add_address(xml, payment_method, address, options, shipTo = false)
534
+ first_name, last_name = address_names(address[:name], payment_method)
535
+
521
536
  xml.tag! shipTo ? 'shipTo' : 'billTo' do
522
- xml.tag! 'firstName', payment_method.first_name if payment_method
523
- xml.tag! 'lastName', payment_method.last_name if payment_method
537
+ xml.tag! 'firstName', first_name if first_name
538
+ xml.tag! 'lastName', last_name if last_name
524
539
  xml.tag! 'street1', address[:address1]
525
540
  xml.tag! 'street2', address[:address2] unless address[:address2].blank?
526
541
  xml.tag! 'city', address[:city]
@@ -537,6 +552,16 @@ module ActiveMerchant #:nodoc:
537
552
  end
538
553
  end
539
554
 
555
+ def address_names(address_name, payment_method)
556
+ names = split_names(address_name)
557
+ return names if names.any?(&:present?)
558
+
559
+ [
560
+ payment_method&.first_name,
561
+ payment_method&.last_name
562
+ ]
563
+ end
564
+
540
565
  def add_creditcard(xml, creditcard)
541
566
  xml.tag! 'card' do
542
567
  xml.tag! 'accountNumber', creditcard.number
@@ -574,7 +599,7 @@ module ActiveMerchant #:nodoc:
574
599
  end
575
600
 
576
601
  def add_mdd_fields(xml, options)
577
- return unless options.keys.any? { |key| key.to_s.start_with?('mdd_field') }
602
+ return unless options.keys.any? { |key| key.to_s.start_with?('mdd_field') && options[key] }
578
603
 
579
604
  xml.tag! 'merchantDefinedData' do
580
605
  (1..100).each do |each|
@@ -593,7 +618,7 @@ module ActiveMerchant #:nodoc:
593
618
  end
594
619
 
595
620
  def add_tax_service(xml)
596
- xml.tag! 'taxService', {'run' => 'true'} do
621
+ xml.tag! 'taxService', { 'run' => 'true' } do
597
622
  xml.tag!('nexus', @options[:nexus]) unless @options[:nexus].blank?
598
623
  xml.tag!('sellerRegistration', @options[:vat_reg_number]) unless @options[:vat_reg_number].blank?
599
624
  end
@@ -603,7 +628,7 @@ module ActiveMerchant #:nodoc:
603
628
  if network_tokenization?(payment_method)
604
629
  add_auth_network_tokenization(xml, payment_method, options)
605
630
  else
606
- xml.tag! 'ccAuthService', {'run' => 'true'} do
631
+ xml.tag! 'ccAuthService', { 'run' => 'true' } do
607
632
  if options[:three_d_secure]
608
633
  add_normalized_threeds_2_data(xml, payment_method, options)
609
634
  else
@@ -676,7 +701,7 @@ module ActiveMerchant #:nodoc:
676
701
 
677
702
  case brand
678
703
  when :visa
679
- xml.tag! 'ccAuthService', {'run' => 'true'} do
704
+ xml.tag! 'ccAuthService', { 'run' => 'true' } do
680
705
  xml.tag!('cavv', payment_method.payment_cryptogram)
681
706
  xml.tag!('commerceIndicator', ECI_BRAND_MAPPING[brand])
682
707
  xml.tag!('xid', payment_method.payment_cryptogram)
@@ -687,13 +712,13 @@ module ActiveMerchant #:nodoc:
687
712
  xml.tag!('authenticationData', payment_method.payment_cryptogram)
688
713
  xml.tag!('collectionIndicator', DEFAULT_COLLECTION_INDICATOR)
689
714
  end
690
- xml.tag! 'ccAuthService', {'run' => 'true'} do
715
+ xml.tag! 'ccAuthService', { 'run' => 'true' } do
691
716
  xml.tag!('commerceIndicator', ECI_BRAND_MAPPING[brand])
692
717
  xml.tag!('reconciliationID', options[:reconciliation_id]) if options[:reconciliation_id]
693
718
  end
694
719
  when :american_express
695
720
  cryptogram = Base64.decode64(payment_method.payment_cryptogram)
696
- xml.tag! 'ccAuthService', {'run' => 'true'} do
721
+ xml.tag! 'ccAuthService', { 'run' => 'true' } do
697
722
  xml.tag!('cavv', Base64.encode64(cryptogram[0...20]))
698
723
  xml.tag!('commerceIndicator', ECI_BRAND_MAPPING[brand])
699
724
  xml.tag!('xid', Base64.encode64(cryptogram[20...40]))
@@ -709,7 +734,7 @@ module ActiveMerchant #:nodoc:
709
734
  end
710
735
 
711
736
  def add_capture_service(xml, request_id, request_token)
712
- xml.tag! 'ccCaptureService', {'run' => 'true'} do
737
+ xml.tag! 'ccCaptureService', { 'run' => 'true' } do
713
738
  xml.tag! 'authRequestID', request_id
714
739
  xml.tag! 'authRequestToken', request_token
715
740
  xml.tag! 'reconciliationID', options[:reconciliation_id] if options[:reconciliation_id]
@@ -718,56 +743,56 @@ module ActiveMerchant #:nodoc:
718
743
 
719
744
  def add_purchase_service(xml, payment_method, options)
720
745
  if options[:pinless_debit_card]
721
- xml.tag! 'pinlessDebitService', {'run' => 'true'} do
746
+ xml.tag! 'pinlessDebitService', { 'run' => 'true' } do
722
747
  xml.tag!('reconciliationID', options[:reconciliation_id]) if options[:reconciliation_id]
723
748
  end
724
749
  else
725
750
  add_auth_service(xml, payment_method, options)
726
- xml.tag! 'ccCaptureService', {'run' => 'true'} do
751
+ xml.tag! 'ccCaptureService', { 'run' => 'true' } do
727
752
  xml.tag!('reconciliationID', options[:reconciliation_id]) if options[:reconciliation_id]
728
753
  end
729
754
  end
730
755
  end
731
756
 
732
757
  def add_void_service(xml, request_id, request_token)
733
- xml.tag! 'voidService', {'run' => 'true'} do
758
+ xml.tag! 'voidService', { 'run' => 'true' } do
734
759
  xml.tag! 'voidRequestID', request_id
735
760
  xml.tag! 'voidRequestToken', request_token
736
761
  end
737
762
  end
738
763
 
739
764
  def add_auth_reversal_service(xml, request_id, request_token)
740
- xml.tag! 'ccAuthReversalService', {'run' => 'true'} do
765
+ xml.tag! 'ccAuthReversalService', { 'run' => 'true' } do
741
766
  xml.tag! 'authRequestID', request_id
742
767
  xml.tag! 'authRequestToken', request_token
743
768
  end
744
769
  end
745
770
 
746
771
  def add_credit_service(xml, request_id = nil, request_token = nil)
747
- xml.tag! 'ccCreditService', {'run' => 'true'} do
772
+ xml.tag! 'ccCreditService', { 'run' => 'true' } do
748
773
  xml.tag! 'captureRequestID', request_id if request_id
749
774
  xml.tag! 'captureRequestToken', request_token if request_token
750
775
  end
751
776
  end
752
777
 
753
778
  def add_check_service(xml)
754
- xml.tag! 'ecDebitService', {'run' => 'true'}
779
+ xml.tag! 'ecDebitService', { 'run' => 'true' }
755
780
  end
756
781
 
757
782
  def add_subscription_create_service(xml, options)
758
- xml.tag! 'paySubscriptionCreateService', {'run' => 'true'}
783
+ xml.tag! 'paySubscriptionCreateService', { 'run' => 'true' }
759
784
  end
760
785
 
761
786
  def add_subscription_update_service(xml, options)
762
- xml.tag! 'paySubscriptionUpdateService', {'run' => 'true'}
787
+ xml.tag! 'paySubscriptionUpdateService', { 'run' => 'true' }
763
788
  end
764
789
 
765
790
  def add_subscription_delete_service(xml, options)
766
- xml.tag! 'paySubscriptionDeleteService', {'run' => 'true'}
791
+ xml.tag! 'paySubscriptionDeleteService', { 'run' => 'true' }
767
792
  end
768
793
 
769
794
  def add_subscription_retrieve_service(xml, options)
770
- xml.tag! 'paySubscriptionRetrieveService', {'run' => 'true'}
795
+ xml.tag! 'paySubscriptionRetrieveService', { 'run' => 'true' }
771
796
  end
772
797
 
773
798
  def add_subscription(xml, options, reference = nil)
@@ -832,13 +857,13 @@ module ActiveMerchant #:nodoc:
832
857
  end
833
858
 
834
859
  def add_validate_pinless_debit_service(xml)
835
- xml.tag! 'pinlessDebitValidateService', {'run' => 'true'}
860
+ xml.tag! 'pinlessDebitValidateService', { 'run' => 'true' }
836
861
  end
837
862
 
838
863
  def add_threeds_services(xml, options)
839
- xml.tag! 'payerAuthEnrollService', {'run' => 'true'} if options[:payer_auth_enroll_service]
864
+ xml.tag! 'payerAuthEnrollService', { 'run' => 'true' } if options[:payer_auth_enroll_service]
840
865
  if options[:payer_auth_validate_service]
841
- xml.tag! 'payerAuthValidateService', {'run' => 'true'} do
866
+ xml.tag! 'payerAuthValidateService', { 'run' => 'true' } do
842
867
  xml.tag! 'signedPARes', options[:pares]
843
868
  end
844
869
  end
@@ -849,7 +874,7 @@ module ActiveMerchant #:nodoc:
849
874
  country_code&.code(:alpha2)
850
875
  end
851
876
 
852
- def add_stored_credential_subsequent_auth(xml, options={})
877
+ def add_stored_credential_subsequent_auth(xml, options = {})
853
878
  return unless options[:stored_credential] || options[:stored_credential_overrides]
854
879
 
855
880
  stored_credential_subsequent_auth = 'true' if options.dig(:stored_credential, :initiator) == 'merchant'
@@ -859,7 +884,7 @@ module ActiveMerchant #:nodoc:
859
884
  xml.subsequentAuth override_subsequent_auth.nil? ? stored_credential_subsequent_auth : override_subsequent_auth
860
885
  end
861
886
 
862
- def add_stored_credential_options(xml, options={})
887
+ def add_stored_credential_options(xml, options = {})
863
888
  return unless options[:stored_credential] || options[:stored_credential_overrides]
864
889
 
865
890
  stored_credential_subsequent_auth_first = 'true' if options.dig(:stored_credential, :initial_transaction)
@@ -887,17 +912,17 @@ module ActiveMerchant #:nodoc:
887
912
 
888
913
  xml = Builder::XmlMarkup.new indent: 2
889
914
  xml.instruct!
890
- xml.tag! 's:Envelope', {'xmlns:s' => 'http://schemas.xmlsoap.org/soap/envelope/'} do
915
+ xml.tag! 's:Envelope', { 'xmlns:s' => 'http://schemas.xmlsoap.org/soap/envelope/' } do
891
916
  xml.tag! 's:Header' do
892
- xml.tag! 'wsse:Security', {'s:mustUnderstand' => '1', 'xmlns:wsse' => 'http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd'} do
917
+ xml.tag! 'wsse:Security', { 's:mustUnderstand' => '1', 'xmlns:wsse' => 'http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd' } do
893
918
  xml.tag! 'wsse:UsernameToken' do
894
919
  xml.tag! 'wsse:Username', @options[:login]
895
920
  xml.tag! 'wsse:Password', @options[:password], 'Type' => 'http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText'
896
921
  end
897
922
  end
898
923
  end
899
- xml.tag! 's:Body', {'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance', 'xmlns:xsd' => 'http://www.w3.org/2001/XMLSchema'} do
900
- xml.tag! 'requestMessage', {'xmlns' => "urn:schemas-cybersource-com:transaction-data-#{xsd_version}"} do
924
+ xml.tag! 's:Body', { 'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance', 'xmlns:xsd' => 'http://www.w3.org/2001/XMLSchema' } do
925
+ xml.tag! 'requestMessage', { 'xmlns' => "urn:schemas-cybersource-com:transaction-data-#{xsd_version}" } do
901
926
  add_merchant_data(xml, options)
902
927
  xml << body
903
928
  end
@@ -930,8 +955,7 @@ module ActiveMerchant #:nodoc:
930
955
  authorization: authorization,
931
956
  fraud_review: in_fraud_review?(response),
932
957
  avs_result: { code: response[:avsCode] },
933
- cvv_result: response[:cvCode]
934
- )
958
+ cvv_result: response[:cvCode])
935
959
  end
936
960
 
937
961
  # Parse the SOAP response