Added tryGetTransactionsOfLast90DaysWithoutTan()
This commit is contained in:
parent
29a2f29f72
commit
496b800b5e
|
@ -20,6 +20,7 @@ import net.dankito.utils.web.client.RequestParameters
|
||||||
import net.dankito.utils.web.client.WebClientResponse
|
import net.dankito.utils.web.client.WebClientResponse
|
||||||
import org.slf4j.LoggerFactory
|
import org.slf4j.LoggerFactory
|
||||||
import java.math.BigDecimal
|
import java.math.BigDecimal
|
||||||
|
import java.util.*
|
||||||
|
|
||||||
|
|
||||||
open class FinTsClient @JvmOverloads constructor(
|
open class FinTsClient @JvmOverloads constructor(
|
||||||
|
@ -82,6 +83,46 @@ open class FinTsClient @JvmOverloads constructor(
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Some banks support that according to PSD2 account transactions may be retrieved without
|
||||||
|
* a TAN (= no strong customer authorization needed).
|
||||||
|
*/
|
||||||
|
open fun tryGetTransactionsOfLast90DaysWithoutTanAsync(bank: BankData, customer: CustomerData,
|
||||||
|
callback: (GetTransactionsResponse) -> Unit) {
|
||||||
|
|
||||||
|
callback(tryGetTransactionsOfLast90DaysWithoutTan(bank, customer, false))
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Some banks support that according to PSD2 account transactions may be retrieved without
|
||||||
|
* a TAN (= no strong customer authorization needed).
|
||||||
|
*/
|
||||||
|
open fun tryGetTransactionsOfLast90DaysWithoutTan(bank: BankData, customer: CustomerData): GetTransactionsResponse {
|
||||||
|
|
||||||
|
return tryGetTransactionsOfLast90DaysWithoutTan(bank, customer, false)
|
||||||
|
}
|
||||||
|
|
||||||
|
protected open fun tryGetTransactionsOfLast90DaysWithoutTan(bank: BankData, customer: CustomerData,
|
||||||
|
skipSettingCustomerFlag: Boolean): GetTransactionsResponse {
|
||||||
|
|
||||||
|
val ninetyDaysAgoMilliseconds = 90 * 24 * 60 * 60 * 1000L
|
||||||
|
val ninetyDaysAgo = Date(Date().time - ninetyDaysAgoMilliseconds)
|
||||||
|
|
||||||
|
val response = getTransactions(
|
||||||
|
GetTransactionsParameter(false, ninetyDaysAgo), bank, customer)
|
||||||
|
|
||||||
|
customer.triedToRetrieveTransactionsOfLast90DaysWithoutTan = true
|
||||||
|
|
||||||
|
if (response.isSuccessful) {
|
||||||
|
if (skipSettingCustomerFlag == false) {
|
||||||
|
customer.supportsRetrievingTransactionsOfLast90DaysWithoutTan =
|
||||||
|
response.isStrongAuthenticationRequired
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return response
|
||||||
|
}
|
||||||
|
|
||||||
open fun getTransactionsAsync(parameter: GetTransactionsParameter, bank: BankData,
|
open fun getTransactionsAsync(parameter: GetTransactionsParameter, bank: BankData,
|
||||||
customer: CustomerData, callback: (GetTransactionsResponse) -> Unit) {
|
customer: CustomerData, callback: (GetTransactionsResponse) -> Unit) {
|
||||||
|
|
||||||
|
@ -95,6 +136,12 @@ open class FinTsClient @JvmOverloads constructor(
|
||||||
|
|
||||||
// synchronizeCustomerSystemIdIfNotDoneYet(bank, customer) // even though specification says this is required it can be omitted
|
// synchronizeCustomerSystemIdIfNotDoneYet(bank, customer) // even though specification says this is required it can be omitted
|
||||||
|
|
||||||
|
if (customer.supportsRetrievingTransactionsOfLast90DaysWithoutTan == null &&
|
||||||
|
customer.triedToRetrieveTransactionsOfLast90DaysWithoutTan == false &&
|
||||||
|
parameter.fromDate == null) {
|
||||||
|
tryGetTransactionsOfLast90DaysWithoutTan(bank, customer, true)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
val dialogData = DialogData()
|
val dialogData = DialogData()
|
||||||
|
|
||||||
|
@ -130,6 +177,13 @@ open class FinTsClient @JvmOverloads constructor(
|
||||||
|
|
||||||
|
|
||||||
response.getFirstSegmentById<ReceivedAccountTransactions>(InstituteSegmentId.AccountTransactionsMt940)?.let { transactions ->
|
response.getFirstSegmentById<ReceivedAccountTransactions>(InstituteSegmentId.AccountTransactionsMt940)?.let { transactions ->
|
||||||
|
// TODO: that should not work. Find out in which method transactions are retrieved after entering TAN
|
||||||
|
// just retrieved all transactions -> check if retrieving that ones of last 90 days is possible without entering TAN
|
||||||
|
if (customer.supportsRetrievingTransactionsOfLast90DaysWithoutTan == null &&
|
||||||
|
response.successful && transactions.bookedTransactions.isNotEmpty() && parameter.fromDate == null) {
|
||||||
|
tryGetTransactionsOfLast90DaysWithoutTan(bank, customer)
|
||||||
|
}
|
||||||
|
|
||||||
return GetTransactionsResponse(response,
|
return GetTransactionsResponse(response,
|
||||||
transactions.bookedTransactions.sortedByDescending { it.bookingDate },
|
transactions.bookedTransactions.sortedByDescending { it.bookingDate },
|
||||||
transactions.unbookedTransactions,
|
transactions.unbookedTransactions,
|
||||||
|
|
|
@ -19,7 +19,9 @@ open class CustomerData(
|
||||||
var version: VersionDesSicherheitsverfahrens = VersionDesSicherheitsverfahrens.PIN_Zwei_Schritt,
|
var version: VersionDesSicherheitsverfahrens = VersionDesSicherheitsverfahrens.PIN_Zwei_Schritt,
|
||||||
var selectedLanguage: Dialogsprache = Dialogsprache.Default,
|
var selectedLanguage: Dialogsprache = Dialogsprache.Default,
|
||||||
var customerSystemId: String = KundensystemID.Anonymous,
|
var customerSystemId: String = KundensystemID.Anonymous,
|
||||||
var customerSystemStatus: KundensystemStatusWerte = KundensystemStatus.SynchronizingCustomerSystemId
|
var customerSystemStatus: KundensystemStatusWerte = KundensystemStatus.SynchronizingCustomerSystemId,
|
||||||
|
var supportsRetrievingTransactionsOfLast90DaysWithoutTan: Boolean? = null,
|
||||||
|
var triedToRetrieveTransactionsOfLast90DaysWithoutTan: Boolean = false
|
||||||
) {
|
) {
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
|
|
@ -11,7 +11,6 @@ import net.dankito.fints.util.Java8Base64Service
|
||||||
import org.assertj.core.api.Assertions.assertThat
|
import org.assertj.core.api.Assertions.assertThat
|
||||||
import org.junit.Ignore
|
import org.junit.Ignore
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import java.util.*
|
|
||||||
|
|
||||||
|
|
||||||
@Ignore // not an automatic test, supply your settings below
|
@Ignore // not an automatic test, supply your settings below
|
||||||
|
@ -66,13 +65,11 @@ class FinTsClientTest {
|
||||||
@Test
|
@Test
|
||||||
fun getTransactions() {
|
fun getTransactions() {
|
||||||
|
|
||||||
// given
|
|
||||||
// some banks support retrieving account transactions of last 90 days without TAN
|
|
||||||
val ninetyDaysAgoMilliseconds = 90 * 24 * 60 * 60 * 1000L
|
|
||||||
val ninetyDaysAgo = Date(Date().time - ninetyDaysAgoMilliseconds)
|
|
||||||
|
|
||||||
// when
|
// when
|
||||||
val result = underTest.getTransactions(GetTransactionsParameter(fromDate = ninetyDaysAgo), Bank, Customer)
|
|
||||||
|
// some banks support retrieving account transactions of last 90 days without TAN
|
||||||
|
val result = underTest.tryGetTransactionsOfLast90DaysWithoutTan(Bank, Customer)
|
||||||
|
|
||||||
|
|
||||||
// then
|
// then
|
||||||
assertThat(result.isSuccessful).isTrue()
|
assertThat(result.isSuccessful).isTrue()
|
||||||
|
|
Loading…
Reference in New Issue