minfraud 2.9.0 → 2.11.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 (49) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +69 -0
  3. data/LICENSE.txt +1 -1
  4. data/README.md +46 -35
  5. data/lib/minfraud/assessments.rb +1 -1
  6. data/lib/minfraud/components/account.rb +1 -1
  7. data/lib/minfraud/components/addressable.rb +46 -11
  8. data/lib/minfraud/components/base.rb +11 -13
  9. data/lib/minfraud/components/billing.rb +1 -1
  10. data/lib/minfraud/components/credit_card.rb +8 -7
  11. data/lib/minfraud/components/custom_inputs.rb +1 -1
  12. data/lib/minfraud/components/device.rb +9 -1
  13. data/lib/minfraud/components/email.rb +28 -4
  14. data/lib/minfraud/components/event.rb +3 -3
  15. data/lib/minfraud/components/order.rb +2 -2
  16. data/lib/minfraud/components/payment.rb +6 -1
  17. data/lib/minfraud/components/report/transaction.rb +8 -4
  18. data/lib/minfraud/components/shipping.rb +1 -3
  19. data/lib/minfraud/components/shopping_cart.rb +1 -1
  20. data/lib/minfraud/components/shopping_cart_item.rb +4 -4
  21. data/lib/minfraud/enum.rb +33 -9
  22. data/lib/minfraud/http_service/response.rb +4 -2
  23. data/lib/minfraud/model/abstract.rb +3 -0
  24. data/lib/minfraud/model/device.rb +1 -1
  25. data/lib/minfraud/model/email.rb +2 -1
  26. data/lib/minfraud/model/email_domain.rb +3 -2
  27. data/lib/minfraud/model/email_domain_visit.rb +10 -7
  28. data/lib/minfraud/model/factors.rb +1 -1
  29. data/lib/minfraud/model/geoip2_location.rb +1 -1
  30. data/lib/minfraud/model/insights.rb +1 -1
  31. data/lib/minfraud/model/ip_address.rb +1 -1
  32. data/lib/minfraud/model/reason.rb +1 -1
  33. data/lib/minfraud/model/risk_score_reason.rb +2 -2
  34. data/lib/minfraud/model/shipping_address.rb +3 -1
  35. data/lib/minfraud/model/warning.rb +13 -2
  36. data/lib/minfraud/report.rb +1 -1
  37. data/lib/minfraud/validates.rb +223 -32
  38. data/lib/minfraud/version.rb +1 -1
  39. metadata +20 -19
  40. data/.rspec +0 -2
  41. data/.rubocop.yml +0 -113
  42. data/CLAUDE.md +0 -443
  43. data/CODE_OF_CONDUCT.md +0 -49
  44. data/Gemfile +0 -5
  45. data/README.dev.md +0 -28
  46. data/Rakefile +0 -12
  47. data/bin/console +0 -15
  48. data/bin/setup +0 -8
  49. data/minfraud.gemspec +0 -42
@@ -4,7 +4,7 @@ module Minfraud
4
4
  module Components
5
5
  # Payment corresponds to the payment object of a minFraud request.
6
6
  #
7
- # @see https://dev.maxmind.com/minfraud/api-documentation/requests?lang=en#schema--request--payment
7
+ # @see https://dev.maxmind.com/minfraud/api-documentation/requests/?lang=en#schema--request--payment
8
8
  class Payment < Base
9
9
  include ::Minfraud::Enum
10
10
  include Minfraud::Validates
@@ -48,6 +48,7 @@ module Minfraud
48
48
  aps_payments
49
49
  authorizenet
50
50
  balanced
51
+ banquest
51
52
  beanstream
52
53
  bluepay
53
54
  bluesnap
@@ -96,6 +97,7 @@ module Minfraud
96
97
  epx
97
98
  eway
98
99
  exact
100
+ fat_zebra
99
101
  first_atlantic_commerce
100
102
  first_data
101
103
  fiserv
