From e951cdec4add5452cd398780e2d2aac9b882f019 Mon Sep 17 00:00:00 2001 From: "Tzouvaras, Stilianos" Date: Tue, 30 Jul 2024 12:07:22 +0300 Subject: [PATCH] Fixed deferred issuance pending status --- Sources/Issuers/IssuanceRequester.swift | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/Sources/Issuers/IssuanceRequester.swift b/Sources/Issuers/IssuanceRequester.swift index d0ee1ba..947d8ed 100644 --- a/Sources/Issuers/IssuanceRequester.swift +++ b/Sources/Issuers/IssuanceRequester.swift @@ -199,7 +199,7 @@ public actor IssuanceRequester: IssuanceRequesterType { let encodedRequest: [JSON] = try request .map { try $0.toDictionary() } - + let merged = authorizationHeader.merging(["credential_requests": encodedRequest]) { (_, new) in new } let response: BatchIssuanceSuccessResponse = try await service.formPost( @@ -240,6 +240,16 @@ public actor IssuanceRequester: IssuanceRequesterType { ) return .success(response) + } catch PostError.response(let response) { + + let issuanceError = response.toIssuanceError() + + if case .deferredCredentialIssuancePending = issuanceError { + return .success(.issuancePending(transactionId: transactionId)) + } + + return .failure(issuanceError) + } catch PostError.cannotParse(let string) { if let responseEncryptionSpec = issuanceResponseEncryptionSpec {