Skip to content

Commit 15b2448

Browse files
committed
Add new matches_postal phone property
1 parent ce82ba7 commit 15b2448

5 files changed

Lines changed: 29 additions & 0 deletions

File tree

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ CHANGELOG
44
3.4.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` property on `MaxMind\MinFraud\Model\Phone`.
710
* Added `cryptomus` to the payment processor validation.
811

912
3.3.0

src/MinFraud/Model/Phone.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,16 @@ class Phone implements \JsonSerializable
2424
*/
2525
public readonly ?bool $isVoip;
2626

27+
/**
28+
* @var bool|null This is `true` if the phone number's prefix is commonly
29+
* associated with the postal code. It is `false` if the
30+
* prefix is not associated with the postal code. It
31+
* is non-`null` only when the phone number is in the US,
32+
* the number prefix is in our database, and the postal
33+
* code and country are provided in the request.
34+
*/
35+
public readonly ?bool $matchesPostal;
36+
2737
/**
2838
* @var string|null The name of the original network operator associated with
2939
* the phone number. This property does not reflect phone numbers
@@ -45,6 +55,7 @@ public function __construct(?array $response)
4555
{
4656
$this->country = $response['country'] ?? null;
4757
$this->isVoip = $response['is_voip'] ?? null;
58+
$this->matchesPostal = $response['matches_postal'] ?? null;
4859
$this->networkOperator = $response['network_operator'] ?? null;
4960
$this->numberType = $response['number_type'] ?? null;
5061
}
@@ -64,6 +75,10 @@ public function jsonSerialize(): array
6475
$js['is_voip'] = $this->isVoip;
6576
}
6677

78+
if ($this->matchesPostal !== null) {
79+
$js['matches_postal'] = $this->matchesPostal;
80+
}
81+
6782
if ($this->networkOperator !== null) {
6883
$js['network_operator'] = $this->networkOperator;
6984
}

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ public function testPhone(): void
1919
$array = [
2020
'country' => 'US',
2121
'is_voip' => true,
22+
'matches_postal' => false,
2223
'network_operator' => 'Verizon/1',
2324
'number_type' => 'fixed',
2425
];
@@ -36,6 +37,12 @@ public function testPhone(): void
3637
'isVoip'
3738
);
3839

40+
$this->assertSame(
41+
$array['matches_postal'],
42+
$phone->matchesPostal,
43+
'matchesPostal'
44+
);
45+
3946
$this->assertSame(
4047
$array['network_operator'],
4148
$phone->networkOperator,

tests/data/minfraud/factors-response.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@
123123
"billing_phone": {
124124
"country": "US",
125125
"is_voip": true,
126+
"matches_postal": true,
126127
"network_operator": "Verizon/1",
127128
"number_type": "fixed"
128129
},
@@ -166,6 +167,7 @@
166167
"shipping_phone": {
167168
"country": "CA",
168169
"is_voip": true,
170+
"matches_postal": true,
169171
"network_operator": "Telus Mobility-SVR/2",
170172
"number_type": "mobile"
171173
},

tests/data/minfraud/insights-response.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@
123123
"billing_phone": {
124124
"country": "US",
125125
"is_voip": true,
126+
"matches_postal": true,
126127
"network_operator": "Verizon/1",
127128
"number_type": "fixed"
128129
},
@@ -166,6 +167,7 @@
166167
"shipping_phone": {
167168
"country": "CA",
168169
"is_voip": true,
170+
"matches_postal": true,
169171
"network_operator": "Telus Mobility-SVR/2",
170172
"number_type": "mobile"
171173
},

0 commit comments

Comments
 (0)