diff --git a/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/FinTsClient.kt b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/FinTsClient.kt index 5f79dbb5..e5505ca0 100644 --- a/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/FinTsClient.kt +++ b/fints4k/src/commonMain/kotlin/net/dankito/banking/fints/FinTsClient.kt @@ -33,6 +33,7 @@ import net.dankito.banking.fints.webclient.KtorWebClient import net.dankito.banking.fints.webclient.WebClientResponse import net.dankito.utils.multiplatform.Date import net.dankito.utils.multiplatform.getInnerExceptionMessage +import net.dankito.utils.multiplatform.ObjectReference open class FinTsClient( @@ -842,9 +843,15 @@ open class FinTsClient( val bank = dialogContext.bank // TODO: copy required data to TanChallenge val tanChallenge = createTanChallenge(tanResponse, bank) + val userDidCancelEnteringTan = ObjectReference(false) + this.callback.enterTan(bank, tanChallenge) { enteredTanResult -> + userDidCancelEnteringTan.value = true + handleEnterTanResult(enteredTanResult, tanResponse, response, dialogContext, callback) } + + mayRetrieveAutomaticallyIfUserEnteredDecoupledTan(tanChallenge, tanResponse, userDidCancelEnteringTan, dialogContext) } protected open fun createTanChallenge(tanResponse: TanResponse, bank: BankData): TanChallenge { @@ -866,6 +873,19 @@ open class FinTsClient( } } + protected open fun mayRetrieveAutomaticallyIfUserEnteredDecoupledTan(tanChallenge: TanChallenge, tanResponse: TanResponse, + userDidCancelEnteringTan: ObjectReference, dialogContext: DialogContext) { + dialogContext.bank.selectedTanMethod.decoupledParameters?.let { decoupledTanMethodParameters -> + if (tanResponse.tanProcess == TanProcess.AppTan && decoupledTanMethodParameters.periodicStateRequestsAllowed) { + automaticallyRetrieveIfUserEnteredDecoupledTan(tanChallenge, userDidCancelEnteringTan, dialogContext) + } + } + } + + protected open fun automaticallyRetrieveIfUserEnteredDecoupledTan(tanChallenge: TanChallenge, userDidCancelEnteringTan: ObjectReference, dialogContext: DialogContext) { + log.info("automaticallyRetrieveIfUserEnteredDecoupledTan() called for $tanChallenge") + } + protected open fun handleEnterTanResult(enteredTanResult: EnterTanResult, tanResponse: TanResponse, response: BankResponse, dialogContext: DialogContext, callback: (BankResponse) -> Unit) {