Skip to content

Commit

Permalink
Merge pull request #338 from getyoti/release/4.2.1
Browse files Browse the repository at this point in the history
**Added**

- Updated session config to configure consent screen location 

**Requested with**
```php	
->withSdkConfig(
                (new SdkConfigBuilder())
                    ->withAllowsCameraAndUpload()
                    ->withPrimaryColour('#2d9fff')
                    ->withSecondaryColour('#FFFFFF')
                    ->withFontColour('#FFFFFF')
                    ->withLocale('en-GB')
                    ->withPresetIssuingCountry('GBR')
                    ->withSuccessUrl(config('app.url') . '/success')
                    ->withErrorUrl(config('app.url') . '/error')
                    ->withPrivacyPolicyUrl(config('app.url') . '/privacy-policy')
                    ->withBiometricConsentFlow('EARLY')
                    ->build()
            )
```

**Added**

- Support for show enable expanded document fields media

**Requested with**
```php	
->withRequestedTask(
                (new RequestedTextExtractionTaskBuilder())
                    ->withManualCheckAlways()
                    ->withChipDataDesired()
                    ->withCreateExpandedDocumentFields(true)
                    ->build()
            )
```

### Fixed

- Fixed a bug that occurs when retrieving advanced checks
  • Loading branch information
mehmet-yoti committed Jul 19, 2023
2 parents 102de43 + ad27c2a commit 4401a3d
Show file tree
Hide file tree
Showing 24 changed files with 571 additions and 16 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "yoti/yoti-php-sdk",
"description": "Yoti SDK for quickly integrating your PHP backend with Yoti",
"version": "4.2.0",
"version": "4.2.1",
"keywords": [
"yoti",
"sdk"
Expand Down
3 changes: 3 additions & 0 deletions examples/doc-scan/app/Http/Controllers/HomeController.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ public function show(Request $request, DocScanClient $client)
(new RequestedTextExtractionTaskBuilder())
->withManualCheckAlways()
->withChipDataDesired()
->withCreateExpandedDocumentFields(true)
->build()
)
->withRequestedTask(
Expand All @@ -136,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 All @@ -160,6 +162,7 @@ public function show(Request $request, DocScanClient $client)
)
->build();


$session = $client->createSession($sessionSpec);

$request->session()->put('YOTI_SESSION_ID', $session->getSessionId());
Expand Down
35 changes: 35 additions & 0 deletions examples/doc-scan/resources/views/success.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,41 @@ class="badge badge-primary">{{ $document->getIssuingCountry() }}</span></h3>
</div>
@endif

@if ($document->getExpandedDocumentFields())
<div class="card">
<div class="card-header" id="expanded-document-fields-{{ $docNum }}">
<h4 class="mb-0">
<button class="btn btn-link" type="button" data-toggle="collapse"
data-target="#collapse-expanded-document-fields-{{ $docNum }}"
aria-expanded="true"
aria-controls="collapse-expanded-document-fields-{{ $docNum }}">
Expanded Document Fields
</button>
</h4>
</div>
<div id="collapse-expanded-document-fields-{{ $docNum }}" class="collapse"
aria-labelledby="expanded-document-fields-{{ $docNum }}">
<div class="card-body">
@if ($document->getExpandedDocumentFields()->getMedia())
<h5>Media</h5>
<table class="table table-striped table-light">
<tbody>
<tr>
<td>ID</td>
<td>
<a href="/media/{{ $document->getExpandedDocumentFields()->getMedia()->getId() }}">
{{ $document->getExpandedDocumentFields()->getMedia()->getId() }}
</a>
</td>
</tr>
</tbody>
</table>
@endif
</div>
</div>
</div>
@endif

@if ($document->getDocumentIdPhoto())
<div class="card">
<div class="card-header" id="document-id-photo-{{ $docNum }}">
Expand Down
2 changes: 1 addition & 1 deletion src/Constants.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class Constants
public const SDK_IDENTIFIER = 'PHP';

/** Default SDK version */
public const SDK_VERSION = '4.2.0';
public const SDK_VERSION = '4.2.1';

/** Base url for connect page (user will be redirected to this page eg. baseurl/app-id) */
public const CONNECT_BASE_URL = 'https://www.yoti.com/connect';
Expand Down
51 changes: 51 additions & 0 deletions src/DocScan/Session/Create/ImportToken.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?php

namespace Yoti\DocScan\Session\Create;

use JsonSerializable;
use Yoti\DocScan\Exception\DocScanException;
use Yoti\Util\Json;

class ImportToken implements JsonSerializable
{
private const MIN_TTL = 3600 * 24 * 30;
private const MAX_TTL = 3600 * 24 * 365;

private int $ttl;

/**
* @throws DocScanException
*/
public function __construct(int $ttl)
{
$this->validate($ttl);
$this->ttl = $ttl;
}

public function jsonSerialize(): \stdClass
{
return (object)Json::withoutNullValues([
'ttl' => $this->getTtl(),
]);
}

/**
* @return int
*/
public function getTtl(): int
{
return $this->ttl;
}

/**
* @throws DocScanException
*/
private function validate(int $ttl): void
{
if (self::MAX_TTL < $ttl || self::MIN_TTL > $ttl) {
throw new DocScanException(
'Your TTL is invalid. Min value - ' . self::MIN_TTL . '.Max value - ' . self::MAX_TTL . '.'
);
}
}
}
27 changes: 27 additions & 0 deletions src/DocScan/Session/Create/ImportTokenBuilder.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

