Skip to content

Commit 15f008d

Browse files
authored
Added fraud check (#406)
1 parent c9b8ada commit 15f008d

File tree

2 files changed

+39
-0
lines changed

2 files changed

+39
-0
lines changed

src/Verify2/Request/BaseVerifyRequest.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ abstract class BaseVerifyRequest implements RequestInterface
1616

1717
protected int $timeout = 300;
1818

19+
protected bool $fraudCheck = true;
20+
1921
protected ?string $clientRef = null;
2022

2123
protected int $length = 4;
@@ -132,9 +134,22 @@ public function addWorkflow(VerificationWorkflow $verificationWorkflow): static
132134
return $this;
133135
}
134136

137+
public function getFraudCheck(): bool
138+
{
139+
return $this->fraudCheck;
140+
}
141+
142+
public function setFraudCheck(bool $fraudCheck): BaseVerifyRequest
143+
{
144+
$this->fraudCheck = $fraudCheck;
145+
146+
return $this;
147+
}
148+
135149
public function getBaseVerifyUniversalOutputArray(): array
136150
{
137151
$returnArray = [
152+
'fraud_check' => $this->getFraudCheck(),
138153
'locale' => $this->getLocale()->getCode(),
139154
'channel_timeout' => $this->getTimeout(),
140155
'code_length' => $this->getLength(),

test/Verify2/ClientTest.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ public function testCanRequestSMS(): void
9898
);
9999

100100
$this->assertRequestJsonBodyContains('locale', 'en-us', $request);
101+
$this->assertRequestJsonBodyContains('fraud_check', true, $request);
101102
$this->assertRequestJsonBodyContains('channel_timeout', 300, $request);
102103
$this->assertRequestJsonBodyContains('client_ref', $payload['client_ref'], $request);
103104
$this->assertRequestJsonBodyContains('code_length', 4, $request);
@@ -115,6 +116,29 @@ public function testCanRequestSMS(): void
115116
$this->assertArrayHasKey('request_id', $result);
116117
}
117118

119+
public function testCanBypassFraudCheck(): void
120+
{
121+
$payload = [
122+
'to' => '07785254785',
123+
'client_ref' => 'my-verification',
124+
'brand' => 'my-brand',
125+
];
126+
127+
$smsVerification = new SMSRequest($payload['to'], $payload['brand']);
128+
$smsVerification->setFraudCheck(false);
129+
130+
$this->vonageClient->send(Argument::that(function (Request $request) use ($payload) {
131+
$this->assertRequestJsonBodyContains('fraud_check', false, $request);
132+
133+
return true;
134+
}))->willReturn($this->getResponse('verify-request-success', 202));
135+
136+
$result = $this->verify2Client->startVerification($smsVerification);
137+
138+
$this->assertIsArray($result);
139+
$this->assertArrayHasKey('request_id', $result);
140+
}
141+
118142
/**
119143
* @dataProvider localeProvider
120144
*/

0 commit comments

Comments
 (0)