minfraud 1.3.0 → 1.6.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 +4 -4
- data/.github/dependabot.yml +7 -0
- data/.github/workflows/rubocop.yml +12 -0
- data/.github/workflows/test.yml +14 -31
- data/.rubocop.yml +3 -5
- data/CHANGELOG.md +42 -0
- data/LICENSE.txt +1 -1
- data/README.dev.md +1 -1
- data/README.md +11 -10
- data/Rakefile +1 -10
- data/lib/maxmind/geoip2/record/traits.rb +3 -3
- data/lib/minfraud/components/credit_card.rb +20 -8
- data/lib/minfraud/components/device.rb +1 -1
- data/lib/minfraud/components/email.rb +92 -3
- data/lib/minfraud/components/payment.rb +10 -0
- data/lib/minfraud/components/shopping_cart.rb +1 -1
- data/lib/minfraud/error_handler.rb +3 -9
- data/lib/minfraud/model/disposition.rb +11 -4
- data/lib/minfraud/model/ip_address.rb +20 -1
- data/lib/minfraud/model/ip_risk_reason.rb +48 -0
- data/lib/minfraud/version.rb +1 -1
- data/minfraud.gemspec +2 -1
- metadata +25 -10
- data/.travis.yml +0 -21
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 6df345c5d62d26c7e778a55423ac6a542ec8b94c040c6a43d26ef0cdad484503
|
|
4
|
+
data.tar.gz: 9d7d427983c71db3e4aa8ac1f7ef1008388a4847b455db50179e579292ac8c61
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 2cb3b9e1e1d825c828cf1e73684b70784ee1ba5de18902a1d76cd08b5f625cb276bd3a276c64e74f8c3cf8a8269be9c7707a6cd5afa12700d59281985178d070
|
|
7
|
+
data.tar.gz: 55fd1da7ed9543c44a6efcd4b3638b03a1537c31de12773a0446789f129234ceed750e16e8b0c8c629bcf2956815ef0b0f00cfdfe482fe3e4ad736b0cef5b3ef
|
data/.github/workflows/test.yml
CHANGED
|
@@ -1,14 +1,7 @@
|
|
|
1
|
-
name:
|
|
2
|
-
on:
|
|
3
|
-
push:
|
|
4
|
-
paths-ignore:
|
|
5
|
-
- "**.md"
|
|
6
|
-
pull_request:
|
|
7
|
-
paths-ignore:
|
|
8
|
-
- "**.md"
|
|
1
|
+
name: Run tests
|
|
2
|
+
on: [push, pull_request]
|
|
9
3
|
jobs:
|
|
10
|
-
|
|
11
|
-
name: ruby
|
|
4
|
+
test:
|
|
12
5
|
runs-on: ${{ matrix.os }}
|
|
13
6
|
strategy:
|
|
14
7
|
fail-fast: false
|
|
@@ -16,31 +9,21 @@ jobs:
|
|
|
16
9
|
os: [ubuntu-latest, windows-latest, macos-latest]
|
|
17
10
|
version:
|
|
18
11
|
[
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
"2.7",
|
|
25
|
-
"head",
|
|
26
|
-
"jruby",
|
|
27
|
-
"jruby-head",
|
|
12
|
+
2.5,
|
|
13
|
+
2.6,
|
|
14
|
+
2.7,
|
|
15
|
+
'3.0',
|
|
16
|
+
jruby,
|
|
28
17
|
]
|
|
29
18
|
exclude:
|
|
30
19
|
- os: windows-latest
|
|
31
|
-
version:
|
|
32
|
-
- os: windows-latest
|
|
33
|
-
version: "jruby-head"
|
|
20
|
+
version: jruby
|
|
34
21
|
steps:
|
|
35
|
-
-
|
|
36
|
-
|
|
37
|
-
|
|
22
|
+
- uses: actions/checkout@v2
|
|
23
|
+
with:
|
|
24
|
+
submodules: true
|
|
38
25
|
- uses: ruby/setup-ruby@v1
|
|
39
26
|
with:
|
|
40
27
|
ruby-version: ${{ matrix.version }}
|
|
41
|
-
-
|
|
42
|
-
|
|
43
|
-
- run: bundler install
|
|
44
|
-
name: install
|
|
45
|
-
- run: bundler exec rake -t
|
|
46
|
-
name: test
|
|
28
|
+
- run: bundle install
|
|
29
|
+
- run: bundle exec rake -t spec
|
data/.rubocop.yml
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
AllCops:
|
|
2
|
+
TargetRubyVersion: 2.5
|
|
3
|
+
NewCops: enable
|
|
3
4
|
|
|
4
5
|
# Metrics.
|
|
5
6
|
|
|
@@ -103,6 +104,3 @@ Lint/MissingSuper:
|
|
|
103
104
|
|
|
104
105
|
Naming/VariableNumber:
|
|
105
106
|
Enabled: false # Doesn't always make sense.
|
|
106
|
-
|
|
107
|
-
AllCops:
|
|
108
|
-
NewCops: enable
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,47 @@
|
|
|
1
1
|
# Minfraud Changelog
|
|
2
2
|
|
|
3
|
+
## v1.6.0 (2021-08-19)
|
|
4
|
+
|
|
5
|
+
* Adds new processor to `Minfraud::Components::Payment`: `:cardknox`,
|
|
6
|
+
`:creditguard`, `:credorax`, `:datacap`, `:dlocal`, `:onpay`, and
|
|
7
|
+
`:safecharge`.
|
|
8
|
+
* Adds `rule_label` to minFraud output `/disposition`.
|
|
9
|
+
* Adds support for the `/credit_card/was_3d_secure_successful` input. This is
|
|
10
|
+
available by setting the `was_3d_secure_successful` attribute on
|
|
11
|
+
`Minfraud::Components::CreditCard`.
|
|
12
|
+
* Ruby 2.5+ is now required. If you're using Ruby 2.1, 2.2, 2.3, or 2.4,
|
|
13
|
+
please use version 1.5.0 of this gem.
|
|
14
|
+
|
|
15
|
+
## v1.5.0 (2021-02-02)
|
|
16
|
+
|
|
17
|
+
* Add the `hash_address` attribute to `Minfraud::Components::Email`. If
|
|
18
|
+
this is `true`, the MD5 hash of the `address` will be sent instead of the
|
|
19
|
+
plain text `address`. Use this if you prefer to send the hash of the
|
|
20
|
+
`address` rather than the plain text. Note that this normalizes the
|
|
21
|
+
`address`, so we recommend using it as opposed to hashing the `address`
|
|
22
|
+
manually.
|
|
23
|
+
* The email `domain` input is now automatically set if the email `address`
|
|
24
|
+
input is set but the `domain` is not.
|
|
25
|
+
* Adds new payment processors `:apple_pay` and `:aps_payments` to
|
|
26
|
+
`Minfraud::Components::Payment`.
|
|
27
|
+
* Added support for the IP address risk reasons in the minFraud Insights
|
|
28
|
+
and Factors responses. This is available at `.ip_address.risk_reasons`.
|
|
29
|
+
It is an array of `IPRiskReason` objects.
|
|
30
|
+
|
|
31
|
+
## v1.4.1 (2020-12-01)
|
|
32
|
+
|
|
33
|
+
* Do not throw an exception if the response does not include IP address
|
|
34
|
+
information. Previously we would incorrectly try to retrieve fields from
|
|
35
|
+
`nil`, leading to a `NoMethodError`.
|
|
36
|
+
|
|
37
|
+
## v1.4.0 (2020-10-13)
|
|
38
|
+
|
|
39
|
+
* IMPORTANT: Ruby 2.0 is no longer supported. If you're using Ruby 2.0,
|
|
40
|
+
please use version 1.3.0.
|
|
41
|
+
* Add handling for the `REQUEST_INVALID` error code.
|
|
42
|
+
* The IP address is no longer a required input.
|
|
43
|
+
* Adds new payment processor `:tsys` to `Minfraud::Components::Payment`.
|
|
44
|
+
|
|
3
45
|
## v1.3.0 (2020-09-25)
|
|
4
46
|
|
|
5
47
|
* Adds support for persistent HTTP connections. Connections persist
|
data/LICENSE.txt
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
The MIT License (MIT)
|
|
2
2
|
|
|
3
3
|
Copyright (c) 2016-2020 kushnir.yb
|
|
4
|
-
Copyright (c) 2020 MaxMind, Inc.
|
|
4
|
+
Copyright (c) 2020-2021 MaxMind, Inc.
|
|
5
5
|
|
|
6
6
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
7
|
of this software and associated documentation files (the "Software"), to deal
|
data/README.dev.md
CHANGED
data/README.md
CHANGED
|
@@ -122,14 +122,15 @@ assessment = Minfraud::Assessments.new(
|
|
|
122
122
|
decline_code: 'invalid number',
|
|
123
123
|
},
|
|
124
124
|
credit_card: {
|
|
125
|
-
issuer_id_number:
|
|
126
|
-
last_4_digits:
|
|
127
|
-
bank_name:
|
|
128
|
-
bank_phone_country_code:
|
|
129
|
-
bank_phone_number:
|
|
130
|
-
token:
|
|
131
|
-
avs_result:
|
|
132
|
-
cvv_result:
|
|
125
|
+
issuer_id_number: '411111',
|
|
126
|
+
last_4_digits: '7643',
|
|
127
|
+
bank_name: 'Bank of No Hope',
|
|
128
|
+
bank_phone_country_code: '1',
|
|
129
|
+
bank_phone_number: '123-456-1234',
|
|
130
|
+
token: 'abcd',
|
|
131
|
+
avs_result: 'Y',
|
|
132
|
+
cvv_result: 'N',
|
|
133
|
+
was_3d_secure_successful: true,
|
|
133
134
|
},
|
|
134
135
|
order: {
|
|
135
136
|
amount: 323.21,
|
|
@@ -264,7 +265,7 @@ to the client API, please see
|
|
|
264
265
|
|
|
265
266
|
## Requirements
|
|
266
267
|
|
|
267
|
-
This gem works with Ruby 2.
|
|
268
|
+
This gem works with Ruby 2.5 and above.
|
|
268
269
|
|
|
269
270
|
## Contributing
|
|
270
271
|
|
|
@@ -282,7 +283,7 @@ This API uses [Semantic Versioning](https://semver.org/).
|
|
|
282
283
|
|
|
283
284
|
Copyright (c) 2016-2020 kushnir.yb.
|
|
284
285
|
|
|
285
|
-
Copyright (c) 2020 MaxMind, Inc.
|
|
286
|
+
Copyright (c) 2020-2021 MaxMind, Inc.
|
|
286
287
|
|
|
287
288
|
The gem is available as open source under the terms of the [MIT
|
|
288
289
|
License](https://opensource.org/licenses/MIT).
|
data/Rakefile
CHANGED
|
@@ -9,13 +9,4 @@ RSpec::Core::RakeTask.new(:spec)
|
|
|
9
9
|
RuboCop::RakeTask.new
|
|
10
10
|
|
|
11
11
|
task default: :spec
|
|
12
|
-
|
|
13
|
-
# The current version of rubocop supports Ruby 2.4+. While we could run its
|
|
14
|
-
# older versions, the config isn't backwards compatible. Let's run it only for
|
|
15
|
-
# 2.4+. This isn't perfect, but as long as 1.9+ tests pass we should be okay.
|
|
16
|
-
version_pieces = RUBY_VERSION.split('.')
|
|
17
|
-
major_version = version_pieces[0]
|
|
18
|
-
minor_version = version_pieces[1]
|
|
19
|
-
if major_version == '2' && minor_version.to_i >= 4
|
|
20
|
-
task default: :rubocop
|
|
21
|
-
end
|
|
12
|
+
task default: :rubocop
|
|
@@ -33,7 +33,7 @@ module MaxMind
|
|
|
33
33
|
# @!visibility private
|
|
34
34
|
def initialize(record)
|
|
35
35
|
super(record)
|
|
36
|
-
if !record.key?('network') && record.key?('ip_address') &&
|
|
36
|
+
if record && !record.key?('network') && record.key?('ip_address') &&
|
|
37
37
|
record.key?('prefix_length')
|
|
38
38
|
ip = IPAddr.new(record['ip_address']).mask(record['prefix_length'])
|
|
39
39
|
# We could use ip.prefix instead of record['prefix_length'], but that
|
|
@@ -89,7 +89,7 @@ module MaxMind
|
|
|
89
89
|
# NAT, this may differ from the IP address locally assigned to it. This
|
|
90
90
|
# attribute is returned by all end points.
|
|
91
91
|
#
|
|
92
|
-
# @return [String]
|
|
92
|
+
# @return [String, nil]
|
|
93
93
|
def ip_address
|
|
94
94
|
get('ip_address')
|
|
95
95
|
end
|
|
@@ -169,7 +169,7 @@ module MaxMind
|
|
|
169
169
|
# this is the largest network where all of the fields besides ip_address
|
|
170
170
|
# have the same value.
|
|
171
171
|
#
|
|
172
|
-
# @return [String]
|
|
172
|
+
# @return [String, nil]
|
|
173
173
|
def network
|
|
174
174
|
get('network')
|
|
175
175
|
end
|
|
@@ -62,17 +62,28 @@ module Minfraud
|
|
|
62
62
|
# @return [String, nil]
|
|
63
63
|
attr_accessor :cvv_result
|
|
64
64
|
|
|
65
|
+
# Whether the outcome of 3-D Secure verification (e.g. Safekey,
|
|
66
|
+
# SecureCode, Verified by Visa) was successful. +true+ if customer
|
|
67
|
+
# verification was successful, or +false+ if the customer failed
|
|
68
|
+
# verification. If 3-D Secure verification was not used, was unavailable,
|
|
69
|
+
# or resulted in an outcome other than success or failure, do not
|
|
70
|
+
# include this field.
|
|
71
|
+
#
|
|
72
|
+
# @return [Boolean, nil]
|
|
73
|
+
attr_accessor :was_3d_secure_successful
|
|
74
|
+
|
|
65
75
|
# @param params [Hash] Hash of parameters. Each key/value should
|
|
66
76
|
# correspond to one of the available attributes.
|
|
67
77
|
def initialize(params = {})
|
|
68
|
-
@bank_phone_country_code
|
|
69
|
-
@issuer_id_number
|
|
70
|
-
@last_4_digits
|
|
71
|
-
@bank_name
|
|
72
|
-
@bank_phone_number
|
|
73
|
-
@avs_result
|
|
74
|
-
@cvv_result
|
|
75
|
-
@token
|
|
78
|
+
@bank_phone_country_code = params[:bank_phone_country_code]
|
|
79
|
+
@issuer_id_number = params[:issuer_id_number]
|
|
80
|
+
@last_4_digits = params[:last_4_digits]
|
|
81
|
+
@bank_name = params[:bank_name]
|
|
82
|
+
@bank_phone_number = params[:bank_phone_number]
|
|
83
|
+
@avs_result = params[:avs_result]
|
|
84
|
+
@cvv_result = params[:cvv_result]
|
|
85
|
+
@token = params[:token]
|
|
86
|
+
@was_3d_secure_successful = params[:was_3d_secure_successful]
|
|
76
87
|
|
|
77
88
|
validate
|
|
78
89
|
end
|
|
@@ -90,6 +101,7 @@ module Minfraud
|
|
|
90
101
|
validate_string('avs_result', 1, @avs_result)
|
|
91
102
|
validate_string('cvv_result', 1, @cvv_result)
|
|
92
103
|
validate_credit_card_token('token', @token)
|
|
104
|
+
validate_boolean('was_3d_secure_successful', @was_3d_secure_successful)
|
|
93
105
|
end
|
|
94
106
|
end
|
|
95
107
|
end
|
|
@@ -11,7 +11,7 @@ module Minfraud
|
|
|
11
11
|
# The IP address associated with the device used by the customer in the
|
|
12
12
|
# transaction. The IP address must be in IPv4 or IPv6 presentation
|
|
13
13
|
# format, i.e., dotted-quad notation or the IPv6 hexadecimal-colon
|
|
14
|
-
# notation.
|
|
14
|
+
# notation.
|
|
15
15
|
#
|
|
16
16
|
# @return [String, nil]
|
|
17
17
|
attr_accessor :ip_address
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
require 'digest/md5'
|
|
4
|
+
require 'simpleidn'
|
|
5
|
+
|
|
3
6
|
module Minfraud
|
|
4
7
|
module Components
|
|
5
8
|
# Email corresponds to the email object of a minFraud request.
|
|
@@ -11,7 +14,8 @@ module Minfraud
|
|
|
11
14
|
# This field must be either be a valid email address or an MD5 of the
|
|
12
15
|
# lowercased email used in the transaction. Important: if using the MD5
|
|
13
16
|
# hash, please be sure to convert the email address to lowercase before
|
|
14
|
-
# calculating its MD5 hash.
|
|
17
|
+
# calculating its MD5 hash. Instead of converting an address to an MD5
|
|
18
|
+
# hash yourself, please use the hash_address attribute in this class.
|
|
15
19
|
#
|
|
16
20
|
# @return [String, nil]
|
|
17
21
|
attr_accessor :address
|
|
@@ -21,15 +25,46 @@ module Minfraud
|
|
|
21
25
|
# @return [String, nil]
|
|
22
26
|
attr_accessor :domain
|
|
23
27
|
|
|
28
|
+
# By default, the address will be sent in plain text. If this is set
|
|
29
|
+
# true, the address will instead be sent as an MD5 hash.
|
|
30
|
+
#
|
|
31
|
+
# @return [Boolean, nil]
|
|
32
|
+
attr_accessor :hash_address
|
|
33
|
+
|
|
24
34
|
# @param params [Hash] Hash of parameters. Each key/value should
|
|
25
35
|
# correspond to one of the available attributes.
|
|
26
36
|
def initialize(params = {})
|
|
27
|
-
@address
|
|
28
|
-
@domain
|
|
37
|
+
@address = params[:address]
|
|
38
|
+
@domain = params[:domain]
|
|
39
|
+
@hash_address = params[:hash_address]
|
|
29
40
|
|
|
30
41
|
validate
|
|
31
42
|
end
|
|
32
43
|
|
|
44
|
+
# A JSON representation of Minfraud::Components::Email.
|
|
45
|
+
#
|
|
46
|
+
# @return [Hash]
|
|
47
|
+
def to_json(*_args)
|
|
48
|
+
json = super
|
|
49
|
+
|
|
50
|
+
if json['address'] && !json['domain']
|
|
51
|
+
_, domain = address.split('@', 2)
|
|
52
|
+
if domain
|
|
53
|
+
domain = clean_domain(domain)
|
|
54
|
+
json['domain'] = domain if domain
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
if json.delete('hash_address') && json['address']
|
|
59
|
+
hash = hash_email_address(json['address'])
|
|
60
|
+
|
|
61
|
+
# We could consider clearing the key if !hash.
|
|
62
|
+
json['address'] = hash if hash
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
json
|
|
66
|
+
end
|
|
67
|
+
|
|
33
68
|
private
|
|
34
69
|
|
|
35
70
|
def validate
|
|
@@ -38,6 +73,60 @@ module Minfraud
|
|
|
38
73
|
validate_email('email', @address)
|
|
39
74
|
validate_string('domain', 255, @domain)
|
|
40
75
|
end
|
|
76
|
+
|
|
77
|
+
def hash_email_address(address)
|
|
78
|
+
address = clean_email_address(address)
|
|
79
|
+
return nil if !address
|
|
80
|
+
|
|
81
|
+
Digest::MD5.hexdigest(address)
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
def clean_email_address(address)
|
|
85
|
+
address = address.strip
|
|
86
|
+
address.downcase!
|
|
87
|
+
|
|
88
|
+
local_part, domain = address.split('@', 2)
|
|
89
|
+
return nil if !local_part || !domain
|
|
90
|
+
|
|
91
|
+
domain = clean_domain(domain)
|
|
92
|
+
|
|
93
|
+
if domain == 'yahoo.com'
|
|
94
|
+
local_part.sub!(/\A([^-]+)-.*\z/, '\1')
|
|
95
|
+
else
|
|
96
|
+
local_part.sub!(/\A([^+]+)\+.*\z/, '\1')
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
"#{local_part}@#{domain}"
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
TYPO_DOMAINS = {
|
|
103
|
+
# gmail.com
|
|
104
|
+
'35gmai.com' => 'gmail.com',
|
|
105
|
+
'636gmail.com' => 'gmail.com',
|
|
106
|
+
'gamil.com' => 'gmail.com',
|
|
107
|
+
'gmail.comu' => 'gmail.com',
|
|
108
|
+
'gmial.com' => 'gmail.com',
|
|
109
|
+
'gmil.com' => 'gmail.com',
|
|
110
|
+
'yahoogmail.com' => 'gmail.com',
|
|
111
|
+
# outlook.com
|
|
112
|
+
'putlook.com' => 'outlook.com',
|
|
113
|
+
}.freeze
|
|
114
|
+
private_constant :TYPO_DOMAINS
|
|
115
|
+
|
|
116
|
+
def clean_domain(domain)
|
|
117
|
+
domain = domain.strip
|
|
118
|
+
|
|
119
|
+
# We could use delete_suffix!, but that is in Ruby 2.5+ only.
|
|
120
|
+
domain.sub!(/\.\z/, '')
|
|
121
|
+
|
|
122
|
+
domain = SimpleIDN.to_ascii(domain)
|
|
123
|
+
|
|
124
|
+
if TYPO_DOMAINS.key?(domain)
|
|
125
|
+
domain = TYPO_DOMAINS[domain]
|
|
126
|
+
end
|
|
127
|
+
|
|
128
|
+
domain
|
|
129
|
+
end
|
|
41
130
|
end
|
|
42
131
|
end
|
|
43
132
|
end
|
|
@@ -22,6 +22,8 @@ module Minfraud
|
|
|
22
22
|
:altapay,
|
|
23
23
|
:amazon_payments,
|
|
24
24
|
:american_express_payment_gateway,
|
|
25
|
+
:apple_pay,
|
|
26
|
+
:aps_payments,
|
|
25
27
|
:authorizenet,
|
|
26
28
|
:balanced,
|
|
27
29
|
:beanstream,
|
|
@@ -29,6 +31,7 @@ module Minfraud
|
|
|
29
31
|
:bluesnap,
|
|
30
32
|
:bpoint,
|
|
31
33
|
:braintree,
|
|
34
|
+
:cardknox,
|
|
32
35
|
:cardpay,
|
|
33
36
|
:cashfree,
|
|
34
37
|
:ccavenue,
|
|
@@ -42,15 +45,19 @@ module Minfraud
|
|
|
42
45
|
:compropago,
|
|
43
46
|
:concept_payments,
|
|
44
47
|
:conekta,
|
|
48
|
+
:creditguard,
|
|
49
|
+
:credorax,
|
|
45
50
|
:ct_payments,
|
|
46
51
|
:cuentadigital,
|
|
47
52
|
:curopayments,
|
|
48
53
|
:cybersource,
|
|
49
54
|
:dalenys,
|
|
50
55
|
:dalpay,
|
|
56
|
+
:datacap,
|
|
51
57
|
:datacash,
|
|
52
58
|
:dibs,
|
|
53
59
|
:digital_river,
|
|
60
|
+
:dlocal,
|
|
54
61
|
:dotpay,
|
|
55
62
|
:ebs,
|
|
56
63
|
:ecomm365,
|
|
@@ -87,6 +94,7 @@ module Minfraud
|
|
|
87
94
|
:nmi,
|
|
88
95
|
:oceanpayment,
|
|
89
96
|
:oney,
|
|
97
|
+
:onpay,
|
|
90
98
|
:openpaymx,
|
|
91
99
|
:optimal_payments,
|
|
92
100
|
:orangepay,
|
|
@@ -122,6 +130,7 @@ module Minfraud
|
|
|
122
130
|
:rede,
|
|
123
131
|
:redpagos,
|
|
124
132
|
:rewardspay,
|
|
133
|
+
:safecharge,
|
|
125
134
|
:sagepay,
|
|
126
135
|
:securetrading,
|
|
127
136
|
:simplify_commerce,
|
|
@@ -136,6 +145,7 @@ module Minfraud
|
|
|
136
145
|
:telerecargas,
|
|
137
146
|
:towah,
|
|
138
147
|
:transact_pro,
|
|
148
|
+
:tsys,
|
|
139
149
|
:usa_epay,
|
|
140
150
|
:vantiv,
|
|
141
151
|
:verepay,
|
|
@@ -13,7 +13,7 @@ module Minfraud
|
|
|
13
13
|
attr_accessor :items
|
|
14
14
|
|
|
15
15
|
# @param params [Array] Array of shopping cart items. You may provide
|
|
16
|
-
# each item as either
|
|
16
|
+
# each item as either a Hash where each key is a symbol corresponding
|
|
17
17
|
# to an item's field, or as a Minfraud:::Components::ShoppingCartItem
|
|
18
18
|
# object.
|
|
19
19
|
def initialize(params = [])
|
|
@@ -27,15 +27,6 @@ module Minfraud
|
|
|
27
27
|
|
|
28
28
|
# @!visibility private
|
|
29
29
|
STATUS_CODES = {
|
|
30
|
-
IP_ADDRESS_INVALID: [
|
|
31
|
-
ClientError, 'You have not supplied a valid IPv4 or IPv6 address'
|
|
32
|
-
],
|
|
33
|
-
IP_ADDRESS_REQUIRED: [
|
|
34
|
-
ClientError, 'You have not supplied an IP address which is a required field'
|
|
35
|
-
],
|
|
36
|
-
IP_ADDRESS_RESERVED: [
|
|
37
|
-
ClientError, 'You have supplied an IP address which is reserved'
|
|
38
|
-
],
|
|
39
30
|
JSON_INVALID: [
|
|
40
31
|
ClientError, 'JSON body cannot be decoded'
|
|
41
32
|
],
|
|
@@ -48,6 +39,9 @@ module Minfraud
|
|
|
48
39
|
PARAMETER_UNKNOWN: [
|
|
49
40
|
ClientError, 'You have supplied an unknown parameter'
|
|
50
41
|
],
|
|
42
|
+
REQUEST_INVALID: [
|
|
43
|
+
ClientError, 'The request did not contain any valid input values.'
|
|
44
|
+
],
|
|
51
45
|
TAG_REQUIRED: [
|
|
52
46
|
ClientError, 'You have not supplied a tag, which is a required field'
|
|
53
47
|
],
|
|
@@ -10,8 +10,8 @@ module Minfraud
|
|
|
10
10
|
# rules.
|
|
11
11
|
class Disposition < Abstract
|
|
12
12
|
# The action to take on the transaction as defined by your custom rules.
|
|
13
|
-
# The current set of values are "accept", "manual_review",
|
|
14
|
-
# If you do not have custom rules set up, this will be nil.
|
|
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
15
|
#
|
|
16
16
|
# @return [String, nil]
|
|
17
17
|
attr_reader :action
|
|
@@ -23,12 +23,19 @@ module Minfraud
|
|
|
23
23
|
# @return [String, nil]
|
|
24
24
|
attr_reader :reason
|
|
25
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
|
+
|
|
26
32
|
# @!visibility private
|
|
27
33
|
def initialize(record)
|
|
28
34
|
super(record)
|
|
29
35
|
|
|
30
|
-
@action
|
|
31
|
-
@reason
|
|
36
|
+
@action = get('action')
|
|
37
|
+
@reason = get('reason')
|
|
38
|
+
@rule_label = get('rule_label')
|
|
32
39
|
end
|
|
33
40
|
end
|
|
34
41
|
end
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
require 'maxmind/geoip2/model/insights'
|
|
4
4
|
require 'minfraud/model/geoip2_location'
|
|
5
|
+
require 'minfraud/model/ip_risk_reason'
|
|
5
6
|
|
|
6
7
|
module Minfraud
|
|
7
8
|
module Model
|
|
@@ -13,9 +14,20 @@ module Minfraud
|
|
|
13
14
|
# @return [Float]
|
|
14
15
|
attr_reader :risk
|
|
15
16
|
|
|
17
|
+
# This field contains IPRiskReason objects identifying the reasons why
|
|
18
|
+
# the IP address received the associated risk. This will be an empty
|
|
19
|
+
# array if there are no reasons.
|
|
20
|
+
#
|
|
21
|
+
# @return [Array<Minfraud::Model::IPRiskReason>]
|
|
22
|
+
attr_reader :risk_reasons
|
|
23
|
+
|
|
16
24
|
# @!visibility private
|
|
17
25
|
def initialize(record, locales)
|
|
18
|
-
|
|
26
|
+
if record
|
|
27
|
+
super(record, locales)
|
|
28
|
+
else
|
|
29
|
+
super({}, locales)
|
|
30
|
+
end
|
|
19
31
|
|
|
20
32
|
if record
|
|
21
33
|
@location = Minfraud::Model::GeoIP2Location.new(record.fetch('location', nil))
|
|
@@ -28,6 +40,13 @@ module Minfraud
|
|
|
28
40
|
@risk = nil
|
|
29
41
|
end
|
|
30
42
|
|
|
43
|
+
@risk_reasons = []
|
|
44
|
+
if record && record.key?('risk_reasons')
|
|
45
|
+
record['risk_reasons'].each do |r|
|
|
46
|
+
@risk_reasons << Minfraud::Model::IPRiskReason.new(r)
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
|
|
31
50
|
# Decorate objects with deprecated attributes and names for backwards
|
|
32
51
|
# compatibility. Do this here rather than with the overhead of
|
|
33
52
|
# subclasses/modules for them in the hope that one day we can delete
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'minfraud/model/abstract'
|
|
4
|
+
|
|
5
|
+
module Minfraud
|
|
6
|
+
module Model
|
|
7
|
+
# Reason for the IP risk.
|
|
8
|
+
#
|
|
9
|
+
# This class provides both a machine-readable code and a human-readable
|
|
10
|
+
# explanation of the reason for the IP risk score.
|
|
11
|
+
#
|
|
12
|
+
# Although more codes may be added in the future, the current codes are:
|
|
13
|
+
#
|
|
14
|
+
# * ANONYMOUS_IP - The IP address belongs to an anonymous network. See the
|
|
15
|
+
# object at ip_address.traits for more details.
|
|
16
|
+
# * BILLING_POSTAL_VELOCITY - Many different billing postal codes have been
|
|
17
|
+
# seen on this IP address.
|
|
18
|
+
# * EMAIL_VELOCITY - Many different email addresses have been seen on this
|
|
19
|
+
# IP address.
|
|
20
|
+
# * HIGH_RISK_DEVICE - A high risk device was seen on this IP address.
|
|
21
|
+
# * HIGH_RISK_EMAIL - A high risk email address was seen on this IP address
|
|
22
|
+
# in your past transactions.
|
|
23
|
+
# * ISSUER_ID_NUMBER_VELOCITY - Many different issuer ID numbers have been
|
|
24
|
+
# seen on this IP address.
|
|
25
|
+
# * MINFRAUD_NETWORK_ACTIVITY - Suspicious activity has been seen on this
|
|
26
|
+
# IP address across minFraud customers.
|
|
27
|
+
class IPRiskReason < Abstract
|
|
28
|
+
# This value is a machine-readable code identifying the reason.
|
|
29
|
+
#
|
|
30
|
+
# @return [String, nil]
|
|
31
|
+
attr_reader :code
|
|
32
|
+
|
|
33
|
+
# This field provides a human-readable explanation of the reason. The
|
|
34
|
+
# text may change at any time and should not be matched against.
|
|
35
|
+
#
|
|
36
|
+
# @return [String, nil]
|
|
37
|
+
attr_reader :reason
|
|
38
|
+
|
|
39
|
+
# @!visibility private
|
|
40
|
+
def initialize(record)
|
|
41
|
+
super(record)
|
|
42
|
+
|
|
43
|
+
@code = get('code')
|
|
44
|
+
@reason = get('reason')
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
end
|
data/lib/minfraud/version.rb
CHANGED
data/minfraud.gemspec
CHANGED
|
@@ -15,7 +15,7 @@ Gem::Specification.new do |spec|
|
|
|
15
15
|
spec.homepage = 'https://github.com/maxmind/minfraud-api-ruby'
|
|
16
16
|
spec.license = 'MIT'
|
|
17
17
|
|
|
18
|
-
spec.required_ruby_version = '>= 2.0'
|
|
18
|
+
spec.required_ruby_version = '>= 2.5.0'
|
|
19
19
|
|
|
20
20
|
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
|
21
21
|
spec.bindir = 'exe'
|
|
@@ -25,6 +25,7 @@ Gem::Specification.new do |spec|
|
|
|
25
25
|
spec.add_runtime_dependency 'faraday', '>= 0.9.1', '< 2.0'
|
|
26
26
|
spec.add_runtime_dependency 'faraday_middleware', '>= 0.9.1', '< 2.0'
|
|
27
27
|
spec.add_runtime_dependency 'net-http-persistent', '>= 2.0.0', '< 5.0'
|
|
28
|
+
spec.add_runtime_dependency 'simpleidn', '>= 0.1.1'
|
|
28
29
|
|
|
29
30
|
spec.add_development_dependency 'bundler', '>= 1.16'
|
|
30
31
|
spec.add_development_dependency 'rake'
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: minfraud
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.
|
|
4
|
+
version: 1.6.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- kushnir.yb
|
|
8
|
-
autorequire:
|
|
8
|
+
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2021-08-19 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: faraday
|
|
@@ -70,6 +70,20 @@ dependencies:
|
|
|
70
70
|
- - "<"
|
|
71
71
|
- !ruby/object:Gem::Version
|
|
72
72
|
version: '5.0'
|
|
73
|
+
- !ruby/object:Gem::Dependency
|
|
74
|
+
name: simpleidn
|
|
75
|
+
requirement: !ruby/object:Gem::Requirement
|
|
76
|
+
requirements:
|
|
77
|
+
- - ">="
|
|
78
|
+
- !ruby/object:Gem::Version
|
|
79
|
+
version: 0.1.1
|
|
80
|
+
type: :runtime
|
|
81
|
+
prerelease: false
|
|
82
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
83
|
+
requirements:
|
|
84
|
+
- - ">="
|
|
85
|
+
- !ruby/object:Gem::Version
|
|
86
|
+
version: 0.1.1
|
|
73
87
|
- !ruby/object:Gem::Dependency
|
|
74
88
|
name: bundler
|
|
75
89
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -140,18 +154,19 @@ dependencies:
|
|
|
140
154
|
- - ">="
|
|
141
155
|
- !ruby/object:Gem::Version
|
|
142
156
|
version: '0'
|
|
143
|
-
description:
|
|
157
|
+
description:
|
|
144
158
|
email:
|
|
145
159
|
- support@maxmind.com
|
|
146
160
|
executables: []
|
|
147
161
|
extensions: []
|
|
148
162
|
extra_rdoc_files: []
|
|
149
163
|
files:
|
|
164
|
+
- ".github/dependabot.yml"
|
|
165
|
+
- ".github/workflows/rubocop.yml"
|
|
150
166
|
- ".github/workflows/test.yml"
|
|
151
167
|
- ".gitignore"
|
|
152
168
|
- ".rspec"
|
|
153
169
|
- ".rubocop.yml"
|
|
154
|
-
- ".travis.yml"
|
|
155
170
|
- CHANGELOG.md
|
|
156
171
|
- CODE_OF_CONDUCT.md
|
|
157
172
|
- Gemfile
|
|
@@ -211,6 +226,7 @@ files:
|
|
|
211
226
|
- lib/minfraud/model/geoip2_location.rb
|
|
212
227
|
- lib/minfraud/model/insights.rb
|
|
213
228
|
- lib/minfraud/model/ip_address.rb
|
|
229
|
+
- lib/minfraud/model/ip_risk_reason.rb
|
|
214
230
|
- lib/minfraud/model/issuer.rb
|
|
215
231
|
- lib/minfraud/model/score.rb
|
|
216
232
|
- lib/minfraud/model/score_ip_address.rb
|
|
@@ -226,7 +242,7 @@ homepage: https://github.com/maxmind/minfraud-api-ruby
|
|
|
226
242
|
licenses:
|
|
227
243
|
- MIT
|
|
228
244
|
metadata: {}
|
|
229
|
-
post_install_message:
|
|
245
|
+
post_install_message:
|
|
230
246
|
rdoc_options: []
|
|
231
247
|
require_paths:
|
|
232
248
|
- lib
|
|
@@ -234,16 +250,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
234
250
|
requirements:
|
|
235
251
|
- - ">="
|
|
236
252
|
- !ruby/object:Gem::Version
|
|
237
|
-
version:
|
|
253
|
+
version: 2.5.0
|
|
238
254
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
239
255
|
requirements:
|
|
240
256
|
- - ">="
|
|
241
257
|
- !ruby/object:Gem::Version
|
|
242
258
|
version: '0'
|
|
243
259
|
requirements: []
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
signing_key:
|
|
260
|
+
rubygems_version: 3.1.2
|
|
261
|
+
signing_key:
|
|
247
262
|
specification_version: 4
|
|
248
263
|
summary: Ruby API for the minFraud Score, Insights, Factors, and Report Transactions
|
|
249
264
|
services
|
data/.travis.yml
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
language: ruby
|
|
2
|
-
|
|
3
|
-
rvm:
|
|
4
|
-
- 2.0
|
|
5
|
-
- 2.1
|
|
6
|
-
- 2.2
|
|
7
|
-
- 2.3
|
|
8
|
-
- 2.4
|
|
9
|
-
- 2.5
|
|
10
|
-
- 2.6
|
|
11
|
-
- 2.7
|
|
12
|
-
|
|
13
|
-
notifications:
|
|
14
|
-
email:
|
|
15
|
-
on_failure: always
|
|
16
|
-
on_success: change
|
|
17
|
-
recipients:
|
|
18
|
-
- dev-ci@maxmind.com
|
|
19
|
-
slack:
|
|
20
|
-
rooms:
|
|
21
|
-
secure: "wuwMo+BWnaBtkt1uGAi4Zd0EARX3B2TXDmBGCtn8r4PLfehh61S6nLQDASNXSk200PmniFM8PyOUNVGVJqWpYQAEMn32WWdy4vTK2c8CsjwfsMhgnOI2YDCzw+jiP+8EfIGBsPO4xA7yrzweP8gkzBtplb3LbaCiW83WfFo9+402yr0/0F9gfWi8qvuIw29XAS1XWhTY4itqGfkSPdOHQz/45ElpLkGlgreuRrih3tAgn9YLb/Uh/6McHfHkL74YwQU3p0NiZcoleWYM0CLpPzyrN8EsbmIT+L75nIVwXnh62Gx2jJWayj7ZzvyKtVKHtLb/LKRs4Dg0UEg65xX1EcBAkC5fn4KG1jQHvi/tdOx1Sfh3hO6OK+68q1R6cQQYy+uG84q8RUjpO6dzFcWpE1yMdbQ5XMKfTh56ZdhXJ803LD2gGeIgcMwJp6HK9tnf0vaPPI9kbr8fqJBUUkciUoqpYzFd5m0ZCUbJsMD0oPY19FSRtfCNQvCbmhYrLy1sQ5FeMzbF0bi2oaUv+JD/A5RKokNMrrwv3nnTtG4vN1hJklQk2VW3sZWl6UjYgzhrbmKABtvPuB+xcYywIu4+JSworpfDwM/PZAKOfd6n+r8OdNV256l8WaNeF6osvXkUR7yxYpytywdQPA0d/z8mxTVoATE3wat7pnmTrqI5fqw=\n"
|