diff --git a/fints4k/src/main/kotlin/net/dankito/fints/FinTsClient.kt b/fints4k/src/main/kotlin/net/dankito/fints/FinTsClient.kt index 637e6ac1..0c81cd24 100644 --- a/fints4k/src/main/kotlin/net/dankito/fints/FinTsClient.kt +++ b/fints4k/src/main/kotlin/net/dankito/fints/FinTsClient.kt @@ -13,6 +13,7 @@ import net.dankito.fints.messages.datenelemente.implementierte.tan.TanMediumKlas import net.dankito.fints.messages.datenelemente.implementierte.tan.ZkaTanProcedure import net.dankito.fints.messages.segmente.id.CustomerSegmentId import net.dankito.fints.model.* +import net.dankito.fints.response.GetUserTanProceduresResponse import net.dankito.fints.response.InstituteSegmentId import net.dankito.fints.response.Response import net.dankito.fints.response.ResponseParser @@ -467,7 +468,7 @@ open class FinTsClient @JvmOverloads constructor( val requestBody = messageBuilder.createInitDialogMessage(bank, customer, product, dialogData, useStrongAuthentication) - val response = getAndHandleResponseForMessage(requestBody, bank) + val response = GetUserTanProceduresResponse(getAndHandleResponseForMessage(requestBody, bank)) if (response.successful) { updateBankData(bank, response) diff --git a/fints4k/src/main/kotlin/net/dankito/fints/response/GetUserTanProceduresResponse.kt b/fints4k/src/main/kotlin/net/dankito/fints/response/GetUserTanProceduresResponse.kt new file mode 100644 index 00000000..765e4b56 --- /dev/null +++ b/fints4k/src/main/kotlin/net/dankito/fints/response/GetUserTanProceduresResponse.kt @@ -0,0 +1,24 @@ +package net.dankito.fints.response + + +open class GetUserTanProceduresResponse(bankResponse: Response) + : Response(bankResponse.didReceiveResponse, bankResponse.receivedResponse, bankResponse.receivedSegments, + bankResponse.exception, bankResponse.noTanProcedureSelected, bankResponse.messageCreationError) { + + /** + * comdirect sends "9955::Unzulässiges TAN-Verfahren." even though '999' is a valid TAN procedure + * for init dialog if user's TAN procedures are not known yet + * -> check if the only error is '9955', then it's still a success. + */ + override val successful: Boolean + get() = noTanProcedureSelected == false && couldCreateMessage && didReceiveResponse + && tanRequiredButUserDidNotEnterOne == false + && (responseContainsErrors == false || containsOnlyInvalidTanProcedureError()) + + protected open fun containsOnlyInvalidTanProcedureError(): Boolean { + val errorFeedbacks = segmentFeedbacks.flatMap { it.feedbacks }.filter { it.isError } + + return errorFeedbacks.size == 1 && errorFeedbacks.first().responseCode == 9955 + } + +} \ No newline at end of file