minfraud 1.0.2 → 1.3.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 -13
- data/.github/workflows/test.yml +46 -0
- data/.gitignore +2 -0
- data/.rubocop.yml +108 -0
- data/.travis.yml +19 -3
- data/CHANGELOG.md +65 -1
- data/CODE_OF_CONDUCT.md +4 -4
- data/Gemfile +11 -2
- data/LICENSE.txt +2 -1
- data/README.dev.md +4 -0
- data/README.md +245 -59
- data/Rakefile +18 -3
- data/bin/console +4 -3
- data/lib/maxmind/geoip2/model/city.rb +99 -0
- data/lib/maxmind/geoip2/model/country.rb +94 -0
- data/lib/maxmind/geoip2/model/insights.rb +38 -0
- data/lib/maxmind/geoip2/record/abstract.rb +46 -0
- data/lib/maxmind/geoip2/record/city.rb +62 -0
- data/lib/maxmind/geoip2/record/continent.rb +61 -0
- data/lib/maxmind/geoip2/record/country.rb +78 -0
- data/lib/maxmind/geoip2/record/location.rb +97 -0
- data/lib/maxmind/geoip2/record/maxmind.rb +41 -0
- data/lib/maxmind/geoip2/record/place.rb +52 -0
- data/lib/maxmind/geoip2/record/postal.rb +54 -0
- data/lib/maxmind/geoip2/record/represented_country.rb +47 -0
- data/lib/maxmind/geoip2/record/subdivision.rb +72 -0
- data/lib/maxmind/geoip2/record/traits.rb +233 -0
- data/lib/minfraud.rb +48 -8
- data/lib/minfraud/assessments.rb +118 -49
- data/lib/minfraud/components/account.rb +31 -9
- data/lib/minfraud/components/addressable.rb +73 -26
- data/lib/minfraud/components/base.rb +35 -11
- data/lib/minfraud/components/billing.rb +5 -0
- data/lib/minfraud/components/credit_card.rb +67 -18
- data/lib/minfraud/components/custom_inputs.rb +25 -0
- data/lib/minfraud/components/device.rb +51 -10
- data/lib/minfraud/components/email.rb +29 -7
- data/lib/minfraud/components/event.rb +60 -13
- data/lib/minfraud/components/order.rb +60 -22
- data/lib/minfraud/components/payment.rb +165 -21
- data/lib/minfraud/components/report/transaction.rb +80 -0
- data/lib/minfraud/components/shipping.rb +14 -5
- 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 -12
- data/lib/minfraud/errors.rb +22 -2
- data/lib/minfraud/http_service.rb +22 -8
- data/lib/minfraud/http_service/request.rb +19 -18
- data/lib/minfraud/http_service/response.rb +49 -12
- 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 +54 -0
- data/lib/minfraud/model/disposition.rb +35 -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 +82 -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 +178 -0
- data/lib/minfraud/model/warning.rb +63 -0
- data/lib/minfraud/report.rb +58 -0
- data/lib/minfraud/resolver.rb +25 -16
- data/lib/minfraud/validates.rb +187 -0
- data/lib/minfraud/version.rb +4 -1
- data/minfraud.gemspec +23 -18
- metadata +123 -48
checksums.yaml
CHANGED
@@ -1,15 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
5
|
-
data.tar.gz: !binary |-
|
6
|
-
ZGZlMWUwYTI3ZGExNTk0MWVlMWUyNTI5Mzc0OTgwNGFkZWNmMTgyZQ==
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: e5fce80d6ea146e9d31c969019ccefb4a79789645ecbb1db17e1221e90d46e7e
|
4
|
+
data.tar.gz: c1c4082e3a4b4305a530ed84f7a126c2f08872930ecc0df50e3fa20a9ece19cd
|
7
5
|
SHA512:
|
8
|
-
metadata.gz:
|
9
|
-
|
10
|
-
ZDVjMzMwMjRkZjY5YjJjNmNmZTBmZjdmMTEwMjYzNWU4ZGI0ZjMyOGFlMjhk
|
11
|
-
NWI2NjFhMTRjMjdhMjQ5OWQxMzU5ZWMzMzU0M2FhMzg2ZTNhODI=
|
12
|
-
data.tar.gz: !binary |-
|
13
|
-
NGMzZGE3YTBlNjRhN2Y3ZTM1NGEzYmI0ZjI5YTU4ZGM4MjRhZDBjYjZkMmVj
|
14
|
-
MWVjMTQ1YmM0YzAzMjRjYThlYzgwYmIyYmI1MTRmMzg2YjQ2MTEwNzg0MDA4
|
15
|
-
YTg4N2U2NzYyYmIzMDQ5MWJkZGRlMWFiOGUxNjQ3Y2Q3ZGJiOWE=
|
6
|
+
metadata.gz: c3996a9546ab76d48a2cd1721612a6d1833c37715f9f4da957dbe584be5a5c8523c552989c766af1f1c72f83b8b20eede3721543f0db86e381a2e8c333d4526b
|
7
|
+
data.tar.gz: 960d79206d07a0ec8b00cb48948dc6699c23693fcf64910a5469d728f6c2028a530f50d3f0079aa59acbd603544c29a88df659686bc8a4f3998bf4804af42a16
|
@@ -0,0 +1,46 @@
|
|
1
|
+
name: ruby-versions
|
2
|
+
on:
|
3
|
+
push:
|
4
|
+
paths-ignore:
|
5
|
+
- "**.md"
|
6
|
+
pull_request:
|
7
|
+
paths-ignore:
|
8
|
+
- "**.md"
|
9
|
+
jobs:
|
10
|
+
run:
|
11
|
+
name: ruby
|
12
|
+
runs-on: ${{ matrix.os }}
|
13
|
+
strategy:
|
14
|
+
fail-fast: false
|
15
|
+
matrix:
|
16
|
+
os: [ubuntu-latest, windows-latest, macos-latest]
|
17
|
+
version:
|
18
|
+
[
|
19
|
+
"2.2",
|
20
|
+
"2.3",
|
21
|
+
"2.4",
|
22
|
+
"2.5",
|
23
|
+
"2.6",
|
24
|
+
"2.7",
|
25
|
+
"head",
|
26
|
+
"jruby",
|
27
|
+
"jruby-head",
|
28
|
+
]
|
29
|
+
exclude:
|
30
|
+
- os: windows-latest
|
31
|
+
version: "jruby"
|
32
|
+
- os: windows-latest
|
33
|
+
version: "jruby-head"
|
34
|
+
steps:
|
35
|
+
- name: checkout
|
36
|
+
uses: actions/checkout@v2
|
37
|
+
|
38
|
+
- uses: ruby/setup-ruby@v1
|
39
|
+
with:
|
40
|
+
ruby-version: ${{ matrix.version }}
|
41
|
+
- name: ruby version
|
42
|
+
run: ruby -v
|
43
|
+
- run: bundler install
|
44
|
+
name: install
|
45
|
+
- run: bundler exec rake -t
|
46
|
+
name: test
|
data/.gitignore
CHANGED
data/.rubocop.yml
ADDED
@@ -0,0 +1,108 @@
|
|
1
|
+
Gemspec/RequiredRubyVersion:
|
2
|
+
Enabled: false # We support 1.9, but newer rubocops don't.
|
3
|
+
|
4
|
+
# Metrics.
|
5
|
+
|
6
|
+
Metrics/BlockLength:
|
7
|
+
Enabled: false # Default is true, but mostly hit in tests.
|
8
|
+
|
9
|
+
Metrics/AbcSize:
|
10
|
+
Enabled: false # To allow for pre-existing code.
|
11
|
+
|
12
|
+
Metrics/ClassLength:
|
13
|
+
Enabled: false # To allow for pre-existing code.
|
14
|
+
|
15
|
+
Metrics/CyclomaticComplexity:
|
16
|
+
Enabled: false # To allow for pre-existing code.
|
17
|
+
|
18
|
+
Metrics/MethodLength:
|
19
|
+
Enabled: false # To allow for pre-existing code.
|
20
|
+
|
21
|
+
Metrics/PerceivedComplexity:
|
22
|
+
Enabled: false # To allow for pre-existing code.
|
23
|
+
|
24
|
+
# Layout.
|
25
|
+
|
26
|
+
Layout/LineLength:
|
27
|
+
Max: 150 # Default is 120.
|
28
|
+
|
29
|
+
Layout/HashAlignment:
|
30
|
+
EnforcedHashRocketStyle: table # Default is key.
|
31
|
+
EnforcedColonStyle: table # Default is key.
|
32
|
+
|
33
|
+
Layout/ExtraSpacing:
|
34
|
+
ForceEqualSignAlignment: true # Default is false.
|
35
|
+
|
36
|
+
Layout/IndentationStyle:
|
37
|
+
IndentationWidth: 2 # Default is <none>.
|
38
|
+
|
39
|
+
# Style.
|
40
|
+
|
41
|
+
Style/HashSyntax:
|
42
|
+
EnforcedStyle: ruby19_no_mixed_keys # Default is ruby19.
|
43
|
+
|
44
|
+
Style/CollectionMethods:
|
45
|
+
Enabled: true # Default is false.
|
46
|
+
|
47
|
+
Style/NumericLiterals:
|
48
|
+
MinDigits: 4 # Default is 5.
|
49
|
+
|
50
|
+
Style/NegatedIf: # I disagree with this.
|
51
|
+
Enabled: false
|
52
|
+
|
53
|
+
Style/IfUnlessModifier: # This doesn't always make sense.
|
54
|
+
Enabled: false
|
55
|
+
|
56
|
+
Style/SymbolArray:
|
57
|
+
EnforcedStyle: brackets # Default is percent, but 1.9 doesn't support that.
|
58
|
+
|
59
|
+
# Trailing commas are often good.
|
60
|
+
Style/TrailingCommaInArguments:
|
61
|
+
Enabled: false
|
62
|
+
Style/TrailingCommaInArrayLiteral:
|
63
|
+
Enabled: false
|
64
|
+
Style/TrailingCommaInHashLiteral:
|
65
|
+
Enabled: false
|
66
|
+
|
67
|
+
Style/SafeNavigation:
|
68
|
+
Enabled: false # Default is true, but this 1.9 doesn't support it.
|
69
|
+
|
70
|
+
# Default is both which is probably fine, but it changes code and I don't want
|
71
|
+
# to investigate any possible behavior change right now.
|
72
|
+
Style/EmptyElse:
|
73
|
+
EnforcedStyle: empty
|
74
|
+
|
75
|
+
Style/ConditionalAssignment:
|
76
|
+
Enabled: false # This produces kind of strange results.
|
77
|
+
|
78
|
+
Style/Dir:
|
79
|
+
Enabled: false # This is good, but not supported on 1.9.
|
80
|
+
|
81
|
+
Style/ExpandPathArguments:
|
82
|
+
Enabled: false # This causes us to use __dir__ which 1.9 doesn't support.
|
83
|
+
|
84
|
+
Style/GuardClause:
|
85
|
+
Enabled: false # Doesn't always make sense.
|
86
|
+
|
87
|
+
Style/Documentation:
|
88
|
+
Enabled: false # We should enable this, but allow for pre-existing code.
|
89
|
+
|
90
|
+
Style/FormatStringToken:
|
91
|
+
Enabled: false # Seems unnecessary.
|
92
|
+
|
93
|
+
# Asks to use x.negative? instead of x < 0. But this isn't available until 2.3.
|
94
|
+
Style/NumericPredicate:
|
95
|
+
Enabled: false
|
96
|
+
|
97
|
+
# Seems unnecessary. Asks us to call super in a bunch of places when there's no
|
98
|
+
# need.
|
99
|
+
Lint/MissingSuper:
|
100
|
+
Enabled: false
|
101
|
+
|
102
|
+
# Naming.
|
103
|
+
|
104
|
+
Naming/VariableNumber:
|
105
|
+
Enabled: false # Doesn't always make sense.
|
106
|
+
|
107
|
+
AllCops:
|
108
|
+
NewCops: enable
|
data/.travis.yml
CHANGED
@@ -1,5 +1,21 @@
|
|
1
|
-
sudo: false
|
2
1
|
language: ruby
|
2
|
+
|
3
3
|
rvm:
|
4
|
-
- 2.
|
5
|
-
|
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"
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,69 @@
|
|
1
1
|
# Minfraud Changelog
|
2
2
|
|
3
|
-
## v1.0
|
3
|
+
## v1.3.0 (2020-09-25)
|
4
|
+
|
5
|
+
* Adds support for persistent HTTP connections. Connections persist
|
6
|
+
automatically.
|
7
|
+
* IMPORTANT: Ruby 1.9 is no longer supported. If you're using Ruby 1.9,
|
8
|
+
please use version 1.2.0 or older.
|
9
|
+
* Adds support for client side validation of inputs. An `InvalidInputError`
|
10
|
+
exception will be raised if an input is invalid. This can be enabled by
|
11
|
+
setting `enable_validation` to `true` when configuring `Minfraud`. It is
|
12
|
+
disabled by default.
|
13
|
+
* Adds the `residential_proxy?` method to `MaxMind::GeoIP2::Record::Traits`
|
14
|
+
for use with minFraud Insights and Factors.
|
15
|
+
|
16
|
+
## v1.2.0 (2020-07-15)
|
17
|
+
|
18
|
+
* Adds new processor types to `Minfraud::Components::Payment`: `:cashfree`,
|
19
|
+
`:first_atlantic_commerce`, `:komoju`, `:paytm`, `:razorpay`, and
|
20
|
+
`:systempay`.
|
21
|
+
* Adds support for three new Factors outputs: `/subscores/device` (the risk
|
22
|
+
associated with the device), `/subscores/email_local_part` (the risk
|
23
|
+
associated with the part of the email address before the @ symbol) and
|
24
|
+
`/subscores/shipping_address` (the risk associated with the shipping
|
25
|
+
address).
|
26
|
+
* Adds support for providing your MaxMind account ID using the `account_id`
|
27
|
+
attribute instead of the `user_id` attribute. In a future release,
|
28
|
+
support for the `user_id` attribute will be removed.
|
29
|
+
|
30
|
+
## v1.1.0 (2020-06-19)
|
31
|
+
|
32
|
+
* Adds support for the minFraud Report Transaction API. Reporting
|
33
|
+
transactions to MaxMind helps us detect about 10-50% more fraud and
|
34
|
+
reduce false positives for you.
|
35
|
+
* Adds support for the new credit card output `/credit_card/is_business`.
|
36
|
+
This indicates whether the card is a business card. It may be accessed
|
37
|
+
via `response.credit_credit.is_business` on the minFraud Insights and
|
38
|
+
Factors response objects.
|
39
|
+
* Adds support for the new email domain output `/email/domain/first_seen`.
|
40
|
+
This may be accessed via `response.email.domain.first_seen` on the
|
41
|
+
minFraud Insights and Factors response objects.
|
42
|
+
* Rename `ErrorHandler#inspect` to `ErrorHandler#examine` in order not to
|
43
|
+
break LSP.
|
44
|
+
* Adds classes for the Score, Insights, and Factors responses. This allows
|
45
|
+
us to provide API documentation for the various response attributes.
|
46
|
+
* Removes `hashie` as a required dependency.
|
47
|
+
* Adds new processor types to `Minfraud::Components::Payment`: `:affirm`,
|
48
|
+
`:afterpay`, `:cardpay`, `:ccavenue`, `:cetelem`, `:ct_payments`,
|
49
|
+
`:dalenys`, `:datacash`, `:dotpay`, `:ecommpay`, `:epx`, `:g2a_pay`,
|
50
|
+
`:gocardless`, `:interac`, `:klarna`, `:mercanet`, `:oney`, `:payeezy`,
|
51
|
+
`:paylike`, `:payment_express`, `:paysafecard`, `:posconnect`,
|
52
|
+
`:smartdebit`, `:synapsefi`, and others.
|
53
|
+
* Adds support for passing custom inputs to minFraud. GitHub #6.
|
54
|
+
* Adds `:email_change`, `:password_reset`, and `:payout_change` as types to
|
55
|
+
`Minfraud::Components::Event`.
|
56
|
+
* Adds support for the `session_id` and `session_age` inputs.
|
57
|
+
|
58
|
+
## v1.0.4 (2016-12-23)
|
59
|
+
|
60
|
+
* Prevents boolean value conversion to string to avoid warnings
|
61
|
+
* Adds `amount` attribute to the `Minfraud::Components::Order` instances
|
62
|
+
|
63
|
+
## v1.0.3 (2016-11-24)
|
64
|
+
* Adds `token` attribute to the `Minfraud::Components::CreditCard` instances
|
65
|
+
according to the MinFraud Release Notes introduced on November 17, 2016
|
66
|
+
|
67
|
+
## v1.0.2 (2016-10-11)
|
4
68
|
|
5
69
|
* Adds support for Ruby >= 1.9
|
data/CODE_OF_CONDUCT.md
CHANGED
@@ -35,7 +35,7 @@ This code of conduct applies both within project spaces and in public spaces
|
|
35
35
|
when an individual is representing the project or its community.
|
36
36
|
|
37
37
|
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
38
|
-
reported by contacting a project maintainer at
|
38
|
+
reported by contacting a project maintainer at support@maxmind.com. All
|
39
39
|
complaints will be reviewed and investigated and will result in a response that
|
40
40
|
is deemed necessary and appropriate to the circumstances. Maintainers are
|
41
41
|
obligated to maintain confidentiality with regard to the reporter of an
|
@@ -43,7 +43,7 @@ incident.
|
|
43
43
|
|
44
44
|
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
|
45
45
|
version 1.3.0, available at
|
46
|
-
[
|
46
|
+
[https://contributor-covenant.org/version/1/3/0/][version]
|
47
47
|
|
48
|
-
[homepage]:
|
49
|
-
[version]:
|
48
|
+
[homepage]: https://contributor-covenant.org
|
49
|
+
[version]: https://contributor-covenant.org/version/1/3/0/
|
data/Gemfile
CHANGED
@@ -1,5 +1,14 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
source 'https://rubygems.org'
|
2
4
|
|
3
|
-
#
|
4
|
-
|
5
|
+
# coveralls fails on Ruby 1.9. My understanding is we don't need to run this on
|
6
|
+
# more than one version anyway, so restrict to the current latest.
|
7
|
+
version_pieces = RUBY_VERSION.split('.')
|
8
|
+
major_version = version_pieces[0]
|
9
|
+
minor_version = version_pieces[1]
|
10
|
+
if major_version == '2' && minor_version == '7'
|
11
|
+
gem 'coveralls', require: false
|
12
|
+
end
|
13
|
+
|
5
14
|
gemspec
|
data/LICENSE.txt
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
The MIT License (MIT)
|
2
2
|
|
3
|
-
Copyright (c) 2016 kushnir.yb
|
3
|
+
Copyright (c) 2016-2020 kushnir.yb
|
4
|
+
Copyright (c) 2020 MaxMind, Inc.
|
4
5
|
|
5
6
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
7
|
of this software and associated documentation files (the "Software"), to deal
|
data/README.dev.md
ADDED
data/README.md
CHANGED
@@ -1,12 +1,14 @@
|
|
1
|
-
#
|
1
|
+
# Ruby API for MaxMind minFraud Services
|
2
2
|
|
3
|
-
|
4
|
-
[](https://coveralls.io/github/kushniryb/minfraud-api-v2?branch=master)
|
5
|
-
[](https://travis-ci.org/kushniryb/minfraud-api-v2)
|
3
|
+
## Description
|
6
4
|
|
7
|
-
|
5
|
+
This package provides an API for the [MaxMind minFraud web
|
6
|
+
services](https://dev.maxmind.com/minfraud/). This includes minFraud Score,
|
7
|
+
Insights, and Factors. It also includes our [minFraud Report Transaction
|
8
|
+
API](https://dev.maxmind.com/minfraud/report-transaction/).
|
8
9
|
|
9
|
-
|
10
|
+
The legacy minFraud Standard and Premium services are not supported by this
|
11
|
+
API.
|
10
12
|
|
11
13
|
## Installation
|
12
14
|
|
@@ -18,90 +20,274 @@ gem 'minfraud'
|
|
18
20
|
|
19
21
|
And then execute:
|
20
22
|
|
21
|
-
```
|
23
|
+
```
|
22
24
|
$ bundle
|
23
25
|
```
|
24
26
|
|
25
27
|
Or install it yourself as:
|
28
|
+
|
26
29
|
```
|
27
30
|
$ gem install minfraud
|
28
31
|
```
|
29
32
|
|
30
|
-
##
|
33
|
+
## API Documentation
|
34
|
+
|
35
|
+
See the [API documentation](https://www.rubydoc.info/gems/minfraud) for
|
36
|
+
more details.
|
37
|
+
|
38
|
+
## Usage
|
31
39
|
|
32
|
-
|
40
|
+
### Configuration
|
41
|
+
|
42
|
+
An account ID and license key are required to work with the web services.
|
43
|
+
Configure these before making a request:
|
33
44
|
|
34
45
|
```ruby
|
35
46
|
Minfraud.configure do |c|
|
47
|
+
c.account_id = 12345
|
36
48
|
c.license_key = 'your_license_key'
|
37
|
-
c.
|
49
|
+
c.enable_validation = true
|
38
50
|
end
|
39
|
-
|
51
|
+
````
|
52
|
+
|
53
|
+
### Making a minFraud Score, Insights, or Factors Request
|
54
|
+
|
55
|
+
To use the minFraud API, create a `Minfraud::Assessments` object. The
|
56
|
+
constructor takes a hash of symbols corresponding to each component of the
|
57
|
+
minFraud request. You can also set components by their attribute after
|
58
|
+
creating the object.
|
59
|
+
|
60
|
+
After populating the object, call the method for the minFraud endpoint you
|
61
|
+
want to use: `#score`, `#insights`, or `#factors`. The returned value is a
|
62
|
+
`MinFraud::Response` object. You can access the response model through its
|
63
|
+
`#body` attribute.
|
64
|
+
|
65
|
+
An exception will be thrown for critical errors. You should check for
|
66
|
+
`warnings` related to your inputs after a request.
|
40
67
|
|
41
|
-
## Usage
|
42
68
|
```ruby
|
43
|
-
#
|
69
|
+
# Prepare the request.
|
44
70
|
assessment = Minfraud::Assessments.new(
|
45
71
|
device: {
|
46
|
-
ip_address:
|
47
|
-
|
72
|
+
ip_address: '152.216.7.110',
|
73
|
+
accept_language: 'en-US,en;q=0.8',
|
74
|
+
session_age: 3600.5,
|
75
|
+
session_id: 'foo',
|
76
|
+
user_agent: 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.89 Safari/537.36',
|
77
|
+
},
|
78
|
+
event: {
|
79
|
+
transaction_id: 'txn3134133',
|
80
|
+
shop_id: 's2123',
|
81
|
+
time: '2012-04-12T23:20:50+00:00',
|
82
|
+
type: :purchase,
|
83
|
+
},
|
84
|
+
account: {
|
85
|
+
user_id: '3132',
|
86
|
+
username_md5: '4f9726678c438914fa04bdb8c1a24088',
|
87
|
+
},
|
88
|
+
email: {
|
89
|
+
address: 'test@maxmind.com',
|
90
|
+
domain: 'maxmind.com',
|
91
|
+
},
|
92
|
+
billing: {
|
93
|
+
first_name: 'First',
|
94
|
+
last_name: 'Last',
|
95
|
+
company: 'Company',
|
96
|
+
address: '101 Address Rd.',
|
97
|
+
address_2: 'Unit 5',
|
98
|
+
city: 'New Haven',
|
99
|
+
region: 'CT',
|
100
|
+
country: 'US',
|
101
|
+
postal: '06510',
|
102
|
+
phone_number: '123-456-7890',
|
103
|
+
phone_country_code: '1',
|
104
|
+
},
|
105
|
+
shipping: {
|
106
|
+
first_name: 'ShipFirst',
|
107
|
+
last_name: 'ShipLast',
|
108
|
+
company: 'ShipCo',
|
109
|
+
address: '322 Ship Addr. Ln.',
|
110
|
+
address_2: 'St. 43',
|
111
|
+
city: 'Nowhere',
|
112
|
+
region: 'OK',
|
113
|
+
country: 'US',
|
114
|
+
postal: '73003',
|
115
|
+
phone_number: '123-456-0000',
|
116
|
+
phone_country_code: '1',
|
117
|
+
delivery_speed: :same_day,
|
118
|
+
},
|
119
|
+
payment: {
|
120
|
+
processor: :stripe,
|
121
|
+
was_authorized: false,
|
122
|
+
decline_code: 'invalid number',
|
123
|
+
},
|
124
|
+
credit_card: {
|
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
|
+
},
|
134
|
+
order: {
|
135
|
+
amount: 323.21,
|
136
|
+
currency: 'USD',
|
137
|
+
discount_code: 'FIRST',
|
138
|
+
is_gift: true,
|
139
|
+
has_gift_message: false,
|
140
|
+
affiliate_id: 'af12',
|
141
|
+
subaffiliate_id: 'saf42',
|
142
|
+
referrer_uri: 'http://www.amazon.com/',
|
143
|
+
},
|
144
|
+
shopping_cart: [
|
145
|
+
{
|
146
|
+
category: 'pets',
|
147
|
+
item_id: 'leash-0231',
|
148
|
+
quantity: 2,
|
149
|
+
price: 20.43,
|
150
|
+
},
|
151
|
+
{
|
152
|
+
category: 'beauty',
|
153
|
+
item_id: 'msc-1232',
|
154
|
+
quantity: 1,
|
155
|
+
price: 100.00,
|
156
|
+
},
|
157
|
+
],
|
158
|
+
custom_inputs: {
|
159
|
+
section: 'news',
|
160
|
+
previous_purchases: 19,
|
161
|
+
discount: 3.2,
|
162
|
+
previous_user: true,
|
163
|
+
},
|
48
164
|
)
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
# You can also change data inbetween requests
|
74
|
-
first_request = assessment.insights
|
75
|
-
assessment.device.ip_address = '22.22.22.33'
|
76
|
-
second_request = assessment.insights
|
165
|
+
|
166
|
+
# To get the Factors response model, use #factors.
|
167
|
+
factors_model = assessment.factors.body
|
168
|
+
|
169
|
+
factors_model.warnings.each { |w| puts w.warning }
|
170
|
+
|
171
|
+
p factors_model.subscores.email_address
|
172
|
+
p factors_model.risk_score
|
173
|
+
|
174
|
+
# To get the Insights response model, use #insights.
|
175
|
+
insights_model = assessment.insights.body
|
176
|
+
|
177
|
+
insights_model.warnings.each { |w| puts w.warning }
|
178
|
+
|
179
|
+
p insights_model.credit_card.issuer.name
|
180
|
+
p insights_model.risk_score
|
181
|
+
|
182
|
+
# To get the Score response model, use #score.
|
183
|
+
score_model = assessment.score.body
|
184
|
+
|
185
|
+
score_model.warnings.each { |w| puts w.warning }
|
186
|
+
|
187
|
+
p score_model.risk_score
|
77
188
|
```
|
78
189
|
|
79
|
-
|
190
|
+
See the [API documentation](https://www.rubydoc.info/gems/minfraud) for
|
191
|
+
more details.
|
80
192
|
|
81
|
-
|
82
|
-
```ruby
|
83
|
-
# Raised if unpermitted key is provided to Minfraud::Assessments initializer
|
84
|
-
class RequestFormatError < BaseError; end
|
193
|
+
### Reporting a Transaction to MaxMind
|
85
194
|
|
86
|
-
|
87
|
-
|
195
|
+
MaxMind encourages the use of this API, as data received through this
|
196
|
+
channel is used to improve the accuracy of their fraud detection
|
197
|
+
algorithms.
|
88
198
|
|
89
|
-
|
90
|
-
|
199
|
+
To use the Report Transaction API, create a
|
200
|
+
`Minfraud::Components::Report::Transaction` object. An IP address and a
|
201
|
+
valid tag are required arguments for this API. Additional parameters may be
|
202
|
+
set, as shown below.
|
91
203
|
|
92
|
-
|
93
|
-
|
204
|
+
If the report is successful, nothing is returned. If the report fails, an
|
205
|
+
exception will be thrown.
|
94
206
|
|
95
|
-
|
96
|
-
|
207
|
+
```ruby
|
208
|
+
# The report_transaction method only makes use of a transaction component:
|
209
|
+
txn = Minfraud::Components::Report::Transaction.new(
|
210
|
+
ip_address: '152.216.7.110',
|
211
|
+
tag: :suspected_fraud,
|
212
|
+
maxmind_id: '12345678',
|
213
|
+
minfraud_id: '58fa38d8-4b87-458b-a22b-f00eda1aa20d',
|
214
|
+
notes: 'notes go here',
|
215
|
+
transaction_id: '1FA254yZ'
|
216
|
+
)
|
217
|
+
reporter = Minfraud::Report.new(transaction: txn)
|
218
|
+
reporter.report_transaction
|
97
219
|
```
|
98
220
|
|
221
|
+
See the [API documentation](https://www.rubydoc.info/gems/minfraud) for
|
222
|
+
more details.
|
223
|
+
|
224
|
+
### Persistent HTTP Connections
|
225
|
+
|
226
|
+
This gem supports persistent HTTP connections, allowing you to avoid the
|
227
|
+
overhead of creating a new HTTP connection for each minFraud request if you
|
228
|
+
plan to perform more than one. You do not need to do anything to enable
|
229
|
+
this functionality.
|
230
|
+
|
231
|
+
### Exceptions
|
232
|
+
|
233
|
+
The gem supplies several distinct exception-types:
|
234
|
+
|
235
|
+
* `RequestFormatError` - Raised if an unknown key is provided to the
|
236
|
+
`Minfraud::Assessments` constructor
|
237
|
+
* `ClientError` - Raised if the IP address is absent, reserved, or the JSON
|
238
|
+
body cannot be decoded
|
239
|
+
* `AuthorizationError` - Raised if there are problems with the account ID
|
240
|
+
and/or license key
|
241
|
+
* `ServerError` - Raised if minFraud returns an error or if there is an
|
242
|
+
HTTP error
|
243
|
+
* `NotEnumValueError` - Raised if an attribute value doesn't belong to the
|
244
|
+
predefined set of values
|
245
|
+
|
246
|
+
### Thread Safety
|
247
|
+
|
248
|
+
This gem is safe for use from multiple threads.
|
249
|
+
|
250
|
+
`Minfraud::Assessments` and `Minfraud::Report` objects must not be shared
|
251
|
+
across threads.
|
252
|
+
|
253
|
+
Please note that you must run `Minfraud.configure` before calling any
|
254
|
+
functionality using multiple threads.
|
255
|
+
|
256
|
+
## Support
|
257
|
+
|
258
|
+
Please report all issues with this code using the
|
259
|
+
[GitHub issue tracker](https://github.com/maxmind/minfraud-api-ruby/issues).
|
260
|
+
|
261
|
+
If you are having an issue with the minFraud service that is not specific
|
262
|
+
to the client API, please see
|
263
|
+
[our support page](https://www.maxmind.com/en/support).
|
264
|
+
|
265
|
+
## Requirements
|
266
|
+
|
267
|
+
This gem works with Ruby 2.0 and above.
|
268
|
+
|
99
269
|
## Contributing
|
100
270
|
|
101
|
-
Bug reports and pull requests are welcome on
|
271
|
+
Bug reports and pull requests are welcome on
|
272
|
+
[GitHub](https://github.com/maxmind/minfraud-api-ruby). This project is
|
273
|
+
intended to be a safe, welcoming space for collaboration, and contributors
|
274
|
+
are expected to adhere to the [Contributor
|
275
|
+
Covenant](https://contributor-covenant.org) code of conduct.
|
276
|
+
|
277
|
+
## Versioning
|
278
|
+
|
279
|
+
This API uses [Semantic Versioning](https://semver.org/).
|
280
|
+
|
281
|
+
## Copyright and License
|
282
|
+
|
283
|
+
Copyright (c) 2016-2020 kushnir.yb.
|
102
284
|
|
285
|
+
Copyright (c) 2020 MaxMind, Inc.
|
103
286
|
|
104
|
-
|
287
|
+
The gem is available as open source under the terms of the [MIT
|
288
|
+
License](https://opensource.org/licenses/MIT).
|
105
289
|
|
106
|
-
|
290
|
+
## Thank You
|
107
291
|
|
292
|
+
This gem is the work of the creator and original maintainer kushnir.yb
|
293
|
+
(@kushniryb).
|