Skip to content

Commit

Permalink
SDK-2472-added-php-idv-support-brand-id-in-session-config
Browse files Browse the repository at this point in the history
  • Loading branch information
mehmet-yoti committed Sep 19, 2024
1 parent 7c52d7a commit 11ea0f7
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,6 @@ function onErrorListener(...data) {
await Yoti.ready()
await onReadyToStart()
}</script>
<script src="https://www.yoti.com/share/client/v2" onload="onClientLoaded()"></script>
<script src="https://www.public.stg1.dmz.yoti.com/share/client/v2" onload="onClientLoaded()"></script>
</body>
</html>
1 change: 1 addition & 0 deletions examples/doc-scan/app/Http/Controllers/HomeController.php
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ public function show(Request $request, DocScanClient $client)
->withErrorUrl(config('app.url') . '/error')
->withPrivacyPolicyUrl(config('app.url') . '/privacy-policy')
->withBiometricConsentFlow('EARLY')
->withBrandId('brand_id')
->build()
)
->withRequiredDocument(
Expand Down
21 changes: 19 additions & 2 deletions src/DocScan/Session/Create/SdkConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,11 @@ class SdkConfig implements \JsonSerializable
*/
private $biometricConsentFlow;

/**
* @var string|null
*/
private $brandId;

/**
* @param string|null $allowedCaptureMethods
* @param string|null $primaryColour
Expand All @@ -81,6 +86,7 @@ class SdkConfig implements \JsonSerializable
* @param bool|null $allowHandoff
* @param array<string, int>|null $idDocumentTextDataExtractionRetriesConfig
* @param string|null $biometricConsentFlow
* @param string|null $brandId
*/
public function __construct(
?string $allowedCaptureMethods,
Expand All @@ -94,7 +100,8 @@ public function __construct(
?string $privacyPolicyUrl = null,
?bool $allowHandoff = null,
?array $idDocumentTextDataExtractionRetriesConfig = null,
?string $biometricConsentFlow = null
?string $biometricConsentFlow = null,
?string $brandId = null
) {
$this->allowedCaptureMethods = $allowedCaptureMethods;
$this->primaryColour = $primaryColour;
Expand All @@ -110,6 +117,7 @@ public function __construct(
$this->attemptsConfiguration = new AttemptsConfiguration($idDocumentTextDataExtractionRetriesConfig);
}
$this->biometricConsentFlow = $biometricConsentFlow;
$this->brandId = $brandId;
}

/**
Expand All @@ -129,7 +137,8 @@ public function jsonSerialize(): \stdClass
'privacy_policy_url' => $this->getPrivacyPolicyUrl(),
'allow_handoff' => $this->getAllowHandoff(),
'attempts_configuration' => $this->getAttemptsConfiguration(),
'biometric_consent_flow' => $this->getBiometricConsentFlow()
'biometric_consent_flow' => $this->getBiometricConsentFlow(),
'brand_id' => $this->getBrandId()
]);
}

Expand Down Expand Up @@ -228,4 +237,12 @@ public function getBiometricConsentFlow(): ?string
{
return $this->biometricConsentFlow;
}

/**
* @return string|null
*/
public function getBrandId(): ?string
{
return $this->brandId;
}
}
13 changes: 12 additions & 1 deletion src/DocScan/Session/Create/SdkConfigBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,11 @@ class SdkConfigBuilder
*/
private $biometricConsentFlow;

/**
* @var string|null
*/
private $brandId;

public function withAllowsCamera(): self
{
return $this->withAllowedCaptureMethod(self::CAMERA);
Expand Down Expand Up @@ -199,6 +204,11 @@ public function withIdDocumentTextExtractionGenericAttempts(int $genericRetries)
return $this;
}

public function withBrandId(string $brandId): self
{
$this->brandId = $brandId;
return $this;
}

public function build(): SdkConfig
{
Expand All @@ -214,7 +224,8 @@ public function build(): SdkConfig
$this->privacyPolicyUrl,
$this->allowHandoff,
$this->idDocumentTextDataExtractionRetriesConfig,
$this->biometricConsentFlow
$this->biometricConsentFlow,
$this->brandId
);
}
}
5 changes: 5 additions & 0 deletions tests/DocScan/Session/Create/SdkConfigBuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ class SdkConfigBuilderTest extends TestCase
private const SOME_CATEGORY = 'someCategory';
private const SOME_NUMBER_RETRIES = 5;
private const SOME_BIOMETRIC_CONSENT_FLOW = 'someBiometricConsentFlow';
private const SOME_BRAND_ID = 'someBrandId';


/**
Expand All @@ -38,6 +39,7 @@ class SdkConfigBuilderTest extends TestCase
* @covers ::withErrorUrl
* @covers ::withPrivacyPolicyUrl
* @covers ::withAllowHandoff
* @covers ::withBrandId
* @covers \Yoti\DocScan\Session\Create\SdkConfig::__construct
* @covers \Yoti\DocScan\Session\Create\SdkConfig::getAllowedCaptureMethods
* @covers \Yoti\DocScan\Session\Create\SdkConfig::getPrimaryColour
Expand All @@ -49,6 +51,7 @@ class SdkConfigBuilderTest extends TestCase
* @covers \Yoti\DocScan\Session\Create\SdkConfig::getErrorUrl
* @covers \Yoti\DocScan\Session\Create\SdkConfig::getPrivacyPolicyUrl
* @covers \Yoti\DocScan\Session\Create\SdkConfig::getAllowHandoff
* @covers \Yoti\DocScan\Session\Create\SdkConfig::getBrandId
*/
public function shouldCorrectlyBuildSdkConfig()
{
Expand All @@ -63,6 +66,7 @@ public function shouldCorrectlyBuildSdkConfig()
->withErrorUrl(self::SOME_ERROR_URL)
->withPrivacyPolicyUrl(self::SOME_PRIVACY_POLICY_URL)
->withAllowHandoff(true)
->withBrandId(self::SOME_BRAND_ID)
->build();

$this->assertEquals(self::SOME_CAPTURE_METHOD, $result->getAllowedCaptureMethods());
Expand All @@ -75,6 +79,7 @@ public function shouldCorrectlyBuildSdkConfig()
$this->assertEquals(self::SOME_ERROR_URL, $result->getErrorUrl());
$this->assertEquals(self::SOME_PRIVACY_POLICY_URL, $result->getPrivacyPolicyUrl());
$this->assertTrue($result->getAllowHandoff());
$this->assertEquals(self::SOME_BRAND_ID, $result->getBrandId());
}

/**
Expand Down

0 comments on commit 11ea0f7

Please sign in to comment.