activemerchant 1.116.0 → 1.121.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 +148 -1
  3. data/README.md +4 -2
  4. data/lib/active_merchant/billing/check.rb +10 -0
  5. data/lib/active_merchant/billing/credit_card.rb +3 -0
  6. data/lib/active_merchant/billing/credit_card_methods.rb +80 -15
  7. data/lib/active_merchant/billing/gateways/adyen.rb +29 -8
  8. data/lib/active_merchant/billing/gateways/authorize_net.rb +37 -1
  9. data/lib/active_merchant/billing/gateways/authorize_net_cim.rb +4 -0
  10. data/lib/active_merchant/billing/gateways/blue_snap.rb +3 -1
  11. data/lib/active_merchant/billing/gateways/braintree_blue.rb +54 -7
  12. data/lib/active_merchant/billing/gateways/cashnet.rb +7 -2
  13. data/lib/active_merchant/billing/gateways/checkout_v2.rb +33 -2
  14. data/lib/active_merchant/billing/gateways/credorax.rb +30 -14
  15. data/lib/active_merchant/billing/gateways/cyber_source.rb +51 -8
  16. data/lib/active_merchant/billing/gateways/d_local.rb +1 -1
  17. data/lib/active_merchant/billing/gateways/decidir.rb +22 -2
  18. data/lib/active_merchant/billing/gateways/elavon.rb +54 -2
  19. data/lib/active_merchant/billing/gateways/eway_rapid.rb +13 -0
  20. data/lib/active_merchant/billing/gateways/firstdata_e4_v27.rb +17 -6
  21. data/lib/active_merchant/billing/gateways/forte.rb +12 -0
  22. data/lib/active_merchant/billing/gateways/global_collect.rb +25 -6
  23. data/lib/active_merchant/billing/gateways/hps.rb +65 -2
  24. data/lib/active_merchant/billing/gateways/litle.rb +21 -5
  25. data/lib/active_merchant/billing/gateways/mercado_pago.rb +2 -2
  26. data/lib/active_merchant/billing/gateways/netbanx.rb +37 -2
  27. data/lib/active_merchant/billing/gateways/orbital.rb +178 -45
  28. data/lib/active_merchant/billing/gateways/payeezy.rb +53 -11
  29. data/lib/active_merchant/billing/gateways/payment_express.rb +10 -5
  30. data/lib/active_merchant/billing/gateways/paymentez.rb +21 -1
  31. data/lib/active_merchant/billing/gateways/paypal.rb +10 -2
  32. data/lib/active_merchant/billing/gateways/paypal/paypal_common_api.rb +1 -0
  33. data/lib/active_merchant/billing/gateways/paypal_express.rb +1 -0
  34. data/lib/active_merchant/billing/gateways/payway_dot_com.rb +253 -0
  35. data/lib/active_merchant/billing/gateways/pin.rb +11 -0
  36. data/lib/active_merchant/billing/gateways/qvalent.rb +23 -9
  37. data/lib/active_merchant/billing/gateways/redsys.rb +101 -5
  38. data/lib/active_merchant/billing/gateways/safe_charge.rb +39 -6
  39. data/lib/active_merchant/billing/gateways/stripe.rb +9 -9
  40. data/lib/active_merchant/billing/gateways/stripe_payment_intents.rb +82 -25
  41. data/lib/active_merchant/billing/gateways/vpos.rb +177 -0
  42. data/lib/active_merchant/billing/gateways/worldpay.rb +31 -14
  43. data/lib/active_merchant/billing/response.rb +2 -1
  44. data/lib/active_merchant/version.rb +1 -1
  45. data/lib/certs/cacert.pem +1582 -2431
  46. metadata +5 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c32d76816ad9cdc73be63181629990b876d69e62e84c324b0cf0b240bb4fab42
4
- data.tar.gz: 8c4263133c364d786f480ac146e174765ac1a5b5c462680c17f4f104af9f0d49
3
+ metadata.gz: d8bbedca7a5cfd13a87cfcfc7dd7b2eb59a73e6407e5e4df0d0247e9c7e70e0c
4
+ data.tar.gz: 8ca081c01c837adae8a76bdc357c28753cd899cae9b4467b1c390048c4a2794f
5
5
  SHA512:
