activemerchant 1.118.0 → 1.123.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (60) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG +185 -0
  3. data/README.md +4 -2
  4. data/lib/active_merchant/billing/check.rb +19 -12
  5. data/lib/active_merchant/billing/credit_card.rb +4 -0
  6. data/lib/active_merchant/billing/credit_card_formatting.rb +1 -0
  7. data/lib/active_merchant/billing/credit_card_methods.rb +44 -17
  8. data/lib/active_merchant/billing/gateways/adyen.rb +36 -19
  9. data/lib/active_merchant/billing/gateways/authorize_net.rb +19 -11
  10. data/lib/active_merchant/billing/gateways/authorize_net_cim.rb +3 -0
  11. data/lib/active_merchant/billing/gateways/blue_pay.rb +29 -0
  12. data/lib/active_merchant/billing/gateways/blue_snap.rb +2 -2
  13. data/lib/active_merchant/billing/gateways/braintree_blue.rb +52 -8
  14. data/lib/active_merchant/billing/gateways/cashnet.rb +7 -2
  15. data/lib/active_merchant/billing/gateways/checkout_v2.rb +31 -0
  16. data/lib/active_merchant/billing/gateways/credorax.rb +15 -9
  17. data/lib/active_merchant/billing/gateways/cyber_source.rb +53 -6
  18. data/lib/active_merchant/billing/gateways/d_local.rb +1 -1
  19. data/lib/active_merchant/billing/gateways/decidir.rb +15 -3
  20. data/lib/active_merchant/billing/gateways/elavon.rb +76 -25
  21. data/lib/active_merchant/billing/gateways/element.rb +2 -0
  22. data/lib/active_merchant/billing/gateways/eway_rapid.rb +13 -0
  23. data/lib/active_merchant/billing/gateways/forte.rb +12 -0
  24. data/lib/active_merchant/billing/gateways/global_collect.rb +25 -16
  25. data/lib/active_merchant/billing/gateways/hps.rb +64 -1
  26. data/lib/active_merchant/billing/gateways/kushki.rb +23 -0
  27. data/lib/active_merchant/billing/gateways/litle.rb +4 -4
  28. data/lib/active_merchant/billing/gateways/mercado_pago.rb +5 -4
  29. data/lib/active_merchant/billing/gateways/merchant_warrior.rb +2 -0
  30. data/lib/active_merchant/billing/gateways/moka.rb +277 -0
  31. data/lib/active_merchant/billing/gateways/monei.rb +228 -144
  32. data/lib/active_merchant/billing/gateways/mundipagg.rb +14 -5
  33. data/lib/active_merchant/billing/gateways/netbanx.rb +37 -2
  34. data/lib/active_merchant/billing/gateways/nmi.rb +14 -9
  35. data/lib/active_merchant/billing/gateways/orbital.rb +127 -64
  36. data/lib/active_merchant/billing/gateways/pay_arc.rb +390 -0
  37. data/lib/active_merchant/billing/gateways/pay_trace.rb +404 -0
  38. data/lib/active_merchant/billing/gateways/payeezy.rb +34 -6
  39. data/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb +1 -0
  40. data/lib/active_merchant/billing/gateways/payflow.rb +9 -0
  41. data/lib/active_merchant/billing/gateways/payment_express.rb +10 -5
  42. data/lib/active_merchant/billing/gateways/paymentez.rb +5 -0
  43. data/lib/active_merchant/billing/gateways/paypal_express.rb +1 -0
  44. data/lib/active_merchant/billing/gateways/paysafe.rb +291 -0
  45. data/lib/active_merchant/billing/gateways/payu_latam.rb +3 -3
  46. data/lib/active_merchant/billing/gateways/payway_dot_com.rb +253 -0
  47. data/lib/active_merchant/billing/gateways/qvalent.rb +23 -9
  48. data/lib/active_merchant/billing/gateways/redsys.rb +44 -25
  49. data/lib/active_merchant/billing/gateways/safe_charge.rb +20 -11
  50. data/lib/active_merchant/billing/gateways/spreedly_core.rb +13 -4
  51. data/lib/active_merchant/billing/gateways/stripe.rb +8 -8
  52. data/lib/active_merchant/billing/gateways/stripe_payment_intents.rb +79 -25
  53. data/lib/active_merchant/billing/gateways/usa_epay_transaction.rb +1 -1
  54. data/lib/active_merchant/billing/gateways/vpos.rb +220 -0
  55. data/lib/active_merchant/billing/gateways/worldpay.rb +64 -19
  56. data/lib/active_merchant/billing/three_d_secure_eci_mapper.rb +27 -0
  57. data/lib/active_merchant/billing.rb +1 -0
  58. data/lib/active_merchant/version.rb +1 -1
  59. data/lib/certs/cacert.pem +1582 -2431
  60. metadata +10 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 506cd11074e8ee661844d74fb2a114665b025952d47517a423f27bd2ca566c49