namespace Yoti\DocScan\Session\Create;

use Yoti\DocScan\Exception\DocScanException;

class ImportTokenBuilder
{
private const DEFAULT_TTL = 3600 * 24 * 365;

private int $ttl;

public function withTtl(int $ttl = null): ImportTokenBuilder
{
$this->ttl = $ttl ?? self::DEFAULT_TTL;

return $this;
}

/**
* @throws DocScanException
*/
public function build(): ImportToken
{
return new ImportToken($this->ttl);
}
}
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
);
}
}
26 changes: 20 additions & 6 deletions src/DocScan/Session/Create/SessionSpecification.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,11 @@ class SessionSpecification implements JsonSerializable

private ?bool $createIdentityProfilePreview;

/**
* @var ImportToken|null
*/
private $importToken;

/**
* @param int|null $clientSessionTokenTtl
* @param string|null $sessionDeadline
Expand All @@ -94,7 +99,8 @@ class SessionSpecification implements JsonSerializable
* @param IbvOptions|null $ibvOptions
* @param object|null $subject
* @param object|null $identityProfileRequirements
* @param bool $createIdentityProfilePreview
* @param bool|null $createIdentityProfilePreview
* @param ImportToken|null $importToken
*/
public function __construct(
?int $clientSessionTokenTtl,
Expand All @@ -108,9 +114,10 @@ public function __construct(
array $requiredDocuments = [],
?bool $blockBiometricConsent = null,
?IbvOptions $ibvOptions = null,
$subject = null,
$identityProfileRequirements = null,
?bool $createIdentityProfilePreview = null
?object $subject = null,
?object $identityProfileRequirements = null,
?bool $createIdentityProfilePreview = null,
?ImportToken $importToken = null
) {
$this->clientSessionTokenTtl = $clientSessionTokenTtl;
$this->sessionDeadline = $sessionDeadline;
Expand All @@ -126,6 +133,7 @@ public function __construct(
$this->subject = $subject;
$this->identityProfileRequirements = $identityProfileRequirements;
$this->createIdentityProfilePreview = $createIdentityProfilePreview;
$this->importToken = $importToken;
}

/**
Expand All @@ -148,6 +156,7 @@ public function jsonSerialize(): stdClass
'subject' => $this->getSubject(),
'identity_profile_requirements' => $this->getIdentityProfileRequirements(),
'create_identity_profile_preview' => $this->getCreateIdentityProfilePreview(),
'import_token' => $this->getImportToken(),
]);
}

Expand Down Expand Up @@ -247,15 +256,15 @@ public function getIbvOptions(): ?IbvOptions
/**
* @return object|null
*/
public function getSubject()
public function getSubject(): ?object
{
return $this->subject;
}

/**
* @return object|null
*/
public function getIdentityProfileRequirements()
public function getIdentityProfileRequirements(): ?object
{
return $this->identityProfileRequirements;
}
Expand All @@ -264,4 +273,9 @@ public function getCreateIdentityProfilePreview(): ?bool
{
return $this->createIdentityProfilePreview;
}

public function getImportToken(): ?ImportToken
{
return $this->importToken;
}
}
22 changes: 20 additions & 2 deletions src/DocScan/Session/Create/SessionSpecificationBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace Yoti\DocScan\Session\Create;

use DateTimeImmutable;
use Yoti\DocScan\Session\Create\Check\RequestedCheck;
use Yoti\DocScan\Session\Create\Filters\RequiredDocument;
use Yoti\DocScan\Session\Create\Task\RequestedTask;
Expand Down Expand Up @@ -77,6 +78,11 @@ class SessionSpecificationBuilder
*/
private $identityProfileRequirements;

/**
* @var ImportToken|null
*/
private $importToken;

/**
* @var bool
*/
Expand All @@ -93,10 +99,10 @@ public function withClientSessionTokenTtl(int $clientSessionTokenTtl): self
}

/**
* @param \DateTimeImmutable $sessionDeadline
* @param DateTimeImmutable $sessionDeadline
* @return $this
*/
public function withSessionDeadLine(\DateTimeImmutable $sessionDeadline): self
public function withSessionDeadLine(DateTimeImmutable $sessionDeadline): self
{
$this->sessionDeadline = $sessionDeadline->format(self::DATETIME_FORMAT);
return $this;
Expand Down Expand Up @@ -257,6 +263,17 @@ public function withCreateIdentityProfilePreview(): self
return $this;
}

/**
* @param ImportToken $importToken
*
* @return $this
*/
public function withImportToken($importToken): self
{
$this->importToken = $importToken;
return $this;
}

/**
* @return SessionSpecification
*/
Expand All @@ -277,6 +294,7 @@ public function build(): SessionSpecification
$this->subject,
$this->identityProfileRequirements,
$this->createIdentityProfilePreview,
$this->importToken,
);
}
}
Loading

0 comments on commit 4401a3d

Please sign in to comment.