Skip to content

Commit

Permalink
Merge pull request #337 from getyoti/SDK-2311-php-update-session-conf…
Browse files Browse the repository at this point in the history
…ig-to-configure-consent-screen-location

Sdk 2311 php update session config to configure consent screen location
  • Loading branch information
mehmet-yoti authored Jul 17, 2023
2 parents 5ff396f + 7c46be2 commit 958cc57
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 2 deletions.
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 @@ -137,6 +137,7 @@ public function show(Request $request, DocScanClient $client)
->withSuccessUrl(config('app.url') . '/success')
->withErrorUrl(config('app.url') . '/error')
->withPrivacyPolicyUrl(config('app.url') . '/privacy-policy')
->withBiometricConsentFlow('EARLY')
->build()
)
->withRequiredDocument(
Expand Down
21 changes: 20 additions & 1 deletion src/DocScan/Session/Create/SdkConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,11 @@ class SdkConfig implements \JsonSerializable
*/
private $attemptsConfiguration;

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

/**
* @param string|null $allowedCaptureMethods
* @param string|null $primaryColour
Expand All @@ -75,6 +80,7 @@ class SdkConfig implements \JsonSerializable
* @param string|null $privacyPolicyUrl
* @param bool|null $allowHandoff
* @param array<string, int>|null $idDocumentTextDataExtractionRetriesConfig
* @param string|null $biometricConsentFlow
*/
public function __construct(
?string $allowedCaptureMethods,
Expand All @@ -87,7 +93,9 @@ public function __construct(
?string $errorUrl,
?string $privacyPolicyUrl = null,
?bool $allowHandoff = null,
?array $idDocumentTextDataExtractionRetriesConfig = null
?array $idDocumentTextDataExtractionRetriesConfig = null,
?string $biometricConsentFlow = null

) {
$this->allowedCaptureMethods = $allowedCaptureMethods;
$this->primaryColour = $primaryColour;
Expand All @@ -102,6 +110,8 @@ public function __construct(
if (!is_null($idDocumentTextDataExtractionRetriesConfig)) {
$this->attemptsConfiguration = new AttemptsConfiguration($idDocumentTextDataExtractionRetriesConfig);
}
$this->biometricConsentFlow = $biometricConsentFlow;

}

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

Expand Down Expand Up @@ -211,4 +222,12 @@ public function getAttemptsConfiguration(): ?AttemptsConfiguration
{
return $this->attemptsConfiguration;
}

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

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

public function withAllowsCamera(): self
{
return $this->withAllowedCaptureMethod(self::CAMERA);
Expand Down Expand Up @@ -136,6 +141,11 @@ public function withAllowHandoff(bool $allowHandoff): self
return $this;
}

public function withBiometricConsentFlow(string $biometricConsentFlow): self
{
$this->biometricConsentFlow = $biometricConsentFlow;
return $this;
}
/**
* Allows configuring the number of attempts permitted for text extraction on an ID document
*
Expand Down Expand Up @@ -203,7 +213,8 @@ public function build(): SdkConfig
$this->errorUrl,
$this->privacyPolicyUrl,
$this->allowHandoff,
$this->idDocumentTextDataExtractionRetriesConfig
$this->idDocumentTextDataExtractionRetriesConfig,
$this->biometricConsentFlow
);
}
}
4 changes: 4 additions & 0 deletions tests/DocScan/Session/Create/SdkConfigBuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ class SdkConfigBuilderTest extends TestCase
private const SOME_PRIVACY_POLICY_URL = 'somePrivacyPolicyUrl';
private const SOME_CATEGORY = 'someCategory';
private const SOME_NUMBER_RETRIES = 5;
private const SOME_BIOMETRIC_CONSENT_FLOW = 'someBiometricConsentFlow';


/**
* @test
Expand Down Expand Up @@ -118,6 +120,7 @@ public function shouldProduceTheCorrectJsonString()
->withErrorUrl(self::SOME_ERROR_URL)
->withPrivacyPolicyUrl(self::SOME_PRIVACY_POLICY_URL)
->withAllowHandoff(true)
->withBiometricConsentFlow(self::SOME_BIOMETRIC_CONSENT_FLOW)
->build();

$expected = [
Expand All @@ -131,6 +134,7 @@ public function shouldProduceTheCorrectJsonString()
'error_url' => self::SOME_ERROR_URL,
'privacy_policy_url' => self::SOME_PRIVACY_POLICY_URL,
'allow_handoff' => true,
'biometric_consent_flow' => self::SOME_BIOMETRIC_CONSENT_FLOW
];

$this->assertJsonStringEqualsJsonString(json_encode($expected), json_encode($result));
Expand Down

0 comments on commit 958cc57

Please sign in to comment.