From 14bc302c6d2ce3beac6bb879fb97429650e27ff1 Mon Sep 17 00:00:00 2001 From: dankl Date: Sat, 26 Oct 2019 01:14:02 +0200 Subject: [PATCH] Implemented sending entered tan and returning retrieved result --- .../main/kotlin/net/dankito/fints/FinTsClient.kt | 13 +++++++++---- .../net/dankito/fints/messages/MessageBuilder.kt | 12 ++++++++++++ 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/fints4javaLib/src/main/kotlin/net/dankito/fints/FinTsClient.kt b/fints4javaLib/src/main/kotlin/net/dankito/fints/FinTsClient.kt index 5020d887..6fc2155f 100644 --- a/fints4javaLib/src/main/kotlin/net/dankito/fints/FinTsClient.kt +++ b/fints4javaLib/src/main/kotlin/net/dankito/fints/FinTsClient.kt @@ -495,7 +495,7 @@ open class FinTsClient @JvmOverloads constructor( response.tanRequiredButNotProvided = true } else { - return sendTanToBank(enteredTan, tanResponse) + return sendTanToBank(enteredTan, tanResponse, bank, customer, dialogData) } } } @@ -503,9 +503,14 @@ open class FinTsClient @JvmOverloads constructor( return response } - protected open fun sendTanToBank(enteredTan: String, tanResponse: TanResponse): Response { - // TODO - return Response(false) + protected open fun sendTanToBank(enteredTan: String, tanResponse: TanResponse, bank: BankData, + customer: CustomerData, dialogData: DialogData): Response { + + dialogData.increaseMessageNumber() + + val message = messageBuilder.createSendEnteredTanMessage(enteredTan, tanResponse, bank, customer, dialogData) + + return getAndHandleResponseForMessageThatMayRequiresTan(message, bank, customer, dialogData) } diff --git a/fints4javaLib/src/main/kotlin/net/dankito/fints/messages/MessageBuilder.kt b/fints4javaLib/src/main/kotlin/net/dankito/fints/messages/MessageBuilder.kt index e79bbcee..7f4001ec 100644 --- a/fints4javaLib/src/main/kotlin/net/dankito/fints/messages/MessageBuilder.kt +++ b/fints4javaLib/src/main/kotlin/net/dankito/fints/messages/MessageBuilder.kt @@ -17,6 +17,7 @@ import net.dankito.fints.messages.segmente.implementierte.umsaetze.Saldenabfrage import net.dankito.fints.model.* import net.dankito.fints.response.segments.JobParameters import net.dankito.fints.response.segments.SepaAccountInfoParameters +import net.dankito.fints.response.segments.TanResponse import net.dankito.fints.util.FinTsUtils import kotlin.random.Random @@ -131,6 +132,17 @@ open class MessageBuilder(protected val generator: ISegmentNumberGenerator = Seg } + open fun createSendEnteredTanMessage(enteredTan: String, tanResponse: TanResponse, bank: BankData, customer: CustomerData, dialogData: DialogData): MessageBuilderResult { + + val tanProcess = if (tanResponse.tanProcess == TanProcess.TanProcess1) TanProcess.TanProcess1 else TanProcess.TanProcess2 + + return MessageBuilderResult(createSignedMessage(bank, customer, dialogData, enteredTan, listOf( + ZweiSchrittTanEinreichung(generator.resetSegmentNumber(2), tanProcess, null, + tanResponse.jobHashValue, tanResponse.jobReference, false, null, tanResponse.tanMediaIdentifier) + ))) + } + + open fun createBankTransferMessage(bankTransferData: BankTransferData, bank: BankData, customer: CustomerData, dialogData: DialogData): MessageBuilderResult { val result = getSupportedVersionsOfJob(CustomerSegmentId.SepaBankTransfer, customer, listOf(1))