6
- metadata.gz: 167eff38aa013365fab6ff2ba49cee58b15b8b5aa7f604f2c58d0040fac2fe931a4550c3fe594df618326630138ef63265767f2270f3ae6838642a26694fb921
7
- data.tar.gz: 23a60e19999c1ce903bfc35503eac491d5cff0de0b59ab8dfe99e67f2f0d4b31380ef3826926c70cc60303c348bfa9377e642ed420f58d519a1ec779521516db
6
+ metadata.gz: 2115a9d6a83597cef54510ce37cb4f3fbf7afecfc9c3662462c554b16e221fec07c1b6ffd622d2f103daf6b2eea7b03899b7a705d04118579833e1c548bb82ed
7
+ data.tar.gz: 2c8c426554798d1f91ece60ea4de4013ba79283a0f2171c4e54976d2c561ad9e0f74ade0ca3af144f24596151ba82910f83ab42bf6c943acca32d97f366e8517
data/CHANGELOG CHANGED
@@ -2,8 +2,154 @@
2
2
 
3
3
  == HEAD
4
4
 
5
+
6
+ == Version 1.121 (June 8th, 2021)
7
+ * Braintree: Lift restriction on gem version to allow for backwards compatibility [naashton] #3993
8
+ * Payment Express/Windcave: Send amount on verify calls [cdmackeyfree] #3995
9
+ * Orbital: Use billing_address name as fallback [curiousepic] #3966
10
+ * vPOS: handle shop_process_id correctly [therufs] #3996
11
+ * Checkout v2: Support metadata field [saschakala] #3992
12
+ * Adyen: Support networkTxReference field [naashton] #3997
13
+ * Paypal Express: Enable PayPal express reference transaction request to send merchant session id [janees-e] #3994
14
+
15
+ == Version 1.120.0 (May 28th, 2021)
16
+ * Braintree: Bump required braintree gem version to 3.0.1
17
+ * Stripe PI: ensure `setup_future_sage` and `off_session` work when using SetupIntents.
18
+ * Orbital: Update commit to accept retry_logic in params [jessiagee] #3890
19
+ * Orbital: Update remote 3DS tests [jessiagee] #3892
20
+ * Mercado Pago: support Creditel card type [therufs] #3893
21
+ * Payeezy: Update error mapping [meagabeth] #3896
22
+ * HPS: Add support for stored_credential [cdmackeyfree] #3894
23
+ * Orbital: Ensure payment_detail sends for ECP [jessiagee] #3899
24
+ * Payeezy: Update `error_code_from` method [meagabeth] #3900
25
+ * Worldpay: Add support for `statementNarrative` field [meagabeth] #3901
26
+ * Mercado Pago: Give ability to pass capture option in authorize txn field [naashton] #3897
27
+ * Orbital: Ensure correct fields sent in refund [jessiagee] #3903
28
+ * WorldPay: remove some defaults in billing address [carrigan] #3902
29
+ * Adyen: Support for General Credit [naashton] #3904
30
+ * Worldpay: reintroduce address1 and city defaults [carrigan] #3905
31
+ * Stripe: ensure potentially nested data is scrubbed #3907
32
+ * Stripe PI: Send Validate on Payment Method Attach [tatsianaclifton] #3909
33
+ * Adyen: Update handling of authorization returned from gateway [meagabeth] #3910
34
+ * Update gateway templates for Rubocop compliance [therufs] #3912 #3895
35
+ * Orbital: Send AVSname for all eCheck transactions [jessiagee] #3911
36
+ * Litle: update support of customerId field [cdmackeyfree] #3913
37
+ * Payment Express: fix signature for `verify` [therufs] #3914
38
+ * Forte: Send xdata fields [dsmcclain] #3915
39
+ * PaywayDotCom: Add New Gateway [DanAtPayway] #3898
40
+ * Orbital: Remove unnecessary requirements [jessiagee] #3917
41
+ * SafeCharge (Nuvei): Add network tokenization support [DStoyanoff] #3847
42
+ * Stripe PI: Enhance testing of SetupIntents API #3908
43
+ * SafeCharge (Nuvei): Fix NT related bug [jimilpatel24] #3921
44
+ * Worldpay: Only override cardholdername for 3ds tests [curiousepic] #3918
45
+ * Orbital: Add support for general credit [meagabeth] #3922
46
+ * Banco Sabadell: Ensure sca_exemption field is used #3923
47
+ * Redsys: Refactor XML character escape logic #3925
48
+ * HPS: Strip zip codes of non-alphanumeric characters [dsmcclain] #3926
49
+ * Orbital: $0 PreNote using authorize for eCheck force_capture [jessiagee] #3927
50
+ * Worldpay: synchronous response changes [naashton] #3928
51
+ * PaywayDotCom: Add more thorough scrubbing [tatsianaclifton] #3929
52
+ * Remove CONTRIBUTING.md and update README.md to reflect new repository wiki [dsmcclain] #3930
53
+ * Qvalent: Add customer_reference_number [fredo-] #3931
54
+ * Orbital: Add 'ND' ECPActionCode to $0 Prenote Check [jessiagee] #3935
55
+ * Checkout: Add support for stored_credential [meagabeth] #3934
56
+ * Credorax: Add support for 3ds_reqchallengeind [dsmcclain] #3936
57
+ * Adyen: cancelOrRefund endpoint when passed as option [naashton] #3937
58
+ * Qvalent: Add customer reference number FIX [fredo-] #3939
59
+ * Orbital: Pass line_items in capture [jessiagee] #3941
60
+ * BraintreeBlue: Add support for $0 auth verification [meagabeth] #3944
61
+ * JCB: Add additional BIN ranges [dsmcclain] #3946
62
+ * vPOS: Support new gateway type [therufs] #3906
63
+ * Braintree: Add support for AVS and CVV results in $0 credit card verification transactions [meagabeth] #3951
64
+ * Braintree: Return cvv_code and avs_code in response [meagabeth] #3952
65
+ * vPOS: Stringify values [therufs] #3954
66
+ * Payeezy: Send level2 fields [dsmcclain] #3953
67
+ * Credorax: adjust logic for sending 3ds shipping address fields [dsmcclain] #3959
68
+ * Orbital: Ensure ECP always sends AVSName [jessiagee] #3963
69
+ * Orbital: Add middle name to EWSMiddleName for ECP [jessiagee] #3962
70
+ * Support Canadian Bank Accounts [naashton] #3964
71
+ * Windcave/Payment Express: Add support for AvsAction and EnableAVSData fields [meagabeth] #3967
72
+ * CyberSource: Update XML tag for merchantDefinedData [meagabeth] #3969
73
+ * Elavon: Send ssl_vendor_id field [dsmcclain] #3972
74
+ * Credorax: Add support for `echo` field [meagabeth] #3973
75
+ * Worldpay: support cancelOrRefund via options [therufs] #3975
76
+ * Payeezy: support general credit [cdmackeyfree] #3977
77
+ * Ripley and Hipercard: Add BIN ranges [naashton] #3978
78
+ * Adyen: Default card holder name for credit cards [shasum] #3980
79
+ * PaywayDotCom: make `source_id` a required field [dsmcclain] # 3981
80
+ * Qvalent: remove `pem_password` from required credentials [dsmcclain] #3982
81
+ * Authorize.net: Fix stored credentials [tatsianaclifton] #3971
82
+ * CyberSource: Add support for multiple new fields [dsmcclain] #3984
83
+ * CASHNet: Update gateway adapter [dsmcclain] #3986
84
+ * Elavon: Send `ssl_vendor_id` field via options on gateway initialization [dsmcclain] #3989
85
+
86
+ == Version 1.119.0 (February 9th, 2021)
87
+ * Payment Express: support verify/validate [therufs] #3874
88
+ * GlobalCollect: Truncate address fields [meagabeth] #3878
89
+ * Litle: Truncate address fields [meagabeth] #3877
90
+ * Netbanx: Add-customer-information(name,email,IP)-to-a-transaction [rockyhakjoong] #3754
91
+ * Netbanx: Adjust the avs and cvv return code in shopify [rockyhakjoong] #3833
92
+ * Decidir: Improve error mapping [meagabeth] #3875
93
+ * Worldpay: support `skip_capture` [therufs] #3879
94
+ * Redsys: Add new response code text [britth] #3880
95
+ * Orbital: Update ECP details to use payment source [jessiagee] #3881
96
+ * Alelo: Add additional BIN ranges [meagabeth] #3882
97
+ * HPS: Update Add support for general credit [naashton] #3885
98
+ * Elavon: Fix issue with encoding data sent in the request [naashton] #3865
99
+ * Orbital: Update ECP to use EWS verification [jessiagee] #3886
100
+ * Eway: Add 3ds field when do direct payment [GavinSun9527] #3860
101
+ * Support Creditel cardtype [therufs] #3883
102
+ * Elavon: Remove ampersand char from fields [naashton] #3891
103
+
104
+ == Version 1.118.0 (January 22nd, 2021)
105
+ * Worldpay: Add support for challengeWindowSize [carrigan] #3823
106
+ * Adyen: Update capitalization on subMerchantId field [cdmackeyfree] #3824
107
+ * Maestro and Elo: Update BIN ranges [meagabeth] #3822
108
+ * HPS: Truncate invoice numbers that are too long [curiousepic] #3825
109
+ * Pass network_transaction_id attribute in Response [therufs] #3815
110
+ * Elavon: support standardized stored credentials [therufs] #3816
111
+ * Decidir: update fraud_detection field [cdmackeyfree] #3829
112
+ * Paymentez: Add Olimpica cardtype [meagabeth] #3831
113
+ * SafeCharge: 3DS external MPI data refinements [curiousepic] #3821
114
+ * Credorax: Add support for 3DS Adviser [meagabeth] #3834
115
+ * Adyen: Support subMerchant data [mymir][therufs] #3835
116
+ * Decidir: add device_unique_identifier to card data [cdmackeyfree] #3839
117
+ * BraintreeBlue: add support for account_type field [jimilpatel24] #3840
118
+ * Redsys: Add support for stored_credential [meagabeth] #3844
119
+ * Redsys: add_payment method solution [meagabeth] #3845
120
+ * Stripe Payment Intents: Add support for error_on_requires_action option [tatsianaclifton] #3846
121
+ * Add 3DS 2.0 values to paypal [nebdil] #3285
122
+ * Redsys: Update Mpi Fields [tatsianaclifton] #3855
123
+ * Paypal: Update AuthStatus3ds MPI field [curiousepic] #3857
124
+ * Orbital: Update 3DS support for Mastercard [meagabeth] #3850
125
+ * Payeezy: Support standardized stored credentials [therufs] #3861
126
+ * CyberSource: Update `billing_address` override [meagabeth] #3862
127
+ * Paymentez: Add 3DS MPI field support [carrigan] #3856
128
+ * BlueSnap: Add support `fraud-session-id` field [meagabeth] #3863
129
+ * BlueSnap: Update handling of `transaction-fraud-info` fields [meagabeth] #3866
130
+ * Payeezy: Allow no stored credential transaction id [therufs] #3868
131
+ * Orbital: eCheck processing added [ajawadmirza] #3870
132
+ * FirsdataE4V27: Fixes some apple pay transaction issues [pi3r] #3872
133
+
134
+ == Version 1.117.0 (November 13th)
135
+ * Checkout V2: Pass attempt_n3d along with 3ds enabled [naashton] #3805
136
+ * GlobalCollect: Add support for Third-party 3DS2 data [molbrown] #3801
137
+ * Authorize.net: Pass stored credentials [therufs] #3804
138
+ * Authorize.net: Don't pass isFirstRecurringPayment [therufs] #3805
139
+ * Litle: Add support for general credit transactions [naashton] #3807
140
+ * Redsys: Add 3DS2 Integration Support [esmitperez] #3794
141
+ * Cybersource: Use firstname/lastname from address instead of the payment method [pi3r] #3798
142
+ * Add MPI functionality for SafeCharge gateway [daniel] #3809
143
+ * SafeCharge: Standardize MPI fields [curiousepic] #3809
144
+ * Credorax: Adds AMEX to supported cards and adds 1A error code [LinTrieu] #3792
145
+ * Stripe PI: Pass external 3DS auth data [curiousepic] #3811
146
+ * Credorax: Allow 3DS1 normalized pass-through, ease version matching [britth] #3812
147
+ * Redsys: Redsys: Harden 3DS v1/v2 check for External MPI [esmitperez] #3814
148
+ * Add card types for Stripe, Worldpay, Checkout.com [LinTrieu] #3810
149
+ * ActiveMerchant::Billing::Response: Include `network_transaction_id` attribute [therufs] #3815
150
+
5
151
  == Version 1.116.0 (October 28th)
