activemerchant 1.124.0 → 1.125.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG +85 -0
  3. data/lib/active_merchant/billing/check.rb +5 -8
  4. data/lib/active_merchant/billing/credit_card.rb +10 -0
  5. data/lib/active_merchant/billing/gateway.rb +1 -1
  6. data/lib/active_merchant/billing/gateways/cashnet.rb +15 -5
  7. data/lib/active_merchant/billing/gateways/checkout_v2.rb +33 -4
  8. data/lib/active_merchant/billing/gateways/cyber_source.rb +11 -3
  9. data/lib/active_merchant/billing/gateways/d_local.rb +4 -5
  10. data/lib/active_merchant/billing/gateways/decidir_plus.rb +173 -0
  11. data/lib/active_merchant/billing/gateways/ebanx.rb +16 -1
  12. data/lib/active_merchant/billing/gateways/elavon.rb +6 -3
  13. data/lib/active_merchant/billing/gateways/element.rb +20 -2
  14. data/lib/active_merchant/billing/gateways/global_collect.rb +106 -16
  15. data/lib/active_merchant/billing/gateways/ipg.rb +416 -0
  16. data/lib/active_merchant/billing/gateways/kushki.rb +7 -0
  17. data/lib/active_merchant/billing/gateways/mercado_pago.rb +3 -1
  18. data/lib/active_merchant/billing/gateways/mundipagg.rb +8 -6
  19. data/lib/active_merchant/billing/gateways/nmi.rb +2 -1
  20. data/lib/active_merchant/billing/gateways/orbital.rb +17 -2
  21. data/lib/active_merchant/billing/gateways/pay_trace.rb +1 -1
  22. data/lib/active_merchant/billing/gateways/payflow.rb +1 -1
  23. data/lib/active_merchant/billing/gateways/paymentez.rb +9 -2
  24. data/lib/active_merchant/billing/gateways/paysafe.rb +41 -5
  25. data/lib/active_merchant/billing/gateways/payu_latam.rb +6 -1
  26. data/lib/active_merchant/billing/gateways/payway_dot_com.rb +3 -3
  27. data/lib/active_merchant/billing/gateways/pin.rb +31 -4
  28. data/lib/active_merchant/billing/gateways/priority.rb +347 -0
  29. data/lib/active_merchant/billing/gateways/safe_charge.rb +1 -0
  30. data/lib/active_merchant/billing/gateways/stripe.rb +20 -10
  31. data/lib/active_merchant/billing/gateways/stripe_payment_intents.rb +37 -3
  32. data/lib/active_merchant/billing/gateways/usa_epay_transaction.rb +20 -6
  33. data/lib/active_merchant/billing/gateways/wompi.rb +193 -0
  34. data/lib/active_merchant/billing/gateways/worldpay.rb +181 -64
  35. data/lib/active_merchant/billing/network_tokenization_credit_card.rb +1 -1
  36. data/lib/active_merchant/version.rb +1 -1
  37. metadata +6 -2
@@ -8,13 +8,26 @@ module ActiveMerchant #:nodoc:
8
8
 
9
9
  self.default_currency = 'GBP'
10
10
  self.money_format = :cents
11
- self.supported_countries = %w(HK GB AU AD AR BE BR CA CH CN CO CR CY CZ DE DK ES FI FR GI GR HU IE IN IT JP LI LU MC MT MY MX NL NO NZ PA PE PL PT SE SG SI SM TR UM VA)
11
+ self.supported_countries = %w(AD AE AG AI AL AM AO AR AS AT AU AW AX AZ BA BB BD BE BF BG BH BI BJ BM BN BO BR BS BT BW
12
+ BY BZ CA CC CF CH CK CL CM CN CO CR CV CX CY CZ DE DJ DK DO DZ EC EE EG EH ES ET FI FJ FK
13
+ FM FO FR GA GB GD GE GF GG GH GI GL GM GN GP GQ GR GT GU GW GY HK HM HN HR HT HU ID IE IL
14
+ IM IN IO IS IT JE JM JO JP KE KG KH KI KM KN KR KW KY KZ LA LC LI LK LS LT LU LV MA MC MD
15
+ ME MG MH MK ML MN MO MP MQ MR MS MT MU MV MW MX MY MZ NA NC NE NF NG NI NL NO NP NR NU NZ
16
+ OM PA PE PF PH PK PL PN PR PT PW PY QA RE RO RS RU RW SA SB SC SE SG SI SK SL SM SN ST SV
17
+ SZ TC TD TF TG TH TJ TK TM TO TR TT TV TW TZ UA UG US UY UZ VA VC VE VI VN VU WF WS YE YT
18
+ ZA ZM)
12
19
  self.supported_cardtypes = %i[visa master american_express discover jcb maestro elo naranja cabal unionpay]
