minfraud 1.0.4 → 2.4.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.
- checksums.yaml +5 -5
- data/.github/dependabot.yml +11 -0
- data/.github/workflows/release.yml +28 -0
- data/.github/workflows/rubocop.yml +18 -0
- data/.github/workflows/test.yml +36 -0
- data/.gitignore +2 -0
- data/.rubocop.yml +90 -0
- data/CHANGELOG.md +197 -4
- data/CODE_OF_CONDUCT.md +4 -4
- data/Gemfile +2 -2
- data/LICENSE.txt +2 -1
- data/README.dev.md +4 -0
- data/README.md +255 -58
- data/Rakefile +9 -3
- data/bin/console +4 -3
- data/dev-bin/release.sh +59 -0
- data/lib/minfraud/assessments.rb +127 -53
- data/lib/minfraud/components/account.rb +31 -9
- data/lib/minfraud/components/addressable.rb +73 -26
- data/lib/minfraud/components/base.rb +26 -14
- data/lib/minfraud/components/billing.rb +5 -0
- data/lib/minfraud/components/credit_card.rb +117 -29
- data/lib/minfraud/components/custom_inputs.rb +25 -0
- data/lib/minfraud/components/device.rb +51 -10
- data/lib/minfraud/components/email.rb +120 -9
- data/lib/minfraud/components/event.rb +60 -13
- data/lib/minfraud/components/order.rb +59 -22
- data/lib/minfraud/components/payment.rb +192 -22
- data/lib/minfraud/components/report/transaction.rb +80 -0
- data/lib/minfraud/components/shipping.rb +15 -6
- data/lib/minfraud/components/shopping_cart.rb +19 -12
- data/lib/minfraud/components/shopping_cart_item.rb +42 -13
- data/lib/minfraud/enum.rb +22 -8
- data/lib/minfraud/error_handler.rb +45 -18
- data/lib/minfraud/errors.rb +22 -2
- data/lib/minfraud/http_service/response.rb +61 -17
- data/lib/minfraud/model/abstract.rb +20 -0
- data/lib/minfraud/model/address.rb +52 -0
- data/lib/minfraud/model/billing_address.rb +11 -0
- data/lib/minfraud/model/credit_card.rb +75 -0
- data/lib/minfraud/model/device.rb +51 -0
- data/lib/minfraud/model/disposition.rb +42 -0
- data/lib/minfraud/model/email.rb +54 -0
- data/lib/minfraud/model/email_domain.rb +24 -0
- data/lib/minfraud/model/error.rb +28 -0
- data/lib/minfraud/model/factors.rb +24 -0
- data/lib/minfraud/model/geoip2_location.rb +25 -0
- data/lib/minfraud/model/insights.rb +68 -0
- data/lib/minfraud/model/ip_address.rb +58 -0
- data/lib/minfraud/model/ip_risk_reason.rb +48 -0
- data/lib/minfraud/model/issuer.rb +49 -0
- data/lib/minfraud/model/score.rb +76 -0
- data/lib/minfraud/model/score_ip_address.rb +23 -0
- data/lib/minfraud/model/shipping_address.rb +30 -0
- data/lib/minfraud/model/subscores.rb +156 -0
- data/lib/minfraud/model/warning.rb +63 -0
- data/lib/minfraud/report.rb +66 -0
- data/lib/minfraud/resolver.rb +25 -16
- data/lib/minfraud/validates.rb +187 -0
- data/lib/minfraud/version.rb +4 -1
- data/lib/minfraud.rb +55 -16
- data/minfraud.gemspec +27 -18
- metadata +107 -36
- data/.travis.yml +0 -5
- data/lib/minfraud/http_service/request.rb +0 -37
- data/lib/minfraud/http_service.rb +0 -31
@@ -1,27 +1,34 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Minfraud
|
2
4
|
module Components
|
5
|
+
# ShoppingCart corresponds to the shopping_cart object of a minFraud
|
6
|
+
# request.
|
7
|
+
#
|
8
|
+
# @see https://dev.maxmind.com/minfraud/api-documentation/requests?lang=en#schema--request--shopping-cart
|
3
9
|
class ShoppingCart < Base
|
4
|
-
#
|
5
|
-
#
|
6
|
-
|
10
|
+
# An array of Minfraud::Components::ShoppingCartItem instances.
|
11
|
+
#
|
12
|
+
# @return [Array<Minfraud::Components::ShoppingCartItem>]
|
7
13
|
attr_accessor :items
|
8
|
-
|
9
|
-
# @param
|
10
|
-
#
|
11
|
-
|
14
|
+
|
15
|
+
# @param params [Array] Array of shopping cart items. You may provide
|
16
|
+
# each item as either a Hash where each key is a symbol corresponding
|
17
|
+
# to an item's field, or as a Minfraud:::Components::ShoppingCartItem
|
18
|
+
# object.
|
19
|
+
def initialize(params = [])
|
12
20
|
@items = params.map(&method(:resolve))
|
13
21
|
end
|
14
22
|
|
15
|
-
#
|
16
|
-
|
23
|
+
# A JSON representation of Minfraud::Components::ShoppingCart items.
|
24
|
+
#
|
25
|
+
# @return [Array]
|
26
|
+
def to_json(*_args)
|
17
27
|
@items.map(&:to_json)
|
18
28
|
end
|
19
29
|
|
20
30
|
private
|
21
31
|
|
22
|
-
# @param [Hash] params hash of parameters for Minfraud::Components::ShoppingCartItem
|
23
|
-
# or Minfraud::Components::ShoppingCartItem instance
|
24
|
-
# @return [Minfraud::Components::ShoppingCart] ShoppingCart instance
|
25
32
|
def resolve(params)
|
26
33
|
params.is_a?(ShoppingCartItem) ? params : ShoppingCartItem.new(params)
|
27
34
|
end
|
@@ -1,33 +1,62 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Minfraud
|
2
4
|
module Components
|
5
|
+
# ShoppingCartItem corresponds to objects in the shopping_cart object
|
6
|
+
# of a minFraud request.
|
7
|
+
#
|
8
|
+
# @see https://dev.maxmind.com/minfraud/api-documentation/requests?lang=en#schema--request--shopping-cart--item
|
3
9
|
class ShoppingCartItem < Base
|
4
|
-
|
5
|
-
|
10
|
+
include Minfraud::Validates
|
11
|
+
|
12
|
+
# The category of the item. This can also be a hashed value; see link.
|
13
|
+
#
|
14
|
+
# @see https://dev.maxmind.com/minfraud/api-documentation/requests?lang=en#schema--request--shopping-cart--item__category
|
15
|
+
#
|
16
|
+
# @return [String, nil]
|
6
17
|
attr_accessor :category
|
7
18
|
|
8
|
-
#
|
9
|
-
#
|
19
|
+
# The internal ID of the item. This can also be a hashed value; see link.
|
20
|
+
#
|
21
|
+
# @see https://dev.maxmind.com/minfraud/api-documentation/requests?lang=en#schema--request--shopping-cart--item__item_id
|
22
|
+
#
|
23
|
+
# @return [String, nil]
|
10
24
|
attr_accessor :item_id
|
11
25
|
|
12
|
-
#
|
13
|
-
#
|
26
|
+
# The quantity of the item in the shopping cart. The value must be at
|
27
|
+
# least 0, at most 10^13-1, and have no fractional part.
|
28
|
+
#
|
29
|
+
# @return [Integer, nil]
|
14
30
|
attr_accessor :quantity
|
15
31
|
|
16
|
-
#
|
17
|
-
#
|
32
|
+
# The per-unit price of this item in the shopping cart. This should use
|
33
|
+
# the same currency as the order currency. The value must be at least 0
|
34
|
+
# and at most 1e14 - 1.
|
35
|
+
#
|
36
|
+
# @return [Float, nil]
|
18
37
|
attr_accessor :price
|
19
38
|
|
20
|
-
#
|
21
|
-
#
|
22
|
-
# @return [Minfraud::Components::ShoppingCartItem] ShoppingCartItem instance
|
39
|
+
# @param params [Hash] Hash of parameters. Each key/value should
|
40
|
+
# correspond to one of the available attributes.
|
23
41
|
def initialize(params = {})
|
24
42
|
@category = params[:category]
|
25
43
|
@item_id = params[:item_id]
|
26
44
|
@quantity = params[:quantity]
|
27
45
|
@price = params[:price]
|
46
|
+
|
47
|
+
validate
|
48
|
+
end
|
49
|
+
|
50
|
+
private
|
51
|
+
|
52
|
+
def validate
|
53
|
+
return if !Minfraud.enable_validation
|
54
|
+
|
55
|
+
validate_string('category', 255, @category)
|
56
|
+
validate_string('item_id', 255, @item_id)
|
57
|
+
validate_nonnegative_integer('quantity', @quantity)
|
58
|
+
validate_nonnegative_number('price', @price)
|
28
59
|
end
|
29
60
|
end
|
30
61
|
end
|
31
62
|
end
|
32
|
-
|
33
|
-
|
data/lib/minfraud/enum.rb
CHANGED
@@ -1,19 +1,30 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Minfraud
|
4
|
+
# Enum provides helpers for working with attributes with enumerated types.
|
2
5
|
module Enum
|
3
6
|
def self.included(base)
|
4
7
|
base.extend(ClassMethods)
|
5
8
|
end
|
6
9
|
|
10
|
+
# ClassMethods provides helpers for working with attributes with enumerated
|
11
|
+
# types.
|
7
12
|
module ClassMethods
|
8
|
-
# Returns a hash
|
9
|
-
#
|
13
|
+
# Returns a hash in the following format: attribute_name =>
|
14
|
+
# permitted_values
|
15
|
+
#
|
16
|
+
# @return [Hash]
|
10
17
|
def mapping
|
11
18
|
@mapping ||= {}
|
12
19
|
end
|
13
20
|
|
14
|
-
#
|
15
|
-
#
|
16
|
-
# @param [
|
21
|
+
# Create a set of methods for enum-like behavior of the attribute.
|
22
|
+
#
|
23
|
+
# @param attribute [Symbol] The attribute name.
|
24
|
+
#
|
25
|
+
# @param assignable_values [Array] The set of permitted values.
|
26
|
+
#
|
27
|
+
# @return [nil]
|
17
28
|
def enum_accessor(attribute, assignable_values)
|
18
29
|
mapping[attribute] = assignable_values.map(&:intern)
|
19
30
|
|
@@ -21,13 +32,16 @@ module Minfraud
|
|
21
32
|
define_method("#{attribute}_values") { mapping[attribute] }
|
22
33
|
end
|
23
34
|
|
24
|
-
|
25
|
-
define_method(
|
35
|
+
class_eval do
|
36
|
+
define_method(attribute.to_s) { instance_variable_get("@#{attribute}") }
|
26
37
|
define_method "#{attribute}=" do |value|
|
27
|
-
raise NotEnumValueError,
|
38
|
+
raise NotEnumValueError, 'Value is not permitted' if value && !self.class.mapping[attribute].include?(value.intern)
|
39
|
+
|
28
40
|
instance_variable_set("@#{attribute}", value ? value.intern : nil)
|
29
41
|
end
|
30
42
|
end
|
43
|
+
|
44
|
+
nil
|
31
45
|
end
|
32
46
|
end
|
33
47
|
end
|
@@ -1,37 +1,64 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Minfraud
|
4
|
+
# ErrorHandler provides a method to raise exceptions on errors.
|
2
5
|
module ErrorHandler
|
3
6
|
class << self
|
4
|
-
#
|
5
|
-
#
|
6
|
-
#
|
7
|
-
|
8
|
-
|
7
|
+
# Return the response if the HTTP status code is 2xx. Otherwise raise
|
8
|
+
# an error.
|
9
|
+
#
|
10
|
+
# @param response [Minfraud::HTTPService::Response]
|
11
|
+
#
|
12
|
+
# @return [Minfraud::HTTPService::Response]
|
13
|
+
#
|
14
|
+
# @raise [Minfraud::AuthorizationError] If there was an authentication
|
15
|
+
# problem.
|
16
|
+
#
|
17
|
+
# @raise [Minfraud::ClientError] If there was a critical problem with one
|
18
|
+
# of your inputs.
|
19
|
+
#
|
20
|
+
# @raise [Minfraud::ServerError] If the server reported an error of some
|
21
|
+
# kind.
|
22
|
+
def examine(response)
|
23
|
+
return response if response.status > 199 && response.status < 300
|
9
24
|
|
10
|
-
raise
|
25
|
+
raise(*STATUS_CODES.fetch(response.code, [ServerError, 'Server error']))
|
11
26
|
end
|
12
27
|
|
13
|
-
#
|
28
|
+
# @!visibility private
|
14
29
|
STATUS_CODES = {
|
15
|
-
|
16
|
-
ClientError, '
|
30
|
+
JSON_INVALID: [
|
31
|
+
ClientError, 'JSON body cannot be decoded'
|
17
32
|
],
|
18
|
-
|
19
|
-
ClientError,
|
33
|
+
MAXMIND_ID_INVALID: [
|
34
|
+
ClientError, 'You have not supplied a valid maxmind_id'
|
20
35
|
],
|
21
|
-
|
22
|
-
ClientError, 'You have supplied
|
36
|
+
MINFRAUD_ID_INVALID: [
|
37
|
+
ClientError, 'You have not supplied a valid minfraud_id'
|
23
38
|
],
|
24
|
-
|
25
|
-
ClientError, '
|
39
|
+
PARAMETER_UNKNOWN: [
|
40
|
+
ClientError, 'You have supplied an unknown parameter'
|
41
|
+
],
|
42
|
+
REQUEST_INVALID: [
|
43
|
+
ClientError, 'The request did not contain any valid input values.'
|
44
|
+
],
|
45
|
+
TAG_REQUIRED: [
|
46
|
+
ClientError, 'You have not supplied a tag, which is a required field'
|
47
|
+
],
|
48
|
+
TAG_INVALID: [
|
49
|
+
ClientError, 'You have not supplied a valid tag'
|
50
|
+
],
|
51
|
+
ACCOUNT_ID_REQUIRED: [
|
52
|
+
AuthorizationError, 'You have not supplied a account ID'
|
26
53
|
],
|
27
54
|
AUTHORIZATION_INVALID: [
|
28
|
-
AuthorizationError, 'Invalid license key and / or
|
55
|
+
AuthorizationError, 'Invalid license key and / or account ID'
|
29
56
|
],
|
30
57
|
LICENSE_KEY_REQUIRED: [
|
31
58
|
AuthorizationError, 'You have not supplied a license key'
|
32
59
|
],
|
33
60
|
USER_ID_REQUIRED: [
|
34
|
-
AuthorizationError, 'You have not supplied a
|
61
|
+
AuthorizationError, 'You have not supplied a account id'
|
35
62
|
],
|
36
63
|
INSUFFICIENT_FUNDS: [
|
37
64
|
ClientError, 'The license key you have provided does not have a sufficient funds to use this service'
|
@@ -39,7 +66,7 @@ module Minfraud
|
|
39
66
|
PERMISSION_REQUIRED: [
|
40
67
|
ClientError, 'You do not have permission to use this service'
|
41
68
|
]
|
42
|
-
}
|
69
|
+
}.freeze
|
43
70
|
end
|
44
71
|
end
|
45
72
|
end
|
data/lib/minfraud/errors.rb
CHANGED
@@ -1,10 +1,30 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Minfraud
|
2
|
-
#
|
3
|
-
class BaseError
|
4
|
+
# The base error class for Minfraud exceptions.
|
5
|
+
class BaseError < StandardError; end
|
6
|
+
|
7
|
+
# An error indicating the input value is not valid.
|
8
|
+
class InvalidInputError < BaseError; end
|
4
9
|
|
10
|
+
# An error indicating the value is not valid for the enumerated type.
|
5
11
|
class NotEnumValueError < BaseError; end
|
12
|
+
|
13
|
+
# An error indicating the field is not recognized.
|
6
14
|
class RequestFormatError < BaseError; end
|
15
|
+
|
16
|
+
# An error indicating minFraud cannot serve your request as there is a
|
17
|
+
# problem on the client side.
|
18
|
+
#
|
19
|
+
# For example, this may happen if there is a problem with the format or
|
20
|
+
# contents of your request, if you lack funds to use the service, or if you
|
21
|
+
# don't have permission to use the service.
|
7
22
|
class ClientError < BaseError; end
|
23
|
+
|
24
|
+
# An error indicating there is a problem with authorization or
|
25
|
+
# authentication.
|
8
26
|
class AuthorizationError < BaseError; end
|
27
|
+
|
28
|
+
# An error indicating the server had an error handling the request.
|
9
29
|
class ServerError < BaseError; end
|
10
30
|
end
|
@@ -1,32 +1,76 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'json'
|
4
|
+
require 'minfraud/model/error'
|
5
|
+
require 'minfraud/model/factors'
|
6
|
+
require 'minfraud/model/insights'
|
7
|
+
require 'minfraud/model/score'
|
8
|
+
|
1
9
|
module Minfraud
|
2
10
|
module HTTPService
|
11
|
+
# Response class for HTTP requests.
|
3
12
|
class Response
|
4
|
-
#
|
5
|
-
#
|
13
|
+
# Response HTTP status code.
|
14
|
+
#
|
15
|
+
# @return [Fixnum, nil]
|
6
16
|
attr_reader :status
|
7
17
|
|
8
|
-
#
|
9
|
-
#
|
18
|
+
# Response model.
|
19
|
+
#
|
20
|
+
# @return [Minfraud::Model::Score, Minfraud::Model::Insights,
|
21
|
+
# Minfraud::Model::Factors, nil]
|
10
22
|
attr_reader :body
|
11
23
|
|
12
|
-
# @
|
13
|
-
#
|
14
|
-
|
15
|
-
|
16
|
-
#
|
17
|
-
#
|
18
|
-
# @
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
@
|
24
|
+
# @param endpoint [Symbol, nil] endpoint name, like :score.
|
25
|
+
#
|
26
|
+
# @param locales [Array<String>, nil] locales, like ["en"].
|
27
|
+
#
|
28
|
+
# @param response [HTTP::Response] the response object.
|
29
|
+
#
|
30
|
+
# @param body [String] the response body.
|
31
|
+
#
|
32
|
+
# @raise [JSON::ParserError] if there was invalid JSON in the response.
|
33
|
+
def initialize(endpoint, locales, response, body)
|
34
|
+
@status = response.code
|
35
|
+
|
36
|
+
@body = make_body(
|
37
|
+
endpoint,
|
38
|
+
locales,
|
39
|
+
response,
|
40
|
+
body,
|
41
|
+
)
|
23
42
|
end
|
24
43
|
|
25
|
-
#
|
26
|
-
#
|
44
|
+
# Return the minFraud-specific response code.
|
45
|
+
#
|
46
|
+
# @return [Symbol, nil]
|
27
47
|
def code
|
48
|
+
return nil if body.nil?
|
49
|
+
|
28
50
|
body.code.intern if body.respond_to?(:code) && body.code
|
29
51
|
end
|
52
|
+
|
53
|
+
private
|
54
|
+
|
55
|
+
def make_body(endpoint, locales, response, body)
|
56
|
+
if !response.mime_type || !response.mime_type.match(/json/i)
|
57
|
+
return nil
|
58
|
+
end
|
59
|
+
|
60
|
+
h = JSON.parse(body)
|
61
|
+
|
62
|
+
if @status != 200
|
63
|
+
return Minfraud::Model::Error.new(h)
|
64
|
+
end
|
65
|
+
|
66
|
+
ENDPOINT_TO_CLASS[endpoint].new(h, locales)
|
67
|
+
end
|
68
|
+
|
69
|
+
ENDPOINT_TO_CLASS = {
|
70
|
+
factors: Minfraud::Model::Factors,
|
71
|
+
insights: Minfraud::Model::Insights,
|
72
|
+
score: Minfraud::Model::Score
|
73
|
+
}.freeze
|
30
74
|
end
|
31
75
|
end
|
32
76
|
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Minfraud
|
4
|
+
module Model
|
5
|
+
# @!visibility private
|
6
|
+
class Abstract
|
7
|
+
def initialize(record)
|
8
|
+
@record = record
|
9
|
+
end
|
10
|
+
|
11
|
+
protected
|
12
|
+
|
13
|
+
def get(key)
|
14
|
+
return nil if @record.nil? || !@record.key?(key)
|
15
|
+
|
16
|
+
@record[key]
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'minfraud/model/abstract'
|
4
|
+
|
5
|
+
module Minfraud
|
6
|
+
module Model
|
7
|
+
# Abstract model for a postal address.
|
8
|
+
class Address < Abstract
|
9
|
+
# The distance in kilometers from the address to the IP location.
|
10
|
+
#
|
11
|
+
# @return [Integer, nil]
|
12
|
+
attr_reader :distance_to_ip_location
|
13
|
+
|
14
|
+
# This property is true if the address is in the IP country. The property
|
15
|
+
# is false when the address is not in the IP country. If the address
|
16
|
+
# could not be parsed or was not provided or if the IP address could not
|
17
|
+
# be geolocated, the property will be nil.
|
18
|
+
#
|
19
|
+
# @return [Boolean, nil]
|
20
|
+
attr_reader :is_in_ip_country
|
21
|
+
|
22
|
+
# This property is true if the postal code provided with the address is
|
23
|
+
# in the city for the address. The property is false when the postal code
|
24
|
+
# is not in the city. If the address was not provided or could not be
|
25
|
+
# parsed, the property will be nil.
|
26
|
+
#
|
27
|
+
# @return [Boolean, nil]
|
28
|
+
attr_reader :is_postal_in_city
|
29
|
+
|
30
|
+
# The latitude associated with the address.
|
31
|
+
#
|
32
|
+
# @return [Float, nil]
|
33
|
+
attr_reader :latitude
|
34
|
+
|
35
|
+
# The longitude associated with the address.
|
36
|
+
#
|
37
|
+
# @return [Float, nil]
|
38
|
+
attr_reader :longitude
|
39
|
+
|
40
|
+
# @!visibility private
|
41
|
+
def initialize(record)
|
42
|
+
super(record)
|
43
|
+
|
44
|
+
@distance_to_ip_location = get('distance_to_ip_location')
|
45
|
+
@is_in_ip_country = get('is_in_ip_country')
|
46
|
+
@is_postal_in_city = get('is_postal_in_city')
|
47
|
+
@latitude = get('latitude')
|
48
|
+
@longitude = get('longitude')
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,75 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'minfraud/model/abstract'
|
4
|
+
require 'minfraud/model/issuer'
|
5
|
+
|
6
|
+
module Minfraud
|
7
|
+
module Model
|
8
|
+
# Model with details about the credit card used.
|
9
|
+
class CreditCard < Abstract
|
10
|
+
# The card brand, such as "Visa", "Discover", "American Express", etc.
|
11
|
+
#
|
12
|
+
# @return [String, nil]
|
13
|
+
attr_reader :brand
|
14
|
+
|
15
|
+
# This property contains the two letter ISO 3166-1 alpha-2 country code
|
16
|
+
# (https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) associated with the
|
17
|
+
# location of the majority of customers using this credit card as
|
18
|
+
# determined by their billing address. In cases where the location of
|
19
|
+
# customers is highly mixed, this defaults to the country of the bank
|
20
|
+
# issuing the card.
|
21
|
+
#
|
22
|
+
# @return [String, nil]
|
23
|
+
attr_reader :country
|
24
|
+
|
25
|
+
# This property is true if the card is a business card.
|
26
|
+
#
|
27
|
+
# @return [Boolean, nil]
|
28
|
+
attr_reader :is_business
|
29
|
+
|
30
|
+
# This property is true if the country of the billing address matches the
|
31
|
+
# country of the majority of customers using this credit card. In cases
|
32
|
+
# where the location of customers is highly mixed, the match is to the
|
33
|
+
# country of the bank issuing the card.
|
34
|
+
#
|
35
|
+
# @return [Boolean, nil]
|
36
|
+
attr_reader :is_issued_in_billing_address_country
|
37
|
+
|
38
|
+
# This property is true if the card is a prepaid card.
|
39
|
+
#
|
40
|
+
# @return [Boolean, nil]
|
41
|
+
attr_reader :is_prepaid
|
42
|
+
|
43
|
+
# This property is true if the card is a virtual card.
|
44
|
+
#
|
45
|
+
# @return [Boolean, nil]
|
46
|
+
attr_reader :is_virtual
|
47
|
+
|
48
|
+
# An object containing information about the credit card issuer.
|
49
|
+
#
|
50
|
+
# @return [Minfraud::Model::Issuer]
|
51
|
+
attr_reader :issuer
|
52
|
+
|
53
|
+
# The card's type. The valid values are: charge, credit, debit.
|
54
|
+
#
|
55
|
+
# @return [String, nil]
|
56
|
+
attr_reader :type
|
57
|
+
|
58
|
+
# @!visibility private
|
59
|
+
def initialize(record)
|
60
|
+
super(record)
|
61
|
+
|
62
|
+
@brand = get('brand')
|
63
|
+
@country = get('country')
|
64
|
+
@is_business = get('is_business')
|
65
|
+
@is_issued_in_billing_address_country = get(
|
66
|
+
'is_issued_in_billing_address_country'
|
67
|
+
)
|
68
|
+
@is_prepaid = get('is_prepaid')
|
69
|
+
@is_virtual = get('is_virtual')
|
70
|
+
@issuer = Minfraud::Model::Issuer.new(get('issuer'))
|
71
|
+
@type = get('type')
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'minfraud/model/abstract'
|
4
|
+
|
5
|
+
module Minfraud
|
6
|
+
module Model
|
7
|
+
# Model with information about the device.
|
8
|
+
#
|
9
|
+
# In order to receive device output from minFraud Insights or minFraud
|
10
|
+
# Factors, you must be using the Device Tracking Add-on
|
11
|
+
# (https://dev.maxmind.com/minfraud/track-devices?lang=en).
|
12
|
+
class Device < Abstract
|
13
|
+
# This number represents our confidence that the device_id refers to a
|
14
|
+
# unique device as opposed to a cluster of similar devices. A confidence
|
15
|
+
# of 0.01 indicates very low confidence that the device is unique,
|
16
|
+
# whereas 99 indicates very high confidence.
|
17
|
+
#
|
18
|
+
# @return [Float, nil]
|
19
|
+
attr_reader :confidence
|
20
|
+
|
21
|
+
# A UUID that MaxMind uses for the device associated with this IP
|
22
|
+
# address.
|
23
|
+
#
|
24
|
+
# @return [String, nil]
|
25
|
+
attr_reader :id
|
26
|
+
|
27
|
+
# This is the date and time of the last sighting of the device. This is
|
28
|
+
# an RFC 3339 date-time.
|
29
|
+
#
|
30
|
+
# @return [String, nil]
|
31
|
+
attr_reader :last_seen
|
32
|
+
|
33
|
+
# This is the local date and time of the transaction in the time zone of
|
34
|
+
# the device. This is determined by using the UTC offset associated with
|
35
|
+
# the device. This is an RFC 3339 date-time
|
36
|
+
#
|
37
|
+
# @return [String, nil]
|
38
|
+
attr_reader :local_time
|
39
|
+
|
40
|
+
# @!visibility private
|
41
|
+
def initialize(record)
|
42
|
+
super(record)
|
43
|
+
|
44
|
+
@confidence = get('confidence')
|
45
|
+
@id = get('id')
|
46
|
+
@last_seen = get('last_seen')
|
47
|
+
@local_time = get('local_time')
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'minfraud/model/abstract'
|
4
|
+
|
5
|
+
module Minfraud
|
6
|
+
module Model
|
7
|
+
# Model with the disposition set by custom rules.
|
8
|
+
#
|
9
|
+
# In order to receive a disposition, you must be using minFraud custom
|
10
|
+
# rules.
|
11
|
+
class Disposition < Abstract
|
12
|
+
# The action to take on the transaction as defined by your custom rules.
|
13
|
+
# The current set of values are "accept", "manual_review", "reject", and
|
14
|
+
# "test". If you do not have custom rules set up, this will be nil.
|
15
|
+
#
|
16
|
+
# @return [String, nil]
|
17
|
+
attr_reader :action
|
18
|
+
|
19
|
+
# The reason for the action. The current possible values are
|
20
|
+
# "custom_rule" and "default". If you do not have custom rules set up,
|
21
|
+
# this will be nil.
|
22
|
+
#
|
23
|
+
# @return [String, nil]
|
24
|
+
attr_reader :reason
|
25
|
+
|
26
|
+
# The label of the custom rule that was triggered. If you do not have
|
27
|
+
# custom rules set up, the triggered custom rule does not have a label,
|
28
|
+
# or no custom rule was triggered, this will be nil.
|
29
|
+
# @return [String, nil]
|
30
|
+
attr_reader :rule_label
|
31
|
+
|
32
|
+
# @!visibility private
|
33
|
+
def initialize(record)
|
34
|
+
super(record)
|
35
|
+
|
36
|
+
@action = get('action')
|
37
|
+
@reason = get('reason')
|
38
|
+
@rule_label = get('rule_label')
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|