@@ -167,6 +169,7 @@ module Minfraud
167
169
  rede
168
170
  redpagos
169
171
  rewardspay
172
+ ryft
170
173
  safecharge
171
174
  sagepay
172
175
  securepay
@@ -179,6 +182,7 @@ module Minfraud
179
182
  solidtrust_pay
180
183
  sps_decidir
181
184
  stripe
185
+ summit_payments
182
186
  synapsefi
183
187
  systempay
184
188
  telerecargas
@@ -198,6 +202,7 @@ module Minfraud
198
202
  windcave
199
203
  wirecard
200
204
  worldpay
205
+ yaadpay
201
206
  ]
202
207
 
203
208
  # The authorization outcome from the payment processor. If the
@@ -2,10 +2,11 @@
2
2
 
3
3
  module Minfraud
4
4
  module Components
5
+ # Components for the Report Transaction API.
5
6
  module Report
6
7
  # Contains the fields used in the Report Transaction API.
7
8
  #
8
- # @see https://dev.maxmind.com/minfraud/report-a-transaction?lang=en
9
+ # @see https://dev.maxmind.com/minfraud/report-a-transaction/?lang=en
9
10
  class Transaction < Base
10
11
  include ::Minfraud::Enum
11
12
  include ::Minfraud::Validates
@@ -22,13 +23,13 @@ module Minfraud
22
23
  # A symbol indicating the likelihood that a transaction may be
23
24
  # fraudulent.
24
25
  #
25
- # This may be one of +:chargeback+, +:not_fraud+, +:spam_or_abuse+, or
26
- # +:suspected_fraud+.
26
+ # This may be one of +:chargeback+, +:clear+ (to retract a previous
27
+ # report), +:not_fraud+, +:spam_or_abuse+, or +:suspected_fraud+.
27
28
  #
28
29
  # @!attribute tag
29
30
  #
30
31
  # @return [Symbol, nil]
31
- enum_accessor :tag, %i[chargeback not_fraud spam_or_abuse suspected_fraud]
32
+ enum_accessor :tag, %i[chargeback clear not_fraud spam_or_abuse suspected_fraud]
32
33
 
33
34
  # A string which is provided by your payment processor indicating the
34
35
  # reason for the chargeback.
@@ -93,6 +94,9 @@ module Minfraud
93
94
  validate_ip('ip_address', @ip_address)
94
95
  validate_string('maxmind_id', 8, @maxmind_id)
95
96
  validate_uuid('minfraud_id', @minfraud_id)
97
+ validate_not_boolean('chargeback_code', @chargeback_code)
98
+ validate_not_boolean('notes', @notes)
99
+ validate_not_boolean('transaction_id', @transaction_id)
96
100
 
97
101
  if ip_address.nil? &&
98
102
  (minfraud_id.nil? || empty_uuid?(minfraud_id)) &&
@@ -4,10 +4,8 @@ module Minfraud
4
4
  module Components
5
5
  # Shipping corresponds to the shipping object of a minFraud request.
6
6
  #
7
- # @see https://dev.maxmind.com/minfraud/api-documentation/requests?lang=en#schema--request--shipping
7
+ # @see https://dev.maxmind.com/minfraud/api-documentation/requests/?lang=en#schema--request--shipping
8
8
  class Shipping < Addressable
9
- include ::Minfraud::Enum
10
-
11
9
  # The shipping delivery speed for the order. Must be one of +:same_day+,
12
10
  # +:overnight+, +:expedited+, or +:standard+.
13
11
  #
@@ -5,7 +5,7 @@ module Minfraud
5
5
  # ShoppingCart corresponds to the shopping_cart object of a minFraud
6
6
  # request.
7
7
  #
8
- # @see https://dev.maxmind.com/minfraud/api-documentation/requests?lang=en#schema--request--shopping-cart
8
+ # @see https://dev.maxmind.com/minfraud/api-documentation/requests/?lang=en#schema--request--shopping-cart
9
9
  class ShoppingCart < Base
