Skip to content

Commit d4bb833

Browse files
authored
Merge pull request #245 from maxmind/greg/eng-3902-expose-anonymizer-data-on-minfraud-php-insights-model
Add anonymizer property to IpAddress model
2 parents 201f2b0 + 71520b7 commit d4bb833

7 files changed

Lines changed: 74 additions & 3 deletions

File tree

CHANGELOG.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
11
CHANGELOG
22
=========
33

4-
3.6.0
4+
3.6.0 (2026-01-20)
55
------------------
66

7+
* Added the `anonymizer` property to `MaxMind\MinFraud\Model\IpAddress`. This
8+
contains anonymizer data from the GeoIP2 Insights response, including VPN
9+
detection confidence, provider name, and network last seen date. This was
10+
previously available in the GeoIP2 library but not exposed in minFraud
11+
responses.
712
* Added `banquest`, `summit_payments`, and `yaadpay` to the payment processor
813
validation.
914

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ You should now have the file `composer.phar` in your project directory.
2525
Run in your project root:
2626

2727
```
28-
php composer.phar require maxmind/minfraud:^3.5.0
28+
php composer.phar require maxmind/minfraud:^3.6.0
2929
```
3030

3131
You should now have the files `composer.json` and `composer.lock` as well as

src/MinFraud/Model/IpAddress.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
namespace MaxMind\MinFraud\Model;
66

77
use GeoIp2\Model\Insights;
8+
use GeoIp2\Record\Anonymizer;
89
use GeoIp2\Record\City;
910
use GeoIp2\Record\Continent;
1011
use GeoIp2\Record\Country;
@@ -18,6 +19,13 @@
1819
*/
1920
class IpAddress implements \JsonSerializable
2021
{
22+
/**
23+
* @var Anonymizer data for the anonymizer status of the requested IP
24+
* address. This object contains information about whether
25+
* the IP address belongs to an anonymous network.
26+
*/
27+
public readonly Anonymizer $anonymizer;
28+
2129
/**
2230
* @var City city data for the requested IP address
2331
*/
@@ -123,6 +131,7 @@ public function __construct(?array $response, array $locales = ['en'])
123131
$this->representedCountry = $insights->representedCountry;
124132
$this->subdivisions = $insights->subdivisions;
125133
$this->traits = $insights->traits;
134+
$this->anonymizer = $insights->anonymizer;
126135

127136
$this->location = new GeoIp2Location($response['location'] ?? []);
128137
$this->risk = $response['risk'] ?? null;
@@ -143,6 +152,11 @@ public function jsonSerialize(): ?array
143152
{
144153
$js = [];
145154

155+
$anonymizer = $this->anonymizer->jsonSerialize();
156+
if (!empty($anonymizer)) {
157+
$js['anonymizer'] = $anonymizer;
158+
}
159+
146160
$city = $this->city->jsonSerialize();
147161
if (!empty($city)) {
148162
$js['city'] = $city;

src/MinFraud/ServiceClient.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
abstract class ServiceClient
1111
{
12-
public const VERSION = 'v3.5.0';
12+
public const VERSION = 'v3.6.0';
1313

1414
/**
1515
* @var Client

tests/MaxMind/Test/MinFraud/Model/InsightsTest.php

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,38 @@ public function testInsightsProperties(): void
124124
'correct mobile network code'
125125
);
126126

127+
// Test anonymizer object
128+
foreach ([
129+
'isAnonymous',
130+
'isAnonymousVpn',
131+
'isHostingProvider',
132+
'isPublicProxy',
133+
'isTorExitNode',
134+
] as $property) {
135+
$this->assertTrue(
136+
$insights->ipAddress->anonymizer->{$property},
137+
"anonymizer {$property} is true"
138+
);
139+
}
140+
141+
$this->assertSame(
142+
$array['ip_address']['anonymizer']['confidence'],
143+
$insights->ipAddress->anonymizer->confidence,
144+
'correct anonymizer confidence'
145+
);
146+
147+
$this->assertSame(
148+
$array['ip_address']['anonymizer']['provider_name'],
149+
$insights->ipAddress->anonymizer->providerName,
150+
'correct anonymizer provider name'
151+
);
152+
153+
$this->assertSame(
154+
$array['ip_address']['anonymizer']['network_last_seen'],
155+
$insights->ipAddress->anonymizer->networkLastSeen,
156+
'correct anonymizer network last seen'
157+
);
158+
127159
$this->assertSame(
128160
$array['billing_phone']['country'],
129161
$insights->billingPhone->country,

tests/data/minfraud/factors-response.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,16 @@
111111
"network": "152.216.7.0/24",
112112
"organization": "STONEHOUSE office network",
113113
"user_type": "government"
114+
},
115+
"anonymizer": {
116+
"confidence": 99,
117+
"is_anonymous": true,
118+
"is_anonymous_vpn": true,
119+
"is_hosting_provider": true,
120+
"is_public_proxy": true,
121+
"is_tor_exit_node": true,
122+
"network_last_seen": "2025-01-15",
123+
"provider_name": "TestVPN"
114124
}
115125
},
116126
"billing_address": {

tests/data/minfraud/insights-response.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,16 @@
111111
"network": "152.216.7.0/24",
112112
"organization": "STONEHOUSE office network",
113113
"user_type": "government"
114+
},
115+
"anonymizer": {
116+
"confidence": 99,
117+
"is_anonymous": true,
118+
"is_anonymous_vpn": true,
119+
"is_hosting_provider": true,
120+
"is_public_proxy": true,
121+
"is_tor_exit_node": true,
122+
"network_last_seen": "2025-01-15",
123+
"provider_name": "TestVPN"
114124
}
115125
},
116126
"billing_address": {

0 commit comments

Comments
 (0)