diff --git a/yoti-sdk-spring-boot-example/src/main/java/com/yoti/api/examples/springboot/IdentityLoginController.java b/yoti-sdk-spring-boot-example/src/main/java/com/yoti/api/examples/springboot/IdentityLoginController.java index 68438b53..9ac672cb 100644 --- a/yoti-sdk-spring-boot-example/src/main/java/com/yoti/api/examples/springboot/IdentityLoginController.java +++ b/yoti-sdk-spring-boot-example/src/main/java/com/yoti/api/examples/springboot/IdentityLoginController.java @@ -71,22 +71,32 @@ public String identityShare(Model model) { public String receipt(@RequestParam("receiptId") String receiptId, Model model) { Receipt receipt = execute(() -> client.fetchShareReceipt(receiptId), model); - if (receipt == null || receipt.getError().isPresent()) { - model.addAttribute("error", receipt.getError().get()); - return "error"; - } - - Receipt.ApplicationContent applicationContent = receipt.getApplicationContent(); + return Optional.ofNullable(receipt) + .map(r -> + receipt.getError() + .map(error -> { + model.addAttribute("error", error); + receipt.getErrorReason().ifPresent(reason -> + model.addAttribute("errorReason", reason) + ); + return "error"; + }) + .orElseGet(() -> setProfile(receipt, model)) + ) + .orElse("error"); + } - Optional.ofNullable(applicationContent.getProfile()) + private String setProfile(Receipt receipt, Model model) { + Optional.ofNullable(receipt.getApplicationContent().getProfile()) .map(ApplicationProfile::getApplicationLogo) .map(attr -> model.addAttribute("appLogo", attr.getValue().getBase64Content())); - receipt.getProfile().map(HumanProfile::getSelfie) + Optional profile = receipt.getProfile(); + profile.map(HumanProfile::getSelfie) .map(attr -> model.addAttribute("base64Selfie", attr.getValue().getBase64Content())); - receipt.getProfile().map(HumanProfile::getFullName) + profile.map(HumanProfile::getFullName) .map(attr -> model.addAttribute("fullName", attr.getValue())); - receipt.getProfile().map(HumanProfile::getAttributes) + profile.map(HumanProfile::getAttributes) .map(attr -> model.addAttribute("displayAttributes", mapAttributes(attr))); return "profile"; diff --git a/yoti-sdk-spring-boot-example/src/main/java/com/yoti/api/examples/springboot/IdentitySessionController.java b/yoti-sdk-spring-boot-example/src/main/java/com/yoti/api/examples/springboot/IdentitySessionController.java index e037e484..78c06f57 100644 --- a/yoti-sdk-spring-boot-example/src/main/java/com/yoti/api/examples/springboot/IdentitySessionController.java +++ b/yoti-sdk-spring-boot-example/src/main/java/com/yoti/api/examples/springboot/IdentitySessionController.java @@ -37,8 +37,8 @@ public IdentitySessionController(DigitalIdentityClient client) { public String identityShareSession() { ShareSession session = client.createShareSession( // forMinimalShare() - forDynamicScenarioShare() - // forIdentityProfileShare() + // forDynamicScenarioShare() + forIdentityProfileShare() // forLocationExtensionShare() ); diff --git a/yoti-sdk-spring-boot-example/src/main/resources/templates/error.html b/yoti-sdk-spring-boot-example/src/main/resources/templates/error.html index eed82bc9..168507d4 100644 --- a/yoti-sdk-spring-boot-example/src/main/resources/templates/error.html +++ b/yoti-sdk-spring-boot-example/src/main/resources/templates/error.html @@ -18,10 +18,19 @@

Home

Oops, something went wrong.

-

Error:

+

Error:

+ +
+

Reason:

+

+      
+ +