diff --git a/README.md b/README.md index f80907f3..d3c3b989 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,7 @@ Not uploaded to Maven Central yet, will do this the next few days! Gradle: ``` dependencies { - compile 'net.dankito.banking:fints4java:0.1' + compile 'net.dankito.banking:fints4java:0.1.0' } ``` @@ -34,17 +34,69 @@ Maven: net.dankito.banking fints4java - 0.1 + 0.1.0 ``` ## Usage -Get your bank's FinTS server address and BIC from this file: +See e.g. [JavaShowcase](fints4javaLib/src/test/java/net/dankito/fints/java/JavaShowcase) or [FinTsClientTest](fints4javaLib/src/test/kotlin/net/dankito/fints/FinTsClientTest). ```java -FinTsClient client = new FinTsClient(); + public static void main(String[] args) { + BankFinder bankFinder = new BankFinder(); + + // set your bank code (Bankleitzahl) here. Or create BankData manually. Required fields are: + // bankCode, bankCountryCode (Germany = 280), finTs3ServerAddress and for bank transfers bic + List foundBanks = bankFinder.findBankByBankCode("10070000"); + + if (foundBanks.isEmpty() == false) { + BankData bank = new BankDataMapper().mapFromBankInfo(foundBanks.get(0)); + // set your customer data (customerId = Kontonummer in most cases, pin = online banking pin) + CustomerData customer = new CustomerData("", ""); + customer.setSelectedTanProcedure(new TanProcedure("", Sicherheitsfunktion.PIN_TAN_911, TanProcedureType.ChipTan)); + + FinTsClient finTsClient = new FinTsClient(new Java8Base64Service()); + + // some banks support retrieving account transactions of last 90 days without TAN + long ninetyDaysAgoMilliseconds = 90 * 24 * 60 * 60 * 1000L; + Date ninetyDaysAgo = new Date(new Date().getTime() - ninetyDaysAgoMilliseconds); + + GetTransactionsResponse response = finTsClient.getTransactions( + new GetTransactionsParameter(true, ninetyDaysAgo), bank, customer); + + showResponse(response); + } + } + + private static void showResponse(GetTransactionsResponse response) { + if (response.isSuccessful()) { + System.out.println("Balance (Saldo) = " + response.getBalance()); + + System.out.println("Account transactions (Umsätze):"); + for (AccountTransaction transaction : response.getBookedTransactions()) { + System.out.println(transaction.toString()); + } + } + else { + if (response.isStrongAuthenticationRequired()) { + System.out.println("Sorry, your bank doesn't support retrieving account " + + "transactions of last 90 days without TAN"); + } + else { + System.out.println("An error occurred:"); + if (response.getException() != null) { // something severe occurred + System.out.println(response.getException().getMessage()); + } + + // error messages retrieved from bank (e.g. PIN is wrong, message contains errors, ...) + for (String retrievedErrorMessage : response.getErrorsToShowToUser()) { + System.out.println(retrievedErrorMessage); + } + } + } + } ```