6
- * Remove Braintree specific version dependency [pi3r] #38000
152
+ * Remove Braintree specific version dependency [pi3r] #3800
7
153
 
8
154
  == Version 1.115.0 (October 27th)
9
155
  * Checkout v2: $0 Auth on gateway [jessiagee] #3762
@@ -46,6 +192,7 @@
46
192
  * Checkout V2: Support for attempt_n3d 3DS field [naashton] #3790
47
193
  * Elavon: Strip ampersands [therufs] #3795
48
194
  * Paybox: Add support for 3DS 1.0 values [jcpaybox] #3335
195
+ * Decidir: Add additional fraud_detection options [cdmackeyfree] #3812
49
196
 
50
197
  == Version 1.114.0
51
198
  * BlueSnap: Add address1,address2,phone,shipping_* support #3749
data/README.md CHANGED
@@ -1,5 +1,5 @@
1
1
  # Active Merchant
2
- [![Build Status](https://travis-ci.org/activemerchant/active_merchant.svg?branch=master)](https://travis-ci.org/activemerchant/active_merchant)
2
+ [![Build Status](https://github.com/activemerchant/active_merchant/workflows/CI/badge.svg?branch=master)](https://github.com/activemerchant/active_merchant/actions?query=workflow%3ACI)
3
3
  [![Code Climate](https://codeclimate.com/github/activemerchant/active_merchant.svg)](https://codeclimate.com/github/activemerchant/active_merchant)
4
4
 
5
5
  Active Merchant is an extraction from the ecommerce system [Shopify](http://www.shopify.com).
@@ -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
 
@@ -13,6 +13,14 @@ 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
+ 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
22
+ )
23
+
16
24
  def name
17
25
  @name ||= "#{first_name} #{last_name}".strip
18
26
  end
@@ -67,6 +75,8 @@ module ActiveMerchant #:nodoc:
67
75
  else
68
76
  false
69
77
  end
78
+ when 8
79
+ true if INSTITUTION_NUMBERS.include?(routing_number[0..2].to_s)
70
80
  else
71
81
  false
72
82
  end
@@ -24,6 +24,7 @@ module ActiveMerchant #:nodoc:
24
24
  # * Naranja
25
25
  # * UnionPay
26
26
  # * Alia
27
+ # * Olimpica
27
28
  #
28
29
  # For testing purposes, use the 'bogus' credit card brand. This skips the vast majority of
29
30
  # validations, allowing you to focus on your core concerns until you're ready to be more concerned
@@ -100,6 +101,8 @@ module ActiveMerchant #:nodoc:
100
101
  # * +'naranja'+
101
102
  # * +'union_pay'+
102
103
  # * +'alia'+
104
+ # * +'olimpica'+
105
+ # * +'creditel'+
103
106
  #
104
107
  # Or, if you wish to test your implementation, +'bogus'+.
105
108
  #
@@ -11,7 +11,7 @@ module ActiveMerchant #:nodoc:
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 =~ /^(35(28|29|[3-8]\d)\d{12}|308800\d{10})$/ },
15
15
  'dankort' => ->(num) { num =~ /^5019\d{12}$/ },
16
16
  'maestro' => lambda { |num|
17
17
  (12..19).cover?(num&.size) && (
@@ -30,7 +30,9 @@ module ActiveMerchant #:nodoc:
30
30
  in_bin_range?(num.slice(0, 6), CARNET_RANGES) ||
31
31
  CARNET_BINS.any? { |bin| num.slice(0, bin.size) == bin }
32
32
  )
33
- }
33
+ },
34
+ 'olimpica' => ->(num) { num =~ /^636853\d{10}$/ },
35
+ 'creditel' => ->(num) { num =~ /^601933\d{10}$/ }
34
36
  }
35
37
 
36
38
  # http://www.barclaycard.co.uk/business/files/bin_rules.pdf
@@ -69,14 +71,66 @@ module ActiveMerchant #:nodoc:
69
71
  MASTERCARD_RANGES = [
70
72
  (222100..272099),
71
73
  (510000..559999),
74
+ [605272],
75
+ [606282],
76
+ [637095],
77
+ [637568],
78
+ (637599..637600),
79
+ [637609],
72
80
  ]
73
81
 
74
82
  MAESTRO_BINS = Set.new(
75
- %w[500033 581149]
83
+ %w[ 500057
84
+ 501018 501043 501045 501047 501049 501051 501072 501075 501087 501089 501095
85
+ 501500
86
+ 501879 502113 502301 503175
87
+ 503645 503670
88
+ 504310 504338 504363 504533 504587 504620 504639 504656 504738 504781 504910
89
+ 507001 507002 507004 507082 507090
90
+ 560014 560565 561033
91
+ 572402 572610 572626
92
+ 576904
93
+ 578614
94
+ 581149
95
+ 585274 585697
96
+ 586509
97
+ 588729 588792
98
+ 589244 589407 589471 589605 589633 589647 589671
99
+ 590043 590206 590263 590265 590278 590361 590362 590379 590393 590590
100
+ 591235 591420 591481 591620 591770 591948 591994
101
+ 592024 592161 592184 592186 592201 592384 592393 592528 592566 592704 592735 592879 592884
102
+ 593074 593264 593272 593355 593496 593556 593589 593666 593709 593825 593963 593994
103
+ 594184 594409 594468 594475 594581 594665 594691 594710 594874 594968
104
+ 595355 595364 595532 595547 595561 595568 595743 595929
105
+ 596245 596289 596399 596405 596590 596608 596645 596646 596791 596808 596815 596846
106
+ 597077 597094 597143 597370 597410 597765 597855 597862
107
+ 598053 598054 598395 598585 598793 598794 598815 598835 598838 598880 598889
108
+ 599000 599069 599089 599148 599191 599310 599741 599742 599867
109
+ 601070
110
+ 604983
111
+ 606126
112
+ 636380 636422 636502 636639
113
+ 637046 637756
114
+ 639130 639229
115
+ 690032]
76
116
  )
77
117
 
78
118
  # https://www.mastercard.us/content/dam/mccom/global/documents/mastercard-rules.pdf, page 73
79
119
  MAESTRO_RANGES = [
120
+ (500032..500033),
121
+ (501015..501016),
122
+ (501020..501021),
123
+ (501023..501029),
124
+ (501038..501041),
125
+ (501053..501058),
126
+ (501060..501063),
127
+ (501066..501067),
128
+ (501080..501083),
129
+ (501091..501092),
130
+ (501104..501105),
131
+ (501107..501108),
132
+ (501104..501105),
133
+ (501107..501108),
80
134
  (561200..561269),
81
135
  (561271..561299),
82
136
  (561320..561356),
@@ -101,14 +155,14 @@ module ActiveMerchant #:nodoc:
101
155
 
102
156
  # https://dev.elo.com.br/apis/tabela-de-bins, download csv from left sidebar
103
157
  ELO_RANGES = [
104
- 506707..506708, 506715..506715, 506718..506722, 506724..506724, 506726..506736, 506739..506739, 506741..506743,
105
- 506745..506747, 506753..506753, 506774..506776, 506778..506778, 509000..509001, 509003..509003, 509007..509007,
106
- 509020..509022, 509035..509035, 509039..509042, 509045..509045, 509048..509048, 509051..509071, 509073..509074,
107
- 509077..509080, 509084..509089, 509091..509094, 509098..509098, 509100..509100, 509104..509104, 509106..509109,
108
- 509257..509257, 627780..627780, 636368..636368, 650031..650033, 650035..650045, 650047..650047, 650406..650410,
109
- 650434..650436, 650439..650439, 650485..650504, 650506..650530, 650577..650580, 650582..650591, 650721..650727,
110
- 650901..650922, 650928..650928, 650938..650939, 650946..650948, 650954..650955, 650962..650963, 650967..650967,
111
- 650971..650971, 651652..651667, 651675..651678, 655000..655010, 655012..655015, 655051..655052, 655056..655057
158
+ 506707..506708, 506715..506715, 506717..506722, 506724..506736, 506739..506743,
159
+ 506745..506747, 506753..506753, 506774..506778, 509000..509007, 509009..509014,
160
+ 509020..509030, 509035..509042, 509044..509089, 509091..509101, 509104..509807,
161
+ 509831..509877, 509897..509900, 509918..509964, 509971..509986, 509995..509999,
162
+ 627780..627780, 636368..636368, 650031..650033, 650035..650051, 650057..650081,
163
+ 650406..650439, 650485..650504, 650506..650538, 650552..650598, 650720..650727,
164
+ 650901..650922, 650928..650928, 650938..650939, 650946..650978, 651652..651704,
165
+ 655000..655019, 655021..655057
112
166
  ]
113
167
 
114
168
  # Alelo provides BIN ranges by e-mailing them out periodically.
@@ -120,8 +174,9 @@ module ActiveMerchant #:nodoc:
120
174
  402588..402588, 404347..404347, 405876..405876, 405882..405882, 405884..405884,
121
175
  405886..405886, 430471..430471, 438061..438061, 438064..438064, 470063..470066,
122
176
  496067..496067, 506699..506704, 506706..506706, 506713..506714, 506716..506716,
123
- 506749..506750, 506752..506752, 506754..506756, 506758..506762, 506764..506767,
124
- 506770..506771, 509015..509019, 509880..509882, 509884..509885, 509987..509992
177
+ 506749..506750, 506752..506752, 506754..506756, 506758..506767, 506770..506771,
178
+ 506773..506773, 509015..509019, 509880..509882, 509884..509885, 509887..509887,
179
+ 509987..509992
125
180
  ]
126
181
 
127
182
  CABAL_RANGES = [
@@ -149,7 +204,7 @@ module ActiveMerchant #:nodoc:
149
204
  def self.in_bin_range?(number, ranges)
150
205
  bin = number.to_i
151
206
  ranges.any? do |range|
152
- range.cover?(bin)
207
+ range.include?(bin)
153
208
  end
154
209
  end
155
210
 
@@ -298,6 +353,8 @@ module ActiveMerchant #:nodoc:
298
353
  case brand
299
354
  when 'naranja'
300
355
  valid_naranja_algo?(numbers)
356
+ when 'creditel'
357
+ valid_creditel_algo?(numbers)
301
358
  when 'alia'
302
359
  true
303
360
  else
@@ -352,7 +409,7 @@ module ActiveMerchant #:nodoc:
352
409
  sum % 10 == 0
353
410
  end
354
411
 
355
- # Checks the validity of a card number by use of Naranja's specific algorithm.
412
+ # Checks the validity of a card number by use of specific algorithms
356
413
  def valid_naranja_algo?(numbers) #:nodoc:
357
414
  num_array = numbers.to_s.chars.map(&:to_i)
358
415
  multipliers = [4, 3, 2, 7, 6, 5, 4, 3, 2, 7, 6, 5, 4, 3, 2]
@@ -361,6 +418,14 @@ module ActiveMerchant #:nodoc:
361
418
  final_num = intermediate > 9 ? 0 : intermediate
362
419
  final_num == num_array[15]
363
420
  end
421
+
422
+ def valid_creditel_algo?(numbers) #:nodoc:
423
+ num_array = numbers.to_s.chars.map(&:to_i)
424
+ multipliers = [5, 4, 3, 2, 1, 9, 8, 7, 6, 5, 4, 3, 2, 1, 9]
425
+ num_sum = num_array[0..14].zip(multipliers).map { |a, b| a * b }.reduce(:+)
426
+ final_num = num_sum % 10
427
+ final_num == num_array[15]
428
+ end
364
429
  end
365
430
  end
366
431
  end
@@ -78,10 +78,19 @@ module ActiveMerchant #:nodoc:
78
78
  commit('refund', post, options)
79
79
  end
80
80
 
81
+ def credit(money, payment, options = {})
82
+ post = init_post(options)
83
+ add_invoice(post, money, options)
84
+ add_payment(post, payment, options)
85
+ add_shopper_reference(post, options)
86
+ commit('refundWithData', post, options)
87
+ end
88
+
81
89
  def void(authorization, options = {})
82
90
  post = init_post(options)
91
+ endpoint = options[:cancel_or_refund] ? 'cancelOrRefund' : 'cancel'
83
92
  add_reference(post, authorization, options)
84
- commit('cancel', post, options)
93
+ commit(endpoint, post, options)
85
94
  end
86
95
 
87
96
  def adjust(money, authorization, options = {})
@@ -227,7 +236,7 @@ module ActiveMerchant #:nodoc:
227
236
  end
228
237
 
229
238
  def add_merchant_data(post, options)
230
- post[:additionalData][:subMerchantId] = options[:sub_merchant_id] if options[:sub_merchant_id]
239
+ post[:additionalData][:subMerchantID] = options[:sub_merchant_id] if options[:sub_merchant_id]
231
240
  post[:additionalData][:subMerchantName] = options[:sub_merchant_name] if options[:sub_merchant_name]
232
241
  post[:additionalData][:subMerchantStreet] = options[:sub_merchant_street] if options[:sub_merchant_street]
233
242
  post[:additionalData][:subMerchantCity] = options[:sub_merchant_city] if options[:sub_merchant_city]
@@ -235,8 +244,8 @@ module ActiveMerchant #:nodoc:
235
244
  post[:additionalData][:subMerchantPostalCode] = options[:sub_merchant_postal_code] if options[:sub_merchant_postal_code]
236
245
  post[:additionalData][:subMerchantCountry] = options[:sub_merchant_country] if options[:sub_merchant_country]
237
246
  post[:additionalData][:subMerchantTaxId] = options[:sub_merchant_tax_id] if options[:sub_merchant_tax_id]
238
- post[:additionalData][:subMerchantId] = options[:sub_merchant_id] if options[:sub_merchant_id]
239
247
  post[:additionalData][:subMerchantMCC] = options[:sub_merchant_mcc] if options[:sub_merchant_mcc]
248
+ post[:additionalData] = post[:additionalData].merge(options[:sub_merchant_data]) if options[:sub_merchant_data]
240
249
  end
241
250
 
242
251
  def add_risk_data(post, options)
@@ -374,7 +383,7 @@ module ActiveMerchant #:nodoc:
374
383
  }
375
384
 
376
385
  card.delete_if { |_k, v| v.blank? }
377
- card[:holderName] ||= 'Not Provided' if credit_card.is_a?(NetworkTokenizationCreditCard)
386
+ card[:holderName] ||= 'Not Provided'
378
387
  requires!(card, :expiryMonth, :expiryYear, :holderName, :number)
379
388
  post[:card] = card
380
389
  end
@@ -388,10 +397,15 @@ module ActiveMerchant #:nodoc:
388
397
  def add_reference(post, authorization, options = {})
389
398
  _, psp_reference, = authorization.split('#')
390
399
  post[:originalReference] = single_reference(authorization) || psp_reference
400
+ post[:networkTxReference] = options[:network_transaction_id] if options[:network_transaction_id]
391
401
  end
392
402
 
393
403
  def add_original_reference(post, authorization, options = {})
394
- original_psp_reference, = authorization.split('#')
404
+ if authorization.start_with?('#')
405
+ _, original_psp_reference, = authorization.split('#')
406
+ else
407
+ original_psp_reference, = authorization.split('#')
408
+ end
395
409
  post[:originalReference] = single_reference(authorization) || original_psp_reference
396
410
  end
397
411
 
@@ -498,6 +512,7 @@ module ActiveMerchant #:nodoc:
498
512
  raw_response = e.response.body
499
513
  response = parse(raw_response)
500
514
  end
515
+
501
516
  success = success_from(action, response, options)
502
517
  Response.new(
503
518
  success,
@@ -506,6 +521,7 @@ module ActiveMerchant #:nodoc:
506
521
  authorization: authorization_from(action, parameters, response),
507
522
  test: test?,
508
523
  error_code: success ? nil : error_code_from(response),
524
+ network_transaction_id: network_transaction_id_from(response),
509
525
  avs_result: AVSResult.new(code: avs_code_from(response)),
510
526
  cvv_result: CVVResult.new(cvv_result_from(response))
511
527
  )
@@ -552,11 +568,10 @@ module ActiveMerchant #:nodoc:
552
568
  response['refusalReason'] = 'Received unexpected 3DS authentication response. Use the execute_threed and/or threed_dynamic options to initiate a proper 3DS flow.'
553
569
  return false
554
570
  end
555
-
556
571
  case action.to_s
557
572
  when 'authorise', 'authorise3d'
558
573
  %w[Authorised Received RedirectShopper].include?(response['resultCode'])
559
- when 'capture', 'refund', 'cancel'
574
+ when 'capture', 'refund', 'cancel', 'cancelOrRefund'
560
575
  response['response'] == "[#{action}-received]"
561
576
  when 'adjustAuthorisation'
562
577
  response['response'] == 'Authorised' || response['response'] == '[adjustAuthorisation-received]'
@@ -564,6 +579,8 @@ module ActiveMerchant #:nodoc:
564
579
  response['result'] == 'Success'
565
580
  when 'disable'
566
581
  response['response'] == '[detail-successfully-disabled]'
582
+ when 'refundWithData'
583
+ response['resultCode'] == 'Received'
567
584
  else
568
585
  false
569
586
  end
@@ -572,7 +589,7 @@ module ActiveMerchant #:nodoc:
572
589
  def message_from(action, response)
573
590
  return authorize_message_from(response) if %w(authorise authorise3d authorise3ds2).include?(action.to_s)
574
591
 
575
- response['response'] || response['message'] || response['result']
592
+ response['response'] || response['message'] || response['result'] || response['resultCode']
576
593
  end
577
594
 
578
595
  def authorize_message_from(response)
@@ -607,6 +624,10 @@ module ActiveMerchant #:nodoc:
607
624
  STANDARD_ERROR_CODE_MAPPING[response['errorCode']]
608
625
  end
609
626
 
627
+ def network_transaction_id_from(response)
628
+ response.dig('additionalData', 'networkTxReference')
629
+ end
630
+
610
631
  def add_browser_info(browser_info, post)
611
632
  return unless browser_info
612
633