10
10
  # An array of Minfraud::Components::ShoppingCartItem instances.
11
11
  #
@@ -5,20 +5,20 @@ module Minfraud
5
5
  # ShoppingCartItem corresponds to objects in the shopping_cart object
6
6
  # of a minFraud request.
7
7
  #
8
- # @see https://dev.maxmind.com/minfraud/api-documentation/requests?lang=en#schema--request--shopping-cart--item
8
+ # @see https://dev.maxmind.com/minfraud/api-documentation/requests/?lang=en#schema--request--shopping-cart
9
9
  class ShoppingCartItem < Base
10
10
  include Minfraud::Validates
11
11
 
12
12
  # The category of the item. This can also be a hashed value; see link.
13
13
  #
14
- # @see https://dev.maxmind.com/minfraud/api-documentation/requests?lang=en#schema--request--shopping-cart--item__category
14
+ # @see https://dev.maxmind.com/minfraud/api-documentation/requests/?lang=en#schema--request--shopping-cart__category
15
15
  #
16
16
  # @return [String, nil]
17
17
  attr_accessor :category
18
18
 
19
19
  # The internal ID of the item. This can also be a hashed value; see link.
20
20
  #
21
- # @see https://dev.maxmind.com/minfraud/api-documentation/requests?lang=en#schema--request--shopping-cart--item__item_id
21
+ # @see https://dev.maxmind.com/minfraud/api-documentation/requests/?lang=en#schema--request--shopping-cart__item_id
22
22
  #
23
23
  # @return [String, nil]
24
24
  attr_accessor :item_id
@@ -31,7 +31,7 @@ module Minfraud
31
31
 
32
32
  # The per-unit price of this item in the shopping cart. This should use
33
33
  # the same currency as the order currency. The value must be at least 0
34
- # and at most 1e14 - 1.
34
+ # and at most 1e13 - 1.
35
35
  #
36
36
  # @return [Float, nil]
37
37
  attr_accessor :price
data/lib/minfraud/enum.rb CHANGED
@@ -3,6 +3,12 @@
3
3
  module Minfraud
4
4
  # Enum provides helpers for working with attributes with enumerated types.
5
5
  module Enum
6
+ # Hook method called when the module is included into a class.
7
+ # Extends the class with ClassMethods.
8
+ #
9
+ # @param base [Class] The class including this module.
10
+ #
11
+ # @return [Class] The base class.
6
12
  def self.included(base)
7
13
  base.extend(ClassMethods)
8
14
  end
@@ -11,14 +17,22 @@ module Minfraud
11
17
  # types.
12
18
  module ClassMethods
13
19
  # Returns a hash in the following format: attribute_name =>
14
- # permitted_values
20
+ # permitted_values. It includes the attributes declared on parent
21
+ # classes.
15
22
  #
16
23
  # @return [Hash]
17
24
  def mapping
18
25
  # rubocop:disable ThreadSafety/ClassInstanceVariable
19
- # This is a false positive - this is set during class definition and then only read
20
- @mapping ||= {}
26
+ # This is a false positive - this only reads the mapping that
27
+ # enum_accessor sets during class definition
28
+ declared = @declared_mapping || {}
21
29
  # rubocop:enable ThreadSafety/ClassInstanceVariable
30
+
31
+ if superclass.respond_to?(:mapping)
32
+ superclass.mapping.merge(declared)
33
+ else
34
+ declared.dup
35
+ end
22
36
  end
23
37
 
24
38
  # Create a set of methods for enum-like behavior of the attribute.
@@ -29,23 +43,33 @@ module Minfraud
29
43
  #
30
44
  # @return [nil]
31
45
  def enum_accessor(attribute, assignable_values)
32
- mapping[attribute] = assignable_values.map(&:intern)
46
+ values = assignable_values.map(&:intern).freeze
47
+ declared_mapping[attribute] = values
33
48
 
