diff --git a/README.md b/README.md
index baf6ffee..6f35b579 100755
--- a/README.md
+++ b/README.md
@@ -42,13 +42,13 @@ Add the Yoti SDK dependency:
```json
"require": {
- "yoti/yoti-php-sdk" : "^4.1"
+ "yoti/yoti-php-sdk" : "^4.3.0"
}
```
Or run this Composer command
```console
-$ composer require yoti/yoti-php-sdk "^4.1"
+$ composer require yoti/yoti-php-sdk "^4.3.0"
```
## Setup
diff --git a/composer.json b/composer.json
index 46af649a..95ef8a52 100755
--- a/composer.json
+++ b/composer.json
@@ -1,7 +1,7 @@
{
"name": "yoti/yoti-php-sdk",
"description": "Yoti SDK for quickly integrating your PHP backend with Yoti",
- "version": "4.2.2",
+ "version": "4.3.0",
"keywords": [
"yoti",
"sdk"
@@ -15,7 +15,7 @@
"phpseclib/phpseclib": "^3.0",
"guzzlehttp/guzzle": "^7.0",
"psr/http-client": "^1.0",
- "psr/http-message": "^1.0",
+ "psr/http-message": "^2.0",
"guzzlehttp/psr7": "^2.4",
"ext-openssl": "*"
},
@@ -66,4 +66,4 @@
"phpstan/extension-installer": true
}
}
-}
\ No newline at end of file
+}
diff --git a/examples/digitalidentity/README.md b/examples/digitalidentity/README.md
index 8faa9b32..9bf2d1b3 100644
--- a/examples/digitalidentity/README.md
+++ b/examples/digitalidentity/README.md
@@ -18,7 +18,10 @@ This example requires [Docker](https://docs.docker.com/)
* Visit [https://localhost:4002](https://localhost:4002)
* Run the `docker-compose stop` command to stop the containers.
-> To see how to retrieve activity details using the one time use token, refer to the [digitalidentity controller](app/Http/Controllers/IdentityController.php)
-
+> To see how to retrieve a profile using share receipt, refer to the [receipt controller](app/Http/Controllers/ReceiptController.php)
## Digital Identity Example
* Visit [/generate-share](https://localhost:4002/generate-share)
+## Digital Identity(Advanced) Share Example
+* Visit [/generate-advanced-identity-share](https://localhost:4002/generate-advanced-identity-share)
+* ## Digital Identity DBS Example
+* Visit [/generate-dbs-share](https://localhost:4002/generate-dbs-share)
diff --git a/examples/digitalidentity/app/Http/Controllers/AdvancedIdentityController.php b/examples/digitalidentity/app/Http/Controllers/AdvancedIdentityController.php
index cdfda0f6..c084faf2 100644
--- a/examples/digitalidentity/app/Http/Controllers/AdvancedIdentityController.php
+++ b/examples/digitalidentity/app/Http/Controllers/AdvancedIdentityController.php
@@ -4,12 +4,10 @@
use Illuminate\Routing\Controller as BaseController;
use Illuminate\Support\Facades\Log;
-use mysql_xdevapi\Exception;
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
use Yoti\DigitalIdentityClient;
use Yoti\Identity\Policy\PolicyBuilder;
use Yoti\Identity\ShareSessionRequestBuilder;
-use Yoti\YotiClient;
class AdvancedIdentityController extends BaseController
{
diff --git a/examples/digitalidentity/app/Http/Controllers/DbsController.php b/examples/digitalidentity/app/Http/Controllers/DbsController.php
new file mode 100644
index 00000000..e8e47e74
--- /dev/null
+++ b/examples/digitalidentity/app/Http/Controllers/DbsController.php
@@ -0,0 +1,53 @@
+withIdentityProfileRequirements((object)[
+ 'trust_framework' => 'UK_TFIDA',
+ 'scheme' => [
+ 'type' => 'DBS',
+ 'objective' => 'BASIC'
+ ]
+ ])
+ ->build();
+
+ $redirectUri = 'https://host/redirect/';
+
+ $shareSessionRequest = (new ShareSessionRequestBuilder())
+ ->withPolicy($policy)
+ ->withRedirectUri($redirectUri)
+ ->build();
+ $session = $client->createShareSession($shareSessionRequest);
+ return $session->getId();
+ }
+ catch (\Throwable $e) {
+ Log::error($e->getTraceAsString());
+ throw new BadRequestHttpException($e->getMessage());
+ }
+ }
+ public function show(DigitalIdentityClient $client)
+ {
+ try {
+ return view('dbs', [
+ 'title' => 'Digital Identity DBS Check Example',
+ 'sdkId' => $client->id
+ ]);
+ } catch (\Throwable $e) {
+ Log::error($e->getTraceAsString());
+ throw new BadRequestHttpException($e->getMessage());
+ }
+ }
+}
diff --git a/examples/digitalidentity/app/Http/Controllers/IdentityController.php b/examples/digitalidentity/app/Http/Controllers/IdentityController.php
index 72ba9fc3..ca987617 100644
--- a/examples/digitalidentity/app/Http/Controllers/IdentityController.php
+++ b/examples/digitalidentity/app/Http/Controllers/IdentityController.php
@@ -4,12 +4,10 @@
use Illuminate\Routing\Controller as BaseController;
use Illuminate\Support\Facades\Log;
-use mysql_xdevapi\Exception;
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
use Yoti\DigitalIdentityClient;
use Yoti\Identity\Policy\PolicyBuilder;
use Yoti\Identity\ShareSessionRequestBuilder;
-use Yoti\YotiClient;
class IdentityController extends BaseController
{
diff --git a/examples/digitalidentity/app/Http/Controllers/ReceiptController.php b/examples/digitalidentity/app/Http/Controllers/ReceiptController.php
index 39fe75a6..40299d42 100644
--- a/examples/digitalidentity/app/Http/Controllers/ReceiptController.php
+++ b/examples/digitalidentity/app/Http/Controllers/ReceiptController.php
@@ -3,12 +3,12 @@
namespace App\Http\Controllers;
use Yoti\DigitalIdentityClient;
-use Yoti\YotiClient;
use Illuminate\Http\Request;
use Illuminate\Routing\Controller as BaseController;
use Yoti\Profile\Attribute;
use Yoti\Profile\UserProfile;
use Yoti\Util\Logger;
+
class ReceiptController extends BaseController
{
public function show(Request $request, DigitalIdentityClient $client, ?LoggerInterface $logger = null)
@@ -17,14 +17,25 @@ public function show(Request $request, DigitalIdentityClient $client, ?LoggerInt
$logger->warning("Unknown Content Type parsing as a String");
$shareReceipt = $client->fetchShareReceipt($request->query('ReceiptID'));
-
- $profile = $shareReceipt->getProfile();
-
- return view('receipt', [
- 'fullName' => $profile->getFullName(),
- 'selfie' => $profile->getSelfie(),
- 'profileAttributes' => $this->createAttributesDisplayList($profile),
- ]);
+ if ($shareReceipt->getError() != null)
+ {
+ error_log($shareReceipt->getErrorReason()->getRequirementNotMetDetails()->getDocumentCountryIsoCode());
+ return view('receipt', [
+ 'fullName' => null,
+ 'selfie' => null,
+ 'profileAttributes' => null,
+ 'error' => $shareReceipt->getErrorReason()
+ ]);
+ }
+ else {
+ $profile = $shareReceipt->getProfile();
+ return view('receipt', [
+ 'fullName' => $profile->getFullName(),
+ 'selfie' => $profile->getSelfie(),
+ 'profileAttributes' => $this->createAttributesDisplayList($profile),
+ 'error' => null
+ ]);
+ }
}
/**
diff --git a/examples/digitalidentity/resources/views/dbs.blade.php b/examples/digitalidentity/resources/views/dbs.blade.php
new file mode 100644
index 00000000..1359cc7c
--- /dev/null
+++ b/examples/digitalidentity/resources/views/dbs.blade.php
@@ -0,0 +1,89 @@
+
+
+
+
+
+
+ {{ $title }}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/examples/digitalidentity/resources/views/partial/report.blade.php b/examples/digitalidentity/resources/views/partial/report.blade.php
index 28bdd3f0..ec1dc60d 100644
--- a/examples/digitalidentity/resources/views/partial/report.blade.php
+++ b/examples/digitalidentity/resources/views/partial/report.blade.php
@@ -1,39 +1,54 @@
-@foreach ($report as $key => $value)
-
-
-
-
- {{ $key }}
- |
-
-
-
- @foreach ($value as $name => $result)
- @if (is_array($result))
- @foreach ($result as $data => $view)
- @if (is_array($view))
- @foreach ($view as $key2 => $value2)
- @if (is_array($value2))
- {{json_encode($value2)}}
- @else
-
- {{ $key2 }} {{ $value2 }} |
-
- @endif
- @endforeach
- @else
-
- {{ $data }} {{ $view }} |
-
- @endif
- @endforeach
- @else
-
+@if (isset($key) && is_array($key))
+ @foreach ($report as $key => $value)
+
+
+
+
+ {{ $key }}
+ |
+
+
+
+ @foreach ($value as $name => $result)
+ @if (isset($result) && is_array($result))
+ @foreach ($result as $data => $view)
+ @if (is_array($view))
+ @foreach ($view as $key2 => $value2)
+ @if (is_array($value2))
+ {{json_encode($value2)}}
+ @else
+
+ {{ $key2 }} {{ $value2 }} |
+
+ @endif
+ @endforeach
+ @else
+
+ {{ $data }} {{ $view }} |
+
+ @endif
+ @endforeach
+ @else
+
{{ $name }} {{ $result }} |
-
- @endif
- @endforeach
+
+ @endif
+ @endforeach
-
-
+
+
@endforeach
+@else
+
+ @foreach ($report as $key => $value)
+
+
+ {{ $key }}
+
+ {!! json_encode($value, JSON_PRETTY_PRINT) !!}
+
+ |
+
+ @endforeach
+
+@endif
diff --git a/examples/digitalidentity/resources/views/receipt.blade.php b/examples/digitalidentity/resources/views/receipt.blade.php
index 1fef5463..b166dbdd 100644
--- a/examples/digitalidentity/resources/views/receipt.blade.php
+++ b/examples/digitalidentity/resources/views/receipt.blade.php
@@ -36,10 +36,37 @@
+
+ @if ($error)
+
+
+
+
+
+
+ @endif
+ @if(@$profileAttributes)
@foreach($profileAttributes as $item)
@if ($item['obj'])
@@ -96,6 +124,7 @@
@endif
@endforeach
+ @endif
diff --git a/examples/digitalidentity/routes/web.php b/examples/digitalidentity/routes/web.php
index 44933279..3fb377e7 100644
--- a/examples/digitalidentity/routes/web.php
+++ b/examples/digitalidentity/routes/web.php
@@ -18,3 +18,5 @@
Route::get('/generate-session', 'IdentityController@generateSession');
Route::get('/generate-advanced-identity-share', 'AdvancedIdentityController@show');
Route::get('/generate-advanced-identity-session', 'AdvancedIdentityController@generateSession');
+Route::get('/generate-dbs-share', 'DbsController@show');
+Route::get('/generate-dbs-session', 'DbsController@generateSession');
\ No newline at end of file
diff --git a/examples/doc-scan/app/Http/Controllers/HomeController.php b/examples/doc-scan/app/Http/Controllers/HomeController.php
index 9bd67d01..299fa6b1 100644
--- a/examples/doc-scan/app/Http/Controllers/HomeController.php
+++ b/examples/doc-scan/app/Http/Controllers/HomeController.php
@@ -77,18 +77,30 @@ public function show(Request $request, DocScanClient $client)
->withRemoveDeceased(true)
->build();
+ //Identity Profile Requeirements Object
+ /*$identityProfileRequirements = (object)[
+ 'trust_framework' => 'UK_TFIDA',
+ 'scheme' => [
+ 'type' => 'DBS',
+ 'objective' => 'BASIC'
+ ]
+ ];*/
$sessionSpec = (new SessionSpecificationBuilder())
->withClientSessionTokenTtl(600)
- ->withResourcesTtl(90000)
+ ->withResourcesTtl(604800)
->withUserTrackingId('some-user-tracking-id')
+ //For Identity Profile Requirements Object
+ //->withBlockBiometricConsent(false) //User needs to provide consent for the liveness detection
+ //->withIdentityProfileRequirements($identityProfileRequirements)
->withRequestedCheck(
(new RequestedDocumentAuthenticityCheckBuilder())
->build()
)
->withRequestedCheck(
(new RequestedLivenessCheckBuilder())
- ->forZoomLiveness()
+ ->forStaticLiveness()
+ ->withMaxRetries(3)
->build()
)
->withRequestedCheck(
@@ -98,7 +110,7 @@ public function show(Request $request, DocScanClient $client)
)
->withRequestedCheck(
(new RequestedFaceMatchCheckBuilder())
- ->withManualCheckAlways()
+ ->withManualCheckFallback()
->build()
)
->withRequestedCheck(
@@ -116,20 +128,20 @@ public function show(Request $request, DocScanClient $client)
)
->withRequestedTask(
(new RequestedTextExtractionTaskBuilder())
- ->withManualCheckAlways()
+ ->withManualCheckFallback()
->withChipDataDesired()
->withCreateExpandedDocumentFields(true)
->build()
)
->withRequestedTask(
(new RequestedSupplementaryDocTextExtractionTaskBuilder())
- ->withManualCheckAlways()
+ ->withManualCheckFallback()
->build()
)
->withSdkConfig(
(new SdkConfigBuilder())
->withAllowsCameraAndUpload()
- ->withPrimaryColour('#2d9fff')
+ ->withPrimaryColour('#2875BC')
->withSecondaryColour('#FFFFFF')
->withFontColour('#FFFFFF')
->withLocale('en-GB')
diff --git a/examples/doc-scan/resources/views/success.blade.php b/examples/doc-scan/resources/views/success.blade.php
index 0e49c218..63b0b486 100644
--- a/examples/doc-scan/resources/views/success.blade.php
+++ b/examples/doc-scan/resources/views/success.blade.php
@@ -293,7 +293,61 @@
@endif
-
+ @if (isset($sessionResult))
+ @if ($sessionResult->getIdentityProfile() != null)
+ @if ($sessionResult->getIdentityProfile()->getFailureReason() != null)
+ @if ($sessionResult->getIdentityProfile()->getFailureReason()->getReasonCode())
+
+
+
Identity Result Error
+
+
+ @if ($sessionResult->getIdentityProfile()->getFailureReason()->getReasonCode())
+
+
+
+ Reason Code |
+
+ {{$sessionResult->getIdentityProfile()->getFailureReason()->getReasonCode()}}
+ |
+
+
+ Failure Type |
+
+ {{$sessionResult->getIdentityProfile()->getFailureReason()->getRequirementNotMetDetails()->getFailureType()}}
+ |
+
+
+ Details |
+
+ {{$sessionResult->getIdentityProfile()->getFailureReason()->getRequirementNotMetDetails()->getDetails()}}
+ |
+
+
+ Audit Id |
+
+ {{$sessionResult->getIdentityProfile()->getFailureReason()->getRequirementNotMetDetails()->getAuditId()}}
+ |
+
+
+ Country ISO Code |
+
+ {{$sessionResult->getIdentityProfile()->getFailureReason()->getRequirementNotMetDetails()->getDocumentCountryIsoCode()}}
+ |
+
+
+ Document Type |
+
+ {{$sessionResult->getIdentityProfile()->getFailureReason()->getRequirementNotMetDetails()->getDocumentType()}}
+ |
+
+
+
+ @endif
+ @endif
+ @endif
+ @endif
+ @endif
@if (count($sessionResult->getResources()->getIdDocuments()) > 0)
diff --git a/examples/profile/resources/views/partial/report.blade.php b/examples/profile/resources/views/partial/report.blade.php
index 707abe99..d3466436 100644
--- a/examples/profile/resources/views/partial/report.blade.php
+++ b/examples/profile/resources/views/partial/report.blade.php
@@ -1,40 +1,54 @@
-@foreach ($report as $key => $value)
-
-
-
-
- {{ $key }}
- |
-
-
-
- @if (isset($value) && is_array($value))
- @foreach ($value as $name => $result)
- @if (is_array($result))
- @foreach ($result as $data => $view)
- @if (is_array($view))
- @foreach ($view as $key2 => $value2)
- @if (is_array($value2))
- {{json_encode($value2)}}
- @else
-
- {{ $key2 }} {{ $value2 }} |
-
- @endif
- @endforeach
- @else
-
- {{ $data }} {{ $view }} |
-
- @endif
- @endforeach
- @else
-
+@if (isset($key) && is_array($key))
+ @foreach ($report as $key => $value)
+
+
+
+
+ {{ $key }}
+ |
+
+
+
+ @foreach ($value as $name => $result)
+ @if (isset($result) && is_array($result))
+ @foreach ($result as $data => $view)
+ @if (is_array($view))
+ @foreach ($view as $key2 => $value2)
+ @if (is_array($value2))
+ {{json_encode($value2)}}
+ @else
+
+ {{ $key2 }} {{ $value2 }} |
+
+ @endif
+ @endforeach
+ @else
+
+ {{ $data }} {{ $view }} |
+
+ @endif
+ @endforeach
+ @else
+
{{ $name }} {{ $result }} |
-
- @endif
+
+ @endif
+ @endforeach
+
+
+
+ @endforeach
+@else
+
+ @foreach ($report as $key => $value)
+
+
+ {{ $key }}
+
+ {!! json_encode($value, JSON_PRETTY_PRINT) !!}
+
+ |
+
@endforeach
- @endif
-
- @endforeach
+@endif
\ No newline at end of file
diff --git a/src/Constants.php b/src/Constants.php
index e6dd08d8..b1cb4499 100644
--- a/src/Constants.php
+++ b/src/Constants.php
@@ -31,7 +31,7 @@ class Constants
public const SDK_IDENTIFIER = 'PHP';
/** Default SDK version */
- public const SDK_VERSION = '4.2.2';
+ public const SDK_VERSION = '4.3.0';
/** 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';
diff --git a/src/DocScan/Session/Retrieve/GetSessionResult.php b/src/DocScan/Session/Retrieve/GetSessionResult.php
index 919053c3..857e3263 100644
--- a/src/DocScan/Session/Retrieve/GetSessionResult.php
+++ b/src/DocScan/Session/Retrieve/GetSessionResult.php
@@ -313,7 +313,11 @@ function ($checkResponse) use ($class): bool {
public function getIdentityProfile(): ?IdentityProfileResponse
{
- return $this->identityProfile;
+ if (isset($this->identityProfile)) {
+ return $this->identityProfile;
+ } else {
+ return null;
+ }
}
public function getIdentityProfilePreview(): ?IdentityProfilePreviewResponse
diff --git a/src/DocScan/Session/Retrieve/IdentityProfileResponse.php b/src/DocScan/Session/Retrieve/IdentityProfileResponse.php
index 17643e89..06bea9c2 100644
--- a/src/DocScan/Session/Retrieve/IdentityProfileResponse.php
+++ b/src/DocScan/Session/Retrieve/IdentityProfileResponse.php
@@ -31,7 +31,7 @@ class IdentityProfileResponse
*/
public function __construct(array $sessionData)
{
- $this->subjectId = $sessionData['subject_id'];
+ $this->subjectId = $sessionData['subject_id'] ?? '';
$this->result = $sessionData['result'];
if (isset($sessionData['failure_reason'])) {
@@ -62,7 +62,7 @@ public function getResult(): string
/**
* @return FailureReasonResponse
*/
- public function getFailureReason(): FailureReasonResponse
+ public function getFailureReason(): ?FailureReasonResponse
{
return $this->failureReason;
}
diff --git a/src/Identity/Policy/Policy.php b/src/Identity/Policy/Policy.php
index a71e1fdc..5c54f2fa 100644
--- a/src/Identity/Policy/Policy.php
+++ b/src/Identity/Policy/Policy.php
@@ -37,7 +37,7 @@ class Policy implements \JsonSerializable
* @param int[] $wantedAuthTypes
* Auth types represents the authentication type to be used.
* @param object $identityProfileRequirements
- * @param object $advancedidentityProfileRequirements
+ * @param object $advancedIdentityProfileRequirements
*/
public function __construct(
array $wantedAttributes,
diff --git a/src/Identity/Receipt.php b/src/Identity/Receipt.php
index 162761f2..893c5459 100644
--- a/src/Identity/Receipt.php
+++ b/src/Identity/Receipt.php
@@ -12,8 +12,8 @@ class Receipt
private string $id;
private string $sessionId;
private \DateTime $timestamp;
- private ApplicationContent $applicationContent;
- private UserContent $userContent;
+ private ?ApplicationContent $applicationContent;
+ private ?UserContent $userContent;
private ?string $rememberMeId;
private ?string $parentRememberMeId;
private ?string $error;
@@ -23,8 +23,8 @@ public function __construct(
string $id,
string $sessionId,
\DateTime $timestamp,
- ApplicationContent $applicationContent,
- UserContent $userContent,
+ ?ApplicationContent $applicationContent,
+ ?UserContent $userContent,
?string $rememberMeId,
?string $parentRememberMeId,
?string $error,
@@ -58,20 +58,28 @@ public function getTimestamp(): \DateTime
public function getProfile(): ?UserProfile
{
- return $this->userContent->getProfile();
+ if ($this->userContent !== null) {
+ return $this->userContent->getProfile();
+ } else {
+ return null;
+ }
}
public function getExtraData(): ?ExtraData
{
- return $this->userContent->getExtraData();
+ if ($this->userContent !== null) {
+ return $this->userContent->getExtraData();
+ } else {
+ return null;
+ }
}
- public function getApplicationContent(): ApplicationContent
+ public function getApplicationContent(): ?ApplicationContent
{
return $this->applicationContent;
}
- public function getUserContent(): UserContent
+ public function getUserContent(): ?UserContent
{
return $this->userContent;
}
diff --git a/src/Identity/ReceiptBuilder.php b/src/Identity/ReceiptBuilder.php
index 7a091388..0851a088 100644
--- a/src/Identity/ReceiptBuilder.php
+++ b/src/Identity/ReceiptBuilder.php
@@ -16,9 +16,9 @@ class ReceiptBuilder
private \DateTime $timestamp;
- private ApplicationContent $applicationContent;
+ private ?ApplicationContent $applicationContent = null;
- private UserContent $userContent;
+ private ?UserContent $userContent = null;
private ?string $rememberMeId = null;
diff --git a/src/Identity/ReceiptParser.php b/src/Identity/ReceiptParser.php
index 375249da..904ef7b7 100644
--- a/src/Identity/ReceiptParser.php
+++ b/src/Identity/ReceiptParser.php
@@ -93,8 +93,11 @@ public function createFailure(WrappedReceipt $wrappedReceipt): Receipt
->build();
}
- private function decryptReceiptKey(string $wrappedKey, ReceiptItemKey $wrappedItemKey, PemFile $pemFile): string
+ private function decryptReceiptKey(?string $wrappedKey, ReceiptItemKey $wrappedItemKey, PemFile $pemFile): string
{
+ if ($wrappedKey == null) {
+ throw new EncryptedDataException('Wrapped is null');
+ }
// Convert 'iv' and 'value' from base64 to binary
$iv = (string)base64_decode($wrappedItemKey->getIv(), true);
$encryptedItemKey = (string)base64_decode($wrappedItemKey->getValue(), true);
diff --git a/src/Identity/WrappedReceipt.php b/src/Identity/WrappedReceipt.php
index 7d1f4b74..28e93f60 100644
--- a/src/Identity/WrappedReceipt.php
+++ b/src/Identity/WrappedReceipt.php
@@ -19,9 +19,9 @@ class WrappedReceipt
private Content $otherPartyContent;
- private string $wrappedItemKeyId;
+ private ?string $wrappedItemKeyId = null;
- private string $wrappedKey;
+ private ?string $wrappedKey;
private ?string $rememberMeId = null;
@@ -38,8 +38,8 @@ public function __construct(array $sessionData)
$this->id = $sessionData['id'];
$this->sessionId = $sessionData['sessionId'];
$this->timestamp = DateTime::stringToDateTime($sessionData['timestamp']);
- $this->wrappedItemKeyId = $sessionData['wrappedItemKeyId'];
- $this->wrappedKey = $sessionData['wrappedKey'];
+ $this->wrappedItemKeyId = $sessionData['wrappedItemKeyId'] ?? null;
+ $this->wrappedKey = $sessionData['wrappedKey'] ?? null;
if (isset($sessionData['content'])) {
$this->content = new Content(
@@ -63,10 +63,10 @@ public function __construct(array $sessionData)
if (isset($sessionData['error'])) {
$this->error = $sessionData['error'];
}
- if (isset($sessionData['errorDetails'])) {
- if (isset($sessionData["error_details"]["error_reason"]["requirements_not_met_details"])) {
+ if (isset($sessionData['errorReason'])) {
+ if (isset($sessionData["errorReason"]["requirements_not_met_details"])) {
$this->errorReason = new ErrorReason(
- $sessionData['errorDetails']['error_reason']['requirements_not_met_details']
+ $sessionData["errorReason"]["requirements_not_met_details"]
);
}
}
@@ -115,12 +115,12 @@ public function getOtherPartyExtraData(): ?string
return $this->otherPartyContent->getExtraData();
}
- public function getWrappedItemKeyId(): string
+ public function getWrappedItemKeyId(): ?string
{
return $this->wrappedItemKeyId;
}
- public function getWrappedKey(): string
+ public function getWrappedKey(): ?string
{
return $this->wrappedKey;
}
diff --git a/src/Profile/UserProfile.php b/src/Profile/UserProfile.php
index d9ac0210..e4189a56 100644
--- a/src/Profile/UserProfile.php
+++ b/src/Profile/UserProfile.php
@@ -28,7 +28,6 @@ class UserProfile extends BaseProfile
public const ATTR_DOCUMENT_IMAGES = 'document_images';
public const ATTR_STRUCTURED_POSTAL_ADDRESS = 'structured_postal_address';
public const ATTR_IDENTITY_PROFILE_REPORT = 'identity_profile_report';
-
/** @var \Yoti\Profile\Attribute\AgeVerification[] */
private $ageVerifications;
diff --git a/tests/DocScan/DocScanClientTest.php b/tests/DocScan/DocScanClientTest.php
index 306e1d17..623c0a60 100644
--- a/tests/DocScan/DocScanClientTest.php
+++ b/tests/DocScan/DocScanClientTest.php
@@ -6,6 +6,7 @@
use Psr\Http\Client\ClientInterface;
use Psr\Http\Message\ResponseInterface;
+use Psr\Http\Message\StreamInterface;
use Yoti\DocScan\DocScanClient;
use Yoti\DocScan\Session\Create\CreateSessionResult;
use Yoti\DocScan\Session\Create\FaceCapture\CreateFaceCaptureResourcePayload;
@@ -92,8 +93,12 @@ public function testEmptyApiUrlEnvironmentVariable()
*/
private function assertApiUrlStartsWith($expectedUrl, $clientApiUrl = null)
{
+ $stream = $this->createMock(\Psr\Http\Message\StreamInterface::class);
+ $stream->method('getContents')->willReturn(file_get_contents(TestData::DOC_SCAN_SESSION_CREATION_RESPONSE));
+ $stream->method('__toString')->willReturn(file_get_contents(TestData::DOC_SCAN_SESSION_CREATION_RESPONSE));
+
$response = $this->createMock(ResponseInterface::class);
- $response->method('getBody')->willReturn(file_get_contents(TestData::DOC_SCAN_SESSION_CREATION_RESPONSE));
+ $response->method('getBody')->willReturn($stream);
$response->method('getStatusCode')->willReturn(200);
$httpClient = $this->createMock(ClientInterface::class);
@@ -126,8 +131,13 @@ private function assertApiUrlStartsWith($expectedUrl, $clientApiUrl = null)
*/
public function testCreateSession()
{
+ $stream = $this->createMock(\Psr\Http\Message\StreamInterface::class);
+ $stream->method('getContents')->willReturn(file_get_contents(TestData::DOC_SCAN_SESSION_CREATION_RESPONSE));
+ $stream->method('__toString')->willReturn(file_get_contents(TestData::DOC_SCAN_SESSION_CREATION_RESPONSE));
+
$response = $this->createMock(ResponseInterface::class);
- $response->method('getBody')->willReturn(file_get_contents(TestData::DOC_SCAN_SESSION_CREATION_RESPONSE));
+ $response->method('getBody')->willReturn($stream);
+
$response->method('getStatusCode')->willReturn(200);
$httpClient = $this->createMock(ClientInterface::class);
@@ -155,8 +165,12 @@ public function testCreateSession()
*/
public function testGetSession()
{
+ $stream = $this->createMock(\Psr\Http\Message\StreamInterface::class);
+ $stream->method('getContents')->willReturn(file_get_contents(TestData::DOC_SCAN_SESSION_RESPONSE));
+ $stream->method('__toString')->willReturn(file_get_contents(TestData::DOC_SCAN_SESSION_RESPONSE));
+
$response = $this->createMock(ResponseInterface::class);
- $response->method('getBody')->willReturn(file_get_contents(TestData::DOC_SCAN_SESSION_RESPONSE));
+ $response->method('getBody')->willReturn($stream);
$response->method('getStatusCode')->willReturn(200);
$httpClient = $this->createMock(ClientInterface::class);
@@ -203,8 +217,13 @@ public function testDeleteSessionDoesNotThrowException()
*/
public function testGetMedia()
{
+ $stream = $this->createMock(\Psr\Http\Message\StreamInterface::class);
+ $stream->method('getContents')->willReturn(file_get_contents(TestData::DOC_SCAN_SESSION_RESPONSE));
+ $stream->method('__toString')->willReturn(file_get_contents(TestData::DOC_SCAN_SESSION_RESPONSE));
+
$response = $this->createMock(ResponseInterface::class);
- $response->method('getBody')->willReturn(file_get_contents(TestData::DOC_SCAN_SESSION_RESPONSE));
+ $response->method('getBody')->willReturn($stream);
+
$response->method('getStatusCode')->willReturn(200);
$response->method('getHeader')->willReturn([ 'image/png' ]);
@@ -276,8 +295,12 @@ public function testDeleteMediaDoesNotThrowException()
*/
public function testGetSupportedDocuments()
{
+ $stream = $this->createMock(StreamInterface::class);
+ $stream->method('getContents')->willReturn(json_encode((object)[]));
+ $stream->method('__toString')->willReturn(json_encode((object)[]));
+
$response = $this->createMock(ResponseInterface::class);
- $response->method('getBody')->willReturn(json_encode((object)[]));
+ $response->method('getBody')->willReturn($stream);
$response->method('getStatusCode')->willReturn(200);
$httpClient = $this->createMock(ClientInterface::class);
@@ -301,8 +324,12 @@ public function testGetSupportedDocuments()
*/
public function testCreateFaceCaptureResource()
{
+ $stream = $this->createMock(StreamInterface::class);
+ $stream->method('getContents')->willReturn(json_encode((object)[]));
+ $stream->method('__toString')->willReturn(json_encode((object)[]));
+
$response = $this->createMock(ResponseInterface::class);
- $response->method('getBody')->willReturn(json_encode((object)[]));
+ $response->method('getBody')->willReturn($stream);
$response->method('getStatusCode')->willReturn(201);
$createFaceCaptureResourcePayloadMock = $this->createMock(CreateFaceCaptureResourcePayload::class);
@@ -331,9 +358,14 @@ public function testCreateFaceCaptureResource()
*/
public function testUploadFaceCaptureImage()
{
+
+ $stream = $this->createMock(StreamInterface::class);
+ $stream->method('getContents')->willReturn(json_encode((object)[]));
+ $stream->method('__toString')->willReturn(json_encode((object)[]));
+
$response = $this->createMock(ResponseInterface::class);
+ $response->method('getBody')->willReturn($stream);
$uploadFaceCaptureImagePayloadMock = $this->createMock(UploadFaceCaptureImagePayload::class);
- $response->method('getBody')->willReturn(json_encode((object)[]));
$response->method('getStatusCode')->willReturn(200);
$httpClient = $this->createMock(ClientInterface::class);
@@ -358,8 +390,12 @@ public function testUploadFaceCaptureImage()
*/
public function testGetSessionConfiguration()
{
+ $stream = $this->createMock(StreamInterface::class);
+ $stream->method('getContents')->willReturn(json_encode((object)[]));
+ $stream->method('__toString')->willReturn(json_encode((object)[]));
+
$response = $this->createMock(ResponseInterface::class);
- $response->method('getBody')->willReturn(json_encode((object)[]));
+ $response->method('getBody')->willReturn($stream);
$response->method('getStatusCode')->willReturn(200);
$httpClient = $this->createMock(ClientInterface::class);
@@ -383,9 +419,13 @@ public function testGetSessionConfiguration()
*/
public function testPutIbvInstructions()
{
+ $stream = $this->createMock(StreamInterface::class);
+ $stream->method('getContents')->willReturn(json_encode((object)[]));
+ $stream->method('__toString')->willReturn(json_encode((object)[]));
+
$response = $this->createMock(ResponseInterface::class);
+ $response->method('getBody')->willReturn($stream);
$instructionsMock = $this->createMock(Instructions::class);
- $response->method('getBody')->willReturn(json_encode((object)[]));
$response->method('getStatusCode')->willReturn(200);
$httpClient = $this->createMock(ClientInterface::class);
@@ -409,8 +449,12 @@ public function testPutIbvInstructions()
*/
public function testGetIbvInstructions()
{
+ $stream = $this->createMock(StreamInterface::class);
+ $stream->method('getContents')->willReturn(json_encode((object)[]));
+ $stream->method('__toString')->willReturn(json_encode((object)[]));
+
$response = $this->createMock(ResponseInterface::class);
- $response->method('getBody')->willReturn(json_encode((object)[]));
+ $response->method('getBody')->willReturn($stream);
$response->method('getStatusCode')->willReturn(200);
$httpClient = $this->createMock(ClientInterface::class);
@@ -433,8 +477,12 @@ public function testGetIbvInstructions()
*/
public function testGetIbvInstructionsPdf()
{
+ $stream = $this->createMock(StreamInterface::class);
+ $stream->method('getContents')->willReturn(json_encode((object)[]));
+ $stream->method('__toString')->willReturn(json_encode((object)[]));
+
$response = $this->createMock(ResponseInterface::class);
- $response->method('getBody')->willReturn(json_encode((object)[]));
+ $response->method('getBody')->willReturn($stream);
$response->method('getStatusCode')->willReturn(200);
$httpClient = $this->createMock(ClientInterface::class);
@@ -457,8 +505,12 @@ public function testGetIbvInstructionsPdf()
*/
public function testFetchInstructionsContactProfile()
{
+ $stream = $this->createMock(StreamInterface::class);
+ $stream->method('getContents')->willReturn(json_encode((object)[]));
+ $stream->method('__toString')->willReturn(json_encode((object)[]));
+
$response = $this->createMock(ResponseInterface::class);
- $response->method('getBody')->willReturn(json_encode((object)[]));
+ $response->method('getBody')->willReturn($stream);
$response->method('getStatusCode')->willReturn(200);
$httpClient = $this->createMock(ClientInterface::class);
@@ -481,8 +533,12 @@ public function testFetchInstructionsContactProfile()
*/
public function testTriggerIbvEmailNotification()
{
+ $stream = $this->createMock(StreamInterface::class);
+ $stream->method('getContents')->willReturn(json_encode((object)[]));
+ $stream->method('__toString')->willReturn(json_encode((object)[]));
+
$response = $this->createMock(ResponseInterface::class);
- $response->method('getBody')->willReturn(json_encode((object)[]));
+ $response->method('getBody')->willReturn($stream);
$response->method('getStatusCode')->willReturn(200);
$httpClient = $this->createMock(ClientInterface::class);
diff --git a/tests/Identity/Policy/PolicyBuilderTest.php b/tests/Identity/Policy/PolicyBuilderTest.php
index 58b7968e..4865504b 100644
--- a/tests/Identity/Policy/PolicyBuilderTest.php
+++ b/tests/Identity/Policy/PolicyBuilderTest.php
@@ -680,7 +680,7 @@ public function testWithAdvancedIdentityProfileRequirements()
"label" => "identity-AL-L1",
"type" => "IDENTITY",
- "objective"=> "AL_L1"
+ "objective" => "AL_L1"
],
[
"label" => "identity-AL-M1",
diff --git a/tests/YotiClientTest.php b/tests/YotiClientTest.php
index 9f345a5a..d95b635f 100755
--- a/tests/YotiClientTest.php
+++ b/tests/YotiClientTest.php
@@ -7,6 +7,7 @@
use GuzzleHttp\Psr7;
use Psr\Http\Client\ClientInterface;
use Psr\Http\Message\ResponseInterface;
+use Psr\Http\Message\StreamInterface;
use Psr\Log\LoggerInterface;
use Yoti\Aml\Address as AmlAddress;
use Yoti\Aml\Country as AmlCountry;
@@ -122,8 +123,12 @@ private function assertApiUrlStartsWith($expectedUrl, $clientApiUrl = null)
*/
public function testGetActivityDetails()
{
+ $stream = $this->createMock(StreamInterface::class);
+ $stream->method('getContents')->willReturn(file_get_contents(TestData::RECEIPT_JSON));
+ $stream->method('__toString')->willReturn(file_get_contents(TestData::RECEIPT_JSON));
+
$response = $this->createMock(ResponseInterface::class);
- $response->method('getBody')->willReturn(file_get_contents(TestData::RECEIPT_JSON));
+ $response->method('getBody')->willReturn($stream);
$response->method('getStatusCode')->willReturn(200);
$httpClient = $this->createMock(ClientInterface::class);
@@ -220,20 +225,21 @@ public function testGetLoginUrl()
*/
public function testCustomLogger()
{
- $response = $this->createMock(ResponseInterface::class);
+ $jsonstr = json_encode([
+ 'receipt' => [
+ 'timestamp' => 'some invalid timestamp',
+ 'wrapped_receipt_key' => 'some receipt key',
+ 'sharing_outcome' => 'SUCCESS',
+ ]
+ ]);
+ $stream = $this->createMock(StreamInterface::class);
+ $stream->method('getContents')->willReturn($jsonstr);
+ $stream->method('__toString')->willReturn($jsonstr);
+
+ $response = $this->createMock(ResponseInterface::class);
+ $response->method('getBody')->willReturn($stream);
$response->method('getStatusCode')->willReturn(200);
- $response
- ->method('getBody')
- ->willReturn(
- json_encode([
- 'receipt' => [
- 'timestamp' => 'some invalid timestamp',
- 'wrapped_receipt_key' => 'some receipt key',
- 'sharing_outcome' => 'SUCCESS',
- ]
- ])
- );
$httpClient = $this->createMock(ClientInterface::class);
$httpClient->expects($this->exactly(1))