activemerchant 1.121.0 → 1.123.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (46) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG +86 -0
  3. data/README.md +1 -1
  4. data/lib/active_merchant/billing/check.rb +13 -16
  5. data/lib/active_merchant/billing/credit_card.rb +3 -0
  6. data/lib/active_merchant/billing/credit_card_formatting.rb +1 -0
  7. data/lib/active_merchant/billing/credit_card_methods.rb +21 -12
  8. data/lib/active_merchant/billing/gateways/adyen.rb +15 -19
  9. data/lib/active_merchant/billing/gateways/authorize_net.rb +10 -8
  10. data/lib/active_merchant/billing/gateways/blue_pay.rb +29 -0
  11. data/lib/active_merchant/billing/gateways/blue_snap.rb +2 -2
  12. data/lib/active_merchant/billing/gateways/braintree_blue.rb +6 -3
  13. data/lib/active_merchant/billing/gateways/credorax.rb +2 -1
  14. data/lib/active_merchant/billing/gateways/cyber_source.rb +30 -3
  15. data/lib/active_merchant/billing/gateways/decidir.rb +7 -1
  16. data/lib/active_merchant/billing/gateways/elavon.rb +60 -28
  17. data/lib/active_merchant/billing/gateways/element.rb +2 -0
  18. data/lib/active_merchant/billing/gateways/global_collect.rb +19 -10
  19. data/lib/active_merchant/billing/gateways/kushki.rb +23 -0
  20. data/lib/active_merchant/billing/gateways/mercado_pago.rb +3 -2
  21. data/lib/active_merchant/billing/gateways/merchant_warrior.rb +2 -0
  22. data/lib/active_merchant/billing/gateways/moka.rb +277 -0
  23. data/lib/active_merchant/billing/gateways/monei.rb +228 -144
  24. data/lib/active_merchant/billing/gateways/mundipagg.rb +14 -5
  25. data/lib/active_merchant/billing/gateways/nmi.rb +14 -9
  26. data/lib/active_merchant/billing/gateways/orbital.rb +28 -6
  27. data/lib/active_merchant/billing/gateways/pay_arc.rb +390 -0
  28. data/lib/active_merchant/billing/gateways/pay_trace.rb +404 -0
  29. data/lib/active_merchant/billing/gateways/payeezy.rb +4 -0
  30. data/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb +1 -0
  31. data/lib/active_merchant/billing/gateways/payflow.rb +9 -0
  32. data/lib/active_merchant/billing/gateways/payment_express.rb +2 -2
  33. data/lib/active_merchant/billing/gateways/paymentez.rb +5 -0
  34. data/lib/active_merchant/billing/gateways/paysafe.rb +291 -0
  35. data/lib/active_merchant/billing/gateways/payu_latam.rb +3 -3
  36. data/lib/active_merchant/billing/gateways/redsys.rb +35 -32
  37. data/lib/active_merchant/billing/gateways/safe_charge.rb +2 -0
  38. data/lib/active_merchant/billing/gateways/spreedly_core.rb +13 -4
  39. data/lib/active_merchant/billing/gateways/stripe_payment_intents.rb +19 -1
  40. data/lib/active_merchant/billing/gateways/usa_epay_transaction.rb +1 -1
  41. data/lib/active_merchant/billing/gateways/vpos.rb +49 -6
  42. data/lib/active_merchant/billing/gateways/worldpay.rb +39 -7
  43. data/lib/active_merchant/billing/three_d_secure_eci_mapper.rb +27 -0
  44. data/lib/active_merchant/billing.rb +1 -0
  45. data/lib/active_merchant/version.rb +1 -1
  46. metadata +8 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d8bbedca7a5cfd13a87cfcfc7dd7b2eb59a73e6407e5e4df0d0247e9c7e70e0c
4
- data.tar.gz: 8ca081c01c837adae8a76bdc357c28753cd899cae9b4467b1c390048c4a2794f
3
+ metadata.gz: ce71317ac7aa50f5b0bcbfb6fe301f804eea7919153b9ade64cbd0d34ea7a25c
4
+ data.tar.gz: a62776247abfdb56c2a0cb36e336242191b3809d989999aebb7a906f8b7afa9b
5
5
  SHA512:
6
- metadata.gz: 2115a9d6a83597cef54510ce37cb4f3fbf7afecfc9c3662462c554b16e221fec07c1b6ffd622d2f103daf6b2eea7b03899b7a705d04118579833e1c548bb82ed
7
- data.tar.gz: 2c8c426554798d1f91ece60ea4de4013ba79283a0f2171c4e54976d2c561ad9e0f74ade0ca3af144f24596151ba82910f83ab42bf6c943acca32d97f366e8517
6
+ metadata.gz: 83869085801337d35208b4c41cfebe89e315a9ea9590acb8b168402ab3acf398df011a201dcafd85139af7d01c3b75b35e278b18cd5bc7198655606181fd17ea
7
+ data.tar.gz: 60a54eae2330f8d00959931d933025cd32f302144c37e17a5d11d35ebd3f3356bb80fc8cfb15f3b060410782a667bdae985f07442bd9af4d9a9f03e5df2faa88
data/CHANGELOG CHANGED
@@ -2,6 +2,92 @@
2
2
 
3
3
  == HEAD
4
4
 
5
+ == Version 1.123.0 (September 10th, 2021)
6
+ * Paysafe: Add gateway integration [meagabeth] #4085
7
+ * Elavon: Support recurring transactions with stored credentials [cdmackeyfree] #4086
8
+ * Orbital: Truncate three_d_secure[:version] [carrigan] #4087
9
+ * Credorax: Determine ISK decimal by datetime [curiousepic] #4088
10
+ * Moka: support new gateway type [dsmcclain] #4089
11
+ * Paymentez: Add more_info field [reblevins] #4091
12
+ * Worldpay: Support $0 auth [therufs] #4092
13
+ * Elavon: Support recurring transactions with token, revert stored credentials recurring [cdmackeyfree] #4089
14
+ * SafeCharge(Nuvei): Add support for product_id [rachelkirk] #4095
15
+ * NMI: Change cardholder_auth 3DS field population [carrigan] #4094
16
+ * Synchrony: add card type [therufs] #4096
17
+ * Maestro: support BINs without Luhn check [therufs] #4097
18
+ * Maestro: support BINs [therufs] #4098
19
+ * Redsys: Route MIT Exemptions to webservice endpoint [curiousepic] #4081
20
+ * Adyen: Update Classic Integration API to v64 and Recurring API to v49 [almalee24] #4090
21
+ * Payeezy: support soft_descriptor and merchant_ref [cdmackeyfree] #4099
22
+ * Elavon: add ssl_token field [cdmackeyfree] #4100
23
+ * Credorax: Remove special logic for ISK [curiousepic] #4102
24
+ * UnionPay: Pull UnionPay's 62* BIN ranges out of Discover's #4103
25
+ * Monei: Update Creation of Billing Details [tatsianaclifton] #4107
26
+ * Monei: Typo Correction on Billing Details [tatsianaclifton] #4108
27
+ * Paysafe: Add support for 3DS [meagabeth] #4109
28
+
29
+ == Version 1.122.0 (August 3rd, 2021)
30
+ * Orbital: Correct success logic for refund [tatsianaclifton] #4014
31
+ * usaepay: Added pin gateway setting [DustinHaefele] #4026
32
+ * MercadoPago: Added external_reference, more payer object options, and metadata field [DustinHaefele] #4020
33
+ * Element: Add duplicate_override_flag [almalee24] #4012
34
+ * PayTrace: Support gateway [meagabeth] #3985
35
+ * vPOS: Support credit + refund [therufs] #3998
36
+ * PayArc: Support gateway [senthil-code] #3974
37
+ * NMI: Support cardholder_auth field for 3DS2 [cdmackeyfree] #4002
38
+ * Confiable: Support cardtype [therufs] #4004
39
+ * Maestro: Add BIN [therufs] #4003
40
+ * PayULatam: Ensure phone number is pulled from shipping_address correctly [dsmcclain] #4005
41
+ * SafeCharge: Add challenge_preference for 3DS [klaiv] #3999
42
+ * Adyen: Pass networkTxReference in all transactions [naashton] #4006
43
+ * Adyen: Ensure correct transaction reference is selected [dsmcclain] #4007
44
+ * PayTrace: Support level_3_data fields [meagabeth] #4008
45
+ * BluePay: Add support for Stored Credentials [dsmcclain] #4009
46
+ * Orbital: Add support for SCARecurringPayment [jessiagee] #4010
47
+ * Braintree: Support recurring_first and moto reasons [curiousepic] #4013
48
+ * PayTrace: Adjust capture method [meagabeth] #4015
49
+ * BarclaysEpdqExtraPlus: updated custom_eci test + remote tests [yyapuncich] #4022
50
+ * CyberSource: Add customerID field [deemeyers] #4025
51
+ * CyberSource: Adjust Auth [naashton] #3956
52
+ * Valid Canadian Institution Numbers [naashton] #4024
53
+ * PayTrace: Adjust purchase and capture methods to handle MultiResponse scenarios [meagabeth] #4027
54
+ * Payflow: Add support for MERCHDESCR field [rachelkirk] #4028
55
+ * PayTrace: Support $0 authorize in verify method [meagabeth] #4030
56
+ * PayArc: Add error_code in response [cdm-83] #4021
57
+ * Update bank routing account validation check [jessiagee] #4029
58
+ * Kushki: Add 'contactDetails' fields [mbreenlyles] #4033
59
+ * Adyen: Truncating order_id and remote test [yyapuncich] #4036
60
+ * CyberSource: Allow string content for Ignore AVS/CVV flags [curiousepic] #4043
61
+ * Decidir: Update validation error message handling [arbianchi] #4042
62
+ * Authorize.net: Remove cardholderAuthentication for non-3DS transactions [BritneyS] #4045
63
+ * BlueSnap: Handle 429 errors [britth] #4044
64
+ * Orbital: Update unit test files [meagabeth] #4046
65
+ * Orbital: Strip null characters from responses [britth] #4041
66
+ * Merchant Warrior: Handle invalid XML responses [arbianchi] #4047
67
+ * Braintree: Fix NoMethodError for failed card verification [molbrown] #4048
68
+ * Worldpay: Accepting 3DS1 and 3DS2 authentication data from external MPI [chandan-PS] #4017
69
+ * PayArc: Currency and parameters updates [jessiagee] #4051
70
+ * Elavon: Add support for special characters [mbreenlyles] #4049
71
+ * PayArc: Formatting CC month, adding tax_rate, removing default void reason [jessiagee] #4053
72
+ * Kushki: Add support for fullResponse field [rachelkirk] #4057
73
+ * Element: Add support for `MerchantDescriptor` field [BritneyS] #4058
74
+ * PayArc: Added email and phone to credit and charge [jessiagee] #4056
75
+ * Mundipagg: Added support for 'authentication_secret_key' for 'api_key' overwrite [DustinHaefele] #4059
76
+ * Payflow: Raise an error if store method is called [dsmcclain] #4066
77
+ * Monei: JSON API implementation [jimmyn] #3613
78
+ * Maestro: Update BINs [therufs] #4067
79
+ * Monei: Change domain to monei.com [jimmyn] #4068
80
+ * Spreedly: Support gateway_specific_response_fields in response params [abarrak] #4064
81
+ * Payeezy: Add support for `add_soft_descriptors` [rachelkirk] #4069
82
+ * Stripe Payment Intents: Add support for network_transaction_id field [cdmackeyfree] #4060
83
+ * Worldpay: Support 'CAPTURED' response for authorize transactions [naashton] #4070
84
+ * Ingenico (Global Collect): New idempotence key header [BritneyS] #4073
85
+ * PayTrace: Adjust handling of line_items subfields [meagabeth] #4074
86
+ * Worldpay: Correct Expiration Year Format [tatsianaclifton] #4076
87
+ * Monei: Improve Scrub Regex [tatsianaclifton] #4072
88
+ * Payflow: add THREEDSVERSION and DSTRANSACTIONID when present [bbraschi] #4075
89
+ * CT Payments: update remote tests [cdmackeyfree] #3947
90
+ * Orbital: Ensure full e-check scrubbing [mbreenlyles] #4079
5
91
 