34
- self.class.instance_eval do
35
- define_method("#{attribute}_values") { mapping[attribute] }
36
- end
49
+ define_singleton_method("#{attribute}_values") { values }
37
50
 
38
51
  class_eval do
39
52
  define_method(attribute.to_s) { instance_variable_get("@#{attribute}") }
40
53
  define_method "#{attribute}=" do |value|
41
- raise NotEnumValueError, 'Value is not permitted' if value && !self.class.mapping[attribute].include?(value.intern)
54
+ value = value.intern if value.is_a?(String)
55
+ raise NotEnumValueError, 'Value is not permitted' if !value.nil? && !values.include?(value)
42
56
 
43
- instance_variable_set("@#{attribute}", value ? value.intern : nil)
57
+ instance_variable_set("@#{attribute}", value)
44
58
  end
45
59
  end
46
60
 
47
61
  nil
48
62
  end
63
+
64
+ private
65
+
66
+ def declared_mapping
67
+ # rubocop:disable ThreadSafety/ClassInstanceVariable
68
+ # This is a false positive - only enum_accessor calls this, during class
69
+ # definition
70
+ @declared_mapping ||= {}
71
+ # rubocop:enable ThreadSafety/ClassInstanceVariable
72
+ end
49
73
  end
50
74
  end
51
75
  end
@@ -7,18 +7,20 @@ require 'minfraud/model/insights'
7
7
  require 'minfraud/model/score'
8
8
 
9
9
  module Minfraud
10
+ # HTTPService contains classes for handling HTTP communication with the
11
+ # minFraud web services.
10
12
  module HTTPService
11
13
  # Response class for HTTP requests.
12
14
  class Response
13
15
  # Response HTTP status code.
14
16
  #
15
- # @return [Fixnum, nil]
17
+ # @return [Integer, nil]
16
18
  attr_reader :status
17
19
 
18
20
  # Response model.
19
21
  #
20
22
  # @return [Minfraud::Model::Score, Minfraud::Model::Insights,
21
- # Minfraud::Model::Factors, nil]
23
+ # Minfraud::Model::Factors, Minfraud::Model::Error, nil]
22
24
  attr_reader :body
23
25
 
24
26
  # @param endpoint [Symbol, nil] endpoint name, like :score.
@@ -1,6 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Minfraud
4
+ # Model contains classes for the minFraud response data. These classes
5
+ # represent the data returned by the Score, Insights, and Factors
6
+ # endpoints.
4
7
  module Model
5
8
  # @!visibility private
6
9
  class Abstract
@@ -8,7 +8,7 @@ module Minfraud
8
8
  #
9
9
  # In order to receive device output from minFraud Insights or minFraud
10
10
  # Factors, you must be using the Device Tracking Add-on
11
- # (https://dev.maxmind.com/minfraud/track-devices?lang=en).
11
+ # (https://dev.maxmind.com/minfraud/track-devices/?lang=en).
12
12
  class Device < Abstract
13
13
  # This number represents our confidence that the device_id refers to a
14
14
  # unique device as opposed to a cluster of similar devices. A confidence
@@ -14,7 +14,8 @@ module Minfraud
14
14
 
15
15
  # A date string (e.g. 2017-04-24) to identify the date an email address
16
16
  # was first seen by MaxMind. This is expressed using the ISO 8601 date
17
- # format.
17
+ # format YYYY-MM-DD. The earliest date that may be returned is January
18
+ # 1, 2008.
18
19
  #
19
20
  # @return [String, nil]
20
21
  attr_reader :first_seen
@@ -16,9 +16,10 @@ module Minfraud
16
16
  # @return [String, nil]
17
17
  attr_reader :classification
18
18
 
19
- # A date string (e.g. 2017-04-24) to identify the date an email domain
19
+ # A date string (e.g. 2019-01-01) to identify the date an email domain
20
20
  # was first seen by MaxMind. This is expressed using the ISO 8601 date