4
- data.tar.gz: 35cfe858b3bd6c492558dcd47cf17518edc6dbd96176dbb72abe6df2ff607724
3
+ metadata.gz: ce71317ac7aa50f5b0bcbfb6fe301f804eea7919153b9ade64cbd0d34ea7a25c
4
+ data.tar.gz: a62776247abfdb56c2a0cb36e336242191b3809d989999aebb7a906f8b7afa9b
5
5
  SHA512:
6
- metadata.gz: 8955f8c555ec9049fa06e76176a2a819e2e1bbe54868eab1c88023ece7dcd722201009b39d238acfedc79a5ac50363c73dbfa776b95f61d3db308f0b7dd897e6
7
- data.tar.gz: 77736f76e9483256f71abb8799d8bf4804ba0f56992e226f9f185ecb0fed1cb87dc8956e886473a17c4643d3f799e6b9898565c4ec0420b1b3fcefa7471e1d16
6
+ metadata.gz: 83869085801337d35208b4c41cfebe89e315a9ea9590acb8b168402ab3acf398df011a201dcafd85139af7d01c3b75b35e278b18cd5bc7198655606181fd17ea
7
+ data.tar.gz: 60a54eae2330f8d00959931d933025cd32f302144c37e17a5d11d35ebd3f3356bb80fc8cfb15f3b060410782a667bdae985f07442bd9af4d9a9f03e5df2faa88
data/CHANGELOG CHANGED
@@ -2,6 +2,191 @@
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
91
+
92
+ == Version 1.121 (June 8th, 2021)
93
+ * Braintree: Lift restriction on gem version to allow for backwards compatibility [naashton] #3993
94
+ * Payment Express/Windcave: Send amount on verify calls [cdmackeyfree] #3995
95
+ * Orbital: Use billing_address name as fallback [curiousepic] #3966
96
+ * vPOS: handle shop_process_id correctly [therufs] #3996
97
+ * Checkout v2: Support metadata field [saschakala] #3992
98
+ * Adyen: Support networkTxReference field [naashton] #3997
99
+ * Paypal Express: Enable PayPal express reference transaction request to send merchant session id [janees-e] #3994
100
+
101
+ == Version 1.120.0 (May 28th, 2021)
102
+ * Braintree: Bump required braintree gem version to 3.0.1
103
+ * Stripe PI: ensure `setup_future_sage` and `off_session` work when using SetupIntents.
104
+ * Orbital: Update commit to accept retry_logic in params [jessiagee] #3890
105
+ * Orbital: Update remote 3DS tests [jessiagee] #3892
106
+ * Mercado Pago: support Creditel card type [therufs] #3893
107
+ * Payeezy: Update error mapping [meagabeth] #3896
108
+ * HPS: Add support for stored_credential [cdmackeyfree] #3894
109
+ * Orbital: Ensure payment_detail sends for ECP [jessiagee] #3899
110
+ * Payeezy: Update `error_code_from` method [meagabeth] #3900
111
+ * Worldpay: Add support for `statementNarrative` field [meagabeth] #3901
112
+ * Mercado Pago: Give ability to pass capture option in authorize txn field [naashton] #3897
113
+ * Orbital: Ensure correct fields sent in refund [jessiagee] #3903
114
+ * WorldPay: remove some defaults in billing address [carrigan] #3902
115
+ * Adyen: Support for General Credit [naashton] #3904
116
+ * Worldpay: reintroduce address1 and city defaults [carrigan] #3905
117
+ * Stripe: ensure potentially nested data is scrubbed #3907
118
+ * Stripe PI: Send Validate on Payment Method Attach [tatsianaclifton] #3909
119
+ * Adyen: Update handling of authorization returned from gateway [meagabeth] #3910
120
+ * Update gateway templates for Rubocop compliance [therufs] #3912 #3895
121
+ * Orbital: Send AVSname for all eCheck transactions [jessiagee] #3911
122
+ * Litle: update support of customerId field [cdmackeyfree] #3913
123
+ * Payment Express: fix signature for `verify` [therufs] #3914
124
+ * Forte: Send xdata fields [dsmcclain] #3915
125
+ * PaywayDotCom: Add New Gateway [DanAtPayway] #3898
126
+ * Orbital: Remove unnecessary requirements [jessiagee] #3917
127
+ * SafeCharge (Nuvei): Add network tokenization support [DStoyanoff] #3847
128
+ * Stripe PI: Enhance testing of SetupIntents API #3908
129
+ * SafeCharge (Nuvei): Fix NT related bug [jimilpatel24] #3921
130
+ * Worldpay: Only override cardholdername for 3ds tests [curiousepic] #3918
131
+ * Orbital: Add support for general credit [meagabeth] #3922
132
+ * Banco Sabadell: Ensure sca_exemption field is used #3923
133
+ * Redsys: Refactor XML character escape logic #3925
134
+ * HPS: Strip zip codes of non-alphanumeric characters [dsmcclain] #3926
135
+ * Orbital: $0 PreNote using authorize for eCheck force_capture [jessiagee] #3927
136
+ * Worldpay: synchronous response changes [naashton] #3928
137
+ * PaywayDotCom: Add more thorough scrubbing [tatsianaclifton] #3929
138
+ * Remove CONTRIBUTING.md and update README.md to reflect new repository wiki [dsmcclain] #3930
139
+ * Qvalent: Add customer_reference_number [fredo-] #3931
140
+ * Orbital: Add 'ND' ECPActionCode to $0 Prenote Check [jessiagee] #3935
141
+ * Checkout: Add support for stored_credential [meagabeth] #3934
142
+ * Credorax: Add support for 3ds_reqchallengeind [dsmcclain] #3936
143
+ * Adyen: cancelOrRefund endpoint when passed as option [naashton] #3937
144
+ * Qvalent: Add customer reference number FIX [fredo-] #3939
145
+ * Orbital: Pass line_items in capture [jessiagee] #3941
146
+ * BraintreeBlue: Add support for $0 auth verification [meagabeth] #3944
147
+ * JCB: Add additional BIN ranges [dsmcclain] #3946
148
+ * vPOS: Support new gateway type [therufs] #3906
149
+ * Braintree: Add support for AVS and CVV results in $0 credit card verification transactions [meagabeth] #3951
150
+ * Braintree: Return cvv_code and avs_code in response [meagabeth] #3952
151
+ * vPOS: Stringify values [therufs] #3954
152
+ * Payeezy: Send level2 fields [dsmcclain] #3953
153
+ * Credorax: adjust logic for sending 3ds shipping address fields [dsmcclain] #3959
154
+ * Orbital: Ensure ECP always sends AVSName [jessiagee] #3963
155
+ * Orbital: Add middle name to EWSMiddleName for ECP [jessiagee] #3962
156
+ * Support Canadian Bank Accounts [naashton] #3964
157
+ * Windcave/Payment Express: Add support for AvsAction and EnableAVSData fields [meagabeth] #3967
158
+ * CyberSource: Update XML tag for merchantDefinedData [meagabeth] #3969
159
+ * Elavon: Send ssl_vendor_id field [dsmcclain] #3972
160
+ * Credorax: Add support for `echo` field [meagabeth] #3973
161
+ * Worldpay: support cancelOrRefund via options [therufs] #3975
162
+ * Payeezy: support general credit [cdmackeyfree] #3977
163
+ * Ripley and Hipercard: Add BIN ranges [naashton] #3978
164
+ * Adyen: Default card holder name for credit cards [shasum] #3980
165
+ * PaywayDotCom: make `source_id` a required field [dsmcclain] # 3981
166
+ * Qvalent: remove `pem_password` from required credentials [dsmcclain] #3982
167
+ * Authorize.net: Fix stored credentials [tatsianaclifton] #3971
168
+ * CyberSource: Add support for multiple new fields [dsmcclain] #3984
169
+ * CASHNet: Update gateway adapter [dsmcclain] #3986
170
+ * Elavon: Send `ssl_vendor_id` field via options on gateway initialization [dsmcclain] #3989
171
+
172
+ == Version 1.119.0 (February 9th, 2021)
173
+ * Payment Express: support verify/validate [therufs] #3874
174
+ * GlobalCollect: Truncate address fields [meagabeth] #3878
175
+ * Litle: Truncate address fields [meagabeth] #3877
176
+ * Netbanx: Add-customer-information(name,email,IP)-to-a-transaction [rockyhakjoong] #3754
177
+ * Netbanx: Adjust the avs and cvv return code in shopify [rockyhakjoong] #3833
178
+ * Decidir: Improve error mapping [meagabeth] #3875
179
+ * Worldpay: support `skip_capture` [therufs] #3879
180
+ * Redsys: Add new response code text [britth] #3880
181
+ * Orbital: Update ECP details to use payment source [jessiagee] #3881
182
+ * Alelo: Add additional BIN ranges [meagabeth] #3882
183
+ * HPS: Update Add support for general credit [naashton] #3885
184
+ * Elavon: Fix issue with encoding data sent in the request [naashton] #3865
185
+ * Orbital: Update ECP to use EWS verification [jessiagee] #3886
186
+ * Eway: Add 3ds field when do direct payment [GavinSun9527] #3860
187
+ * Support Creditel cardtype [therufs] #3883
188
+ * Elavon: Remove ampersand char from fields [naashton] #3891
189
+
5
190
  == Version 1.118.0 (January 22nd, 2021)