6
92
  == Version 1.121 (June 8th, 2021)
7
93
  * Braintree: Lift restriction on gem version to allow for backwards compatibility [naashton] #3993
data/README.md CHANGED
@@ -160,7 +160,7 @@ The [ActiveMerchant Wiki](https://github.com/activemerchant/active_merchant/wiki
160
160
  * [Metrics Global](http://www.metricsglobal.com) - US
161
161
  * [MasterCard Internet Gateway Service (MiGS)](http://mastercard.com/mastercardsps) - AU, AE, BD, BN, EG, HK, ID, IN, JO, KW, LB, LK, MU, MV, MY, NZ, OM, PH, QA, SA, SG, TT, VN
162
162
  * [Modern Payments](http://www.modpay.com) - US
163
- * [MONEI](http://www.monei.net/) - AD, AT, BE, BG, CA, CH, CY, CZ, DE, DK, EE, ES, FI, FO, FR, GB, GI, GR, HU, IE, IL, IS, IT, LI, LT, LU, LV, MT, NL, NO, PL, PT, RO, SE, SI, SK, TR, US, VA
163
+ * [MONEI](http://www.monei.com/) - AD, AT, BE, BG, CA, CH, CY, CZ, DE, DK, EE, ES, FI, FO, FR, GB, GI, GR, HU, IE, IL, IS, IT, LI, LT, LU, LV, MT, NL, NO, PL, PT, RO, SE, SI, SK, TR, US, VA
164
164
  * [Moneris](http://www.moneris.com/) - CA
165
165
  * [MoneyMovers](http://mmoa.us/) - US
166
166
  * [NAB Transact](http://transact.nab.com.au) - AU
@@ -15,10 +15,12 @@ module ActiveMerchant #:nodoc:
15
15
 
16
16
  # Canadian Institution Numbers
17
17
  # Found here: https://en.wikipedia.org/wiki/Routing_number_(Canada)
18
- INSTITUTION_NUMBERS = %w(
18
+ CAN_INSTITUTION_NUMBERS = %w(
19
19
  001 002 003 004 006 010 016 030 039 117 127 177 219 245 260 269 270 308
20
20
  309 310 315 320 338 340 509 540 608 614 623 809 815 819 828 829 837 839
21
- 865 879 889 899
21
+ 865 879 889 899 241 242 248 250 265 275 277 290 294 301 303 307 311 314
22
+ 321 323 327 328 330 332 334 335 342 343 346 352 355 361 362 366 370 372
23
+ 376 378 807 853
22
24
  )
23
25
 
24
26
  def name
@@ -64,22 +66,17 @@ module ActiveMerchant #:nodoc:
64
66
  # See http://en.wikipedia.org/wiki/Routing_transit_number#Internal_checksums
65
67
  def valid_routing_number?
66
68
  digits = routing_number.to_s.split('').map(&:to_i).select { |d| (0..9).cover?(d) }
67
- case digits.size
68
- when 9
69
+ if digits.size == 9
69
70
  checksum = ((3 * (digits[0] + digits[3] + digits[6])) +
70
- (7 * (digits[1] + digits[4] + digits[7])) +
71
- (digits[2] + digits[5] + digits[8])) % 10
72
- case checksum
73
- when 0
74
- true
75
- else
76
- false
77
- end
78
- when 8
79
- true if INSTITUTION_NUMBERS.include?(routing_number[0..2].to_s)
80
- else
81
- false
71
+ (7 * (digits[1] + digits[4] + digits[7])) +
72
+ (digits[2] + digits[5] + digits[8])) % 10
73
+
74
+ return checksum == 0
82
75
  end
76
+
77
+ return CAN_INSTITUTION_NUMBERS.include?(routing_number[0..2]) if digits.size == 8
78
+
79
+ false
83
80
  end
84
81
  end
85
82
  end
@@ -25,6 +25,8 @@ module ActiveMerchant #:nodoc:
25
25
  # * UnionPay
26
26
  # * Alia
27
27
  # * Olimpica
28
+ # * Creditel
29
+ # * Confiable
28
30
  #
29
31
  # For testing purposes, use the 'bogus' credit card brand. This skips the vast majority of
30
32
  # validations, allowing you to focus on your core concerns until you're ready to be more concerned
@@ -103,6 +105,7 @@ module ActiveMerchant #:nodoc:
103
105
  # * +'alia'+
104
106
  # * +'olimpica'+
105
107
  # * +'creditel'+
108
+ # * +'confiable'+
106
109
  #
107
110
  # Or, if you wish to test your implementation, +'bogus'+.
108
111
  #
@@ -15,6 +15,7 @@ module ActiveMerchant #:nodoc:
15
15
  case option
16
16
  when :two_digits then sprintf('%.2i', number.to_i)[-2..-1]
17
17
  when :four_digits then sprintf('%.4i', number.to_i)[-4..-1]
18
+ when :four_digits_year then number.to_s.length == 2 ? '20' + number.to_s : format(number, :four_digits)
18
19
  else number
19
20
  end
20
21
  end
@@ -7,11 +7,11 @@ module ActiveMerchant #:nodoc:
7
7
  'master' => ->(num) { num&.size == 16 && in_bin_range?(num.slice(0, 6), MASTERCARD_RANGES) },
8
8
  'elo' => ->(num) { num&.size == 16 && in_bin_range?(num.slice(0, 6), ELO_RANGES) },
9
9
  'alelo' => ->(num) { num&.size == 16 && in_bin_range?(num.slice(0, 6), ALELO_RANGES) },
10
- 'discover' => ->(num) { num =~ /^(6011|65\d{2}|64[4-9]\d)\d{12,15}|(62\d{14,17})$/ },
10
+ 'discover' => ->(num) { num =~ /^(6011|65\d{2}|64[4-9]\d)\d{12,15}$/ },
11
11
  'american_express' => ->(num) { num =~ /^3[47]\d{13}$/ },
12
12
  'naranja' => ->(num) { num&.size == 16 && in_bin_range?(num.slice(0, 6), NARANJA_RANGES) },
13
13
  'diners_club' => ->(num) { num =~ /^3(0[0-5]|[68]\d)\d{11,16}$/ },
14
- 'jcb' => ->(num) { num =~ /^(35(28|29|[3-8]\d)\d{12}|308800\d{10})$/ },
14
+ 'jcb' => ->(num) { num&.size == 16 && in_bin_range?(num.slice(0, 4), JCB_RANGES) },
15
15
  'dankort' => ->(num) { num =~ /^5019\d{12}$/ },
16
16
  'maestro' => lambda { |num|
17
17
  (12..19).cover?(num&.size) && (
@@ -19,6 +19,7 @@ module ActiveMerchant #:nodoc:
19
19
  MAESTRO_BINS.any? { |bin| num.slice(0, bin.size) == bin }
20
20
  )
21
21
  },
22
+ 'maestro_no_luhn' => ->(num) { num =~ /^(501080|501081|501082)\d{10}$/ },
22
23
  'forbrugsforeningen' => ->(num) { num =~ /^600722\d{10}$/ },
23
24
  'sodexo' => ->(num) { num =~ /^(606071|603389|606070|606069|606068|600818)\d{10}$/ },
24
25
  'alia' => ->(num) { num =~ /^(504997|505878|601030|601073|505874)\d{10}$/ },
@@ -32,7 +33,9 @@ module ActiveMerchant #:nodoc:
32
33
  )
33
34
  },
34
35
  'olimpica' => ->(num) { num =~ /^636853\d{10}$/ },
35
- 'creditel' => ->(num) { num =~ /^601933\d{10}$/ }
36
+ 'creditel' => ->(num) { num =~ /^601933\d{10}$/ },
37
+ 'confiable' => ->(num) { num =~ /^560718\d{10}$/ },
38
+ 'synchrony' => ->(num) { num =~ /^700600\d{10}$/ }
36
39
  }
37
40
 
38
41
  # http://www.barclaycard.co.uk/business/files/bin_rules.pdf
@@ -81,7 +84,7 @@ module ActiveMerchant #:nodoc:
81
84
 
82
85
  MAESTRO_BINS = Set.new(
83
86
  %w[ 500057
84
- 501018 501043 501045 501047 501049 501051 501072 501075 501087 501089 501095
87
+ 501018 501043 501045 501047 501049 501051 501072 501075 501083 501087 501089 501095
85
88
  501500
86
89
  501879 502113 502301 503175
87
90
  503645 503670
@@ -106,7 +109,7 @@ module ActiveMerchant #:nodoc:
106
109
  597077 597094 597143 597370 597410 597765 597855 597862
107
110
  598053 598054 598395 598585 598793 598794 598815 598835 598838 598880 598889
108
111
  599000 599069 599089 599148 599191 599310 599741 599742 599867
109
- 601070
112
+ 601070 601638
110
113
  604983
111
114
  606126
112
115
  636380 636422 636502 636639
@@ -115,7 +118,7 @@ module ActiveMerchant #:nodoc:
115
118
  690032]
116
119
  )
117
120
 
118
- # https://www.mastercard.us/content/dam/mccom/global/documents/mastercard-rules.pdf, page 73
121
+ # https://www.mastercard.us/content/dam/mccom/global/documents/mastercard-rules.pdf, page 79
119
122
  MAESTRO_RANGES = [
120
123
  (500032..500033),
121
124
  (501015..501016),
@@ -125,17 +128,20 @@ module ActiveMerchant #:nodoc:
125
128
  (501053..501058),
126
129
  (501060..501063),
127
130
  (501066..501067),
128
- (501080..501083),
129
131
  (501091..501092),
130
132
  (501104..501105),
131
133
  (501107..501108),
132
134
  (501104..501105),
133
135
  (501107..501108),
136
+ (501800..501899),
137
+ (502000..502099),
138
+ (503800..503899),
134
139
  (561200..561269),
135
140
  (561271..561299),
136
141
  (561320..561356),
137
142
  (581700..581751),
138
143
  (581753..581800),
144
+ (589300..589399),
139
145
  (589998..591259),
140
146
  (591261..596770),
141
147
  (596772..598744),
@@ -149,6 +155,7 @@ module ActiveMerchant #:nodoc:
149
155
  (601640..601652),
150
156
  (601689..601700),
151
157
  (602011..602050),
158
+ (630400..630499),
152
159
  (639000..639099),
153
160
  (670000..679999),
154
161
  ]
@@ -189,14 +196,16 @@ module ActiveMerchant #:nodoc:
189
196
  589562..589562
190
197
  ]
191
198
 
192
- # In addition to the BIN ranges listed here that all begin with 81, UnionPay cards
193
- # include many ranges that start with 62.
194
- # Prior to adding UnionPay, cards that start with 62 were all classified as Discover.
195
- # Because UnionPay cards are able to run on Discover rails, this was kept the same.
199
+ # https://www.discoverglobalnetwork.com/content/dam/discover/en_us/dgn/pdfs/IPP-VAR-Enabler-Compliance.pdf
196
200
  UNIONPAY_RANGES = [
201
+ 62212600..62379699, 62400000..62699999, 62820000..62889999,
197
202
  81000000..81099999, 81100000..81319999, 81320000..81519999, 81520000..81639999, 81640000..81719999
198
203
  ]
199
204
 
205
+ JCB_RANGES = [
206
+ 3528..3589, 3088..3094, 3096..3102, 3112..3120, 3158..3159, 3337..3349
207
+ ]
208
+
200
209
  def self.included(base)
201
210
  base.extend(ClassMethods)
202
211
  end
@@ -355,7 +364,7 @@ module ActiveMerchant #:nodoc:
355
364
  valid_naranja_algo?(numbers)
356
365
  when 'creditel'
357
366
  valid_creditel_algo?(numbers)
358
- when 'alia'
367
+ when 'alia', 'confiable', 'maestro_no_luhn'
359
368
  true
360
369
  else
361
370
  valid_luhn?(numbers)
@@ -16,8 +16,8 @@ module ActiveMerchant #:nodoc:
16
16
  self.homepage_url = 'https://www.adyen.com/'
17
17
  self.display_name = 'Adyen'
18
18
 
19
- PAYMENT_API_VERSION = 'v40'
20
- RECURRING_API_VERSION = 'v30'
19
+ PAYMENT_API_VERSION = 'v64'
20
+ RECURRING_API_VERSION = 'v49'
21
21
 
22
22
  STANDARD_ERROR_CODE_MAPPING = {
23
23
  '101' => STANDARD_ERROR_CODE[:incorrect_number],
@@ -59,6 +59,7 @@ module ActiveMerchant #:nodoc:
59
59
  add_3ds_authenticated_data(post, options)
60
60
  add_splits(post, options)
61
61
  add_recurring_contract(post, options)
62
+ add_network_transaction_reference(post, options)
62
63
  commit('authorise', post, options)
63
64
  end
64
65
 
@@ -67,14 +68,16 @@ module ActiveMerchant #:nodoc:
67
68
  add_invoice_for_modification(post, money, options)
68
69
  add_reference(post, authorization, options)
69
70
  add_splits(post, options)
71
+ add_network_transaction_reference(post, options)
70
72
  commit('capture', post, options)
71
73
  end
72
74
 
73
75
  def refund(money, authorization, options = {})
74
76
  post = init_post(options)
75
77
  add_invoice_for_modification(post, money, options)
76
- add_original_reference(post, authorization, options)
78
+ add_reference(post, authorization, options)
77
79
  add_splits(post, options)
80
+ add_network_transaction_reference(post, options)
78
81
  commit('refund', post, options)
79
82
  end
80
83
 
@@ -83,6 +86,7 @@ module ActiveMerchant #:nodoc:
83
86
  add_invoice(post, money, options)
84
87
  add_payment(post, payment, options)
85
88
  add_shopper_reference(post, options)
89
+ add_network_transaction_reference(post, options)
86
90
  commit('refundWithData', post, options)
87
91
  end
88
92
 
@@ -90,6 +94,7 @@ module ActiveMerchant #:nodoc:
90
94
  post = init_post(options)
91
95
  endpoint = options[:cancel_or_refund] ? 'cancelOrRefund' : 'cancel'
92
96
  add_reference(post, authorization, options)
97
+ add_network_transaction_reference(post, options)
93
98
  commit(endpoint, post, options)
94
99
  end
95
100
 
@@ -394,19 +399,14 @@ module ActiveMerchant #:nodoc:
394
399
  options
395
400
  end
396
401
 
397
- def add_reference(post, authorization, options = {})
398
- _, psp_reference, = authorization.split('#')
399
- post[:originalReference] = single_reference(authorization) || psp_reference
400
- post[:networkTxReference] = options[:network_transaction_id] if options[:network_transaction_id]
402
+ def add_network_transaction_reference(post, options)
403
+ post[:additionalData] = {} unless post[:additionalData]
404
+ post[:additionalData][:networkTxReference] = options[:network_transaction_id] if options[:network_transaction_id]
401
405
  end
402
406
 
403
- def add_original_reference(post, authorization, options = {})
404
- if authorization.start_with?('#')
405
- _, original_psp_reference, = authorization.split('#')
406
- else
407
- original_psp_reference, = authorization.split('#')
408
- end
409
- post[:originalReference] = single_reference(authorization) || original_psp_reference
407
+ def add_reference(post, authorization, options = {})
408
+ original_reference = authorization.split('#').reject(&:empty?).first
409
+ post[:originalReference] = original_reference
410
410
  end
411
411
 
412
412
  def add_mpi_data_for_network_tokenization_card(post, payment)
@@ -417,10 +417,6 @@ module ActiveMerchant #:nodoc:
417
417
  post[:mpiData][:eci] = payment.eci || '07'
418
418
  end
419
419
 
420
- def single_reference(authorization)
421
- authorization if !authorization.include?('#')
422
- end
423
-
424
420
  def add_recurring_contract(post, options = {})
425
421
  return unless options[:recurring_contract_type]
426
422
 
@@ -612,7 +608,7 @@ module ActiveMerchant #:nodoc:
612
608
  def init_post(options = {})
613
609
  post = {}
614
610
  add_merchant_account(post, options)
615
- post[:reference] = options[:order_id] if options[:order_id]
611
+ post[:reference] = options[:order_id][0..79] if options[:order_id]
616
612
  post
617
613
  end
618
614
 
@@ -567,14 +567,16 @@ module ActiveMerchant
567
567
 
568
568
  xml.customerIP(options[:ip]) unless empty?(options[:ip])
569
569
 
570
- xml.cardholderAuthentication do
571
- three_d_secure = options.fetch(:three_d_secure, {})
572
- xml.authenticationIndicator(
573
- options[:authentication_indicator] || three_d_secure[:eci]
574
- )
575
- xml.cardholderAuthenticationValue(
576
- options[:cardholder_authentication_value] || three_d_secure[:cavv]
577
- )
570
+ if !empty?(options.fetch(:three_d_secure, {})) || options[:authentication_indicator] || options[:cardholder_authentication_value]
571
+ xml.cardholderAuthentication do
572
+ three_d_secure = options.fetch(:three_d_secure, {})
573
+ xml.authenticationIndicator(
574
+ options[:authentication_indicator] || three_d_secure[:eci]
575
+ )
576
+ xml.cardholderAuthenticationValue(
577
+ options[:cardholder_authentication_value] || three_d_secure[:cavv]
578
+ )
579
+ end
578
580
  end
579
581
  end
580
582
 
@@ -84,6 +84,7 @@ module ActiveMerchant #:nodoc:
84
84
  add_customer_data(post, options)
85
85
  add_rebill(post, options) if options[:rebill]
86
86
  add_duplicate_override(post, options)
87
+ add_stored_credential(post, options)
87
88
  post[:TRANS_TYPE] = 'AUTH'
88
89
  commit('AUTH_ONLY', money, post, options)
89
90
  end
@@ -107,6 +108,7 @@ module ActiveMerchant #:nodoc:
107
108
  add_customer_data(post, options)
108
109
  add_rebill(post, options) if options[:rebill]
109
110
  add_duplicate_override(post, options)
111
+ add_stored_credential(post, options)
110
112
  post[:TRANS_TYPE] = 'SALE'
111
113
  commit('AUTH_CAPTURE', money, post, options)
112
114
  end
@@ -461,6 +463,33 @@ module ActiveMerchant #:nodoc:
461
463
  post[:REB_CYCLES] = options[:rebill_cycles]
462
464
  end
463
465
 
466
+ def add_stored_credential(post, options)
467
+ post[:cof] = initiator(options)
468
+ post[:cofscheduled] = scheduled(options)
469
+ end
470
+
471
+ def initiator(options)
472
+ return unless initiator = options.dig(:stored_credential, :initiator)
473
+
474
+ case initiator
475
+ when 'merchant'
476
+ 'M'
477
+ when 'cardholder'
478
+ 'C'
479
+ end
480
+ end
481
+
482
+ def scheduled(options)
483
+ return unless reason_type = options.dig(:stored_credential, :reason_type)
484
+
485
+ case reason_type
486
+ when 'recurring' || 'installment'
487
+ 'Y'
488
+ when 'unscheduled'
489
+ 'N'
490
+ end
491
+ end
492
+
464
493
  def post_data(action, parameters = {})
465
494
  post = {}
466
495
  post[:version] = '1'