Skip to content

Commit dda3f4c

Browse files
authored
Merge pull request #159 from maxmind/greg/ip-risk-reasons
Add suport for IP risk reasons
2 parents cf1912f + 58d662a commit dda3f4c

28 files changed

+376
-137
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ CHANGELOG
99
* `APS_PAYMENTS`
1010
* Added additional normalizing of the email address if `hashAddress` is
1111
enabled.
12+
* Added support for the IP address risk reasons in the minFraud Insights and
13+
Factors responses. This is available at `response.getIpAddress().getRiskReasons()`.
14+
It is a list of `IpRiskReason` objects.
1215

1316
1.16.0 (2020-10-14)
1417
-------------------

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ an Insights request by calling `insights` method:
7777
InsightsResponse insights = client.insights(transaction);
7878
```
7979

80-
an Factors request by calling `factors` method:
80+
a Factors request by calling `factors` method:
8181

8282
```java
8383
FactorsResponse factors = client.factors(transaction);

src/main/java/com/maxmind/minfraud/response/CreditCard.java

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,17 @@ public final class CreditCard extends AbstractModel {
1616
private final Boolean isVirtual;
1717
private final String type;
1818

19-
// This method is for backwards compatibility. We should remove it when we
20-
// do a major release.
19+
/**
20+
* @deprecated This constructor only exists for backward compatibility
21+
* and will be removed in the next major release.
22+
*
23+
* @param brand The credit card brand.
24+
* @param country The country the card was issued in.
25+
* @param isIssuedInBillingAddressCountry Whether the issuing country matches billing country.
26+
* @param isPrepaid Whether the card was prepaid.
27+
* @param issuer The issuer information.
28+
* @param type The type.
29+
*/
2130
public CreditCard(
2231
String brand,
2332
String country,
@@ -30,8 +39,18 @@ public CreditCard(
3039
issuer, type);
3140
}
3241

33-
// This method is for backwards compatibility. We should remove it when we
34-
// do a major release.
42+
/**
43+
* @deprecated This constructor only exists for backward compatibility
44+
* and will be removed in the next major release.
45+
*
46+
* @param brand The credit card brand.
47+
* @param country The country the card was issued in.
48+
* @param isIssuedInBillingAddressCountry Whether the issuing country matches billing country.
49+
* @param isPrepaid Whether the card was prepaid.
50+
* @param isVirtual Whether it is a virtual card.
51+
* @param issuer The issuer information.
52+
* @param type The type.
53+
*/
3554
public CreditCard(
3655
String brand,
3756
String country,

src/main/java/com/maxmind/minfraud/response/Device.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,14 @@ public final class Device extends AbstractModel {
2121
private final String lastSeen;
2222
private final String localTime;
2323

24-
// This method is for backwards compatibility. We should remove it when we
25-
// do a major release.
24+
/**
25+
* @deprecated This constructor only exists for backward compatibility
26+
* and will be removed in the next major release.
27+
*
28+
* @param confidence The device confidence.
29+
* @param id The device ID.
30+
* @param lastSeen When the device was last seen.
31+
*/
2632
public Device(
2733
Double confidence,
2834
UUID id,

src/main/java/com/maxmind/minfraud/response/Email.java

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,15 @@ public Email(
3030
this.firstSeen = firstSeen;
3131
}
3232

33-
// The following constructors are for backward compatibility and
34-
// can be removed as part of a major release
33+
/**
34+
* @deprecated This constructor only exists for backward compatibility
35+
* and will be removed in the next major release.
36+
*
37+
* @param isDisposable Whether it is a disposable email.
38+
* @param isFree Whether it is a free email.
39+
* @param isHighRisk Whether it is a high risk email.
40+
* @param firstSeen When the email was first seen.
41+
*/
3542
public Email(
3643
Boolean isDisposable,
3744
Boolean isFree,
@@ -41,6 +48,14 @@ public Email(
4148
this(null, isDisposable, isFree, isHighRisk, firstSeen);
4249
}
4350

51+
/**
52+
* @deprecated This constructor only exists for backward compatibility
53+
* and will be removed in the next major release.
54+
*
55+
* @param isFree Whether it is a free email.
56+
* @param isHighRisk Whether it is a high risk email.
57+
* @param firstSeen When the email was first seen.
58+
*/
4459
public Email(
4560
Boolean isFree,
4661
Boolean isHighRisk,
@@ -49,6 +64,13 @@ public Email(
4964
this(null, isFree, isHighRisk, firstSeen);
5065
}
5166

67+
/**
68+
* @deprecated This constructor only exists for backward compatibility
69+
* and will be removed in the next major release.
70+
*
71+
* @param isFree Whether it is a free email.
72+
* @param isHighRisk Whether it is a high risk email.
73+
*/
5274
public Email(
5375
Boolean isFree,
5476
Boolean isHighRisk

src/main/java/com/maxmind/minfraud/response/GeoIp2Country.java

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,17 @@
1414
public final class GeoIp2Country extends Country {
1515
private final boolean isHighRisk;
1616

17-
// This method is for backwards compatibility. We should remove it when we
18-
// do a major release.
17+
/**
18+
* @deprecated This constructor only exists for backward compatibility
19+
* and will be removed in the next major release.
20+
*
21+
* @param locales The locales.
22+
* @param confidence The confidence.
23+
* @param geoNameId The GeoName ID.
24+
* @param isHighRisk Whether it is a high risk country.
25+
* @param isoCode The ISO code.
26+
* @param names The names.
27+
*/
1928
public GeoIp2Country(
2029
List<String> locales,
2130
Integer confidence,

src/main/java/com/maxmind/minfraud/response/IpAddress.java

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
import com.maxmind.geoip2.model.InsightsResponse;
55
import com.maxmind.geoip2.record.*;
66

7+
import java.util.ArrayList;
8+
import java.util.Collections;
79
import java.util.List;
810

911
/**
@@ -13,6 +15,7 @@ public final class IpAddress extends InsightsResponse implements IpAddressInterf
1315
private final GeoIp2Country country;
1416
private final GeoIp2Location location;
1517
private final Double risk;
18+
private final List<IpRiskReason> riskReasons;
1619

1720
public IpAddress(
1821
@JsonProperty("city") City city,
@@ -24,13 +27,48 @@ public IpAddress(
2427
@JsonProperty("registered_country") Country registeredCountry,
2528
@JsonProperty("represented_country") RepresentedCountry representedCountry,
2629
@JsonProperty("risk") Double risk,
30+
@JsonProperty("risk_reasons") List<IpRiskReason> riskReasons,
2731
@JsonProperty("subdivisions") List<Subdivision> subdivisions,
2832
@JsonProperty("traits") Traits traits
2933
) {
3034
super(city, continent, country, location, maxmind, postal, registeredCountry, representedCountry, subdivisions, traits);
3135
this.country = country == null ? new GeoIp2Country() : country;
3236
this.location = location == null ? new GeoIp2Location() : location;
3337
this.risk = risk;
38+
this.riskReasons = Collections.unmodifiableList(riskReasons == null ? new ArrayList<>() : riskReasons);
39+
}
40+
41+
/**
42+
* @deprecated This constructor only exists for backward compatibility
43+
* and will be removed in the next major release.
44+
*
45+
* @param city The city information.
46+
* @param continent The continent information.
47+
* @param country The country information.
48+
* @param location The location information.
49+
* @param maxmind MaxMind-specific information.
50+
* @param postal The postal information.
51+
* @param registeredCountry The information about the country where the IP was registered.
52+
* @param representedCountry The represented country, e.g., for military bases in other countries.
53+
* @param risk The IP risk.
54+
* @param subdivisions The list of subdivisions.
55+
* @param traits Information about various other IP traits.
56+
*/
57+
public IpAddress(
58+
City city,
59+
Continent continent,
60+
GeoIp2Country country,
61+
GeoIp2Location location,
62+
MaxMind maxmind,
63+
Postal postal,
64+
Country registeredCountry,
65+
RepresentedCountry representedCountry,
66+
Double risk,
67+
List<Subdivision> subdivisions,
68+
Traits traits
69+
) {
70+
this(city, continent, country, location, maxmind, postal, registeredCountry, representedCountry,
71+
risk, null, subdivisions, traits);
3472
}
3573

3674
public IpAddress() {
@@ -63,4 +101,14 @@ public GeoIp2Location getLocation() {
63101
public Double getRisk() {
64102
return risk;
65103
}
104+
105+
/**
106+
* @return An unmodifiable list containing risk reason objects that identify
107+
* the reasons why the IP address received the associated risk. This will
108+
* be an empty list if there are no reasons.
109+
*/
110+
@JsonProperty("risk_reasons")
111+
public final List<IpRiskReason> getRiskReasons() {
112+
return riskReasons;
113+
}
66114
}
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
package com.maxmind.minfraud.response;
2+
3+
import com.fasterxml.jackson.annotation.JsonProperty;
4+
import com.maxmind.minfraud.AbstractModel;
5+
6+
/**
7+
* This class represents the reason for the IP risk.
8+
*/
9+
public final class IpRiskReason extends AbstractModel {
10+
private final String code;
11+
private final String reason;
12+
13+
public IpRiskReason(
14+
@JsonProperty("code") String code,
15+
@JsonProperty("reason") String reason
16+
) {
17+
this.code = code;
18+
this.reason = reason;
19+
}
20+
21+
/**
22+
* This provides a machine-readable code identifying the reason. Although
23+
* more codes may be added in the future, the current codes are:
24+
* <dl>
25+
* <dt>ANONYMOUS_IP</dt>
26+
* <dd>The IP address belongs to an anonymous network. See the
27+
* object at <code>.IPAddress.Traits</code> for more details.</dd>
28+
*
29+
* <dt>BILLING_POSTAL_VELOCITY</dt>
30+
* <dd>Many different billing postal codes have been seen on
31+
* this IP address.</dd>
32+
*
33+
* <dt>EMAIL_VELOCITY</dt>
34+
* <dd>Many different email addresses have been seen on this
35+
* IP address.</dd>
36+
*
37+
* <dt>HIGH_RISK_DEVICE</dt>
38+
* <dd>A high risk device was seen on this IP address.</dd>
39+
*
40+
* <dt>HIGH_RISK_EMAIL</dt>
41+
* <dd>A high risk email address was seen on this IP address in
42+
* your past transactions.</dd>
43+
*
44+
* <dt>ISSUER_ID_NUMBER_VELOCITY</dt>
45+
* <dd>Many different issuer ID numbers have been seen on this
46+
* IP address.</dd>
47+
*
48+
* <dt>MINFRAUD_NETWORK_ACTIVITY</dt>
49+
* <dd>Suspicious activity has been seen on this IP address
50+
* across minFraud customers.</dd>
51+
* </dl>
52+
*
53+
* @return The reason code.
54+
*/
55+
public String getCode() {
56+
return this.code;
57+
}
58+
59+
/**
60+
* @return This field provides a human-readable explanation of the reason.
61+
* The description may change at any time and should not be matched against.
62+
*/
63+
public String getReason() {
64+
return this.reason;
65+
}
66+
}

src/main/java/com/maxmind/minfraud/response/ScoreResponse.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,8 @@ public final Double getRiskScore() {
9393
}
9494

9595
/**
96-
* @return An unmodifiable list contains warning objects detailing issues
97-
* with the request that was sent such as invalid or unknown inputs. It is
96+
* @return An unmodifiable list containing warning objects that detail
97+
* issues with the request such as invalid or unknown inputs. It is
9898
* highly recommended that you check this list for issues when integrating
9999
* the web service.
100100
*/

src/main/java/com/maxmind/minfraud/response/Subscores.java

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,28 @@ public Subscores(
7272
this.timeOfDay = timeOfDay;
7373
}
7474

75-
// This method is for backwards compatibility. We should remove it when we
76-
// do a major release.
75+
/**
76+
* @deprecated This constructor only exists for backward compatibility
77+
* and will be removed in the next major release.
78+
*
79+
* @param avsResult The AVS result subscore.
80+
* @param billingAddress The billing address subscore.
81+
* @param billingAddressDistanceToIpLocation The billing address distance to the IP location subscore.
82+
* @param browser The browser subscore.
83+
* @param chargeback The chargeback subscore.
84+
* @param country The country subscore.
85+
* @param countryMismatch The country mismatch subscore.
86+
* @param cvvResult The CVV result subscore.
87+
* @param emailAddress The email address subscore.
88+
* @param emailDomain The email domain subscore.
89+
* @param emailTenure The email tenure subscore.
90+
* @param ipTenure The IP tenure subscore.
91+
* @param issuerIdNumber The IIN subscore.
92+
* @param orderAmount The order amount subscore.
93+
* @param phoneNumber The phone number subscore.
94+
* @param shippingAddressDistanceToIpLocation The shipping address distance to IP location subscore.
95+
* @param timeOfDay The time of day subscore.
96+
*/
7797
public Subscores(
7898
Double avsResult,
7999
Double billingAddress,

0 commit comments

Comments
 (0)