6
191
  * Worldpay: Add support for challengeWindowSize [carrigan] #3823
7
192
  * Adyen: Update capitalization on subMerchantId field [cdmackeyfree] #3824
data/README.md CHANGED
@@ -17,7 +17,7 @@ from an ever-growing set of contributors.
17
17
  See [GettingStarted.md](GettingStarted.md) if you want to learn more about using Active Merchant in your
18
18
  applications.
19
19
 
20
- If you'd like to contribute to Active Merchant, please start with our [contribution guide](CONTRIBUTING.md).
20
+ If you'd like to contribute to Active Merchant, please start with our [Contribution Guide](https://github.com/activemerchant/active_merchant/wiki/Contributing).
21
21
 
22
22
  ## Installation
23
23
 
@@ -81,6 +81,8 @@ if credit_card.validate.empty?
81
81
  end
82
82
  ```
83
83
 
84
+ ## Contributing
85
+
84
86
  For more in-depth documentation and tutorials, see [GettingStarted.md](GettingStarted.md) and the
85
87
  [API documentation](http://www.rubydoc.info/github/activemerchant/active_merchant/).
86
88
 
@@ -158,7 +160,7 @@ The [ActiveMerchant Wiki](https://github.com/activemerchant/active_merchant/wiki
158
160
  * [Metrics Global](http://www.metricsglobal.com) - US
159
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
160
162
  * [Modern Payments](http://www.modpay.com) - US
161
- * [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
162
164
  * [Moneris](http://www.moneris.com/) - CA
163
165
  * [MoneyMovers](http://mmoa.us/) - US
164
166
  * [NAB Transact](http://transact.nab.com.au) - AU
@@ -13,6 +13,16 @@ module ActiveMerchant #:nodoc:
13
13
  # Used for Canadian bank accounts
14
14
  attr_accessor :institution_number, :transit_number
15
15
 
16
+ # Canadian Institution Numbers
17
+ # Found here: https://en.wikipedia.org/wiki/Routing_number_(Canada)
18
+ CAN_INSTITUTION_NUMBERS = %w(
19
+ 001 002 003 004 006 010 016 030 039 117 127 177 219 245 260 269 270 308
20
+ 309 310 315 320 338 340 509 540 608 614 623 809 815 819 828 829 837 839
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
24
+ )
25
+
16
26
  def name
17
27
  @name ||= "#{first_name} #{last_name}".strip
18
28
  end
@@ -56,20 +66,17 @@ module ActiveMerchant #:nodoc:
56
66
  # See http://en.wikipedia.org/wiki/Routing_transit_number#Internal_checksums
57
67
  def valid_routing_number?
58
68
  digits = routing_number.to_s.split('').map(&:to_i).select { |d| (0..9).cover?(d) }
59
- case digits.size
60
- when 9
69
+ if digits.size == 9
61
70
  checksum = ((3 * (digits[0] + digits[3] + digits[6])) +
62
- (7 * (digits[1] + digits[4] + digits[7])) +
63
- (digits[2] + digits[5] + digits[8])) % 10
64
- case checksum
65
- when 0
66
- true
67
- else
68
- false
69
- end
70
- else
71
- false
71
+ (7 * (digits[1] + digits[4] + digits[7])) +
72
+ (digits[2] + digits[5] + digits[8])) % 10
73
+
74
+ return checksum == 0
72
75
  end
76
+
77
+ return CAN_INSTITUTION_NUMBERS.include?(routing_number[0..2]) if digits.size == 8
78
+
79
+ false
73
80
  end
74
81
  end
75
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
@@ -102,6 +104,8 @@ module ActiveMerchant #:nodoc:
102
104
  # * +'union_pay'+
103
105
  # * +'alia'+
104
106
  # * +'olimpica'+
107
+ # * +'creditel'+
108
+ # * +'confiable'+
105
109
  #
106
110
  # Or, if you wish to test your implementation, +'bogus'+.
107
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}$/ },
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}$/ },
@@ -31,7 +32,10 @@ module ActiveMerchant #:nodoc:
31
32
  CARNET_BINS.any? { |bin| num.slice(0, bin.size) == bin }
32
33
  )
33
34
  },
34
- 'olimpica' => ->(num) { num =~ /^636853\d{10}$/ }
35
+ 'olimpica' => ->(num) { num =~ /^636853\d{10}$/ },
36
+ 'creditel' => ->(num) { num =~ /^601933\d{10}$/ },
37
+ 'confiable' => ->(num) { num =~ /^560718\d{10}$/ },
38
+ 'synchrony' => ->(num) { num =~ /^700600\d{10}$/ }
35
39
  }
36
40
 
37
41
  # http://www.barclaycard.co.uk/business/files/bin_rules.pdf
@@ -70,11 +74,17 @@ module ActiveMerchant #:nodoc:
70
74
  MASTERCARD_RANGES = [
71
75
  (222100..272099),
72
76
  (510000..559999),
77
+ [605272],
78
+ [606282],
79
+ [637095],
80
+ [637568],
81
+ (637599..637600),
82
+ [637609],
73
83
  ]
74
84
 
75
85
  MAESTRO_BINS = Set.new(
76
86
  %w[ 500057
77
- 501018 501043 501045 501047 501049 501051 501072 501075 501087 501089 501095
87
+ 501018 501043 501045 501047 501049 501051 501072 501075 501083 501087 501089 501095
78
88
  501500
79
89
  501879 502113 502301 503175
80
90
  503645 503670
@@ -99,16 +109,16 @@ module ActiveMerchant #:nodoc:
99
109
  597077 597094 597143 597370 597410 597765 597855 597862
100
110
  598053 598054 598395 598585 598793 598794 598815 598835 598838 598880 598889
101
111
  599000 599069 599089 599148 599191 599310 599741 599742 599867
102
- 601070
112
+ 601070 601638
103
113
  604983
104
114
  606126
105
115
  636380 636422 636502 636639
106
116
  637046 637756
107
- 639130
117
+ 639130 639229
108
118
  690032]
109
119
  )
110
120
 
111
- # 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
112
122
  MAESTRO_RANGES = [
113
123
  (500032..500033),
114
124
  (501015..501016),
@@ -118,17 +128,20 @@ module ActiveMerchant #:nodoc:
118
128
  (501053..501058),
119
129
  (501060..501063),
120
130
  (501066..501067),
121
- (501080..501083),
122
131
  (501091..501092),
123
132
  (501104..501105),
124
133
  (501107..501108),
125
134
  (501104..501105),
126
135
  (501107..501108),
136
+ (501800..501899),
137
+ (502000..502099),
138
+ (503800..503899),
127
139
  (561200..561269),
128
140
  (561271..561299),
129
141
  (561320..561356),
130
142
  (581700..581751),
131
143
  (581753..581800),
144
+ (589300..589399),
132
145
  (589998..591259),
133
146
  (591261..596770),
134
147
  (596772..598744),
@@ -142,6 +155,7 @@ module ActiveMerchant #:nodoc:
142
155
  (601640..601652),
143
156
  (601689..601700),
144
157
  (602011..602050),
158
+ (630400..630499),
145
159
  (639000..639099),
146
160
  (670000..679999),
147
161
  ]
@@ -167,8 +181,9 @@ module ActiveMerchant #:nodoc:
167
181
  402588..402588, 404347..404347, 405876..405876, 405882..405882, 405884..405884,
168
182
  405886..405886, 430471..430471, 438061..438061, 438064..438064, 470063..470066,
169
183
  496067..496067, 506699..506704, 506706..506706, 506713..506714, 506716..506716,
170
- 506749..506750, 506752..506752, 506754..506756, 506758..506762, 506764..506767,
171
- 506770..506771, 509015..509019, 509880..509882, 509884..509885, 509987..509992
184
+ 506749..506750, 506752..506752, 506754..506756, 506758..506767, 506770..506771,
185
+ 506773..506773, 509015..509019, 509880..509882, 509884..509885, 509887..509887,
186
+ 509987..509992
172
187
  ]
173
188
 
174
189
  CABAL_RANGES = [
@@ -181,14 +196,16 @@ module ActiveMerchant #:nodoc:
181
196
  589562..589562
182
197
  ]
183
198
 
184
- # In addition to the BIN ranges listed here that all begin with 81, UnionPay cards
185
- # include many ranges that start with 62.
186
- # Prior to adding UnionPay, cards that start with 62 were all classified as Discover.
187
- # 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
188
200
  UNIONPAY_RANGES = [
201
+ 62212600..62379699, 62400000..62699999, 62820000..62889999,
189
202
  81000000..81099999, 81100000..81319999, 81320000..81519999, 81520000..81639999, 81640000..81719999
190
203
  ]
191
204
 
205
+ JCB_RANGES = [
206
+ 3528..3589, 3088..3094, 3096..3102, 3112..3120, 3158..3159, 3337..3349
207
+ ]
208
+
192
209
  def self.included(base)
193
210
  base.extend(ClassMethods)
194
211
  end
@@ -196,7 +213,7 @@ module ActiveMerchant #:nodoc:
196
213
  def self.in_bin_range?(number, ranges)
197
214
  bin = number.to_i
198
215
  ranges.any? do |range|
199
- range.cover?(bin)
216
+ range.include?(bin)
200
217
  end
201
218
  end
202
219
 
@@ -345,7 +362,9 @@ module ActiveMerchant #:nodoc:
345
362
  case brand
346
363
  when 'naranja'
347
364
  valid_naranja_algo?(numbers)
348
- when 'alia'
365
+ when 'creditel'
366
+ valid_creditel_algo?(numbers)
367
+ when 'alia', 'confiable', 'maestro_no_luhn'
349
368
  true
350
369
  else
351
370
  valid_luhn?(numbers)
@@ -399,7 +418,7 @@ module ActiveMerchant #:nodoc:
399
418
  sum % 10 == 0
400
419
  end
401
420
 
402
- # Checks the validity of a card number by use of Naranja's specific algorithm.
421
+ # Checks the validity of a card number by use of specific algorithms
403
422
  def valid_naranja_algo?(numbers) #:nodoc:
404
423
  num_array = numbers.to_s.chars.map(&:to_i)
405
424
  multipliers = [4, 3, 2, 7, 6, 5, 4, 3, 2, 7, 6, 5, 4, 3, 2]
@@ -408,6 +427,14 @@ module ActiveMerchant #:nodoc:
408
427
  final_num = intermediate > 9 ? 0 : intermediate
409
428
  final_num == num_array[15]
410
429
  end
430
+
431
+ def valid_creditel_algo?(numbers) #:nodoc:
432
+ num_array = numbers.to_s.chars.map(&:to_i)
433
+ multipliers = [5, 4, 3, 2, 1, 9, 8, 7, 6, 5, 4, 3, 2, 1, 9]
434
+ num_sum = num_array[0..14].zip(multipliers).map { |a, b| a * b }.reduce(:+)
435
+ final_num = num_sum % 10
436
+ final_num == num_array[15]
437
+ end
411
438
  end
412
439
  end
413
440
  end