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,20 +1,131 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'digest/md5'
|
4
|
+
require 'simpleidn'
|
5
|
+
|
1
6
|
module Minfraud
|
2
7
|
module Components
|
8
|
+
# Email corresponds to the email object of a minFraud request.
|
9
|
+
#
|
10
|
+
# @see https://dev.maxmind.com/minfraud/api-documentation/requests?lang=en#schema--request--email
|
3
11
|
class Email < Base
|
4
|
-
|
5
|
-
|
12
|
+
include Minfraud::Validates
|
13
|
+
|
14
|
+
# This field must be either be a valid email address or an MD5 of the
|
15
|
+
# lowercased email used in the transaction. Important: if using the MD5
|
16
|
+
# hash, please be sure to convert the email address to lowercase before
|
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.
|
19
|
+
#
|
20
|
+
# @return [String, nil]
|
6
21
|
attr_accessor :address
|
7
22
|
|
8
|
-
#
|
9
|
-
#
|
23
|
+
# The domain of the email address used in the transaction.
|
24
|
+
#
|
25
|
+
# @return [String, nil]
|
10
26
|
attr_accessor :domain
|
11
27
|
|
12
|
-
#
|
13
|
-
#
|
14
|
-
#
|
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
|
+
|
34
|
+
# @param params [Hash] Hash of parameters. Each key/value should
|
35
|
+
# correspond to one of the available attributes.
|
15
36
|
def initialize(params = {})
|
16
|
-
@address
|
17
|
-
@domain
|
37
|
+
@address = params[:address]
|
38
|
+
@domain = params[:domain]
|
39
|
+
@hash_address = params[:hash_address]
|
40
|
+
|
41
|
+
validate
|
42
|
+
end
|
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
|
+
|
68
|
+
private
|
69
|
+
|
70
|
+
def validate
|
71
|
+
return if !Minfraud.enable_validation
|
72
|
+
|
73
|
+
validate_email('email', @address)
|
74
|
+
validate_string('domain', 255, @domain)
|
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
|
18
129
|
end
|
19
130
|
end
|
20
131
|
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/api-documentation/requests?lang=en#schema--request--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
|
+
%i[
|
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,51 +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/api-documentation/requests?lang=en#schema--request--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
|
-
def initialize (params = {})
|
58
|
+
# @param params [Hash] Hash of parameters. Each key/value should
|
59
|
+
# correspond to one of the available attributes.
|
60
|
+
def initialize(params = {})
|
41
61
|
@amount = params[:amount]
|
42
62
|
@has_gift_message = params[:has_gift_message]
|
43
63
|
@affiliate_id = params[:affiliate_id]
|
44
64
|
@subaffiliate_id = params[:subaffiliate_id]
|
45
65
|
@currency = params[:currency]
|
46
|
-
@discount_code = params[:
|
66
|
+
@discount_code = params[:discount_code]
|
47
67
|
@referrer_uri = params[:referrer_uri]
|
48
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)
|
49
86
|
end
|
50
87
|
end
|
51
88
|
end
|
@@ -1,39 +1,209 @@
|
|
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/api-documentation/requests?lang=en#schema--request--payment
|
3
8
|
class Payment < Base
|
4
9
|
include ::Minfraud::Enum
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
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]
|
18
|
+
enum_accessor :processor, %i[
|
19
|
+
adyen
|
20
|
+
affirm
|
21
|
+
afterpay
|
22
|
+
altapay
|
23
|
+
amazon_payments
|
24
|
+
american_express_payment_gateway
|
25
|
+
apple_pay
|
26
|
+
aps_payments
|
27
|
+
authorizenet
|
28
|
+
balanced
|
29
|
+
beanstream
|
30
|
+
bluepay
|
31
|
+
bluesnap
|
32
|
+
boacompra
|
33
|
+
boku
|
34
|
+
bpoint
|
35
|
+
braintree
|
36
|
+
cardknox
|
37
|
+
cardpay
|
38
|
+
cashfree
|
39
|
+
ccavenue
|
40
|
+
ccnow
|
41
|
+
cetelem
|
42
|
+
chase_paymentech
|
43
|
+
checkout_com
|
44
|
+
cielo
|
45
|
+
collector
|
46
|
+
commdoo
|
47
|
+
compropago
|
48
|
+
concept_payments
|
49
|
+
conekta
|
50
|
+
coregateway
|
51
|
+
creditguard
|
52
|
+
credorax
|
53
|
+
ct_payments
|
54
|
+
cuentadigital
|
55
|
+
curopayments
|
56
|
+
cybersource
|
57
|
+
dalenys
|
58
|
+
dalpay
|
59
|
+
datacap
|
60
|
+
datacash
|
61
|
+
dibs
|
62
|
+
digital_river
|
63
|
+
dlocal
|
64
|
+
dotpay
|
65
|
+
ebs
|
66
|
+
ecomm365
|
67
|
+
ecommpay
|
68
|
+
elavon
|
69
|
+
emerchantpay
|
70
|
+
epay
|
71
|
+
eprocessing_network
|
72
|
+
epx
|
73
|
+
eway
|
74
|
+
exact
|
75
|
+
first_atlantic_commerce
|
76
|
+
first_data
|
77
|
+
fiserv
|
78
|
+
g2a_pay
|
79
|
+
global_payments
|
80
|
+
gocardless
|
81
|
+
google_pay
|
82
|
+
heartland
|
83
|
+
hipay
|
84
|
+
ingenico
|
85
|
+
interac
|
86
|
+
internetsecure
|
87
|
+
intuit_quickbooks_payments
|
88
|
+
iugu
|
89
|
+
klarna
|
90
|
+
komoju
|
91
|
+
lemon_way
|
92
|
+
mastercard_payment_gateway
|
93
|
+
mercadopago
|
94
|
+
mercanet
|
95
|
+
merchant_esolutions
|
96
|
+
mirjeh
|
97
|
+
mollie
|
98
|
+
moneris_solutions
|
99
|
+
neopay
|
100
|
+
neosurf
|
101
|
+
nmi
|
102
|
+
oceanpayment
|
103
|
+
oney
|
104
|
+
onpay
|
105
|
+
openbucks
|
106
|
+
openpaymx
|
107
|
+
optimal_payments
|
108
|
+
orangepay
|
109
|
+
other
|
110
|
+
pacnet_services
|
111
|
+
payeezy
|
112
|
+
payfast
|
113
|
+
paygate
|
114
|
+
paylike
|
115
|
+
payment_express
|
116
|
+
paymentwall
|
117
|
+
payone
|
118
|
+
paypal
|
119
|
+
payplus
|
120
|
+
paysafecard
|
121
|
+
paysera
|
122
|
+
paystation
|
123
|
+
paytm
|
124
|
+
paytrace
|
125
|
+
paytrail
|
126
|
+
payture
|
127
|
+
payu
|
128
|
+
payulatam
|
129
|
+
payvision
|
130
|
+
payway
|
131
|
+
payza
|
132
|
+
pinpayments
|
133
|
+
placetopay
|
134
|
+
posconnect
|
135
|
+
princeton_payment_solutions
|
136
|
+
psigate
|
137
|
+
pxp_financial
|
138
|
+
qiwi
|
139
|
+
quickpay
|
140
|
+
raberil
|
141
|
+
razorpay
|
142
|
+
rede
|
143
|
+
redpagos
|
144
|
+
rewardspay
|
145
|
+
safecharge
|
146
|
+
sagepay
|
147
|
+
securetrading
|
148
|
+
shopify_payments
|
149
|
+
simplify_commerce
|
150
|
+
skrill
|
151
|
+
smartcoin
|
152
|
+
smartdebit
|
153
|
+
solidtrust_pay
|
154
|
+
sps_decidir
|
155
|
+
stripe
|
156
|
+
synapsefi
|
157
|
+
systempay
|
158
|
+
telerecargas
|
159
|
+
towah
|
160
|
+
transact_pro
|
161
|
+
trustly
|
162
|
+
trustpay
|
163
|
+
tsys
|
164
|
+
usa_epay
|
165
|
+
vantiv
|
166
|
+
verepay
|
167
|
+
vericheck
|
168
|
+
vindicia
|
169
|
+
virtual_card_services
|
170
|
+
vme
|
171
|
+
vpos
|
172
|
+
windcave
|
173
|
+
wirecard
|
174
|
+
worldpay
|
20
175
|
]
|
21
176
|
|
22
|
-
#
|
23
|
-
#
|
177
|
+
# The authorization outcome from the payment processor. If the
|
178
|
+
# transaction has not yet been approved or denied, do not include this
|
179
|
+
# field.
|
180
|
+
#
|
181
|
+
# @return [Boolean, nil]
|
24
182
|
attr_accessor :was_authorized
|
25
183
|
|
26
|
-
#
|
27
|
-
#
|
184
|
+
# The decline code as provided by your payment processor. If the
|
185
|
+
# transaction was not declined, do not include this field.
|
186
|
+
#
|
187
|
+
# @return [String, nil]
|
28
188
|
attr_accessor :decline_code
|
29
189
|
|
30
|
-
#
|
31
|
-
#
|
32
|
-
# @return [Minfraud::Components::Payment] Payment instance
|
190
|
+
# @param params [Hash] Hash of parameters. Each key/value should
|
191
|
+
# correspond to one of the available attributes.
|
33
192
|
def initialize(params = {})
|
34
193
|
@was_authorized = params[:was_authorized]
|
35
194
|
@decline_code = params[:decline_code]
|
36
195
|
self.processor = params[:processor]
|
196
|
+
|
197
|
+
validate
|
198
|
+
end
|
199
|
+
|
200
|
+
private
|
201
|
+
|
202
|
+
def validate
|
203
|
+
return if !Minfraud.enable_validation
|
204
|
+
|
205
|
+
validate_boolean('was_authorized', @was_authorized)
|
206
|
+
validate_string('decline_code', 255, @decline_code)
|
37
207
|
end
|
38
208
|
end
|
39
209
|
end
|
@@ -0,0 +1,80 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Minfraud
|
4
|
+
module Components
|
5
|
+
module Report
|
6
|
+
# Contains the fields used in the Report Transaction API.
|
7
|
+
#
|
8
|
+
# @see https://dev.maxmind.com/minfraud/report-a-transaction?lang=en
|
9
|
+
class Transaction < Base
|
10
|
+
include ::Minfraud::Enum
|
11
|
+
|
12
|
+
# The IP address of the customer placing the order. This should be
|
13
|
+
# passed as a string like "152.216.7.110".
|
14
|
+
#
|
15
|
+
# @return [String, nil]
|
16
|
+
attr_accessor :ip_address
|
17
|
+
|
18
|
+
# A symbol indicating the likelihood that a transaction may be
|
19
|
+
# fraudulent.
|
20
|
+
#
|
21
|
+
# This may be one of +:chargeback+, +:not_fraud+, +:spam_or_abuse+, or
|
22
|
+
# +:suspected_fraud+.
|
23
|
+
#
|
24
|
+
# @!attribute tag
|
25
|
+
#
|
26
|
+
# @return [Symbol, nil]
|
27
|
+
enum_accessor :tag, %i[chargeback not_fraud spam_or_abuse suspected_fraud]
|
28
|
+
|
29
|
+
# A string which is provided by your payment processor indicating the
|
30
|
+
# reason for the chargeback.
|
31
|
+
#
|
32
|
+
# @return [String, nil]
|
33
|
+
attr_accessor :chargeback_code
|
34
|
+
|
35
|
+
# A unique eight character string identifying a minFraud Standard or
|
36
|
+
# Premium request. These IDs are returned in the maxmindID field of a
|
37
|
+
# response for a successful minFraud request. This field is not
|
38
|
+
# required, but you are encouraged to provide it, if possible.
|
39
|
+
#
|
40
|
+
# @return [String, nil]
|
41
|
+
attr_accessor :maxmind_id
|
42
|
+
|
43
|
+
# A UUID that identifies a minFraud Score, minFraud Insights, or
|
44
|
+
# minFraud Factors request. This ID is returned at /id in the response.
|
45
|
+
# This field is not required, but you are encouraged to provide it if
|
46
|
+
# the request was made to one of these services.
|
47
|
+
#
|
48
|
+
# @return [String, nil]
|
49
|
+
attr_accessor :minfraud_id
|
50
|
+
|
51
|
+
# Your notes on the fraud tag associated with the transaction. We
|
52
|
+
# manually review many reported transactions to improve our scoring for
|
53
|
+
# you so any additional details to help us understand context are
|
54
|
+
# helpful.
|
55
|
+
#
|
56
|
+
# @return [String, nil]
|
57
|
+
attr_accessor :notes
|
58
|
+
|
59
|
+
# The transaction ID you originally passed to minFraud. This field is
|
60
|
+
# not required, but you are encouraged to provide it or the
|
61
|
+
# transaction's maxmind_id or minfraud_id.
|
62
|
+
#
|
63
|
+
# @return [String, nil]
|
64
|
+
attr_accessor :transaction_id
|
65
|
+
|
66
|
+
# @param params [Hash] Hash of parameters. Each key/value should
|
67
|
+
# correspond to one of the available attributes.
|
68
|
+
def initialize(params = {})
|
69
|
+
@ip_address = params[:ip_address]
|
70
|
+
@chargeback_code = params[:chargeback_code]
|
71
|
+
@maxmind_id = params[:maxmind_id]
|
72
|
+
@minfraud_id = params[:minfraud_id]
|
73
|
+
@notes = params[:notes]
|
74
|
+
@transaction_id = params[:transaction_id]
|
75
|
+
self.tag = params[:tag]
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
@@ -1,14 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Minfraud
|
2
4
|
module Components
|
5
|
+
# Shipping corresponds to the shipping object of a minFraud request.
|
6
|
+
#
|
7
|
+
# @see https://dev.maxmind.com/minfraud/api-documentation/requests?lang=en#schema--request--shipping
|
3
8
|
class Shipping < Addressable
|
4
9
|
include ::Minfraud::Enum
|
5
|
-
# @attribute delivery_speed
|
6
|
-
# @return [String] The shipping delivery speed for the order. The valid values are:
|
7
|
-
enum_accessor :delivery_speed, [:same_day, :overnight, :expedited, :standard]
|
8
10
|
|
9
|
-
#
|
10
|
-
#
|
11
|
-
#
|
11
|
+
# The shipping delivery speed for the order. Must be one of +:same_day+,
|
12
|
+
# +:overnight+, +:expedited+, or +:standard+.
|
13
|
+
#
|
14
|
+
# @!attribute delivery_speed
|
15
|
+
#
|
16
|
+
# @return [Symbol, nil]
|
17
|
+
enum_accessor :delivery_speed, %i[same_day overnight expedited standard]
|
18
|
+
|
19
|
+
# @param params [Hash] Hash of parameters. Each key/value should
|
20
|
+
# correspond to one of the available attributes.
|
12
21
|
def initialize(params = {})
|
13
22
|
self.delivery_speed = params[:delivery_speed]
|
14
23
|
super
|