From b28b5a68c218a86b70993f669b8bbdcfb87bbf61 Mon Sep 17 00:00:00 2001 From: mehmet-yoti Date: Wed, 24 Jul 2024 16:40:07 +0100 Subject: [PATCH] updated failure details error handling --- .../Http/Controllers/ReceiptController.php | 26 +++++++++++++---- .../resources/views/receipt.blade.php | 29 +++++++++++++++++++ 2 files changed, 49 insertions(+), 6 deletions(-) diff --git a/examples/digitalidentity/app/Http/Controllers/ReceiptController.php b/examples/digitalidentity/app/Http/Controllers/ReceiptController.php index 275b524f..cc529386 100644 --- a/examples/digitalidentity/app/Http/Controllers/ReceiptController.php +++ b/examples/digitalidentity/app/Http/Controllers/ReceiptController.php @@ -9,6 +9,7 @@ use Yoti\Profile\Attribute; use Yoti\Profile\UserProfile; use Yoti\Util\Logger; +use Yoti\Exception\ActivityDetailsException; class ReceiptController extends BaseController { public function show(Request $request, DigitalIdentityClient $client, ?LoggerInterface $logger = null) @@ -17,12 +18,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/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) +
+
Errors
+
+
+
+
Audit Id
+
{{ $error->getRequirementNotMetDetails()->getAuditId() }}
+
+
+
Details
+
{{ $error->getRequirementNotMetDetails()->getDetails() }}
+
+
+
Failure Type
+
{{ $error->getRequirementNotMetDetails()->getFailureType() }}
+
+
+
Document Type
+
{{ $error->getRequirementNotMetDetails()->getDocumentType() }}
+
+
+
Country
+
{{ $error->getRequirementNotMetDetails()->getDocumentCountryIsoCode() }}
+
+ @endif
Attribute
Value
@@ -55,6 +82,7 @@
+ @if(@$profileAttributes) @foreach($profileAttributes as $item) @if ($item['obj'])
@@ -96,6 +124,7 @@
@endif @endforeach + @endif