21
- # format.
21
+ # format YYYY-MM-DD. The earliest date that may be returned is January
22
+ # 1, 2019.
22
23
  #
23
24
  # @return [String, nil]
24
25
  attr_reader :first_seen
@@ -7,7 +7,9 @@ module Minfraud
7
7
  # Model containing information about an automated visit to the email
8
8
  # domain.
9
9
  class EmailDomainVisit < Abstract
10
- # Whether the domain redirects to another URL.
10
+ # This is true if the domain in the request has redirects (configured
11
+ # to automatically send visitors to another URL). Otherwise, this will
12
+ # be nil.
11
13
  #
12
14
  # @return [Boolean, nil]
13
15
  attr_reader :has_redirect
@@ -19,12 +21,13 @@ module Minfraud
19
21
  attr_reader :last_visited_on
20
22
 
21
23
  # The status of the domain. Possible values are:
22
- # * live - The domain is operational and serving content.
23
- # * dns_error - The domain has missing, expired, or misconfigured DNS.
24
- # * network_error - The domain is offline or unreachable.
25
- # * http_error - The domain is reachable, but has an application error.
26
- # * parked - The domain is reachable and in a parked state.
27
- # * pre_development - The domain is reachable and in a pre-development
24
+ # * live - The domain is reachable and serving content normally.
25
+ # * dns_error - The domain is missing, expired, or DNS is misconfigured.
26
+ # * network_error - The domain is offline, blocked, or unreachable.
27
+ # * http_error - The domain is reachable but the web application had a
28
+ # problem or denied the request.
29
+ # * parked - The domain is live and is in a parked state.
30
+ # * pre_development - The domain is live and is in a pre-development
28
31
  # state.
29
32
  #
30
33
  # @return [String, nil]
@@ -21,7 +21,7 @@ module Minfraud
21
21
  # that are used to calculate the overall risk score.
22
22
  #
23
23
  # @return [Minfraud::Model::Subscores]
24
- # @deprecated Use {::risk_score_reasons} instead.
24
+ # @deprecated Use {#risk_score_reasons} instead.
25
25
  attr_reader :subscores
26
26
 
27
27
  # @!visibility private
@@ -4,7 +4,7 @@ require 'maxmind/geoip2/record/location'
4
4
 
5
5
  module Minfraud
6
6
  module Model
7
- # Model of the GeoIP2 location information, including the local time.
7
+ # Model of the GeoIP location information, including the local time.
8
8
  class GeoIP2Location < MaxMind::GeoIP2::Record::Location
9
9
  # The date and time of the transaction in the time zone associated with
10
10
  # the IP address. The value is formatted according to RFC 3339. For
@@ -43,7 +43,7 @@ module Minfraud
43
43
  # @return [Minfraud::Model::Email]
44
44
  attr_reader :email
45
45
 
46
- # An object containing GeoIP2 and minFraud Insights information about the
46
+ # An object containing GeoIP and minFraud Insights information about the
47
47
  # geolocated IP address.
48
48
  #
49
49
  # @return [Minfraud::Model::IPAddress]
@@ -6,7 +6,7 @@ require 'minfraud/model/ip_risk_reason'
6
6
 
7
7
  module Minfraud
8
8
  module Model
9
- # Model containing GeoIP2 data and the risk for the IP address.
9
+ # Model containing GeoIP data and the risk for the IP address.
10
10
  class IPAddress < MaxMind::GeoIP2::Model::Insights
11
11
  # This field contains the risk associated with the IP address. The value
12
12
  # ranges from 0.01 to 99. A higher score indicates a higher risk.
@@ -8,7 +8,7 @@ module Minfraud
8
8
  #
9
9
  # This class provides both a machine-readable code and a human-readable
10
10
  # explanation of the reason for the risk score, see
11
- # https://dev.maxmind.com/minfraud/api-documentation/responses/schema--response--risk-score-reason--multiplier-reason.
11
+ # https://dev.maxmind.com/minfraud/api-documentation/responses/#schema--response--risk-score-reason--multiplier-reason.
12
12
  # Although more codes may be added in the future, the current codes are:
13
13
  #
14
14
  # * BROWSER_LANGUAGE - Riskiness of the browser user-agent and
@@ -8,8 +8,8 @@ module Minfraud
8
8
  class RiskScoreReason < Abstract
9
9
  # The factor by which the risk score is increased (if the value is greater than 1)
10
10
  # or decreased (if the value is less than 1) for given risk reason(s).
11
- # Multipliers greater than 1.5 and less than 0.66 are considered significant
12
- # and lead to risk reason(s) being present.
11
+ # Multipliers representing a significant percentage increase or decrease
12
+ # in the risk score lead to risk reason(s) being present.
13
13
  #
14
14
  # @return [Float]
15
15
  attr_reader :multiplier
@@ -6,7 +6,7 @@ module Minfraud
6
6
  module Model
7
7
  # Model containing information about the shipping address.
8
8
  class ShippingAddress < Address
9
- # The distance in kilometers from the shipping address to billing
9
+ # The distance in kilometers from the shipping address to the billing
10
10
  # address.
11
11
  #
12
12
  # @return [Integer, nil]
@@ -16,6 +16,8 @@ module Minfraud
16
16
  # with fraudulent transactions. The field is false when the address is
17
17
  # not associated with increased risk. The key will only be present when a
18
18
  # shipping address is provided.
19
+ #
20
+ # @return [Boolean, nil]
19
21
  attr_reader :is_high_risk
20
22
 
21
23
  # @!visibility private
@@ -17,19 +17,30 @@ module Minfraud
17
17
  # our database.
18
18
  # * BILLING_POSTAL_NOT_FOUND - the billing postal could not be found in our
19
19
  # database.
20
+ # * BILLING_REGION_NOT_FOUND - the billing region could not be found in our
21
+ # database.
22
+ # * EMAIL_ADDRESS_UNUSABLE - the email address entered is likely incorrect
23
+ # due to an integration issue. To avoid false positives, it has not been
24
+ # used in scoring.
20
25
  # * INPUT_INVALID - the value associated with the key does not meet the
21
26
  # required constraints, e.g., "United States" in a field that requires a
22
27
  # two-letter country code.
23
28
  # * INPUT_UNKNOWN - an unknown key was encountered in the request body.
29
+ # * IP_ADDRESS_INVALID - the IP address supplied is not a valid IPv4 or
30
+ # IPv6 address.
24
31
  # * IP_ADDRESS_NOT_FOUND - the IP address could not be geolocated.
25
- # * SHIPPING_COUNTRY_MISSING - shipping address information was provided
26
- # without providing a shipping country.
32
+ # * IP_ADDRESS_RESERVED - the IP address supplied is in a reserved
33
+ # network.
27
34
  # * SHIPPING_CITY_NOT_FOUND - the shipping city could not be found in our
28
35
  # database.
36
+ # * SHIPPING_COUNTRY_MISSING - shipping address information was provided
37
+ # without providing a shipping country.
29
38
  # * SHIPPING_COUNTRY_NOT_FOUND - the shipping country could not be found in
30
39
  # our database.
31
40
  # * SHIPPING_POSTAL_NOT_FOUND - the shipping postal could not be found in
32
41
  # our database.
42
+ # * SHIPPING_REGION_NOT_FOUND - the shipping region could not be found in
43
+ # our database.
33
44
  class Warning < Abstract
34
45
  # This value is a machine-readable code identifying the warning.
35
46
  #
@@ -3,7 +3,7 @@
3
3
  module Minfraud
4
4
  # Report is used to perform minFraud Report Transaction API requests.
5
5
  #
6
- # @see https://dev.maxmind.com/minfraud/report-a-transaction?lang=en
6
+ # @see https://dev.maxmind.com/minfraud/report-a-transaction/?lang=en
7
7
  class Report
8
8
  # The Report::Transaction component.
9
9
  #