From ce82ba744e13d180a33b52a533aae2b40c3ca8b4 Mon Sep 17 00:00:00 2001 From: Gregory Oschwald Date: Wed, 7 May 2025 10:20:19 -0700 Subject: [PATCH 1/2] Update geoip2/geoip2 to latest version --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index ae6efb8..7efe72c 100644 --- a/composer.json +++ b/composer.json @@ -19,7 +19,7 @@ "require": { "php": ">=8.1", "ext-json": "*", - "geoip2/geoip2": "^v3.1.0" + "geoip2/geoip2": "^v3.2.0" }, "require-dev": { "friendsofphp/php-cs-fixer": "3.*", From 15b24480d182717168e6c9f0c6188217bcaee1b5 Mon Sep 17 00:00:00 2001 From: Gregory Oschwald Date: Wed, 7 May 2025 10:39:40 -0700 Subject: [PATCH 2/2] Add new matches_postal phone property --- CHANGELOG.md | 3 +++ src/MinFraud/Model/Phone.php | 15 +++++++++++++++ tests/MaxMind/Test/MinFraud/Model/PhoneTest.php | 7 +++++++ tests/data/minfraud/factors-response.json | 2 ++ tests/data/minfraud/insights-response.json | 2 ++ 5 files changed, 29 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6ad6ffa..be1824d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,9 @@ CHANGELOG 3.4.0 ------------------ +* Added support for the `/billing_phone/matches_postal` and + `/shipping_phone/matches_postal` outputs. These are available as the + `matchesPostal` property on `MaxMind\MinFraud\Model\Phone`. * Added `cryptomus` to the payment processor validation. 3.3.0 diff --git a/src/MinFraud/Model/Phone.php b/src/MinFraud/Model/Phone.php index b483ec7..692c8f5 100644 --- a/src/MinFraud/Model/Phone.php +++ b/src/MinFraud/Model/Phone.php @@ -24,6 +24,16 @@ class Phone implements \JsonSerializable */ public readonly ?bool $isVoip; + /** + * @var bool|null This is `true` if the phone number's prefix is commonly + * associated with the postal code. It is `false` if the + * prefix is not associated with the postal code. It + * is non-`null` only when the phone number is in the US, + * the number prefix is in our database, and the postal + * code and country are provided in the request. + */ + public readonly ?bool $matchesPostal; + /** * @var string|null The name of the original network operator associated with * the phone number. This property does not reflect phone numbers @@ -45,6 +55,7 @@ public function __construct(?array $response) { $this->country = $response['country'] ?? null; $this->isVoip = $response['is_voip'] ?? null; + $this->matchesPostal = $response['matches_postal'] ?? null; $this->networkOperator = $response['network_operator'] ?? null; $this->numberType = $response['number_type'] ?? null; } @@ -64,6 +75,10 @@ public function jsonSerialize(): array $js['is_voip'] = $this->isVoip; } + if ($this->matchesPostal !== null) { + $js['matches_postal'] = $this->matchesPostal; + } + if ($this->networkOperator !== null) { $js['network_operator'] = $this->networkOperator; } diff --git a/tests/MaxMind/Test/MinFraud/Model/PhoneTest.php b/tests/MaxMind/Test/MinFraud/Model/PhoneTest.php index 16a3670..2a74013 100644 --- a/tests/MaxMind/Test/MinFraud/Model/PhoneTest.php +++ b/tests/MaxMind/Test/MinFraud/Model/PhoneTest.php @@ -19,6 +19,7 @@ public function testPhone(): void $array = [ 'country' => 'US', 'is_voip' => true, + 'matches_postal' => false, 'network_operator' => 'Verizon/1', 'number_type' => 'fixed', ]; @@ -36,6 +37,12 @@ public function testPhone(): void 'isVoip' ); + $this->assertSame( + $array['matches_postal'], + $phone->matchesPostal, + 'matchesPostal' + ); + $this->assertSame( $array['network_operator'], $phone->networkOperator, diff --git a/tests/data/minfraud/factors-response.json b/tests/data/minfraud/factors-response.json index f6740eb..0e95102 100644 --- a/tests/data/minfraud/factors-response.json +++ b/tests/data/minfraud/factors-response.json @@ -123,6 +123,7 @@ "billing_phone": { "country": "US", "is_voip": true, + "matches_postal": true, "network_operator": "Verizon/1", "number_type": "fixed" }, @@ -166,6 +167,7 @@ "shipping_phone": { "country": "CA", "is_voip": true, + "matches_postal": true, "network_operator": "Telus Mobility-SVR/2", "number_type": "mobile" }, diff --git a/tests/data/minfraud/insights-response.json b/tests/data/minfraud/insights-response.json index a4662d2..ca42094 100644 --- a/tests/data/minfraud/insights-response.json +++ b/tests/data/minfraud/insights-response.json @@ -123,6 +123,7 @@ "billing_phone": { "country": "US", "is_voip": true, + "matches_postal": true, "network_operator": "Verizon/1", "number_type": "fixed" }, @@ -166,6 +167,7 @@ "shipping_phone": { "country": "CA", "is_voip": true, + "matches_postal": true, "network_operator": "Telus Mobility-SVR/2", "number_type": "mobile" },