Skip to content

Commit b3ce020

Browse files
authored
Merge pull request #480 from maxmind/greg/eng-1673
Add new matchesPostal phone output
2 parents 4921983 + 72da723 commit b3ce020

File tree

6 files changed

+58
-0
lines changed

6 files changed

+58
-0
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ CHANGELOG
44
3.7.0
55
------------------
66

7+
* Added support for the `/billing_phone/matches_postal` and
8+
`/shipping_phone/matches_postal` outputs. These are available as the
9+
`matchesPostal` method on `com.maxmind.minfraud.response.Phone`.
710
* Added `CRYPTOMUS` to the `Payment.Processor` enum.
811

912
3.6.0 (2025-02-10)

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

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,27 +9,49 @@
99
public final class Phone extends AbstractModel {
1010
private final String country;
1111
private final Boolean isVoip;
12+
private final Boolean matchesPostal;
1213
private final String networkOperator;
1314
private final String numberType;
1415

1516
/**
1617
* @param country The ISO 3166-2 country code for the phone number.
1718
* @param isVoip Whether the number is VoIP.
19+
* @param matchesPostal Whether the phone number matches the postal code.
1820
* @param networkOperator The network operator associated with the phone number.
1921
* @param numberType The type of the phone number.
2022
*/
2123
public Phone(
2224
@JsonProperty("country") String country,
2325
@JsonProperty("is_voip") Boolean isVoip,
26+
@JsonProperty("matches_postal") Boolean matchesPostal,
2427
@JsonProperty("network_operator") String networkOperator,
2528
@JsonProperty("number_type") String numberType
2629
) {
2730
this.country = country;
2831
this.isVoip = isVoip;
32+
this.matchesPostal = matchesPostal;
2933
this.networkOperator = networkOperator;
3034
this.numberType = numberType;
3135
}
3236

37+
/**
38+
* @param country The ISO 3166-2 country code for the phone number.
39+
* @param isVoip Whether the number is VoIP.
40+
* @param networkOperator The network operator associated with the phone number.
41+
* @param numberType The type of the phone number.
42+
*
43+
* @deprecated use other constructor instead.
44+
*/
45+
@Deprecated
46+
public Phone(
47+
String country,
48+
Boolean isVoip,
49+
String networkOperator,
50+
String numberType
51+
) {
52+
this(country, isVoip, null, networkOperator, numberType);
53+
}
54+
3355
/**
3456
* Constructor for {@code Phone}.
3557
*/
@@ -56,6 +78,17 @@ public Boolean isVoip() {
5678
return isVoip;
5779
}
5880

81+
/**
82+
* @return This is {@code true} if the phone number's prefix is commonly associated with the
83+
* postal code. It is {@code false} if the prefix is not associated with the postal code.
84+
* It is non-{@code null} only when the phone number is in the US, the number prefix is
85+
* in our database, and the postal code and country are provided in the request.
86+
*/
87+
@JsonProperty("matches_postal")
88+
public Boolean matchesPostal() {
89+
return matchesPostal;
90+
}
91+
5992
/**
6093
* @return The name of the original network operator associated with the phone number. This
6194
* field does not reflect phone numbers that have been ported from the original operator to

src/test/java/com/maxmind/minfraud/response/FactorsResponseTest.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,11 @@ public void testFactors() throws Exception {
2020
.startObject()
2121
.startObjectField("billing_phone")
2222
.put("is_voip", false)
23+
.put("matches_postal", true)
2324
.end()
2425
.startObjectField("shipping_phone")
2526
.put("is_voip", true)
27+
.put("matches_postal", false)
2628
.end()
2729
.startObjectField("subscores")
2830
.put("avs_result", 0.01)
@@ -66,7 +68,9 @@ public void testFactors() throws Exception {
6668
);
6769

6870
assertTrue(factors.getShippingPhone().isVoip(), "correct shipping phone isVoip");
71+
assertFalse(factors.getShippingPhone().matchesPostal(), "correct shipping phone matchesPostal");
6972
assertFalse(factors.getBillingPhone().isVoip(), "correct billing phone isVoip");
73+
assertTrue(factors.getBillingPhone().matchesPostal(), "correct billing phone matchesPostal");
7074

7175
assertEquals(
7276
Double.valueOf(0.01),

src/test/java/com/maxmind/minfraud/response/InsightsResponseTest.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,14 @@ public void testInsights() throws Exception {
4545
.end()
4646
.startObjectField("shipping_phone")
4747
.put("is_voip", true)
48+
.put("matches_postal", false)
4849
.end()
4950
.startObjectField("billing_address")
5051
.put("is_in_ip_country", true)
5152
.end()
5253
.startObjectField("billing_phone")
5354
.put("is_voip", false)
55+
.put("matches_postal", true)
5456
.end()
5557
.put("funds_remaining", 1.20)
5658
.put("queries_remaining", 123)
@@ -78,16 +80,27 @@ public void testInsights() throws Exception {
7880
);
7981
assertTrue(insights.getCreditCard().isBusiness(), "correct credit card is business");
8082
assertTrue(insights.getCreditCard().isPrepaid(), "correct credit card prepaid");
83+
8184
assertTrue(
8285
insights.getShippingAddress().isInIpCountry(),
8386
"correct shipping address is in IP country"
8487
);
8588
assertTrue(insights.getShippingPhone().isVoip(), "correct shipping phone isVoip");
89+
assertFalse(
90+
insights.getShippingPhone().matchesPostal(),
91+
"correct shipping phone matchesPostal"
92+
);
93+
8694
assertTrue(
8795
insights.getBillingAddress().isInIpCountry(),
8896
"correct billing address is in IP country"
8997
);
9098
assertFalse(insights.getBillingPhone().isVoip(), "correct billing phone isVoip");
99+
assertTrue(
100+
insights.getBillingPhone().matchesPostal(),
101+
"correct billing phone matchesPostal"
102+
);
103+
91104
assertEquals(
92105
Double.valueOf(1.20),
93106
insights.getFundsRemaining(),

src/test/java/com/maxmind/minfraud/response/PhoneTest.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.maxmind.minfraud.response;
22

33
import static org.junit.jupiter.api.Assertions.assertEquals;
4+
import static org.junit.jupiter.api.Assertions.assertFalse;
45
import static org.junit.jupiter.api.Assertions.assertTrue;
56

67
import com.fasterxml.jackson.jr.ob.JSON;
@@ -17,6 +18,7 @@ public void testPhone() throws Exception {
1718
.startObject()
1819
.put("country", "US")
1920
.put("is_voip", true)
21+
.put("matches_postal", false)
2022
.put("network_operator", "Operator")
2123
.put("number_type", "fixed")
2224
.end()
@@ -25,6 +27,7 @@ public void testPhone() throws Exception {
2527

2628
assertEquals("US", phone.getCountry());
2729
assertTrue(phone.isVoip());
30+
assertFalse(phone.matchesPostal());
2831
assertEquals("Operator", phone.getNetworkOperator());
2932
assertEquals("fixed", phone.getNumberType());
3033
}

src/test/resources/test-data/insights-response.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@
135135
"billing_phone": {
136136
"country": "US",
137137
"is_voip": false,
138+
"matches_postal": true,
138139
"network_operator": "Verizon/1",
139140
"number_type": "fixed"
140141
},
@@ -185,6 +186,7 @@
185186
"shipping_phone": {
186187
"country": "CA",
187188
"is_voip": true,
189+
"matches_postal": false,
188190
"network_operator": "Telus Mobility-SVR/2",
189191
"number_type": "mobile"
190192
},

0 commit comments

Comments
 (0)