minfraud 1.0.2 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- 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
@@ -1,20 +1,42 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Minfraud
|
2
4
|
module Components
|
5
|
+
# Email corresponds to the email object of a minFraud request.
|
6
|
+
#
|
7
|
+
# @see https://dev.maxmind.com/minfraud/#Email_(/email)
|
3
8
|
class Email < Base
|
4
|
-
|
5
|
-
|
9
|
+
include Minfraud::Validates
|
10
|
+
|
11
|
+
# This field must be either be a valid email address or an MD5 of the
|
12
|
+
# lowercased email used in the transaction. Important: if using the MD5
|
13
|
+
# hash, please be sure to convert the email address to lowercase before
|
14
|
+
# calculating its MD5 hash.
|
15
|
+
#
|
16
|
+
# @return [String, nil]
|
6
17
|
attr_accessor :address
|
7
18
|
|
8
|
-
#
|
9
|
-
#
|
19
|
+
# The domain of the email address used in the transaction.
|
20
|
+
#
|
21
|
+
# @return [String, nil]
|
10
22
|
attr_accessor :domain
|
11
23
|
|
12
|
-
#
|
13
|
-
#
|
14
|
-
# @return [Minfraud::Components::Email] an Email instance
|
24
|
+
# @param params [Hash] Hash of parameters. Each key/value should
|
25
|
+
# correspond to one of the available attributes.
|
15
26
|
def initialize(params = {})
|
16
27
|
@address = params[:address]
|
17
28
|
@domain = params[:domain]
|
29
|
+
|
30
|
+
validate
|
31
|
+
end
|
32
|
+
|
33
|
+
private
|
34
|
+
|
35
|
+
def validate
|
36
|
+
return if !Minfraud.enable_validation
|
37
|
+
|
38
|
+
validate_email('email', @address)
|
39
|
+
validate_string('domain', 255, @domain)
|
18
40
|
end
|
19
41
|
end
|
20
42
|
end
|
@@ -1,32 +1,79 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Minfraud
|
2
4
|
module Components
|
5
|
+
# Event corresponds to the event object of a minFraud request.
|
6
|
+
#
|
7
|
+
# @see https://dev.maxmind.com/minfraud/#Event_(/event)
|
3
8
|
class Event < Base
|
4
9
|
include ::Minfraud::Enum
|
5
|
-
|
6
|
-
|
10
|
+
include Minfraud::Validates
|
11
|
+
|
12
|
+
# Your internal ID for the transaction. MaxMind can use this to locate a
|
13
|
+
# specific transaction in logs, and it will also show up in email alerts
|
14
|
+
# and notifications from MaxMind to you. No specific format is required.
|
15
|
+
#
|
16
|
+
# @return [String, nil]
|
7
17
|
attr_accessor :transaction_id
|
8
18
|
|
9
|
-
#
|
10
|
-
#
|
19
|
+
# Your internal ID for the shop, affiliate, or merchant this order is
|
20
|
+
# coming from. Required for minFraud users who are resellers, payment
|
21
|
+
# providers, gateways and affiliate networks. No specific format is
|
22
|
+
# required.
|
23
|
+
#
|
24
|
+
# @return [String, nil]
|
11
25
|
attr_accessor :shop_id
|
12
26
|
|
13
|
-
#
|
14
|
-
#
|
15
|
-
# If this field is not in the request, the
|
27
|
+
# The date and time the event occurred. The string must be in the RFC
|
28
|
+
# 3339 date-time format, e.g., "2012-04-12T23:20:50.52Z". The time must
|
29
|
+
# be within the past 10 years. If this field is not in the request, the
|
30
|
+
# current time will be used.
|
31
|
+
#
|
32
|
+
# @see https://tools.ietf.org/html/rfc3339
|
33
|
+
#
|
34
|
+
# @return [String, nil]
|
16
35
|
attr_accessor :time
|
17
36
|
|
18
|
-
#
|
19
|
-
#
|
20
|
-
|
37
|
+
# The type of event being scored. This must be one of
|
38
|
+
# +:account_creation+, +:account_login+, +:email_change+,
|
39
|
+
# +:password_reset+, +:payout_change+, +:purchase+,
|
40
|
+
# +:recurring_purchase+, +:referral+, or +:survey+.
|
41
|
+
#
|
42
|
+
# @!attribute type
|
43
|
+
#
|
44
|
+
# @return [Symbol, nil]
|
45
|
+
enum_accessor :type,
|
46
|
+
[
|
47
|
+
:account_creation,
|
48
|
+
:account_login,
|
49
|
+
:email_change,
|
50
|
+
:password_reset,
|
51
|
+
:payout_change,
|
52
|
+
:purchase,
|
53
|
+
:recurring_purchase,
|
54
|
+
:referral,
|
55
|
+
:survey,
|
56
|
+
]
|
21
57
|
|
22
|
-
#
|
23
|
-
#
|
24
|
-
# @return [Minfraud::Components::Event] an Event instance
|
58
|
+
# @param params [Hash] Hash of parameters. Each key/value should
|
59
|
+
# correspond to one of the available attributes.
|
25
60
|
def initialize(params = {})
|
26
61
|
@transaction_id = params[:transaction_id]
|
27
62
|
@shop_id = params[:shop_id]
|
28
63
|
@time = params[:time]
|
29
64
|
self.type = params[:type]
|
65
|
+
|
66
|
+
validate
|
67
|
+
end
|
68
|
+
|
69
|
+
private
|
70
|
+
|
71
|
+
def validate
|
72
|
+
return if !Minfraud.enable_validation
|
73
|
+
|
74
|
+
validate_string('transaction_id', 255, @transaction_id)
|
75
|
+
validate_string('shop_id', 255, @shop_id)
|
76
|
+
validate_rfc3339('time', @time)
|
30
77
|
end
|
31
78
|
end
|
32
79
|
end
|
@@ -1,50 +1,88 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Minfraud
|
2
4
|
module Components
|
5
|
+
# Order corresponds to the order object of a minFraud request.
|
6
|
+
#
|
7
|
+
# @see https://dev.maxmind.com/minfraud/#Order_(/order)
|
3
8
|
class Order < Base
|
4
|
-
|
5
|
-
|
9
|
+
include Minfraud::Validates
|
10
|
+
|
11
|
+
# The total order amount for the transaction before taxes and discounts.
|
12
|
+
# The value must be at least 0 and at most 1e14 - 1.
|
13
|
+
#
|
14
|
+
# @return [Float, nil]
|
6
15
|
attr_accessor :amount
|
7
16
|
|
8
|
-
#
|
9
|
-
#
|
17
|
+
# The ISO 4217 currency code for the currency used in the transaction.
|
18
|
+
#
|
19
|
+
# @see https://en.wikipedia.org/wiki/ISO_4217
|
20
|
+
#
|
21
|
+
# @return [String, nil]
|
10
22
|
attr_accessor :currency
|
11
23
|
|
12
|
-
#
|
13
|
-
#
|
14
|
-
#
|
24
|
+
# The discount code applied to the transaction. If multiple discount
|
25
|
+
# codes are used, please separate them with a comma.
|
26
|
+
#
|
27
|
+
# @return [String, nil]
|
15
28
|
attr_accessor :discount_code
|
16
29
|
|
17
|
-
#
|
18
|
-
#
|
30
|
+
# The ID of the affiliate where the order is coming from. No specific
|
31
|
+
# format is required.
|
32
|
+
#
|
33
|
+
# @return [String, nil]
|
19
34
|
attr_accessor :affiliate_id
|
20
35
|
|
21
|
-
#
|
22
|
-
#
|
36
|
+
# The ID of the sub-affiliate where the order is coming from. No specific
|
37
|
+
# format is required.
|
38
|
+
#
|
39
|
+
# @return [String, nil]
|
23
40
|
attr_accessor :subaffiliate_id
|
24
41
|
|
25
|
-
#
|
26
|
-
#
|
42
|
+
# The URI of the referring site for this order. Needs to be absolute and
|
43
|
+
# have a URI scheme such as +https://+.
|
44
|
+
#
|
45
|
+
# @return [String, nil]
|
27
46
|
attr_accessor :referrer_uri
|
28
47
|
|
29
|
-
#
|
30
|
-
#
|
48
|
+
# Whether order was marked as a gift by the purchaser.
|
49
|
+
#
|
50
|
+
# @return [Boolean, nil]
|
31
51
|
attr_accessor :is_gift
|
32
52
|
|
33
|
-
#
|
34
|
-
#
|
53
|
+
# Whether the purchaser included a gift message.
|
54
|
+
#
|
55
|
+
# @return [Boolean, nil]
|
35
56
|
attr_accessor :has_gift_message
|
36
57
|
|
37
|
-
#
|
38
|
-
#
|
39
|
-
|
40
|
-
|
58
|
+
# @param params [Hash] Hash of parameters. Each key/value should
|
59
|
+
# correspond to one of the available attributes.
|
60
|
+
def initialize(params = {})
|
61
|
+
@amount = params[:amount]
|
41
62
|
@has_gift_message = params[:has_gift_message]
|
42
63
|
@affiliate_id = params[:affiliate_id]
|
43
64
|
@subaffiliate_id = params[:subaffiliate_id]
|
44
65
|
@currency = params[:currency]
|
45
|
-
@discount_code = params[:
|
66
|
+
@discount_code = params[:discount_code]
|
46
67
|
@referrer_uri = params[:referrer_uri]
|
47
68
|
@is_gift = params[:is_gift]
|
69
|
+
|
70
|
+
validate
|
71
|
+
end
|
72
|
+
|
73
|
+
private
|
74
|
+
|
75
|
+
def validate
|
76
|
+
return if !Minfraud.enable_validation
|
77
|
+
|
78
|
+
validate_nonnegative_number('amount', @amount)
|
79
|
+
validate_boolean('has_gift_message', @has_gift_message)
|
80
|
+
validate_string('affiliate_id', 255, @affiliate_id)
|
81
|
+
validate_string('subaffiliate_id', 255, @subaffiliate_id)
|
82
|
+
validate_regex('currency', /\A[A-Z]{3}\z/, @currency)
|
83
|
+
validate_string('discount_code', 255, @discount_code)
|
84
|
+
validate_uri('referrer_uri', @referrer_uri)
|
85
|
+
validate_boolean('is_gift', @is_gift)
|
48
86
|
end
|
49
87
|
end
|
50
88
|
end
|
@@ -1,39 +1,183 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Minfraud
|
2
4
|
module Components
|
5
|
+
# Payment corresponds to the payment object of a minFraud request.
|
6
|
+
#
|
7
|
+
# @see https://dev.maxmind.com/minfraud/#Payment_(/payment)
|
3
8
|
class Payment < Base
|
4
9
|
include ::Minfraud::Enum
|
5
|
-
|
6
|
-
|
10
|
+
include Minfraud::Validates
|
11
|
+
|
12
|
+
# The payment processor used for the transaction. The value is one
|
13
|
+
# listed as a valid value, as a symbol.
|
14
|
+
#
|
15
|
+
# @!attribute processor
|
16
|
+
#
|
17
|
+
# @return [Symbol, nil]
|
7
18
|
enum_accessor :processor, [
|
8
|
-
:adyen,
|
9
|
-
:
|
10
|
-
:
|
11
|
-
:
|
12
|
-
:
|
13
|
-
:
|
14
|
-
:
|
15
|
-
:
|
16
|
-
:
|
17
|
-
:
|
18
|
-
:
|
19
|
-
:
|
19
|
+
:adyen,
|
20
|
+
:affirm,
|
21
|
+
:afterpay,
|
22
|
+
:altapay,
|
23
|
+
:amazon_payments,
|
24
|
+
:american_express_payment_gateway,
|
25
|
+
:authorizenet,
|
26
|
+
:balanced,
|
27
|
+
:beanstream,
|
28
|
+
:bluepay,
|
29
|
+
:bluesnap,
|
30
|
+
:bpoint,
|
31
|
+
:braintree,
|
32
|
+
:cardpay,
|
33
|
+
:cashfree,
|
34
|
+
:ccavenue,
|
35
|
+
:ccnow,
|
36
|
+
:cetelem,
|
37
|
+
:chase_paymentech,
|
38
|
+
:checkout_com,
|
39
|
+
:cielo,
|
40
|
+
:collector,
|
41
|
+
:commdoo,
|
42
|
+
:compropago,
|
43
|
+
:concept_payments,
|
44
|
+
:conekta,
|
45
|
+
:ct_payments,
|
46
|
+
:cuentadigital,
|
47
|
+
:curopayments,
|
48
|
+
:cybersource,
|
49
|
+
:dalenys,
|
50
|
+
:dalpay,
|
51
|
+
:datacash,
|
52
|
+
:dibs,
|
53
|
+
:digital_river,
|
54
|
+
:dotpay,
|
55
|
+
:ebs,
|
56
|
+
:ecomm365,
|
57
|
+
:ecommpay,
|
58
|
+
:elavon,
|
59
|
+
:emerchantpay,
|
60
|
+
:epay,
|
61
|
+
:eprocessing_network,
|
62
|
+
:epx,
|
63
|
+
:eway,
|
64
|
+
:exact,
|
65
|
+
:first_atlantic_commerce,
|
66
|
+
:first_data,
|
67
|
+
:g2a_pay,
|
68
|
+
:global_payments,
|
69
|
+
:gocardless,
|
70
|
+
:heartland,
|
71
|
+
:hipay,
|
72
|
+
:ingenico,
|
73
|
+
:interac,
|
74
|
+
:internetsecure,
|
75
|
+
:intuit_quickbooks_payments,
|
76
|
+
:iugu,
|
77
|
+
:klarna,
|
78
|
+
:komoju,
|
79
|
+
:lemon_way,
|
80
|
+
:mastercard_payment_gateway,
|
81
|
+
:mercadopago,
|
82
|
+
:mercanet,
|
83
|
+
:merchant_esolutions,
|
84
|
+
:mirjeh,
|
85
|
+
:mollie,
|
86
|
+
:moneris_solutions,
|
87
|
+
:nmi,
|
88
|
+
:oceanpayment,
|
89
|
+
:oney,
|
90
|
+
:openpaymx,
|
91
|
+
:optimal_payments,
|
92
|
+
:orangepay,
|
93
|
+
:other,
|
94
|
+
:pacnet_services,
|
95
|
+
:payeezy,
|
96
|
+
:payfast,
|
97
|
+
:paygate,
|
98
|
+
:paylike,
|
99
|
+
:payment_express,
|
100
|
+
:paymentwall,
|
101
|
+
:payone,
|
102
|
+
:paypal,
|
103
|
+
:payplus,
|
104
|
+
:paysafecard,
|
105
|
+
:paystation,
|
106
|
+
:paytm,
|
107
|
+
:paytrace,
|
108
|
+
:paytrail,
|
109
|
+
:payture,
|
110
|
+
:payu,
|
111
|
+
:payulatam,
|
112
|
+
:payway,
|
113
|
+
:payza,
|
114
|
+
:pinpayments,
|
115
|
+
:posconnect,
|
116
|
+
:princeton_payment_solutions,
|
117
|
+
:psigate,
|
118
|
+
:qiwi,
|
119
|
+
:quickpay,
|
120
|
+
:raberil,
|
121
|
+
:razorpay,
|
122
|
+
:rede,
|
123
|
+
:redpagos,
|
124
|
+
:rewardspay,
|
125
|
+
:sagepay,
|
126
|
+
:securetrading,
|
127
|
+
:simplify_commerce,
|
128
|
+
:skrill,
|
129
|
+
:smartcoin,
|
130
|
+
:smartdebit,
|
131
|
+
:solidtrust_pay,
|
132
|
+
:sps_decidir,
|
133
|
+
:stripe,
|
134
|
+
:synapsefi,
|
135
|
+
:systempay,
|
136
|
+
:telerecargas,
|
137
|
+
:towah,
|
138
|
+
:transact_pro,
|
139
|
+
:usa_epay,
|
140
|
+
:vantiv,
|
141
|
+
:verepay,
|
142
|
+
:vericheck,
|
143
|
+
:vindicia,
|
144
|
+
:virtual_card_services,
|
145
|
+
:vme,
|
146
|
+
:vpos,
|
147
|
+
:wirecard,
|
148
|
+
:worldpay
|
20
149
|
]
|
21
150
|
|
22
|
-
#
|
23
|
-
#
|
151
|
+
# The authorization outcome from the payment processor. If the
|
152
|
+
# transaction has not yet been approved or denied, do not include this
|
153
|
+
# field.
|
154
|
+
#
|
155
|
+
# @return [Boolean, nil]
|
24
156
|
attr_accessor :was_authorized
|
25
157
|
|
26
|
-
#
|
27
|
-
#
|
158
|
+
# The decline code as provided by your payment processor. If the
|
159
|
+
# transaction was not declined, do not include this field.
|
160
|
+
#
|
161
|
+
# @return [String, nil]
|
28
162
|
attr_accessor :decline_code
|
29
163
|
|
30
|
-
#
|
31
|
-
#
|
32
|
-
# @return [Minfraud::Components::Payment] Payment instance
|
164
|
+
# @param params [Hash] Hash of parameters. Each key/value should
|
165
|
+
# correspond to one of the available attributes.
|
33
166
|
def initialize(params = {})
|
34
167
|
@was_authorized = params[:was_authorized]
|
35
168
|
@decline_code = params[:decline_code]
|
36
169
|
self.processor = params[:processor]
|
170
|
+
|
171
|
+
validate
|
172
|
+
end
|
173
|
+
|
174
|
+
private
|
175
|
+
|
176
|
+
def validate
|
177
|
+
return if !Minfraud.enable_validation
|
178
|
+
|
179
|
+
validate_boolean('was_authorized', @was_authorized)
|
180
|
+
validate_string('decline_code', 255, @decline_code)
|
37
181
|
end
|
38
182
|
end
|
39
183
|
end
|