13
- self.currencies_without_fractions = %w(HUF IDR ISK JPY KRW)
14
- self.currencies_with_three_decimal_places = %w(BHD KWD OMR RSD TND)
20
+ self.currencies_without_fractions = %w(HUF IDR JPY KRW BEF XOF XAF XPF GRD GNF ITL LUF MGA MGF PYG PTE RWF ESP TRL VND KMF)
21
+ self.currencies_with_three_decimal_places = %w(BHD KWD OMR TND LYD JOD IQD)
15
22
  self.homepage_url = 'http://www.worldpay.com/'
16
23
  self.display_name = 'Worldpay Global'
17
24
 
25
+ NETWORK_TOKEN_TYPE = {
26
+ apple_pay: 'APPLEPAY',
27
+ google_pay: 'GOOGLEPAY',
28
+ network_token: 'NETWORKTOKEN'
29
+ }
30
+
18
31
  CARD_CODES = {
19
32
  'visa' => 'VISA-SSL',
20
33
  'master' => 'ECMC-SSL',
@@ -64,7 +77,7 @@ module ActiveMerchant #:nodoc:
64
77
 
65
78
  def authorize(money, payment_method, options = {})
66
79
  requires!(options, :order_id)
67
- payment_details = payment_details_from(payment_method)
80
+ payment_details = payment_details(payment_method)
68
81
  authorize_request(money, payment_method, payment_details.merge(options))
69
82
  end
70
83
 
@@ -110,8 +123,12 @@ module ActiveMerchant #:nodoc:
110
123
  # and other transactions should be performed on a normal eCom-flagged
111
124
  # merchant ID.
112
125
  def credit(money, payment_method, options = {})
113
- payment_details = payment_details_from(payment_method)
114
- credit_request(money, payment_method, payment_details.merge(credit: true, **options))
126
+ payment_details = payment_details(payment_method)
127
+ if options[:fast_fund_credit]
128
+ fast_fund_credit_request(money, payment_method, payment_details.merge(credit: true, **options))
129
+ else
130
+ credit_request(money, payment_method, payment_details.merge(credit: true, **options))
131
+ end
115
132
  end
116
133
 
117
134
  def verify(payment_method, options = {})
@@ -139,7 +156,9 @@ module ActiveMerchant #:nodoc:
139
156
  transcript.
140
157
  gsub(%r((Authorization: Basic )\w+), '\1[FILTERED]').
141
158
  gsub(%r((<cardNumber>)\d+(</cardNumber>)), '\1[FILTERED]\2').
142
- gsub(%r((<cvc>)[^<]+(</cvc>)), '\1[FILTERED]\2')
159
+ gsub(%r((<cvc>)[^<]+(</cvc>)), '\1[FILTERED]\2').
160
+ gsub(%r((<tokenNumber>)\d+(</tokenNumber>)), '\1[FILTERED]\2').
161
+ gsub(%r((<cryptogram>)[^<]+(</cryptogram>)), '\1[FILTERED]\2')
143
162
  end
144
163
 
145
164
  private
@@ -168,6 +187,10 @@ module ActiveMerchant #:nodoc:
168
187
  commit('credit', build_authorization_request(money, payment_method, options), :ok, 'SENT_FOR_REFUND', options)
169
188
  end
170
189
 
190
+ def fast_fund_credit_request(money, payment_method, options)
191
+ commit('fast_credit', build_fast_fund_credit_request(money, payment_method, options), :ok, 'PUSH_APPROVED', options)
192
+ end
193
+
171
194
  def store_request(credit_card, options)
172
195
  commit('store', build_store_request(credit_card, options), options)
173
196
  end
@@ -206,11 +229,7 @@ module ActiveMerchant #:nodoc:
206
229
  xml.order order_tag_attributes(options) do
207
230
  xml.description(options[:description].blank? ? 'Purchase' : options[:description])
208
231
  add_amount(xml, money, options)
209
- if options[:order_content]
210
- xml.orderContent do
211
- xml.cdata! options[:order_content]
212
- end
213
- end
232
+ add_order_content(xml, options)
214
233
  add_payment_method(xml, money, payment_method, options)
215
234
  add_shopper(xml, options)
216
235
  add_statement_narrative(xml, options)
@@ -227,7 +246,19 @@ module ActiveMerchant #:nodoc:
227
246
  end
228
247
 
229
248
  def order_tag_attributes(options)
230
- { 'orderCode' => options[:order_id], 'installationId' => options[:inst_id] || @options[:inst_id] }.reject { |_, v| !v.present? }
249
+ { 'orderCode' => clean_order_id(options[:order_id]), 'installationId' => options[:inst_id] || @options[:inst_id] }.reject { |_, v| !v.present? }
250
+ end
251
+
252
+ def clean_order_id(order_id)
253
+ order_id.to_s.gsub(/(\s|\||<|>|'|")/, '')[0..64]
254
+ end
255
+
256
+ def add_order_content(xml, options)
257
+ return unless options[:order_content]
258
+
259
+ xml.orderContent do
260
+ xml.cdata! options[:order_content]
261
+ end
231
262
  end
232
263
 
233
264
  def build_capture_request(money, authorization, options)
@@ -272,11 +303,69 @@ module ActiveMerchant #:nodoc:
272
303
  add_card(xml, credit_card, options)
273
304
  end
274
305
  end
306
+ add_transaction_identifier(xml, options) if network_transaction_id(options)
307
+ end
308
+ end
309
+ end
310
+ end
311
+
312
+ def network_transaction_id(options)
313
+ options[:stored_credential_transaction_id] || options.dig(:stored_credential, :network_transaction_id)
314
+ end
315
+
316
+ def add_transaction_identifier(xml, options)
317
+ xml.storedCredentials 'usage' => 'FIRST' do
318
+ xml.schemeTransactionIdentifier network_transaction_id(options)
319
+ end
320
+ end
321
+
322
+ def build_fast_fund_credit_request(money, payment_method, options)
323
+ build_request do |xml|
324
+ xml.submit do
325
+ xml.order order_tag_attributes(options) do
326
+ xml.description(options[:description].blank? ? 'Fast Fund Credit' : options[:description])
327
+ add_amount(xml, money, options)
328
+ add_order_content(xml, options)
329
+ add_payment_details_for_ff_credit(xml, payment_method, options)
330
+ add_shopper_id(xml, options)
331
+ end
332
+ end
333
+ end
334
+ end
335
+
336
+ def add_payment_details_for_ff_credit(xml, payment_method, options)
337
+ xml.paymentDetails do
338
+ xml.tag! 'FF_DISBURSE-SSL' do
339
+ if payment_method.is_a?(CreditCard)
340
+ add_card_for_ff_credit(xml, payment_method, options)
341
+ else
342
+ add_token_for_ff_credit(xml, payment_method, options)
275
343
  end
276
344
  end
277
345
  end
278
346
  end
279
347
 
348
+ def add_card_for_ff_credit(xml, payment_method, options)
349
+ xml.recipient do
350
+ xml.paymentInstrument do
351
+ xml.cardDetails do
352
+ add_card(xml, payment_method, options)
353
+ end
354
+ end
355
+ end
356
+ end
357
+
358
+ def add_token_for_ff_credit(xml, payment_method, options)
359
+ return unless payment_method.is_a?(String)
360
+
361
+ token_details = token_details_from_authorization(payment_method)
362
+
363
+ xml.tag! 'recipient', 'tokenScope' => token_details[:token_scope] do
364
+ xml.paymentTokenID token_details[:token_id]
365
+ add_authenticated_shopper_id(xml, token_details)
366
+ end
367
+ end
368
+
280
369
  def add_additional_3ds_data(xml, options)
281
370
  additional_data = { 'dfReferenceId' => options[:session_id] }
282
371
  additional_data['challengeWindowSize'] = options[:browser_size] if options[:browser_size]
@@ -403,46 +492,33 @@ module ActiveMerchant #:nodoc:
403
492
  end
404
493
 
405
494
  def add_payment_method(xml, amount, payment_method, options)
406
- if options[:payment_type] == :pay_as_order
407
- if options[:merchant_code]
408
- xml.payAsOrder 'orderCode' => payment_method, 'merchantCode' => options[:merchant_code] do
409
- add_amount(xml, amount, options)
410
- end
411
- else
412
- xml.payAsOrder 'orderCode' => payment_method do
413
- add_amount(xml, amount, options)
414
- end
415
- end
416
- elsif options[:payment_type] == :network_token
495
+ case options[:payment_type]
496
+ when :pay_as_order
497
+ add_amount_for_pay_as_order(xml, amount, payment_method, options)
498
+ when :network_token
417
499
  add_network_tokenization_card(xml, payment_method)
418
500
  else
419
- xml.paymentDetails credit_fund_transfer_attribute(options) do
420
- if options[:payment_type] == :token
421
- xml.tag! 'TOKEN-SSL', 'tokenScope' => options[:token_scope] do
422
- xml.paymentTokenID options[:token_id]
423
- end
424
- else
425
- xml.tag! card_code_for(payment_method) do
426
- add_card(xml, payment_method, options)
427
- end
428
- end
429
- add_stored_credential_options(xml, options)
430
- if options[:ip] && options[:session_id]
431
- xml.session 'shopperIPAddress' => options[:ip], 'id' => options[:session_id]
432
- else
433
- xml.session 'shopperIPAddress' => options[:ip] if options[:ip]
434
- xml.session 'id' => options[:session_id] if options[:session_id]
435
- end
436
- if three_d_secure = options[:three_d_secure]
437
- add_three_d_secure(three_d_secure, xml)
438
- end
501
+ add_card_or_token(xml, payment_method, options)
502
+ end
503
+ end
504
+
505
+ def add_amount_for_pay_as_order(xml, amount, payment_method, options)
506
+ if options[:merchant_code]
507
+ xml.payAsOrder 'orderCode' => payment_method, 'merchantCode' => options[:merchant_code] do
508
+ add_amount(xml, amount, options)
509
+ end
510
+ else
511
+ xml.payAsOrder 'orderCode' => payment_method do
512
+ add_amount(xml, amount, options)
439
513
  end
440
514
  end
441
515
  end
442
516
 
443
517
  def add_network_tokenization_card(xml, payment_method)
518
+ token_type = NETWORK_TOKEN_TYPE.fetch(payment_method.source, 'NETWORKTOKEN')
519
+
444
520
  xml.paymentDetails do
445
- xml.tag! 'EMVCO_TOKEN-SSL', 'type' => 'NETWORKTOKEN' do
521
+ xml.tag! 'EMVCO_TOKEN-SSL', 'type' => token_type do
446
522
  xml.tokenNumber payment_method.number
447
523
  xml.expiryDate do
448
524
  xml.date(
@@ -450,13 +526,52 @@ module ActiveMerchant #:nodoc:
450
526
  'year' => format(payment_method.year, :four_digits_year)
451
527
  )
452
528
  end
529
+ name = card_holder_name(payment_method, options)
530
+ eci = format(payment_method.eci, :two_digits)
531
+ xml.cardHolderName name if name.present?
453
532
  xml.cryptogram payment_method.payment_cryptogram
454
- xml.eciIndicator format(payment_method.eci, :two_digits)
533
+ xml.eciIndicator eci.empty? ? '07' : eci
455
534
  end
456
535
  end
457
536
  end
458
537
 
459
- def add_three_d_secure(three_d_secure, xml)
538
+ def add_card_or_token(xml, payment_method, options)
539
+ xml.paymentDetails credit_fund_transfer_attribute(options) do
540
+ if options[:payment_type] == :token
541
+ add_token_details(xml, options)
542
+ else
543
+ add_card_details(xml, payment_method, options)
544
+ end
545
+ add_stored_credential_options(xml, options)
546
+ add_shopper_id(xml, options)
547
+ add_three_d_secure(xml, options)
548
+ end
549
+ end
550
+
551
+ def add_token_details(xml, options)
552
+ xml.tag! 'TOKEN-SSL', 'tokenScope' => options[:token_scope] do
553
+ xml.paymentTokenID options[:token_id]
554
+ end
555
+ end
556
+
557
+ def add_card_details(xml, payment_method, options)
558
+ xml.tag! card_code_for(payment_method) do
559
+ add_card(xml, payment_method, options)
560
+ end
561
+ end
562
+
563
+ def add_shopper_id(xml, options)
564
+ if options[:ip] && options[:session_id]
565
+ xml.session 'shopperIPAddress' => options[:ip], 'id' => options[:session_id]
566
+ else
567
+ xml.session 'shopperIPAddress' => options[:ip] if options[:ip]
568
+ xml.session 'id' => options[:session_id] if options[:session_id]
569
+ end
570
+ end
571
+
572
+ def add_three_d_secure(xml, options)
573
+ return unless three_d_secure = options[:three_d_secure]
574
+
460
575
  xml.info3DSecure do
461
576
  xml.threeDSVersion three_d_secure[:version]
462
577
  if three_d_secure[:version] && three_d_secure[:ds_transaction_id]
@@ -477,9 +592,7 @@ module ActiveMerchant #:nodoc:
477
592
  'year' => format(payment_method.year, :four_digits_year)
478
593
  )
479
594
  end
480
-
481
- card_holder_name = test? && options[:execute_threed] && !options[:three_ds_version]&.start_with?('2') ? '3D' : payment_method.name
482
- xml.cardHolderName card_holder_name
595
+ xml.cardHolderName card_holder_name(payment_method, options)
483
596
  xml.cvc payment_method.verification_value
484
597
 
485
598
  add_address(xml, (options[:billing_address] || options[:address]), options)
@@ -641,6 +754,7 @@ module ActiveMerchant #:nodoc:
641
754
  def commit(action, request, *success_criteria, options)
642
755
  xml = ssl_post(url, request, headers(options))
643
756
  raw = parse(action, xml)
757
+
644
758
  if options[:execute_threed]
645
759
  raw[:cookie] = @cookie if defined?(@cookie)
646
760
  raw[:session_id] = options[:session_id]
@@ -769,23 +883,22 @@ module ActiveMerchant #:nodoc:
769
883
  token_details
770
884
  end
771
885
 
772
- def payment_details_from(payment_method)
773
- payment_details = {}
774
- if payment_method.is_a?(NetworkTokenizationCreditCard) && payment_method.source == :network_token
775
- payment_details[:payment_type] = :network_token
776
- elsif payment_method.respond_to?(:number)
777
- payment_details[:payment_type] = :credit
886
+ def payment_details(payment_method)
887
+ case payment_method
888
+ when String
889
+ token_type_and_details(payment_method)
890
+ when NetworkTokenizationCreditCard
891
+ { payment_type: :network_token }
778
892
  else
779
- token_details = token_details_from_authorization(payment_method)
780
- payment_details.merge!(token_details)
781
- if token_details.has_key?(:token_id)
782
- payment_details[:payment_type] = :token
783
- else
784
- payment_details[:payment_type] = :pay_as_order
785
- end
893
+ { payment_type: :credit }
786
894
  end
895
+ end
896
+
897
+ def token_type_and_details(token)
898
+ token_details = token_details_from_authorization(token)
899
+ token_details[:payment_type] = token_details.has_key?(:token_id) ? :token : :pay_as_order
787
900
 
788
- payment_details
901
+ token_details
789
902
  end
790
903
 
791
904
  def credit_fund_transfer_attribute(options)
@@ -813,6 +926,10 @@ module ActiveMerchant #:nodoc:
813
926
  def eligible_for_0_auth?(payment_method, options = {})
814
927
  payment_method.is_a?(CreditCard) && %w(visa master).include?(payment_method.brand) && options[:zero_dollar_auth]
815
928
  end
929
+
930
+ def card_holder_name(payment_method, options)
931
+ test? && options[:execute_threed] && !options[:three_ds_version]&.start_with?('2') ? '3D' : payment_method.name
932
+ end
816
933
  end
817
934
  end
818
935
  end
@@ -14,7 +14,7 @@ module ActiveMerchant #:nodoc:
14
14
  self.require_verification_value = false
15
15
  self.require_name = false
16
16
 
17
- attr_accessor :payment_cryptogram, :eci, :transaction_id
17
+ attr_accessor :payment_cryptogram, :eci, :transaction_id, :metadata
18
18
  attr_writer :source
19
19
 
20
20
  SOURCES = %i(apple_pay android_pay google_pay network_token)
@@ -1,3 +1,3 @@
1
1
  module ActiveMerchant
2
- VERSION = '1.124.0'
2
+ VERSION = '1.125.0'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activemerchant
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.124.0
4
+ version: 1.125.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tobias Luetke
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-10-28 00:00:00.000000000 Z
11
+ date: 2022-01-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -233,6 +233,7 @@ files:
233
233
  - lib/active_merchant/billing/gateways/d_local.rb
234
234
  - lib/active_merchant/billing/gateways/data_cash.rb
235
235
  - lib/active_merchant/billing/gateways/decidir.rb
236
+ - lib/active_merchant/billing/gateways/decidir_plus.rb
236
237
  - lib/active_merchant/billing/gateways/dibs.rb
237
238
  - lib/active_merchant/billing/gateways/digitzs.rb
238
239
  - lib/active_merchant/billing/gateways/ebanx.rb
@@ -265,6 +266,7 @@ files:
265
266
  - lib/active_merchant/billing/gateways/in_context_paypal_express.rb
266
267
  - lib/active_merchant/billing/gateways/inspire.rb
267
268
  - lib/active_merchant/billing/gateways/instapay.rb
269
+ - lib/active_merchant/billing/gateways/ipg.rb
268
270
  - lib/active_merchant/billing/gateways/ipp.rb
269
271
  - lib/active_merchant/billing/gateways/iridium.rb
270
272
  - lib/active_merchant/billing/gateways/itransact.rb
@@ -356,6 +358,7 @@ files:
356
358
  - lib/active_merchant/billing/gateways/payway_dot_com.rb
357
359
  - lib/active_merchant/billing/gateways/pin.rb
358
360
  - lib/active_merchant/billing/gateways/plugnpay.rb
361
+ - lib/active_merchant/billing/gateways/priority.rb
359
362
  - lib/active_merchant/billing/gateways/pro_pay.rb
360
363
  - lib/active_merchant/billing/gateways/psigate.rb
361
364
  - lib/active_merchant/billing/gateways/psl_card.rb
@@ -406,6 +409,7 @@ files:
406
409
  - lib/active_merchant/billing/gateways/webpay.rb
407
410
  - lib/active_merchant/billing/gateways/wepay.rb
408
411
  - lib/active_merchant/billing/gateways/wirecard.rb
412
+ - lib/active_merchant/billing/gateways/wompi.rb
409
413
  - lib/active_merchant/billing/gateways/world_net.rb
410
414
  - lib/active_merchant/billing/gateways/worldpay.rb
411
415
  - lib/active_merchant/billing/gateways/worldpay_online_payments.rb