Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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.*",
Expand Down
15 changes: 15 additions & 0 deletions src/MinFraud/Model/Phone.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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;
}
Expand All @@ -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;
}
Expand Down
7 changes: 7 additions & 0 deletions tests/MaxMind/Test/MinFraud/Model/PhoneTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public function testPhone(): void
$array = [
'country' => 'US',
'is_voip' => true,
'matches_postal' => false,
'network_operator' => 'Verizon/1',
'number_type' => 'fixed',
];
Expand All @@ -36,6 +37,12 @@ public function testPhone(): void
'isVoip'
);

$this->assertSame(
$array['matches_postal'],
$phone->matchesPostal,
'matchesPostal'
);

$this->assertSame(
$array['network_operator'],
$phone->networkOperator,
Expand Down
2 changes: 2 additions & 0 deletions tests/data/minfraud/factors-response.json
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@
"billing_phone": {
"country": "US",
"is_voip": true,
"matches_postal": true,
"network_operator": "Verizon/1",
"number_type": "fixed"
},
Expand Down Expand Up @@ -166,6 +167,7 @@
"shipping_phone": {
"country": "CA",
"is_voip": true,
"matches_postal": true,
"network_operator": "Telus Mobility-SVR/2",
"number_type": "mobile"
},
Expand Down
2 changes: 2 additions & 0 deletions tests/data/minfraud/insights-response.json
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@
"billing_phone": {
"country": "US",
"is_voip": true,
"matches_postal": true,
"network_operator": "Verizon/1",
"number_type": "fixed"
},
Expand Down Expand Up @@ -166,6 +167,7 @@
"shipping_phone": {
"country": "CA",
"is_voip": true,
"matches_postal": true,
"network_operator": "Telus Mobility-SVR/2",
"number_type": "mobile"
},
Expand Down